Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local MakePlayerCharacter = require "prefabs/player_common"
- local assets = {
- Asset("SCRIPT", "scripts/prefabs/player_common.lua"),
- Asset( "ANIM", "anim/chara.zip" ),
- }
- local prefabs = {}
- -- Custom starting items
- local start_inv = {
- "friskbandaid",
- "charaworndagger",
- }
- -- When the character is revived from human
- local function onbecamehuman(inst)
- -- Set speed when reviving from ghost (optional)
- inst.components.locomotor:SetExternalSpeedMultiplier(inst, "frisk_speed_mod", 1.35)
- inst.components.talker:Say("*...But It Refused.", 2.5,true)
- end
- local function onbecameghost(inst)
- -- Remove speed modifier when becoming a ghost
- inst.components.locomotor:RemoveExternalSpeedMultiplier(inst, "frisk_speed_mod")
- end
- local function ResetDelay(inst)
- if inst.transform_task ~= nil then
- inst.transform_task:Cancel()
- inst.transform_task = nil
- end
- inst.transform_delay = nil
- inst.components.keyhandler:StopIgnoring()
- end
- local function OnSave(inst, data)
- data.transformed = inst.transformed
- data.transform_delay = inst.transform_delay
- end
- -- When loading or spawning the character
- local function onload(inst, data)
- inst:ListenForEvent("ms_respawnedfromghost", onbecamehuman)
- inst:ListenForEvent("ms_becameghost", onbecameghost)
- if inst:HasTag("playerghost") then
- onbecameghost(inst)
- else
- onbecamehuman(inst)
- end
- end
- --Transform Delay
- local function OnLoad(inst, data)
- if data then
- if data.transformed then
- inst.transformed = data.transformed
- end
- if data.transform_delay then
- inst.transform_delay = GetTime() - data.transform_delay
- end
- end
- onload( inst, data )
- if inst.transformed then
- local fn = GetModRPCHandler( "frisk", "CHARA" )
- fn(inst, true, inst.transform_delay)
- end
- end
- local function Revive(inst)
- inst:DoTaskInTime(5, function(inst)
- if inst.transformed then
- if inst.transform_task ~= nil then
- inst.transform_task:Cancel()
- inst.transform_task = nil
- end
- local fn = GetModRPCHandler( "frisk", "CHARA" )
- fn(inst, true, inst.transform_delay)
- else
- inst.components.keyhandler:StopIgnoring()
- end
- end)
- end
- -- This initializes for both the server and client. Tags can be added here.
- local common_postinit = function(inst)
- -- Minimap icon
- inst.MiniMapEntity:SetIcon( "frisk.tex" )
- inst:AddTag("frisk_builder")
- inst:AddTag("chara_builder")
- --Starting out as Chara
- inst:AddTag("frisk")
- inst:AddTag("doublehealz")
- inst:RemoveTag("nohealz")
- inst:RemoveTag("chara")
- inst:RemoveTag("scarytoprey")
- inst:RemoveTag("monster")
- inst:AddComponent("keyhandler")
- inst.components.keyhandler:AddActionListener("frisk", TUNING.FRISK.KEY, "CHARA")
- end
- -- This initializes for the server only. Components are added here.
- local master_postinit = function(inst)
- -- choose which sounds this character will play
- inst.soundsname = "frisk"
- -- Uncomment if "wathgrithr"(Wigfrid) or "webber" voice is used
- --inst.talker_path_override = "dontstarve_DLC001/characters/"
- -- Stats
- inst.components.health:SetMaxHealth(75)
- inst.components.hunger:SetMax(150)
- inst.components.sanity:SetMax(200)
- inst.components.health.SetPenalty = function(self, penalty)
- self.penalty = math.clamp(penalty, 0, 0)
- end
- -- Hunger rate (optional)
- inst.components.hunger.hungerrate = 1 * TUNING.WILSON_HUNGER_RATE
- inst.components.locomotor:SetExternalSpeedMultiplier(inst, "frisk_speed_mod", 1.35)
- inst.components.health.absorb = 0.1
- inst.components.combat.damagemultiplier = 0.75
- inst.Transform:SetScale(0.7, 0.7, 0.7)
- --Transform Delay
- inst._cooldown = 3 * TUNING.TOTAL_DAY_TIME
- inst.ResetDelay = ResetDelay
- local _DoDelta = inst.components.health.DoDelta
- inst.components.health.DoDelta = function(self, amount, overtime, cause, ignore_invincible, afflicter, ignore_absorb)
- if amount > 0 then
- if self.inst:HasTag("nohealz") then
- amount = 0
- elseif self.inst:HasTag("doublehealz") then
- amount = amount * 2
- end
- end
- _DoDelta(self, amount, overtime, cause, ignore_invincible, afflicter, ignore_absorb)
- end
- inst:ListenForEvent("death", function(inst)
- if not inst.components.keyhandler.ignore_ then
- inst.components.keyhandler:StartIgnoring()
- end
- end)
- inst:ListenForEvent("ms_respawnedfromghost", function(inst)
- Revive(inst)
- end)
- inst.OnSave = OnSave
- inst.OnLoad = OnLoad
- inst.OnNewSpawn = onload
- end
- return MakePlayerCharacter("frisk", prefabs, assets, common_postinit, master_postinit, start_inv)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement