Jump to content

Trigger Character State


Recommended Posts

I've made a 2 handed attack animation.

 

In SGwilson.lua that's where it trigger the state to use :

 

EventHandler("doattack", function(inst)        if not inst.components.health:IsDead() and not inst.sg:HasStateTag("attack") then            local weapon = inst.components.combat and inst.components.combat:GetWeapon()            if weapon and weapon:HasTag("blowdart") then                inst.sg:GoToState("blowdart")            elseif weapon and weapon:HasTag("thrown") then                inst.sg:GoToState("throw")            else                inst.sg:GoToState("attack")            end        end    end)

So if I add :

elseif weapon and weapon:HasTag("2h") then  inst.sg:GoToState("two_handed_spear")

it works perfectly but I don't want to modify the original files so my question is :

 

How would I do it in the modmain.lua?

 

Thanks

 

 

Link to comment
Share on other sites

Ìn your mod, at this line :

AddStategraphActionHandler("wilson", ActionHandler(ACTIONS.BOWATTACK, function(inst, action)--                                                                        inst.sg.mem.localchainattack = not action.forced or nil      if not inst.components.health:IsDead() and not inst.sg:HasStateTag("attack") then        if inst.components.combat ~= nil and (GLOBAL.GetTime() - inst.components.combat.laststartattacktime) > 1.2 then          local weapon = inst.components.inventory:GetEquippedItem(EQUIPSLOTS.HANDS) or nil          return (weapon:HasTag("bow") and weapon:HasTag("zupalexsrangedweapons") and "bow")        end      end    end  ))

When is this ActionHandler called?

 

Link to comment
Share on other sites

Just figured that your action is being triggered by the CollectEquippedActions from your components zupalexsrangedweapons which is called GetEquippedItemActions from the playeractionpicker.

 

Now things is, that my left and right mouse button actions are inverted. It wants to examine with left click and attack with right click.

Link to comment
Share on other sites

Alright. The ds version is outdated though so the way it's done is a bit ugly. You do not really have to go modify the playeractionpicker or stuffs like that. I'll update the ds version to include the dst version improvements soon. Meanwhile I'll check your previous posts from a computer so i can try to help. Cheers

Link to comment
Share on other sites

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
 Share

×
×
  • Create New...