| 06-25-2007, 06:05 PM | #1 |
I'm using Shadow1500's AnyUnitTakesDamage system for my map to register whenever a unit takes damage (found here), but I'm not sure ho to implement it so this trigger runs whenever a unit takes damage: JASS:function OnSwiftnessAttackConds takes nothing returns boolean return GetUnitAbilityLevel(GetAttacker(),'A03A') >= 1 and udg_SwiftnessOn == true endfunction function OnSwiftnessAttack_Actions takes nothing returns nothing local integer i = 0 local unit u = GetAttacker() local unit u2 = GetTriggerUnit() local location l1 = GetUnitLoc(u) local location l2 = GetUnitLoc(u2) call DisplayTextToForce( GetPlayersAll(), "function started" ) loop call DisplayTextToForce( GetPlayersAll(), "Loop run" ) call CreateUnit(Player(GetPlayerId(GetOwningPlayer(GetAttacker()))),'H018',GetUnitX(u),GetUnitY(u),AngleBetweenPoints(l1,l2)) call RemoveLocation(l1) call RemoveLocation(l2) call SetUnitVertexColor(GetLastCreatedUnit(),255,255,255,50) call SetUnitTimeScalePercent(GetLastCreatedUnit(),1.50) call SetHeroLevel(GetLastCreatedUnit(),GetHeroLevel(u),false) call SetUnitAbilityLevel(GetLastCreatedUnit(),'A03A',GetUnitAbilityLevel(u,'A03A')) call SetUnitAbilityLevel(GetLastCreatedUnit(),'A007',GetUnitAbilityLevel(u,'A007')) call SetUnitAbilityLevel(GetLastCreatedUnit(),'A030',GetUnitAbilityLevel(u,'A030')) call SetUnitAbilityLevel(GetLastCreatedUnit(),'A034',GetUnitAbilityLevel(u,'A034')) call IssueTargetOrder(u,"attackonce",u2) call PolledWait(.24) set i = i + 1 exitwhen i >=2 endloop set i = 0 if GetUnitStateSwap(UNIT_STATE_MANA,u) <= (50-(GetUnitAbilityLevel(u,'A03A') * 4)) then call IssueImmediateOrder(u,"unflamingarrows") set udg_SwiftnessOn = false endif set u = null set u2 = null endfunction function InitTrig_OnSwiftnessAttack takes nothing returns nothing set gg_trg_OnSwiftnessAttack = CreateTrigger() call TriggerRegisterAnyUnitEventBJ(gg_trg_OnSwiftnessAttack,AnyUnitTakesDamage) call TriggerAddCondition( gg_trg_OnSwiftnessAttack, Condition( function OnSwiftnessAttackConds ) ) call TriggerAddAction(gg_trg_OnSwiftnessAttack, function OnSwiftnessAttack_Actions ) endfunction SwiftnessOn is a global boolean that I use to check weather the unit is currently autocasting the spell or not. If there is a way to do it that would make it MUI, it would help. Edit: Another question - If im using SetUnitTimeScalePercent, to set it to 150% is it 150 or 1.50? |
| 06-25-2007, 06:51 PM | #2 | |
Umm... If the trigger's action is "Any Unit Takes Damage", then shouldn;t your trigger fire on that action, like you're asking? Quote:
And I'm pretty sure you use 150, not 1.50. |
| 06-25-2007, 07:01 PM | #3 |
I should've posted this first- it finds a syntax error if i use AnyUnitTakesDamage, as if the function doesnt exist. |
| 06-25-2007, 10:09 PM | #4 |
Oh, that helps. Did you put the entire system into the map heading? Are the any typos in your script? Is it just a plain syntax error or is it some other type of error? Maybe, after AnyUnitTakesDamage, you need a (). so it'd be AnyUnitTakesDamage(). I don't personally know, I don't use that system. Just putting up some basic checks. |
| 06-25-2007, 10:40 PM | #5 |
The system doesnt go in the map heading- the directions say to put it in a trigger called AddDmg, which is what I did. I know its not my script, i put messages so if it was running I would see. If you have any other engines which allow you to find an attacker and attacked unit when it takes damage which work well, I would appreciate it. |
| 06-25-2007, 11:16 PM | #6 |
Ok, is the trigger at the top of the list of triggers? I'm betting that could be the issue. Otherwise just check for simple errors, who knows. |
| 06-26-2007, 11:59 AM | #7 |
The position of the trigger in the list of triggers is totally irrelevant. Your problem is most likely the system and related functions are not above the code you posted in the map script. To solve it you should either put the code in the custom script section or use vJass and make it a library. |
