Advertisement
Guest User

Untitled

a guest
Aug 10th, 2020
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.75 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.     "goldenaxe",
  12.     "goldenaxe_blueprint",
  13. }
  14.  
  15. -- When the character is revived from human
  16. local function onbecamehuman(inst)
  17.     -- Set speed when not a ghost (optional)
  18.     inst.components.locomotor:SetExternalSpeedMultiplier(inst, "wizzie_speed_mod", 1)
  19. end
  20.  
  21. local function onbecameghost(inst)
  22.     -- Remove speed modifier when becoming a ghost
  23.    inst.components.locomotor:RemoveExternalSpeedMultiplier(inst, "wizzie_speed_mod")
  24. end
  25.  
  26. -- When loading or spawning the character
  27. local function onload(inst)
  28.     inst:ListenForEvent("ms_respawnedfromghost", onbecamehuman)
  29.     inst:ListenForEvent("ms_becameghost", onbecameghost)
  30.  
  31.     if inst:HasTag("playerghost") then
  32.         onbecameghost(inst)
  33.     else
  34.         onbecamehuman(inst)
  35.     end
  36. end
  37.  
  38. --Sanity gain on kill
  39. local function onkilled(inst)
  40.      inst.components.sanity:DoDelta(5)
  41. end
  42.  
  43. --When equipping axe.
  44. local function onequip(inst, data)
  45.     local equipped_hand = inst.components.inventory:GetEquippedItem(EQUIPSLOTS.HANDS)
  46.     if equipped_hand ~= nil and equipped_hand:HasTag("CHOP_tool") then
  47.         data.item.components.equippable.dapperness = -TUNING.DAPPERNESS_MED
  48.     end
  49.     local equipped_hand = inst.components.inventory:GetEquippedItem(EQUIPSLOTS.HANDS)
  50.     if equipped_hand ~= nil and equipped_hand:HasTag("CHOP_tool") then
  51.         data.item.components.equippable.walkspeedmult = 2
  52.     end
  53. --Test for EquipBody and EquipHead negators
  54.     local equipped_body = inst.components.inventory:GetEquippedItem(EQUIPSLOTS.BODY)
  55.     if equipped_body ~= nil then
  56.         data.item.components.equippable.walkspeedmult = 1
  57.     end
  58.     local equipped_head = inst.components.inventory:GetEquippedItem(EQUIPSLOTS.HEAD)
  59.     if equipped_head ~= nil then
  60.         data.item.components.equippable.walkspeedmult = 1
  61.     end
  62. --End Test
  63.     local equipped_hand = inst.components.inventory:GetEquippedItem(EQUIPSLOTS.HANDS)
  64.     if equipped_hand ~= nil and equipped_hand:HasTag("CHOP_tool") then
  65.         inst.components.combat.damagemultiplier = 5
  66.     end
  67. --  local equipped_hand = inst.components.inventory:GetEquippedItem(EQUIPSLOTS.HANDS)
  68. --  if equipped_hand ~= nil and equipped_hand:HasTag("CHOP_tool") then
  69. --      data.item.components.tool:SetAction(ACTIONS.CHOP, 2)
  70. --  end
  71. end
  72.  
  73. --When unequipping axe.
  74. local function onunequip(inst, data)
  75.     inst.components.combat.damagemultiplier = 0.85
  76.     inst.components.locomotor.walkspeedmult = 0.85
  77. end
  78.  
  79. -- This initializes for both the server and client. Tags can be added here.
  80. local common_postinit = function(inst)
  81.     -- Minimap icon
  82.     inst.MiniMapEntity:SetIcon( "wizzie.tex" )
  83. end
  84.  
  85. -- This initializes for the server only. Components are added here.
  86. local master_postinit = function(inst)
  87.     -- choose which sounds this character will play
  88.     inst.soundsname = "willow"
  89.    
  90.     -- Uncomment if "wathgrithr"(Wigfrid) or "webber" voice is used
  91.     --inst.talker_path_override = "dontstarve_DLC001/characters/"
  92.    
  93.     -- Stats   
  94.     inst.components.health:SetMaxHealth(250)
  95.     inst.components.hunger:SetMax(100)
  96.     inst.components.sanity:SetMax(50)
  97.    
  98.     -- Damage multiplier (optional)
  99.     inst.components.combat.damagemultiplier = 0.85
  100.    
  101.     -- Hunger rate (optional)
  102.     inst.components.hunger.hungerrate = 1 * TUNING.WILSON_HUNGER_RATE
  103.    
  104.     -- Walk speed
  105.     inst.components.locomotor.walkspeedmult = 0.85
  106.    
  107.     -- Listening events for Wizzie's abilities.
  108.     inst:ListenForEvent("equip", onequip)
  109.     inst:ListenForEvent("unequip", onunequip)
  110.     inst:ListenForEvent("killed", onkilled)
  111.  
  112.     inst.OnLoad = onload
  113.     inst.OnNewSpawn = onload
  114. end
  115.  
  116.  
  117. return MakePlayerCharacter("wizzie", prefabs, assets, common_postinit, master_postinit, start_inv)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement