CaiusNelson

LuaGame - System - Weapons

Jan 4th, 2024 (edited)
959
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.86 KB | Gaming | 0 0
  1. --############################################################################
  2. --[[
  3.     Weapon System
  4.     -------------
  5.     Automatically create several weapon items and a proficiency passive skill
  6.     ------ Global Requires -------
  7.     Items={}
  8.     TYPES_WEAPON={}
  9.     Skills={}
  10.     MACROS={}
  11. ]]
  12. --############################################################################
  13.  
  14.  
  15. -- level for items that will be create from a weapon type
  16. local weapon_levels={
  17.     {
  18.         name="Bronze",
  19.         multiplier=1.0,
  20.     },
  21.     {
  22.         name="Steel",
  23.         multiplier=1.5,
  24.  
  25.     },
  26.     {
  27.         name="Silver",
  28.         multiplier=2.2,
  29.  
  30.     },
  31.     {
  32.         name="Brave",
  33.         multiplier=2.7,
  34.  
  35.     },
  36.     {
  37.         name="Runic",
  38.         multiplier=3.2,
  39.  
  40.     },
  41.  
  42. }
  43.  
  44. -- create weapon items and proficiency skill from a weapon type
  45. function MACROS:Create_Weapon(weapon)
  46.     local type_data =TYPES_WEAPON[weapon]
  47.  
  48.     --create weapon levels
  49.     for index, value in ipairs(weapon_levels) do
  50.        
  51.         local new_item={
  52.             name=(weapon_levels[index].name).." "..type_data.name,
  53.             icon=type_data.icon,
  54.            
  55.             item_category="equipment",
  56.             equip_type="weapon",
  57.             wpn_type=weapon,
  58.         }
  59.  
  60.         local item_name = weapon..index
  61.         Items[item_name]=new_item
  62.  
  63.         print_s(item_name)
  64.     end
  65.  
  66.     --create weapon proficiency passive skill
  67.  
  68.     local new_skill={
  69.         name=("Weapon Proficiency: " .. type_data.name),
  70.         description="Allows the use of " .. type_data.name .. " weapons.",
  71.         icon=type_data.icon,
  72.     }
  73.  
  74.     local new_skill_name = "WpnProf_" .. weapon
  75.     Skills[new_skill_name]=new_skill
  76. end
  77.  
  78. -- EXAMPLE --
  79.  
  80. TYPES_WEAPON["TestoBlade"]={
  81.     name="TestoBlade",
  82.     icon="ico_wpn_TestoBlade",
  83. }
  84.  
  85. MACROS:Create_Weapon("TestoBlade")
Advertisement
Add Comment
Please, Sign In to add comment