Jump to content

Little help with character powers


Recommended Posts

This is pretty simple, really

 

I'm trying to make a custom character immune to knockback (so he won't flinch form attacks) i've looked at the thulecite crown code for some sort of hint on how to achieve this, but got no luck.

 

Also, is it possible to make a character to freeze faster?  like i don't know, reducing his total insulation by a fraction or something, I've tried to do this in many different ways and got interesting results and crashes...lots of crashes...

 

Any ideas on how to achieve either of those?

 

 

Link to comment
Share on other sites

So I have recently been messing with creating new mobs for my current mod, and I think I may have the knock back answer, though I haven't tested it.

 

In Wilson's stategraph, there is a state called "hit", and it says this:

 

State{
        name = "hit",
        tags = {"busy"},
        
        onenter = function(inst)
            inst.SoundEmitter:PlaySound("dontstarve/wilson/hit")        
            inst.AnimState:PlayAnimation("hit")
            inst:ClearBufferedAction()
            
            if inst.prefab ~= "wes" then
                local sound_name = inst.soundsname or inst.prefab
   local sound_event = "dontstarve/characters/"..sound_name.."/hurt"
                inst.SoundEmitter:PlaySound(inst.hurtsoundoverride or sound_event)
            end
            inst.components.locomotor:Stop()            
        end,
        
        events=
        {
            EventHandler("animover", function(inst) inst.sg:GoToState("idle") end ),
        }, 
        
        timeline =
        {
            TimeEvent(3*FRAMES, function(inst)
                inst.sg:RemoveStateTag("busy")
            end),
        },        
               
    },
 
I believe if you edited out these two bolded lines, and maybe the italicized one (in a custom stategraph), your character would be immune. This is just an assumption.
Link to comment
Share on other sites

This is just an assumption.

 

Ok looks like that deleting the bolded  and italicized text from the stategraph indeed nullifies knock back.

 

Tested this for like 15 minutes and it seems to work perfectly, damage is taken, current action is not canceled and movement isn't impaired, now, ¿how can I have those 2 lines deleted from the stategraph only when playing as said character?

 

(Sorry if that sounded dumb I have like a month of LUA experience and that was the best way I could describe it)

Link to comment
Share on other sites

Also, is it possible to make a character to freeze faster?  like i don't know, reducing his total insulation by a fraction or something, I've tried to do this in many different ways and got interesting results and crashes...lots of crashes...

 

Any ideas on how to achieve either of those?

 

 

I'm not sure if this would work, but you might try

 

inst.components.temperature.inherentinsulation = -TUNING.INSULATION_SMALL

 

Note the minus sign '-' in theory it gives the character negative insulation and would decrease the time it takes to freeze. Can be one of several values:

        --expressed in 'additional time before you freeze to death'

        INSULATION_TINY = seg_time,

        INSULATION_SMALL = seg_time*2,

        INSULATION_MED = seg_time*4,

        INSULATION_LARGE = seg_time*8,

 

Where seg_time is one day segment (1/16th of the game day) with a default value of 30

 

For reference Earmuffs are 'small' , winter hat is 'med' , and beefalo hat is 'large'

 

 

You can also set it to a numerical value eg.

inst.components.temperature.inherentinsulation = -90

Link to comment
Share on other sites

If you want to only change those lines in the stategraph for your character, I would suggest either making a custom stategraph (SGchar or something) and changing those lines, or copying SGwilson into your mod's stategraph folder (copy, don't delete from Don't Starve) and do something like this:

State{
        name = "hit",
        tags = {"busy"},
        
        onenter = function(inst)
            if inst.prefab == "char" then
                  inst.SoundEmitter:PlaySound("dontstarve/wilson/hit")      
            else
                  inst.SoundEmitter:PlaySound("dontstarve/wilson/hit")
                  inst.AnimState:PlayAnimation("hit")
                  inst:ClearBufferedAction()
            end
            
            if inst.prefab ~= "wes" then
                local sound_name = inst.soundsname or inst.prefab
   local sound_event = "dontstarve/characters/"..sound_name.."/hurt"
                inst.SoundEmitter:PlaySound(inst.hurtsoundoverride or sound_event)
            end
            if inst.prefab ~= "char" then
                  inst.components.locomotor:Stop()    
            end      
        end,
        
        events=
        {
            EventHandler("animover", function(inst) inst.sg:GoToState("idle") end ),
        }, 
        
        timeline =
        {
            TimeEvent(3*FRAMES, function(inst)
                inst.sg:RemoveStateTag("busy")
            end),
        },        
               
    },
 
Change all of the chars to your character's name.  Tell me if it doesn't work, and I'll try to help more.
Link to comment
Share on other sites

 

 Tell me if it doesn't work, and I'll try to help more.

 

 

It did! Thank you so much! :grin:

 

Also I leaved the hit animation play, It looks more natural, It still gets interrupted when attacking and shows briefly while walking without stopping motion It looks amazing!

 

EDIT: Looks like it does not cancels the current attack but it does prevents starting a new one while the animation plays, and movement stops for like a single frame :|

Link to comment
Share on other sites

Yeah, already tried that, ironically it makes the character immune to freezing, heh...

 

Is there a way to make the character get less benefit from insulator items

inst.components.insulator ), give them a fractional multiplier somehow?

So the character receives less benefit from insulating items?

 

Not exactly the same, but it might work

Link to comment
Share on other sites

Is there a way to decrase the temperature tresshold at wich the character will start to thaw and then freeze?

 

Like thawing at 10° and freezing at 5°, I'm assuming that should work.

 

Not that I can find...

however the iceover.lua

...\dont_starve\data\scripts\widgets\iceover.lua

 

seems to controls when the screen displays ice and (I am assuming) at which a player takes damage.

Maybe you can find a way to change it.

Link to comment
Share on other sites

Ok I almost got this.

 

In the temperature component, inside the Temperature:OnUpdate function i found:

 

    local freeze_time = TUNING.SEG_TIME + total_insulation

 

And it looked like it controled freezing speed, so I changed that to something ridiculously low (just for testing):

 

    local freeze_time = ((TUNING.SEG_TIME + total_insulation) / 30)

 

Aparently this made Wilson's temperature to go down lighning fast, while still matching air temperature, and insulating items decelerated this.

 

Now, again, how can I make that small edit to only have effect while playing as my character?

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