Page 1 of 1

Bow with infinite arrows?

Posted: Sun Jan 27, 2019 10:38 pm
by meadwarrior
Hello!

:?: Is it possible to make a bow that shoots arrows infinitely?
The arrows should 'despawn' after hitting an enemy or a wall (sort of similar to a fireball).

Thanks!

Re: Bow with infinite arrows?

Posted: Mon Jan 28, 2019 1:19 am
by Sophia
You can make a disappearing arrow by defining an on_impact function that automatically deletes the object, which is a simplified version of how fireballs and other magic work. You also probably want to set flying_only, which tells DSB to delete the object instead of dropping it to the ground if it runs out of flying energy; this one is also true for fireballs and other magic.

The attack method is probably a little trickier, since the current method kind of relies on there being ammo. You might want to look at method_shoot_spell for an alternative.

Edit: After messing around with this a bit, I'm not satisfied with the way it works. I'll add a create_ammo property for attack methods for DSB 0.74, so, for example, you could create an attack method like this:

Code: Select all

method_info["MAGIC ARROW"] = {
 	   xp_class = CLASS_NINJA,
 	   xp_sub = SKILL_SHOOTING,
	   xp_get = 9,
	   idleness = 14,
	   stamina_used = 3,
	   create_ammo = "magic_arrow"
	}
This method is identical to "SHOOT" (and should call method_shoot_ammo) except it will generate its own ammo rather than looking in the left hand. It will try to spawn an instance of a "magic_arrow" so if obj.magic_arrow isn't defined this code won't work.

If you prefer, you can specify create_ammo as part of the object archetype's properties instead.

Re: Bow with infinite arrows?

Posted: Tue Jan 29, 2019 2:21 am
by meadwarrior
Wow, that's awesome! That would definitely be easier to use, thank you very much!