• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Solved] Focus

Status
Not open for further replies.
Level 16
Joined
Jun 24, 2009
Messages
1,409
Before anyone mention that I miss the event and the condition, I'm using a system that calls the spell most efficiently. The system works perfectly, all other spells work.

I'm making a simple MPI spell similar to the Windrunner's ultimate in DotA. The difference is that I just give her minor attack speed bonus and won't reduce damage. But when I cast the spell it don't gives the hero the attack speed increase ability.

  • Focus
    • Events
    • Conditions
    • Actions
      • Set TempInt = (Player number of (Triggering player))
      • Set TempInt2 = (Strength[TempInt] - 14)
      • Set FCaster[TempInt] = (Triggering unit)
      • Set FTarget[TempInt] = (Target unit of ability being cast)
      • Unit - Add % speed to FCaster[TempInt]
      • Unit - Set level of % speed for FCaster[TempInt] to TempInt2
      • Unit - Order FCaster[TempInt] to Attack FTarget[TempInt]
  • Focus Check
    • Events
      • Unit - A unit Is issued an order targeting an object
    • Conditions
    • Actions
      • Set TempInt = (Player number of (Triggering player))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Issued order) Equal to (Order(attack))
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Attacking unit) Equal to FCaster[TempInt]
              • (Attacked unit) Equal to FTarget[TempInt]
            • Then - Actions
            • Else - Actions
              • Unit - Remove % speed from FCaster[TempInt]
              • Set FCaster[TempInt] = No unit
              • Set FTarget[TempInt] = No unit
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Issued order) Not equal to (Order(move))
            • Then - Actions
              • Unit - Remove % speed from FCaster[TempInt]
              • Set FCaster[TempInt] = No unit
              • Set FTarget[TempInt] = No unit
            • Else - Actions
 
for the units... try setting it to the max number of players... integers should be fine ven if you put 1 as array size... but units should be fine too as they don't need to be initialized...

Is the spell targeted like the original Focus ability? if yes, your two triggers might be conflicting with each other...

anyway, your condition is wrong I think... there is no Attacking unit and attacked unit on that event... Use TriggeringUnit and Target unit of issued order...

I believe this causes the 2nd trigger to run the removal actions after your first... You order him to attack as the last action of the first, the second trigger fires, Condition 1 is satisfied (issued order = attack)... now the second set of conditions will be false since AttackedUnit and Attacking unit are both equal to no unit, meaning the ability will then be removed from your unit...
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
  • Focus
    • Events
    • Conditions
    • Actions
      • Set TempInt = (Player number of (Triggering player))
      • Set TempInt2 = (Strength[TempInt] - 14)
      • Set FCaster[TempInt] = (Triggering unit)
      • Set FTarget[TempInt] = (Target unit of ability being cast)
      • Unit - Add % speed to FCaster[TempInt]
      • Unit - Set level of % speed for FCaster[TempInt] to TempInt2
      • Unit - Order FCaster[TempInt] to Attack FTarget[TempInt]
  • Focus Check
    • Events
      • Unit - A unit Is issued an order targeting an object
    • Conditions
    • Actions
      • Set TempInt = (Player number of (Triggering player))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Issued order) Equal to (Order(attack))
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Attacking unit) Equal to FCaster[TempInt]
              • (Attacked unit) Equal to FTarget[TempInt]
            • Then - Actions
            • Else - Actions
              • Unit - Remove % speed from FCaster[TempInt]
              • Set FCaster[TempInt] = No unit
              • Set FTarget[TempInt] = No unit
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Issued order) Not equal to (Order(move))
            • Then - Actions
              • Unit - Remove % speed from FCaster[TempInt]
              • Set FCaster[TempInt] = No unit
              • Set FTarget[TempInt] = No unit
            • Else - Actions

There is quite a bit of proceural coupling. Try and use negation of the one condition so that only 1 copy of the actions...
Unit - Remove % speed from FCaster[TempInt]
Set FCaster[TempInt] = No unit
Set FTarget[TempInt] = No unit
is used. This is good programming practice as if you ever need to maintain those actions, it means that you do not have to update 2 instances (so less chance of a error occuring).
 
Level 9
Joined
Dec 12, 2007
Messages
489
The problem was that it instantly removed the ability because the hero ordered to cast the spell. Now I added an extra condition that checks if the caster has the spell.
another workaround that i would like to suggest is:

1. at Focus trigger, you add the caster into a unit group, then at the Focus Check, you check again whether the ordered unit is in the unit group before checking the issued order.

2. at Focus Check trigger, change the 'attacking unit' to 'triggering unit', and 'attacked unit' into 'target unit of issued order'.
 
Level 9
Joined
Dec 12, 2007
Messages
489
well that "add unit to group" is there so when the unit cast the spell and triggering the Focus, it doesn't get checked by the Focus Check as the Focus Check will also check the order of casting the spell.

although i haven't confirm which one triggered first, the unit issued order, or starts the effect of an ability.
if the starts the effect of an ability is triggered first, then this is just overcomplicate the trigger.
otherwise well you know about it.

and when the unit has fulfilled the condition for removing the bonus, remove the unit from the unit group too.

also, modifying the spell to base on (unit group and hashtable) instead of variable array will allow the spell to be multi-instanceable.
 
Status
Not open for further replies.
Top