Advertisement
grymlahv

Untitled

Jul 8th, 2020
19
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.13 KB | None | 0 0
  1. local MakePlayerCharacter = require "prefabs/player_common"
  2.  
  3. local assets = {
  4. Asset("SCRIPT", "scripts/prefabs/player_common.lua"),
  5. }
  6.  
  7. -- Your character's stats
  8. TUNING.WARDEN_HEALTH = 300
  9. TUNING.WARDEN_HUNGER = 100
  10. TUNING.WARDEN_SANITY = 50
  11.  
  12. -- Custom starting inventory
  13. TUNING.GAMEMODE_STARTING_ITEMS.DEFAULT.WARDEN = {
  14. "flint",
  15. "flint",
  16. "rocks",
  17. "rocks",
  18. }
  19.  
  20. local start_inv = {}
  21. for k, v in pairs(TUNING.GAMEMODE_STARTING_ITEMS) do
  22. start_inv[string.lower(k)] = v.WARDEN
  23. end
  24. local prefabs = FlattenTree(start_inv, true)
  25.  
  26. --Mine the World
  27. --inst.AddComponent("golem")
  28. local WARDEN_LMB_ACTIONS =
  29. {
  30. "MINE",
  31. }
  32.  
  33. local function GetWardenAction(inst, target)
  34. for i, v in ipairs(WARDEN_LMB_ACTIONS) do
  35. if target:HasTag(v.."_workable") then
  36. return not target:HasTag("sign") and ACTIONS[v] or nil
  37. end
  38. end
  39. end
  40. local function WardenLeftClickPicker(inst, target)
  41. if target ~= nil and target ~= inst then
  42. for i, v in ipairs(WARDEN_LMB_ACTIONS) do
  43. if target:HasTag(v.."_workable") then
  44. return not target:HasTag("sign")
  45. and inst.components.playeractionpicker:SortActionList({ ACTIONS[v] }, target, nil)
  46. or nil
  47. end
  48. end
  49. end
  50. end
  51. local function SetWorker(inst)
  52. inst:RemoveEventCallback("working", onworked)
  53.  
  54. if inst.components.worker == nil then
  55. inst:AddComponent("worker")
  56. inst.components.worker:SetAction(ACTIONS.MINE, 2)
  57. inst.components.worker:SetAction(ACTIONS.HAMMER, 1)
  58. OnWorking(inst)
  59. end
  60. end
  61. --[[local function WardenLeftClickPicker(inst, target)
  62. if target ~= nil and target ~= inst then
  63. if inst.replica.combat:CanTarget(target) then
  64. return (not target:HasTag("player") or inst.components.playercontroller:IsControlPressed(CONTROL_FORCE_ATTACK))
  65. and inst.components.playeractionpicker:SortActionList({ ACTIONS.ATTACK }, target, nil)
  66. or nil
  67. end
  68. for i, v in ipairs(WARDEN_LMB_ACTIONS) do
  69. if target:HasTag(v.."_workable") then
  70. return not target:HasTag("sign")
  71. and inst.components.playeractionpicker:SortActionList({ ACTIONS[v] }, target, nil)
  72. or nil
  73. end
  74. end
  75. end
  76. end]]
  77. local function SetActions(inst)
  78. inst.ActionStringOverride = WardenActionString
  79. if inst.components.playercontroller ~= nil then
  80. inst.components.playercontroller.actionbuttonoverride = WardenActionButton
  81. end
  82. if inst.components.playeractionpicker ~= nil then
  83. inst.components.playeractionpicker.leftclickoverride = WardenLeftClickPicker
  84. end
  85. EnableReticule(inst, false)
  86.  
  87. end]]
  88.  
  89. -- When the character is revived from human
  90. local function onbecamehuman(inst)
  91. -- Set speed when not a ghost (optional)
  92. inst.components.locomotor:SetExternalSpeedMultiplier(inst, "warden_speed_mod", .75)
  93.  
  94. -- Mine the World
  95. SetActions(inst)
  96. SetWorker(inst)
  97. end
  98.  
  99. local function onbecameghost(inst)
  100. -- Remove speed modifier when becoming a ghost
  101. inst.components.locomotor:RemoveExternalSpeedMultiplier(inst, "warden_speed_mod")
  102. end
  103.  
  104. -- When loading or spawning the character
  105. local function onload(inst)
  106. inst:ListenForEvent("ms_respawnedfromghost", onbecamehuman)
  107. inst:ListenForEvent("ms_becameghost", onbecameghost)
  108.  
  109. if inst:HasTag("playerghost") then
  110. onbecameghost(inst)
  111. else
  112. onbecamehuman(inst)
  113. end
  114. end
  115.  
  116. -- This initializes for both the server and client. Tags can be added here.
  117. local common_postinit = function(inst)
  118. -- Minimap icon
  119. inst.MiniMapEntity:SetIcon( "warden.tex" )
  120. end
  121.  
  122. -- This initializes for the server only. Components are added here.
  123. local master_postinit = function(inst)
  124. -- Set starting inventory
  125. inst.starting_inventory = start_inv[TheNet:GetServerGameMode()] or start_inv.default
  126.  
  127. -- choose which sounds this character will play
  128. inst.soundsname = "willow"
  129.  
  130. -- Uncomment if "wathgrithr"(Wigfrid) or "webber" voice is used
  131. --inst.talker_path_override = "dontstarve_DLC001/characters/"
  132.  
  133. -- Stats
  134. inst.components.health:SetMaxHealth(TUNING.WARDEN_HEALTH)
  135. inst.components.hunger:SetMax(TUNING.WARDEN_HUNGER)
  136. inst.components.sanity:SetMax(TUNING.WARDEN_SANITY)
  137.  
  138. -- Damage multiplier (optional)
  139. inst.components.combat.damagemultiplier = 1
  140.  
  141. -- Hunger rate (optional)
  142. inst.components.hunger.hungerrate = .75 * TUNING.WILSON_HUNGER_RATE
  143.  
  144. -- Sanity rate (optional)
  145. inst.components.sanity.rate_modifier = 0.75
  146.  
  147. -- Diet of Rocks
  148. inst.components.eater:SetDiet({ FOODTYPE.ELEMENTAL }, { FOODTYPE.ELEMENTAL })
  149.  
  150. -- Mine the World
  151. --inst.components.golem:AddWorkAction(ACTIONS.MINE, 2)
  152.  
  153. -- Temperature Invulnerability
  154. inst.components.temperature.overheattemp = 69
  155. inst.components.temperature.inherentsummerinsulation = 50
  156. inst.components.temperature.inherentinsulation = 50
  157.  
  158. inst.OnLoad = onload
  159. inst.OnNewSpawn = onload
  160.  
  161. end
  162.  
  163. return MakePlayerCharacter("warden", prefabs, assets, common_postinit, master_postinit, prefabs)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement