Jump to content

Recommended Posts

Mod Character Speed Not Working

Thank you for reading this topic

         The problem that I am facing is that I am developing a character who is balanced that comes along with a great positive and a great negative. My character will know all the magic techs, but to compensate for that advantage is slower than other characters. The Mod has worked before, but all of a sudden no longer works. It might be a result of the Halloween changes to the game, but I am not sure. I am not receiving and error messages, it's just that the character is simply too fast. I am not sure why this is happening and the prefab file for my character is attached. If you want me to attach anything more I will be happy to do so. I started this mod using the extended sample character template. Thanks to anyone who is willing to help. Any and all help is appreciated.

                                                                                                                                                                                                   Aspiring Modder,  

                                                                                                                                                                                                               Vdragoonen

dargon.lua

I haven't made or looked at custom characters yet or changing a character's speed. I'd add some quick print()s so you can tell what is going on with the programming by looking at the log:

local function onbecamehuman(inst)
    print("aaaa modifying speed")
	inst.components.locomotor.walkspeed = 3
	inst.components.locomotor.runspeed = 5
end

local function onbecameghost(inst)
	-- Remove speed modifier when becoming a ghost
   print("aaaa removing external speed modifier")
   inst.components.locomotor:RemoveExternalSpeedMultiplier(inst, "dargon_speed_mod")
end

-- When loading or spawning the character
local function onload(inst)
    print("aaaa onload called")
    inst:ListenForEvent("ms_respawnedfromghost", onbecamehuman)
    inst:ListenForEvent("ms_becameghost", onbecameghost)

    if inst:HasTag("playerghost") then
        onbecameghost(inst)
    else
        onbecamehuman(inst)
    end
end

That will allow you to tell which functions are actually called and when by checking out the log and searching (CTRL-F) for "aaaa" to find your debug output. If onbecamehuman() is called correctly (you can see the message from it), then its contents are probably simply not right to do what you want. You may need to ensure the speed is actually changed on first spawn by calling it in the master postinit, but I suppose your use of OnNewSpawn should already take care of that. It seems to me like you're missing a complemenary call to  inst.components.locomotor:SetExternalSpeedMultiplier(inst, "dargon_speed_mod", xxx) , if only because making only one reference to the "dargon_speed_mod" string doesn't make sense.

Edited by blubuild

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...