Advertisement
grymlahv

warden prefab

Jun 30th, 2020
16
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.66 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. -- When the character is revived from human
  27. local function onbecamehuman(inst)
  28. -- Set speed when not a ghost (optional)
  29. inst.components.locomotor:SetExternalSpeedMultiplier(inst, "warden_speed_mod", .75)
  30. end
  31.  
  32. local function onbecameghost(inst)
  33. -- Remove speed modifier when becoming a ghost
  34. inst.components.locomotor:RemoveExternalSpeedMultiplier(inst, "warden_speed_mod")
  35. end
  36.  
  37. -- When loading or spawning the character
  38. local function onload(inst)
  39. inst:ListenForEvent("ms_respawnedfromghost", onbecamehuman)
  40. inst:ListenForEvent("ms_becameghost", onbecameghost)
  41.  
  42. if inst:HasTag("playerghost") then
  43. onbecameghost(inst)
  44. else
  45. onbecamehuman(inst)
  46. end
  47. end
  48.  
  49.  
  50. -- This initializes for both the server and client. Tags can be added here.
  51. local common_postinit = function(inst)
  52. -- Minimap icon
  53. inst.MiniMapEntity:SetIcon( "warden.tex" )
  54. end
  55.  
  56. -- This initializes for the server only. Components are added here.
  57. local master_postinit = function(inst)
  58. -- Set starting inventory
  59. inst.starting_inventory = start_inv[TheNet:GetServerGameMode()] or start_inv.default
  60.  
  61. -- choose which sounds this character will play
  62. inst.soundsname = "willow"
  63.  
  64. -- Uncomment if "wathgrithr"(Wigfrid) or "webber" voice is used
  65. --inst.talker_path_override = "dontstarve_DLC001/characters/"
  66.  
  67. -- Stats
  68. inst.components.health:SetMaxHealth(TUNING.WARDEN_HEALTH)
  69. inst.components.hunger:SetMax(TUNING.WARDEN_HUNGER)
  70. inst.components.sanity:SetMax(TUNING.WARDEN_SANITY)
  71.  
  72. -- Damage multiplier (optional)
  73. inst.components.combat.damagemultiplier = 1
  74.  
  75. -- Hunger rate (optional)
  76. inst.components.hunger.hungerrate = .75 * TUNING.WILSON_HUNGER_RATE
  77.  
  78. -- Sanity rate (optional)
  79. inst.components.sanity.rate_modifier = 0.75
  80.  
  81. -- Diet of Rocks
  82. inst.components.eater:SetDiet({ FOODTYPE.ELEMENTAL }, { FOODTYPE.ELEMENTAL })
  83.  
  84. -- Mine with Fists
  85. inst.AddComponent("tool")
  86. inst.components.tool:SetAction(ACTIONS.MINE, 1)
  87.  
  88. inst.OnLoad = onload
  89. inst.OnNewSpawn = onload
  90.  
  91. end
  92.  
  93. return MakePlayerCharacter("warden", prefabs, assets, common_postinit, master_postinit, prefabs)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement