Commit d8c877560386e0bce0fc7dbbd26fd1f73d549937

Authored by Joseph Betzwieser
1 parent 437ac2c6

Fixed Archery to properly do on_hit, on_crit, and on_kill effects. It can now h…

…andle multiple types of each from ranged weapons and ammo.
... ... @@ -390,34 +390,70 @@ local function archery_projectile(tx, ty, tg, self, tmp)
390 390 self:callTalent(self.T_WEAPON_FOLDING, "doWeaponFolding", target)
391 391 end
392 392
393   - -- Special effect
394   - if hitted and weapon and weapon.special_on_hit and weapon.special_on_hit.fct and (not target.dead or weapon.special_on_hit.on_kill) then
395   - weapon.special_on_hit.fct(weapon, self, target)
  393 + -- Special weapon effects (passing the special definition to facilitate encapsulating multiple special effects)
  394 + if hitted and weapon and weapon.special_on_hit then
  395 + local specials = weapon.special_on_hit
  396 + if specials.fct then specials = {specials} end
  397 + for _, special in ipairs(specials) do
  398 + if special.fct and (not target.dead or special.on_kill) then
  399 + special.fct(weapon, self, target, dam, special)
  400 + end
  401 + end
396 402 end
397   -
398   - -- Special effect... AMMO!
399   - if hitted and ammo and ammo.special_on_hit and ammo.special_on_hit.fct and (not target.dead or ammo.special_on_hit.on_kill) then
400   - ammo.special_on_hit.fct(ammo, self, target)
  403 +
  404 + -- Special ammo effects (passing the special definition to facilitate encapsulating multiple special effects)
  405 + if hitted and ammo and ammo.special_on_hit then
  406 + local specials = ammo.special_on_hit
  407 + if specials.fct then specials = {specials} end
  408 + for _, special in ipairs(specials) do
  409 + if special.fct and (not target.dead or special.on_kill) then
  410 + special.fct(ammo, self, target, dam, special)
  411 + end
  412 + end
401 413 end
402 414
403   - -- Special effect on crit
404   - if crit and weapon and weapon.special_on_crit and weapon.special_on_crit.fct and (not target.dead or weapon.special_on_crit.on_kill) then
405   - weapon.special_on_crit.fct(weapon, self, target)
  415 + --Special effect on crit
  416 + if hitted and crit and weapon and weapon.special_on_crit then
  417 + local specials = weapon.special_on_crit
  418 + if specials.fct then specials = {specials} end
  419 + for _, special in ipairs(specials) do
  420 + if special.fct and (not target.dead or special.on_kill) then
  421 + special.fct(weapon, self, target, dam, special)
  422 + end
  423 + end
406 424 end
407   -
408   - -- Special effect on crit AMMO!
409   - if crit and ammo and ammo.special_on_crit and ammo.special_on_crit.fct and (not target.dead or ammo.special_on_crit.on_kill) then
410   - ammo.special_on_crit.fct(ammo, self, target)
  425 +
  426 + --Special effect on crit AMMO!
  427 + if hitted and crit and ammo and ammo.special_on_crit then
  428 + local specials = ammo.special_on_crit
  429 + if specials.fct then specials = {specials} end
  430 + for _, special in ipairs(specials) do
  431 + if special.fct and (not target.dead or special.on_kill) then
  432 + special.fct(ammo, self, target, dam, special)
  433 + end
  434 + end
411 435 end
412 436
413 437 -- Special effect on kill
414   - if hitted and weapon and weapon.special_on_kill and weapon.special_on_kill.fct and target.dead then
415   - weapon.special_on_kill.fct(weapon, self, target)
  438 + if hitted and weapon and weapon.special_on_kill and target.dead then
  439 + local specials = weapon.special_on_kill
  440 + if specials.fct then specials = {specials} end
  441 + for _, special in ipairs(specials) do
  442 + if special.fct then
  443 + special.fct(weapon, self, target, dam, special)
  444 + end
  445 + end
416 446 end
417 447
418 448 -- Special effect on kill A-A-A-AMMMO!
419   - if hitted and ammo and ammo.special_on_kill and ammo.special_on_kill.fct and target.dead then
420   - ammo.special_on_kill.fct(ammo, self, target)
  449 + if hitted and ammo and ammo.special_on_kill and target.dead then
  450 + local specials = ammo.special_on_kill
  451 + if specials.fct then specials = {specials} end
  452 + for _, special in ipairs(specials) do
  453 + if special.fct then
  454 + special.fct(ammo, self, target, dam, special)
  455 + end
  456 + end
421 457 end
422 458
423 459 -- Siege Arrows
... ...