SenL Posted February 13, 2016 Share Posted February 13, 2016 (edited) I have a character mod who could do some "power" attack when certain criterias are met. This would be hotkeyed to a button. Let's say x. When the char has this ability enabled, player could press x and he would be able to "right click" an enemy and does a melee "power" attack with more damage. Once this attack is done, I need to disable this ability until the next time certain criterias met again. How do you do this? I copied from Starve Wars mod "Force strike" but it's not working. I don't have fancy button on the hud to enable/disable +cooldown etc. So far my code is below in modmain: Spoiler local BK_IRONFIST = AddAction("BK_IRONFIST", "Iron Fist", function(act) local target = act.target local attacker = act.doer local old_damage = attacker.components.combat.damagemultiplier local targetPos = GLOBAL.Vector3(target.Transform:GetWorldPosition()) if attacker.components.combat:IsValidTarget(target) then attacker.components.combat.damagemultiplier = old_damage*5 attacker.components.combat:DoAttack(target) attacker.ironfistenabled = false --disable ironfist attacker.components.combat.damagemultiplier = old_damage end if targetPos ~= nil then GLOBAL.SpawnPrefab("shock_fx").Transform:SetPosition(targetPos:Get()) end BK_IRONFIST.rmb = false --what does this do? return true end) BK_IRONFIST.rmb = false --what does this do? AddStategraphActionHandler("wilson", GLOBAL.ActionHandler(GLOBAL.ACTIONS.BK_IRONFIST, function(inst) if not (inst.components.health:IsDead() or inst.replica.health:IsDead()) and not inst.sg:HasStateTag("attack") then return "attack" end end )) AddStategraphActionHandler("wilson_client", GLOBAL.ActionHandler(GLOBAL.ACTIONS.BK_IRONFIST, function(inst) if not inst.replica.health:IsDead() and not inst.sg:HasStateTag("attack") then return "attack" end end )) local function IronFist(inst) if inst:HasTag("playerghost") then return end --ignore if ghost if inst.sg:HasStateTag("busy") then return end --ignore if busy if inst.ironfistenabled == false then if inst.components.talker ~= nil then inst.components.talker:Say("I need more Crown Power for that", 4) --4 seconds end return end BK_IRONFIST.rmb = true --what does this do? end AddModRPCHandler("MyChar", "IronFist", IronFist) Thanks. Edited February 13, 2016 by SenL Link to comment https://forums.kleientertainment.com/forums/topic/64301-how-to-add-action-to-rmb-and-enabledisable-it/ Share on other sites More sharing options...
Kzisor Posted February 13, 2016 Share Posted February 13, 2016 4 hours ago, SenL said: I have a character mod who could do some "power" attack when certain criterias are met. This would be hotkeyed to a button. Let's say x. When the char has this ability enabled, player could press x and he would be able to "right click" an enemy and does a melee "power" attack with more damage. Once this attack is done, I need to disable this ability until the next time certain criterias met again. How do you do this? I copied from Starve Wars mod "Force strike" but it's not working. I don't have fancy button on the hud to enable/disable +cooldown etc. So far my code is below in modmain: Hidden Content Thanks. You need to add a component action through AddComponentAction. You can look at the mod More Actions to see how it's done better. Link to comment https://forums.kleientertainment.com/forums/topic/64301-how-to-add-action-to-rmb-and-enabledisable-it/#findComment-722284 Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now