Advertisement
CosmiSora

esctemplate.lua

Nov 7th, 2019
430
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.92 KB | None | 0 0
  1. local MakePlayerCharacter = require "prefabs/player_common"
  2.  
  3.  
  4. local assets = {
  5. Asset("SCRIPT", "scripts/prefabs/player_common.lua"),
  6. }
  7. local prefabs = {}
  8.  
  9. -- Custom starting inventory
  10. local start_inv = {
  11. }
  12.  
  13. -- When the character is revived from human
  14. local function onbecamehuman(inst)
  15. -- Set speed when not a ghost (optional)
  16. inst.components.locomotor:SetExternalSpeedMultiplier(inst, "esctemplate_speed_mod", 1)
  17. end
  18.  
  19. local function onbecameghost(inst)
  20. -- Remove speed modifier when becoming a ghost
  21. inst.components.locomotor:RemoveExternalSpeedMultiplier(inst, "esctemplate_speed_mod")
  22. end
  23.  
  24. -- When loading or spawning the character
  25. local function onload(inst)
  26. inst:ListenForEvent("ms_respawnedfromghost", onbecamehuman)
  27. inst:ListenForEvent("ms_becameghost", onbecameghost)
  28.  
  29. if inst:HasTag("playerghost") then
  30. onbecameghost(inst)
  31. else
  32. onbecamehuman(inst)
  33. end
  34. end
  35.  
  36.  
  37.  
  38. -- This initializes for both the server and client. Tags can be added here.
  39. local common_postinit = function(inst)
  40. -- Minimap icon
  41. inst.MiniMapEntity:SetIcon( "esctemplate.tex" )
  42. end
  43.  
  44. -- This initializes for the server only. Components are added here.
  45. local master_postinit = function(inst)
  46. -- choose which sounds this character will play
  47. inst.soundsname = "willow"
  48.  
  49.  
  50. -- Uncomment if "wathgrithr"(Wigfrid) or "webber" voice is used
  51. --inst.talker_path_override = "dontstarve_DLC001/characters/"
  52.  
  53. -- Stats
  54. inst.components.health:SetMaxHealth(90),
  55. inst.components.hunger:SetMax(100),
  56. inst.components.sanity:SetMax(150),
  57.  
  58. -- Damage multiplier (optional)
  59. inst.components.combat.damagemultiplier = 0.75
  60.  
  61. -- Hunger rate (optional)
  62. inst.components.hunger.hungerrate = 1 * TUNING.WILSON_HUNGER_RATE
  63.  
  64.  
  65.  
  66. inst.OnLoad = onload
  67. inst.OnNewSpawn = onload
  68.  
  69. end
  70.  
  71. return MakePlayerCharacter("esctemplate", prefabs, assets, common_postinit, master_postinit, start_inv)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement