SHARE
TWEET

Untitled

a guest May 5th, 2017 561 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- MOD Nightmare.
  2. local MOD = {}
  3. mods["Nightmare"] = MOD
  4.  
  5. -- origianl status.
  6. mons_org_hp          = {}
  7. mons_org_armor_bash  = {}
  8. mons_org_armor_cut   = {}
  9. mons_org_melee_skill = {}
  10. mons_org_melee_dice  = {}
  11. mons_org_melee_sides = {}
  12.  
  13.  
  14. local monster_types = game.get_monster_types()
  15. for i, monster_type in ipairs(monster_types) do
  16.     local mtype = monster_type:obj()
  17.     if mtype:in_species(species_id("ZOMBIE")) then
  18.         local nname = mtype:nname(1)
  19.         mons_org_hp         [nname] = mtype.hp
  20.         mons_org_armor_bash [nname] = mtype.armor_bash
  21.         mons_org_armor_cut  [nname] = mtype.armor_cut
  22.         mons_org_melee_skill[nname] = mtype.melee_skill
  23.         mons_org_melee_dice [nname] = mtype.melee_dice
  24.         mons_org_melee_sides[nname] = mtype.melee_sides
  25.     end
  26. end
  27.  
  28. function get_total_days()
  29.     return math.ceil( game:get_calendar_turn():get_turn() / 14400 )
  30.     -- 14400 is turns of per a day.
  31. end
  32.  
  33. function calc_new_monster_status(mtype,total_days)
  34.  
  35.     if not( mtype:in_species(species_id("ZOMBIE")) ) then
  36.         return
  37.     end
  38.  
  39.     local nname = mtype:nname(1)
  40.     local SCALE = 56                -- 14(days)x4(seasons) = 56
  41.  
  42.     if total_days > SCALE then
  43.         return
  44.     end
  45.  
  46.     --[[
  47.     Balance Examples
  48.                    |     | armor      | melee
  49.     Monster        | HP  | bash / cut | skill / dice
  50.     ---------------+-----+------------+-----------------
  51.     zombie         |  80 |    0 / 0   |     4 / 2D3 ( 6)
  52.     zombie brute   | 120 |    4 / 6   |     4 / 3D8 (24)
  53.     survivor zombie| 120 |    7 / 7   |     6 / 4D6 (24)
  54.     zombie hulk    | 480 |    8 / 12  |     5 / 4D8 (32)
  55.     armored zombie | 120 |   64 / 64  |     5 / 3D6 (18)
  56.     ]]--
  57.  
  58.     if mons_org_hp[nname] < 10000 then  -- exclude MJ.
  59.         mtype.hp = math.min( 960, math.floor( mons_org_hp[nname] * math.min( 1.5, ( 1 + total_days / SCALE ) ) ) )
  60.     end
  61.  
  62.     if mons_org_armor_bash[nname] < 7 then
  63.         mtype.armor_bash = math.min( 7, mons_org_armor_bash[nname] + math.floor( 7 * total_days / SCALE ) )
  64.     end
  65.  
  66.     if mons_org_armor_cut[nname] < 7 then
  67.         mtype.armor_cut = math.min( 7, mons_org_armor_cut[nname] + math.floor( 7 * total_days / SCALE ) )
  68.     end
  69.  
  70.     if mons_org_melee_skill[nname] < 7 then
  71.         mtype.melee_skill = math.min( 7, mons_org_melee_skill[nname] + math.floor( 7 * total_days / SCALE ) )
  72.     end
  73.  
  74.     if mons_org_melee_dice[nname] * mons_org_melee_sides[nname] < 40 then
  75.         if mons_org_melee_dice[nname] < 5 then
  76.             mtype.melee_dice  = math.min( 5, mons_org_melee_dice[nname]  + math.floor( 5 * total_days / SCALE ) )
  77.         end
  78.  
  79.         if mons_org_melee_sides[nname] < 8 then
  80.             mtype.melee_sides = math.min( 8, mons_org_melee_sides[nname] + math.floor( 8 * total_days / SCALE ) )
  81.         end
  82.     end
  83. end
  84.  
  85. function dream_a_nightmare()
  86.     local monster_types = game.get_monster_types()
  87.     local total_days = get_total_days()
  88.     for i, monster_type in ipairs(monster_types) do
  89.         calc_new_monster_status(monster_type:obj(),total_days)
  90.     end
  91. end
  92.  
  93. function MOD.on_day_passed()
  94.     dream_a_nightmare()
  95. end
  96.  
  97. function MOD.debug()
  98.     local total_days = get_total_days()
  99.     game.add_msg( tostring(total_days).."day"..(total_days == 1 and "" or "s" ) )
  100.     for i, monster_type in ipairs(monster_types) do
  101.         local mtype = monster_type:obj()
  102.         if mtype:in_species(species_id("ZOMBIE")) then
  103.             local nname = mtype:nname(1)
  104.             game.add_msg(nname..":"
  105.             .. "[hp]"..tostring(mons_org_hp         [nname]).."->"..tostring(mtype.hp         )
  106.             .."/[bs]"..tostring(mons_org_armor_bash [nname]).."->"..tostring(mtype.armor_bash )
  107.             .."/[ct]"..tostring(mons_org_armor_cut  [nname]).."->"..tostring(mtype.armor_cut  )
  108.             .."/[ml]"..tostring(mons_org_melee_skill[nname]).."->"..tostring(mtype.melee_skill)
  109.             .."/[dc]"..tostring(mons_org_melee_dice [nname]).."D"
  110.                      ..tostring(mons_org_melee_sides[nname]).."->"
  111.                      ..tostring(mtype.melee_dice).."D"
  112.                      ..tostring(mtype.melee_sides)
  113.             )
  114.         end
  115.     end
  116. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top