Vultraz

Untitled

Aug 1st, 2016
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.38 KB | None | 0 0
  1.     local function sync_weapons_to_items()
  2.         for attack in helper.child_range(unit, 'attack') do
  3.             if not invalid_attacks[attack.name] and not helper.get_child(var, "item", attack.name) then
  4.                 local descrip = string.format("%s - %s %s", attack.damage, attack.number, attack.type)
  5.                 local removal_id = "attack_" .. attack.name
  6.  
  7.                 table.insert(var, {"item", {
  8.                     id = attack.name,
  9.                     name = first_to_upper(attack.description), -- [attack] doesn't have dedicated id keys, and the description is more like a name anyway
  10.                     image = attack.icon or string.format("attacks/%s.png", attack.name),
  11.                     description = descrip,
  12.                     effect_type = "equip",
  13.                     active = true,
  14.                     quantity = 1,
  15.                     T.command {
  16.                         T.object { silent = true, duration = "forever", no_write = true, removal_id = removal_id,
  17.                             { 'effect', lp8.copyTable(attack, { apply_to = 'new_attack' }) }
  18.                         },
  19.                         T.remove_object { skip_effects = true,
  20.                             T.filter_wml { removal_id = removal_id }
  21.                         }
  22.                     },
  23.                     T.removal_command {
  24.                         T.object { silent = true, duration = "forever", no_write = true, removal_id = removal_id,
  25.                             T.effect { apply_to = "remove_attacks", range = attack.range, name = attack.name }
  26.                         },
  27.                         T.remove_object { skip_effects = true,
  28.                             T.filter_wml { removal_id = removal_id }
  29.                         }
  30.                     }
  31.                 } })
  32.             end
  33.         end
  34.  
  35.         wesnoth.put_unit(unit)
  36.     end
Advertisement
Add Comment
Please, Sign In to add comment