[Trigger] Remove event from trigger

Status
Not open for further replies.
Level 8
Joined
Apr 30, 2009
Messages
338
This is pretty tough to explain, so I will try to keep it short.

In the test map I'm making, I am triggering all spells so that I can have their damage/healing affected by the Intelligence stat. Each spell will have a spellpower modifier just like the spell coefficients in World of Warcraft. One thing I want to do is have items that modify ONLY spellpower, without giving any of the other benefits of Intellect (mana regeneration and damage for Intelligence heroes).



So I did figure out how to do this, it is quite simple: When a unit possessing a "spellpower" item begins casting, I will add to his Intelligence. When he stops casting, I will remove that Intelligence:

  • powerboost
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • ((Triggering unit) has an item of type Savant's Staff) Equal to True
    • Actions
      • Hero - Modify Intelligence of (Triggering unit): Add 25
      • Trigger - Add to powerloss <gen> the event (Unit - (Triggering unit) Stops casting an ability)
  • powerloss
    • Events
    • Conditions
      • ((Triggering unit) has an item of type Savant's Staff) Equal to True
    • Actions
      • Hero - Modify Intelligence of (Triggering unit): Subtract 25


Here, in my test map, the item "Savant's Staff" has +25 Intelligence while casting. The triggers I have set up work perfectly for the first time only. After that, they subtracts the Intelligence 2, 3, 4 ... etc. times each cast because the event is counting for each previous spellcast too.



I am thinking if I can add this line to the end of the second trigger, it will work just fine:

  • Trigger - Remove from powerloss <gen> the event (Unit - (Triggering unit) Stops casting an ability)


So is there a custom script line to remove an event?



Attached is my test map, the old one I uploaded in my movespeed thread does not have the triggers for this.
 

Attachments

  • test.w3x
    24.2 KB · Views: 64
Level 8
Joined
Apr 30, 2009
Messages
338
I think I figured out a workaround with a global unit group.


Can you tell me if this works. I don't think a leak will be so bad since a hero will only ever be added to it one time.

  • powerboost
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • ((Triggering unit) has an item of type Savant's Staff) Equal to True
    • Actions
      • Hero - Modify Intelligence of (Triggering unit): Add 25
      • If (((Triggering unit) is in savant_staff) Equal to False) then do (Trigger - Add to powerloss <gen> the event (Unit - (Casting unit) Stops casting an ability)) else do (Unit Group - Add (Triggering unit) to savant_staff)
  • powerloss
    • Events
    • Conditions
      • ((Triggering unit) has an item of type Savant's Staff) Equal to True
    • Actions
      • Hero - Modify Intelligence of (Triggering unit): Subtract 25
 
Level 7
Joined
Jul 18, 2009
Messages
272
If all the spell damage is triggered anyways, why don't you just let it deal <base dmg>+<int bonus>+<item bonus>dmg instead of manipulating the int value? Would be more easy and your hero's dmg wouldn't go up while casting a spell.
 
Level 8
Joined
Apr 30, 2009
Messages
338
I got it to work with these triggers:

  • powerboost
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • ((Triggering unit) has an item of type Savant's Staff) Equal to True
    • Actions
      • Hero - Modify Intelligence of (Triggering unit): Add 55
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Triggering unit) is in savant_staff) Equal to False
        • Then - Actions
          • Trigger - Add to powerloss <gen> the event (Unit - (Casting unit) Stops casting an ability)
          • Unit Group - Add (Triggering unit) to savant_staff
        • Else - Actions
  • powerloss
    • Events
    • Conditions
      • ((Triggering unit) has an item of type Savant's Staff) Equal to True
    • Actions
      • Hero - Modify Intelligence of (Triggering unit): Subtract 55
It works fine, except I would need 1 for every item. On the other hand, if I get rid of the above 2 triggers and just have an integer for every item and set it to 0 or the spellpower based on if the unit has the item, then I would have to code it into every spell. Seems like the same amount of work, but the second way doesn't seem as exploitable.


Here is how I coded my "-sp" command, to show the spellpower of the selected hero:

  • spellpower
    • Events
      • Player - Player 1 (Red) types a chat message containing -sp as An exact match
      • Player - Player 2 (Blue) types a chat message containing -sp as An exact match
      • Player - Player 3 (Teal) types a chat message containing -sp as An exact match
      • Player - Player 4 (Purple) types a chat message containing -sp as An exact match
      • Player - Player 5 (Yellow) types a chat message containing -sp as An exact match
      • Player - Player 6 (Orange) types a chat message containing -sp as An exact match
      • Player - Player 7 (Green) types a chat message containing -sp as An exact match
      • Player - Player 8 (Pink) types a chat message containing -sp as An exact match
      • Player - Player 9 (Gray) types a chat message containing -sp as An exact match
      • Player - Player 10 (Light Blue) types a chat message containing -sp as An exact match
    • Conditions
    • Actions
      • Do nothing
      • Unit Group - Pick every unit in (Units currently selected by (Triggering player)) and do (If (((Picked unit) is A Hero) Equal to True) then do (Unit Group - Add (Picked unit) to spellpower_group) else do (Do nothing))
      • For each (Integer A) from 1 to (Number of units in spellpower_group), do (Actions)
        • Loop - Actions
          • Set spellpower_unit = (Random unit from spellpower_group)
          • If ((spellpower_unit has an item of type Savant's Staff) Equal to True) then do (Set spellpower_items_savant = 55) else do (Set spellpower_items_savant = 0)
          • Set spellpower_items_total = (spellpower_items_savant + 0)
          • Game - Display to (All players matching ((Matching player) Equal to (Triggering player))) the text: (Total spellpower of + ((Name of spellpower_unit) + (: + ((String(((Intelligence of spellpower_unit (Include bonuses)) + spellpower_items_total))) + (, ( + ((String((Intelligence of spellpower_unit (Include bonuses)))) + ( from Intelligence + + ((String(sp
          • Unit Group - Remove spellpower_unit from spellpower_group
          • Custom script: set udg_spellpower_unit = null
      • Unit Group - Remove all units of spellpower_group from spellpower_group


Notice in this line:
  • If ((spellpower_unit has an item of type Savant's Staff) Equal to True) then do (Set spellpower_items_savant = 55) else do (Set spellpower_items_savant = 0)
I would check for every item in the game that adds spellpower (no INT), and set it to 0 or the spellpower value. Then this line:
  • Set spellpower_items_total = (spellpower_items_savant + 0)
Will grow as long as needed based on the number of items in the game that add only spellpower (no INT).



Here is what happens:


2rm128i.jpg
 
Status
Not open for further replies.
Top