ammo clip

nathanknig
25 Dec 2012, 23:35
i need help i am trying to implement a quiver of arrows for a bow and i know this info can be transfered to guns and other things soo HELP

what i exactly want is a quiver that every time you use the bow if the quiver is present in inventory it fires and whene the quiver emtys it goes away and after every fire it counts one of

im sure it is absolutly simple but im rather very newb

sgreig
26 Dec 2012, 17:32
The easiest way I can think of to do this would be to create a quiver (or ammo clip) object, and have an attribute set to that object with the number of rounds, in this case arrows. For example, you could have the value quiver.arrows = 10 or something like that.

You would use a script to check for the presence of the quiver when the bow is used, which is pretty straightforward, and also if there are any arrows in the quiver. If there are, the arrow fires and you would subtract 1 from the value quiver.arrows.

I don't have time to do this with the quest gui and take screenshots so I'll just use code examples. Hopefully that is ok.

Quiver Object:

<object name="quiver">
<inherit name="editor_object" />
<arrows type="int">10</arrows>
</object>


This sets up the quiver object with an arrows attribute, which is currently set to 10. You can change this value at any time by referencing quiver.arrows.

Bow Object:

<object name="bow">
<inherit name="editor_object" />
<use type="script">
if (Got(quiver) and quiver.arrows > 0) {
msg ("You fire an arrow!")
quiver.arrows = quiver.arrows - 1
}
else if (Got(quiver) and quiver.arrows = 0) {
msg ("You have no arrows to fire!")
}
else {
msg ("You need a quiver first.")
}
</use>
</object>


This code is executed when the bow is used. It checks first to see if you have the quiver and if there are any arrows in it. If so, an arrow is fired. If you have the quiver but no arrows, it says you have no arrows. It also includes a condition where if there is no quiver, it tells you that you need a quiver first.

Does that help at all?