Guest User

Untitled

a guest
Feb 24th, 2015
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.48 KB | None | 0 0
  1.  
  2. local MakePlayerCharacter = require "prefabs/player_common"
  3.  
  4.  
  5. local assets = {
  6.  
  7. Asset( "ANIM", "anim/player_basic.zip" ),
  8. Asset( "ANIM", "anim/player_idles_shiver.zip" ),
  9. Asset( "ANIM", "anim/player_actions.zip" ),
  10. Asset( "ANIM", "anim/player_actions_axe.zip" ),
  11. Asset( "ANIM", "anim/player_actions_pickaxe.zip" ),
  12. Asset( "ANIM", "anim/player_actions_shovel.zip" ),
  13. Asset( "ANIM", "anim/player_actions_blowdart.zip" ),
  14. Asset( "ANIM", "anim/player_actions_eat.zip" ),
  15. Asset( "ANIM", "anim/player_actions_item.zip" ),
  16. Asset( "ANIM", "anim/player_actions_uniqueitem.zip" ),
  17. Asset( "ANIM", "anim/player_actions_bugnet.zip" ),
  18. Asset( "ANIM", "anim/player_actions_fishing.zip" ),
  19. Asset( "ANIM", "anim/player_actions_boomerang.zip" ),
  20. Asset( "ANIM", "anim/player_bush_hat.zip" ),
  21. Asset( "ANIM", "anim/player_attacks.zip" ),
  22. Asset( "ANIM", "anim/player_idles.zip" ),
  23. Asset( "ANIM", "anim/player_rebirth.zip" ),
  24. Asset( "ANIM", "anim/player_jump.zip" ),
  25. Asset( "ANIM", "anim/player_amulet_resurrect.zip" ),
  26. Asset( "ANIM", "anim/player_teleport.zip" ),
  27. Asset( "ANIM", "anim/wilson_fx.zip" ),
  28. Asset( "ANIM", "anim/player_one_man_band.zip" ),
  29. Asset( "ANIM", "anim/shadow_hands.zip" ),
  30. Asset( "SOUND", "sound/sfx.fsb" ),
  31. Asset( "SOUND", "sound/wilson.fsb" ),
  32. Asset( "ANIM", "anim/beard.zip" ),
  33.  
  34. Asset( "ANIM", "anim/heather.zip" ),
  35. Asset( "ANIM", "anim/ghost_heather_build.zip" ),
  36. }
  37. local prefabs = {}
  38. local start_inv = {
  39. -- Custom starting items
  40. }
  41.  
  42.  
  43.  
  44. -- This initializes for both clients and the host
  45. local common_postinit = function(inst)
  46. -- Minimap icon
  47. inst.MiniMapEntity:SetIcon( "heather.tex" )
  48. end
  49.  
  50. local function updatestats(inst)
  51. local old_strength = inst.strength
  52. if inst.components.hunger.current < 2 and inst.strength ~= "starving" then
  53. inst.strength = "starving"
  54. inst.components.talker:Say("My body lacks the energy to repair itself.")
  55. elseif inst.strength == "starving" and inst.components.hunger.current > 2 then
  56. inst.components.talker:Say("I have power again!")
  57. inst.strength = "notstarving"
  58. end
  59.  
  60. if inst.strength ~= "starving" then
  61. if inst.strength == "minregen" then
  62. if inst.components.health.currenthealth <= 90 then
  63. inst.strength = "medregen"
  64. inst.components.talker:Say("I should be back to normal in no time.")
  65. end
  66.  
  67. elseif inst.strength == "medregen" then
  68. if inst.components.health.currenthealth <= 60 then
  69. inst.strength = "moreregen"
  70. inst.components.talker:Say("Tissues are repairing incredibly fast now!")
  71. end
  72.  
  73. elseif inst.strength == "maxregen" then
  74. if inst.components.health.currenthealth >= 30 then
  75. inst.strength = "moreregen"
  76. inst.components.talker:Say("Tissue repair is beginning to slow.")
  77. end
  78.  
  79. elseif inst.strength == "moreregen" then
  80. if inst.components.health.currenthealth >= 60 then
  81. inst.strength = "medregen"
  82. inst.components.talker:Say("Cell reproductive rates down to manageable levels.")
  83.  
  84. elseif inst.components.health.currenthealth < 30 and inst.strength ~= "maxregen" then
  85. inst.strength = "maxregen"
  86. inst.components.talker:Say("Metabolic rates have spiked!")
  87. end
  88.  
  89. elseif inst.components.health.currenthealth > 90 and inst.strength ~= "minregen" then
  90. inst.strength = "minregen"
  91. inst.components.talker:Say("Cells replicating as normal.")
  92.  
  93. end
  94.  
  95. end
  96.  
  97. if inst.strength ~= old_strength then
  98. if inst.strength == "starving" then
  99. inst.components.health:StopRegen()
  100. inst.components.hunger:SetRate(TUNING.WILSON_HUNGER_RATE * 1)
  101. inst.components.combat.damagemultiplier = 0.75
  102. local Temperature = Class(function(self, inst)
  103. self.inherentinsulation = 0
  104. end)
  105.  
  106. elseif inst.strength == "minregen" or inst.strength == "notstarving" then
  107. inst.components.hunger:SetRate(TUNING.WILSON_HUNGER_RATE * 1.5)
  108. inst.components.health:StartRegen(1, 2)
  109. inst.components.combat.damagemultiplier = 1
  110. local Temperature = Class(function(self, inst)
  111. self.inherentinsulation = 0
  112. end)
  113.  
  114. elseif inst.strength == "medregen" then
  115. inst.components.hunger:SetRate(TUNING.WILSON_HUNGER_RATE * 3)
  116. inst.components.health:StartRegen(1, 1)
  117. inst.components.combat.damagemultiplier = 1.25
  118. local Temperature = Class(function(self, inst)
  119. self.inherentinsulation = TUNING.INSULATION_TINY
  120. end)
  121.  
  122. elseif inst.strength == "moreregen" then
  123. inst.components.hunger:SetRate(TUNING.WILSON_HUNGER_RATE * 4.5)
  124. inst.components.health:StartRegen(2.5, 1)
  125. inst.components.combat.damagemultiplier = 1.5
  126. inst.components.sanity.dapperness = (-TUNING.DAPPERNESS_MED)
  127. local Temperature = Class(function(self, inst)
  128. self.inherentinsulation = TUNING.INSULATION_MED
  129. end)
  130.  
  131. elseif inst.strength == "maxregen" then
  132. inst.components.hunger:SetRate(TUNING.WILSON_HUNGER_RATE * 6)
  133. inst.components.health:StartRegen(5, 1)
  134. inst.components.combat.damagemultiplier = 2
  135. inst.components.sanity.dapperness = (-TUNING.DAPPERNESS_HUGE)
  136. local Temperature = Class(function(self, inst)
  137. self.inherentinsulation = TUNING.INSULATION_LARGE
  138. end)
  139. end
  140. -- print (inst.strength)
  141. -- old_strength = inst.strength
  142. end
  143. end
  144.  
  145. local function onhealthchange(inst, data)
  146. updatestats(inst)
  147. end
  148.  
  149. local function onnewstate(inst)
  150. if inst._wasnomorph ~= inst.sg:HasStateTag("nomorph") then
  151. inst._wasnomorph = not inst._wasnomorph
  152. if not inst._wasnomorph then
  153. onhealthchange(inst)
  154. end
  155. end
  156. end
  157.  
  158. local function onbecamehuman(inst)
  159. if inst._wasnomorph == nil then
  160. inst.strength = "minregen"
  161. inst._wasnomorph = inst.sg:HasStateTag("nomorph")
  162. inst.talksoundoverride = nil
  163. inst.hurtsoundoverride = nil
  164. inst:ListenForEvent("healthdelta", onhealthchange)
  165. inst:ListenForEvent("newstate", onnewstate)
  166. onhealthchange(inst, nil, true)
  167. end
  168. end
  169.  
  170. local function onbecameghost(inst)
  171. if inst._wasnomorph ~= nil then
  172. inst.strength = "minregen"
  173. inst._wasnomorph = nil
  174. inst.talksoundoverride = nil
  175. inst.hurtsoundoverride = nil
  176. inst:RemoveEventCallback("healthdelta", onhealthchange)
  177. inst:RemoveEventCallback("newstate", onnewstate)
  178. end
  179. end
  180.  
  181. local function onload(inst)
  182. inst:ListenForEvent("ms_respawnedfromghost", onbecamehuman)
  183. inst:ListenForEvent("ms_becameghost", onbecameghost)
  184.  
  185. if inst:HasTag("playerghost") then
  186. onbecameghost(inst)
  187. else
  188. onbecamehuman(inst)
  189. end
  190. end
  191.  
  192. -- This initializes for the host only
  193. local master_postinit = function(inst)
  194.  
  195. -- choose which sounds this character will play
  196. inst.soundsname = "wendy"
  197. -- Stats
  198. inst.strength = "minregen"
  199.  
  200. inst.components.health:SetMaxHealth(120)
  201. inst.components.health:StartRegen(1, 2)
  202. inst.components.hunger:SetMax(200)
  203. inst.components.sanity:SetMax(200)
  204. inst.components.combat.damagemultiplier = 1
  205. inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 1.5)
  206. inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 1.5)
  207.  
  208. inst:ListenForEvent("healthdelta", onhealthchange)
  209. inst:ListenForEvent("hungerdelta", updatestats)
  210.  
  211. inst.OnLoad = onload
  212. inst.OnNewSpawn = onload
  213. end
  214.  
  215. return MakePlayerCharacter("heather", prefabs, assets, common_postinit, master_postinit, start_inv)
Advertisement
Add Comment
Please, Sign In to add comment