Jump to content

Recommended Posts

This is my second mod the first one was just testing and I want this new one to be he character that I mainly play on here's what I want this character to be 

A very weak character during the day but he changes forms during the night to a shadow creature like thing wich is very strong

You can combine the code from these two topics: Listen to phase change events. Change animation build at runtime. For the last one, only the two first functions are interesting to you, SetNormalKin and SetNightmareKin.

Edited by Ultroman
16 hours ago, Ultroman said:

You can combine the code from these two topics: Listen to phase change events. Change animation build at runtime. For the last one, only the two first functions are interesting to you, SetNormalKin and SetNightmareKin.

I screwed up domething here's what I added and it didn't work

local myDayFunction = function()
    local function SetNormalKin(inst)
    inst:RemoveTag("nightmare")
        inst.components.combat.damagemultiplier = 1
        inst.components.locomotor.walkspeed = 5
    end
end

local myNightFunction = function()
    local function SetNightmareKin(inst)
    inst:AddTag("nightmare")
        inst.components.combat.damagemultiplier = 5
        inst.components.locomotor.walkspeed = 9
    end
end

inst:ListenForEvent( "daytime", myDayFunction(), GetWorld())
inst:ListenForEvent( "nighttime", myNightFunction(), GetWorld())

 

 

Edited by Scupake

Several things:

  1. You should just use the functions as they are. No need to make new ones. You're essentially just hooking up a couple of functions, each of which declares a local function which is not called or hooked up to anything.
  2. The functions you made do not have the parameters passed by the events you're listening to, in this case there is only one parameter: inst, the instance of the entity listening for the event, in this case your character.
  3. When you pass an existing function to an event hook-up (like ListenForEvent), you should not include the parentheses. You only do that if you write a full in-line function.
local function SetNormal(inst)
	-- Do whatever is needed to be in the normal state.
	-- You at least need to change the animation build, if your character needs to look different.
	inst.AnimState:SetBuild("normal")
end

local function SetShadowCreature(inst)
	-- Do whatever is needed to be in the shadow creature state.
	-- You at least need to change the animation build, if your character needs to look different.
	inst.AnimState:SetBuild("shadowcreature")
end

inst:ListenForEvent( "daytime", SetNormal, GetWorld())
inst:ListenForEvent( "nighttime", SetShadowCreature, GetWorld())

 

Edited by Ultroman

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...