Post by sekira on Apr 19, 2008 9:37:03 GMT -5
Here is my code to make the Multi Arrows ability of the marksman a passive ability that just boosts your number of shots per round like items with + to number of shots do. I really hated that you had to shoot all the arrows at once in an all or nothing, hit or miss style, and you only got the venemous shots, burning shots, and brand damage once no matter how many you shot. That didn't make much sense. So now, instead, it just makes you shoot one arrow at a time, but lets you do so multiple times per action.
Another thing I didn't like... the way it was before, if you had some way of getting + to number of shots from your equipment, and also had the multi arrows ability, you could fire your "slavo" of arrows as many times as your equipment boosted your number of shots. I just thought it would be better to standardize, and have all the abilities that let you fire more than once in the same round work the same.
oh, and I also fixed the way returning arrows and bolts always disapear and don't return, and the way having base shooting skill above 70 caused ALL ammos to always disapear and never return. It was as simple as wrapping the inven_increase, inven_optimize, inven describe around that if statement near the bottom.
Another thing I didn't like... the way it was before, if you had some way of getting + to number of shots from your equipment, and also had the multi arrows ability, you could fire your "slavo" of arrows as many times as your equipment boosted your number of shots. I just thought it would be better to standardize, and have all the abilities that let you fire more than once in the same round work the same.
oh, and I also fixed the way returning arrows and bolts always disapear and don't return, and the way having base shooting skill above 70 caused ALL ammos to always disapear and never return. It was as simple as wrapping the inven_increase, inven_optimize, inven describe around that if statement near the bottom.
-- Shoot once for every ranged weapons equipped.
for weap = 0, 1 do
if (weap == 0) then
totfire = p_ptr.num_fire
else
totfire = p_ptr.num_fire2
end
-- Multiple Arrows ability.
if (p_ptr.abilities[(CLASS_MARKSMAN * 10) + 7] >= 1 and (inven(INVEN_WIELD + weap).itemtype == 1)) then
totfire = totfire + (p_ptr.abilities[(CLASS_MARKSMAN * 10) + 7] / 5) + 1
end
for j = 1, totfire do
dir = 0
-- Look for a ranged weapon.
if (inven(INVEN_WIELD + weap).tval == TV_RANGED) then
-- Look if we have the proper ammos.
if (inven(INVEN_WIELD + weap).itemtype == inven(INVEN_AMMO).itemtype) then
if (inven(INVEN_WIELD + weap).pval2 >= inven(INVEN_WIELD + weap).extra2) then
-- Determine the needed amount of ammos.
totalammos = inven(INVEN_WIELD + weap).extra2
-- Multiple Arrows ability.
-- if (p_ptr.abilities[(CLASS_MARKSMAN * 10) + 7] >= 1 and (inven(INVEN_WIELD + weap).itemtype == 1) and multishot) then
-- local tmpstring
-- local maxarrows
-- maxarrows = (p_ptr.abilities[(CLASS_MARKSMAN * 10) + 7] / 5) + 2
-- if (maxarrows > inven(INVEN_AMMO).number) then maxarrows = inven(INVEN_AMMO).number end
-- tmpstring = string.format('Shoot how many arrows? (Max: %d)', maxarrows)
-- totalammos = get_quantity(tmpstring, maxarrows)
-- if (totalammos <= 0) then totalammos = 1 end
-- end
-- Look if we have the proper quantity of ammo.
if (inven(INVEN_AMMO).number >= totalammos) then
-- The ammo we're gonna shoot(and possibly drop).
drop_ranged = inven(INVEN_AMMO)
-- Direction
dir = lua_get_aim_dir()
-- Return if we abort this step.
if (dir == 0) then return end
-- Determine the element.
-- The shooter has priority over the ammo.
if (inven(INVEN_WIELD + weap).extra1 == 0) then
element = inven(INVEN_AMMO).extra1
else
element = inven(INVEN_WIELD + weap).extra1
end
-- 0 defaults to physical.
if (element == 0) then element = 15 end
-- Determine damages.
current_weapon = inven(INVEN_WIELD + weap)
dam = ranged_damages()
-- In case of arrows, more damages can be dealt by shooting multiple of them.
-- if (inven(INVEN_AMMO).itemtype == 1) then
-- dam = dam * totalammos
-- end
-- Determine radius
-- Again, shooter has priority.
if (inven(INVEN_WIELD + weap).extra5 >= inven(INVEN_AMMO).extra3) then
rad = inven(INVEN_WIELD + weap).extra5
else
rad = inven(INVEN_AMMO).extra3
end
-- Called shot?
called_shot = calledshot
-- Are we returning?
returning = 0
if ((p_ptr.skill_base[3] >= 70 and not(inven(INVEN_WIELD + weap).itemtype == 3 or inven(INVEN_WIELD + weap).itemtype == 4)) or (get_object_flag4(inven(INVEN_AMMO), TR4_RETURNING))) then
returning = 1
end
-- Determine if the ammo will drop on the ground.
-- A couple of global variables are used here to make
-- things a lot easier.
if ((lua_randint(100) > inven(INVEN_AMMO).extra2) and returning == 0) then
dropshots = TRUE
dropnum = totalammos
end
-- Actually fire a shot!
-- The "ranged_attack" variable is set to true.
-- See elements.lua for extra code for ranged attacks hitting
-- a monster. Nevermiss is set to true to prevent Physical from
-- being treated differently than other spells.
-- Finally, "shoot_type" is the type of shooter that was used.
shoot_type = inven(INVEN_WIELD + weap).itemtype
ranged_attack = TRUE
fire_ball(element, dir, dam, rad)
ranged_attack = FALSE
-- Shooter loses some ammos(except for bows).
if (not(inven(INVEN_WIELD + weap).itemtype == 1) and returning == 0) then
inven(INVEN_WIELD + weap).pval2 = inven(INVEN_WIELD + weap).pval2 - totalammos
end
-- Reduce ammos in inventory.
if (returning == 0) then
inven_item_increase(INVEN_AMMO, -totalammos)
inven_item_describe(INVEN_AMMO)
inven_item_optimize(INVEN_AMMO)
end
-- Take a turn.
energy_use = 100
-- Update.
update_and_handle()
else
msg_print("You need more ammos!")
end
else
msg_print("This weapon needs to be reloaded!")
end
else
msg_print("Cannot shoot these ammos with this weapon!")
end
end
end
end