Page 1 of 1

Need help for scripting Ammo!

Posted: June 20th, 2012, 11:54 pm
by lzrstrm
I made a recipe for making a bow for a bow and arrow and i tryed to modify the code that was used in the RPG tutorial but I still can't figure out how to make ammo and how to use it with my bow.This is what the cod looked like before I edited it:

Code: Select all

r_item_use_new_weapon // 0 - it's good practice to number these entries

//these slots are available in consume and armour use cases as well
r_item_use_name "Magic Arrow"
r_item_use_description "An arrow is conjoured from the caster's finger tip and flung at its target with sheer mental will."
r_item_use_cooldown 1500
//increases the strength of the spell with player skill or charging
r_item_use_chargeflags $CHARGE_MAG
// adds our status effect at 30% efficiency - with the above charge flag that means 30 damge
// its type is also "magic" which means its efficiency is reduced by magic resisting items.
r_item_use_new_status 1 $ATTACK_MAGIC 0.3

//these slots are available with armour use cases as well
r_item_use_slots $SLOT_LHAND
r_item_use_skill $SKILL_MAGIC

//these slots are exclusive to weapons
r_item_use_pflags $P_TIME
r_item_use_angle 0
r_item_use_lifetime 1000
r_item_use_gravity 0
r_item_use_projeffect 0 //substitute with your arrow's effect
r_item_use_traileffect 1 //substitute with your trail's effect
r_item_use_deatheffect -1 //replace with a suitable EoL effect
r_item_use_ammo -1 //use mana
r_item_use_cost 15 //uses 15 units of mana
r_item_use_kickback 10
r_item_use_recoil 10
r_item_use_target $T_SINGLE
r_item_use_speed 1.5 // in 100's of cubes a second

And this is what it looks like from what I did to it trying to make it shoot my arrows:

Code: Select all

r_item_name "Bow and Arrow"
r_item_description "The bow and arrow is really usefull for defending your-self against enemys."
r_item_mdl "bow"


r_item_use_name "Bow and Arrow"
r_item_use_description "The Bow and Arrow can be use to defend your-self against enemys"
r_item_use_cooldown 1000
r_item_use_chargeflags $CHARGE_MAG
r_item_use_new_status 1 $ATTACK_MARKSMAN 0.3

r_item_use_slots $SLOT_LHAND

r_item_use_pflags $P_TIME
r_item_use_angle 0
r_item_use_lifetime 1500
r_item_use_gravity 0
r_item_use_projeffect 0
r_item_use_traileffect 1
r_item_use_deatheffect -1
r_item_use_ammo 0
r_item_use_cost 1
r_item_use_kickback 10
r_item_use_recoil 10
r_item_use_target $T_SINGLE
r_item_use_speed 1.5

What am I doing wrong?
It keeps poping up with an error msg saying "Using wrong knid of ammo" or something close to that

This is my 0.cfg file in the Ammo floder

Code: Select all

r_ammo_additem 4

My arrow is in the item folder as 4.cfg
I have no clue what to do. How do I ake custom ammo, in this case I want it to shoot arrows


Re: Need help for scripting Ammo!

Posted: June 21st, 2012, 2:43 am
by Hirato
Defining ammo this way requires you to equip the ammo in question on the SLOT_QUIVER slot.
I'll just copy some code from the SVN you can use as a reference...
You'll notice that items/9.cfg can be equipped


Code: Select all

r_item_name "Wood Arrow"
r_item_description "A nondescript arrow with a wooden shaft and an iron head is attached at the front. The tail is split to allow easy use with a bow."
r_item_icon "items/woodarrow"
r_item_value 1
r_item_weight 0.075
r_item_mdl "hirato/arrow"
r_item_category $cat_ammo
r_item_recovery .95

r_item_use_slots $SLOT_QUIVER
r_item_use_name "Quiver"
r_item_use_description "Swing a quiver of arrows onto your back for use with a bow or other implement."
r_item_use_icon "items/woodarrow"
r_item_use_projeffect 5
r_item_use_traileffect -1
r_item_use_deatheffect 9
r_item_use_pflags 0
r_item_use_gravity 90
r_item_use_speed 1.5
r_item_use_radius 0
r_item_use_cooldown 0

r_item_use_new_status 2 $ATTACK_PIERCE .3
r_item_use_target $T_SINGLE


Code: Select all

r_item_name "Wooden Bow"
r_item_description "The bow is fashioned from wood and the two ends connected with sinew."
r_item_value 20
r_item_weight 2
r_item_mdl "tentus/moneybag"
r_item_icon "items/woodbow"
r_item_category $cat_weap

// note the bow, generally don't inflict any effects.
// These are normally defined in the ammo

r_item_use_name "Shoot"
r_item_use_description "Knock an arrow and fire it great distances
r_item_use_icon "actions/shoot"
r_item_use_cooldown 400
r_item_use_chargeflags $CHARGE_MAG
r_item_use_slots (| $SLOT_LHAND $SLOT_RHAND)
r_item_use_skill $SKILL_MARKSMAN
r_item_use_pflags 0
r_item_use_range 0
r_item_use_angle 20
r_item_use_lifetime 0
r_item_use_gravity 0
// the projectile defines the particle effects
r_item_use_projeffect -1
r_item_use_traileffect -1
r_item_use_deatheffect -1
r_item_use_cost 1
r_item_use_ammo 1
r_item_use_target $T_SINGLE
r_item_use_radius 4
r_item_use_recoil 0
r_item_use_kickback 20
r_item_use_charge 600
r_item_use_basecharge .5
r_item_use_mincharge .2
r_item_use_maxcharge .5
r_item_use_elasticity 0
r_item_use_speed 2


Code: Select all

include items/14

r_item_name "Bow for Harry"
r_item_description "This bow was commissioned by Gracy for her husband, Harry. It is lovingly crafted and the text, ^"Happy Anniversary, Darling!^" etched into its face. The bow appears to have been infused with some latent abilities."
r_item_value 40

r_select_item_use 0
// improves te basecharge a little bit
r_item_use_basecharge .575
r_item_use_speed 2.4
r_item_use_gravity -5

// add gracy's affection
r_item_use_new_status 23 $ATTACK_MIND 1


Code: Select all

r_ammo_name "Arrows"
r_ammo_add_item 9 //wooden arrow

Re: Need help for scripting Ammo!

Posted: June 21st, 2012, 10:27 am
by lzrstrm
Thx for your help Hirato, I still dont understand what to put in each spot for different kind of weapons. ex(bow ,sword,fists,magic) but i would like to learn what to put where, so I dont have to ask a question every time I would like a new weapon

I'm probally going to make a sword or/and some spells next

Re: Need help for scripting Ammo!

Posted: June 21st, 2012, 2:14 pm
by Mike
Have you looked at the examples in Hirato's RPG? That's always the first thing to do. He also has a lot updated in the SVN aka development version so you might want to grab that. Also why not come in the chat and talk to him about it? Take care.

Re: Need help for scripting Ammo!

Posted: June 21st, 2012, 2:57 pm
by lzrstrm
Thx for the advice Mike 8-)