Jump to content

HELP: Character script help.


Recommended Posts

Hello: I just need some help with the Unikitty mod i am co-authoring with Hollow Shell.

I have an if-else loop based upon the characters sanity that, though having the correct syntax, wont apply to the characers stats. If anyone would be willing to look into the code below and help me correct my error, i will give full credit to you.

 

I would post this as an attachment, but i wont let me.

 

local MakePlayerCharacter = require "prefabs/player_common"
 
 
local assets = {
 
        Asset( "ANIM", "anim/player_basic.zip" ),
        Asset( "ANIM", "anim/player_idles_shiver.zip" ),
        Asset( "ANIM", "anim/player_actions.zip" ),
        Asset( "ANIM", "anim/player_actions_axe.zip" ),
        Asset( "ANIM", "anim/player_actions_pickaxe.zip" ),
        Asset( "ANIM", "anim/player_actions_shovel.zip" ),
        Asset( "ANIM", "anim/player_actions_blowdart.zip" ),
        Asset( "ANIM", "anim/player_actions_eat.zip" ),
        Asset( "ANIM", "anim/player_actions_item.zip" ),
        Asset( "ANIM", "anim/player_actions_uniqueitem.zip" ),
        Asset( "ANIM", "anim/player_actions_bugnet.zip" ),
        Asset( "ANIM", "anim/player_actions_fishing.zip" ),
        Asset( "ANIM", "anim/player_actions_boomerang.zip" ),
        Asset( "ANIM", "anim/player_bush_hat.zip" ),
        Asset( "ANIM", "anim/player_attacks.zip" ),
        Asset( "ANIM", "anim/player_idles.zip" ),
        Asset( "ANIM", "anim/player_rebirth.zip" ),
        Asset( "ANIM", "anim/player_jump.zip" ),
        Asset( "ANIM", "anim/player_amulet_resurrect.zip" ),
        Asset( "ANIM", "anim/player_teleport.zip" ),
        Asset( "ANIM", "anim/wilson_fx.zip" ),
        Asset( "ANIM", "anim/player_one_man_band.zip" ),
        Asset( "ANIM", "anim/shadow_hands.zip" ),
        Asset( "SOUND", "sound/sfx.fsb" ),
        Asset( "SOUND", "sound/wilson.fsb" ),
        Asset( "ANIM", "anim/beard.zip" ),
 
-- Don't forget to include your character's custom assets!
        Asset( "ANIM", "anim/unik.zip" ),
}
local prefabs = {}
 
local fn = function(inst)
 
-- choose which sounds this character will play
inst.soundsname = "willow"
 
-- a minimap icon must be specified
inst.MiniMapEntity:SetIcon( "willow.png" )
 
-- todo: Add an example special power here.
inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 1.3)
inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 1.4)
inst.components.health:SetMaxHealth(100)
inst.components.hunger:SetMax(100)
inst.components.sanity:SetMax(200)
inst.components.combat.damagemultiplier = .75
 
local function updatestats(inst)
if inst.components.sanity.current <= 40 then
--powers when insane
inst.components.combat.damagemultiplier = 2
inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 2)
inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 2.5)
inst.components.combat.attackrange = 4
inst.components.combat.hitrange = 4
inst.components.health:StartRegen(-1, 2)
 
inst.components.talker:Say("Say positive... oh forget it...")
 
end
end
 
 
 
return MakePlayerCharacter("unik", prefabs, assets, fn)
 
Link to comment
Share on other sites

You're not doing anything with the updatestats function, so it's never getting called.

Presumably the goal is to have different stats when insane and sane, so you should do something like this:

local assets = {    Asset( "ANIM", "anim/player_basic.zip" ),    Asset( "ANIM", "anim/player_idles_shiver.zip" ),    Asset( "ANIM", "anim/player_actions.zip" ),    Asset( "ANIM", "anim/player_actions_axe.zip" ),    Asset( "ANIM", "anim/player_actions_pickaxe.zip" ),    Asset( "ANIM", "anim/player_actions_shovel.zip" ),    Asset( "ANIM", "anim/player_actions_blowdart.zip" ),    Asset( "ANIM", "anim/player_actions_eat.zip" ),    Asset( "ANIM", "anim/player_actions_item.zip" ),    Asset( "ANIM", "anim/player_actions_uniqueitem.zip" ),    Asset( "ANIM", "anim/player_actions_bugnet.zip" ),    Asset( "ANIM", "anim/player_actions_fishing.zip" ),    Asset( "ANIM", "anim/player_actions_boomerang.zip" ),    Asset( "ANIM", "anim/player_bush_hat.zip" ),    Asset( "ANIM", "anim/player_attacks.zip" ),    Asset( "ANIM", "anim/player_idles.zip" ),    Asset( "ANIM", "anim/player_rebirth.zip" ),    Asset( "ANIM", "anim/player_jump.zip" ),    Asset( "ANIM", "anim/player_amulet_resurrect.zip" ),    Asset( "ANIM", "anim/player_teleport.zip" ),    Asset( "ANIM", "anim/wilson_fx.zip" ),    Asset( "ANIM", "anim/player_one_man_band.zip" ),    Asset( "ANIM", "anim/shadow_hands.zip" ),    Asset( "SOUND", "sound/sfx.fsb" ),    Asset( "SOUND", "sound/wilson.fsb" ),    Asset( "ANIM", "anim/beard.zip" ),    -- Don't forget to include your character's custom assets!    Asset( "ANIM", "anim/unik.zip" ),}local prefabs = {}local function OnSane(inst, data)    inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 1.3)    inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 1.4)    inst.components.health:SetMaxHealth(100)    inst.components.hunger:SetMax(100)    inst.components.sanity:SetMax(200)    inst.components.combat.damagemultiplier = .75endlocal function OnInsane(inst, data)    inst.components.combat.damagemultiplier = 2    inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 2)    inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 2.5)    inst.components.combat.attackrange = 4    inst.components.combat.hitrange = 4    inst.components.health:StartRegen(-1, 2)        inst.components.talker:Say("Stay positive... oh forget it...")end local fn = function(inst)    -- choose which sounds this character will play    inst.soundsname = "willow"        -- a minimap icon must be specified    inst.MiniMapEntity:SetIcon( "willow.png" )        -- set the default stats to sane; the goinsane event will be called when save data is loaded if you are insane    OnSane(inst)    -- listen for insane/sane changes    inst:ListenForEvent("gosane", OnSane)    inst:ListenForEvent("goinsane", OnInsane)endreturn MakePlayerCharacter("unik", prefabs, assets, fn)
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

×
  • Create New...