Bow with infinite arrows?

This forum is for the Lua scriptable clone of DM/CSB called Dungeon Strikes Back by Sophia. Use DSB to build your own highly customised games.

Moderator: Sophia

Forum rules
Please read the Forum rules and policies before posting. You may Image to help finance the hosting costs of this forum.
Post Reply
User avatar
meadwarrior
Journeyman
Posts: 91
Joined: Sat Dec 01, 2018 1:02 am

Bow with infinite arrows?

Post 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!
User avatar
Sophia
Concise and Honest
Posts: 4306
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Bow with infinite arrows?

Post 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.
User avatar
meadwarrior
Journeyman
Posts: 91
Joined: Sat Dec 01, 2018 1:02 am

Re: Bow with infinite arrows?

Post by meadwarrior »

Wow, that's awesome! That would definitely be easier to use, thank you very much!
Post Reply