• 🏆 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!

Trigger: Help getting started, please

Status
Not open for further replies.

Ardenian

A

Ardenian

Hello,

A.) I would like to create a general trigger for my TD that damages units if a spell is casted on them ( the spell has no damage and the trigger replaces the default damage the spell would have had).

This is what I have for now:
  • Death Bolt
    • Events
      • Unit - A unit is attacked
    • Conditions
      • (Ability being cast) Equal Death Bolt
    • Actions
      • Set Armor_Wave[Levels_Current] = Unit_Armor
      • Unit - Cause (Casting unit) to damage (Attacked unit), dealing ((50.00 + (50.00 x (Real((Level of (Ability being cast) for (Casting unit)))))) - (Real(Unit_Armor))) damage of attack type Spells and damage type Normal
Explanation:
Armor_Wave is an indexed variable that is set at the initialization to the wave armors.

Unit_Armor is an integer variable that is used to check armor influences later ( not added in this trigger) and to define the final damage correctly. Armor reduces the damage with the exact armor value of the time the trigger executes. Negative armor increases the damage by the exact value.

So, now I need your help, please. First of all, the trigger does not work. I think it has something to do with the event and the condition. I also did not indexed the variable yet, but it should result into 0, so the damage still works.

B.)
Additionally, I would like to transform this trigger into a general trigger. That means, one trigger runs for all abilities. This should be possible if using the variable Hero_Ability(1,NUMBER_OF_INDEXED_ABILITIES) as condition ( check if it is casted).

Now I can use another indexed variable called Ability_Damage(1,NUMBER_OF_INDEXED_ABILITIES) to get the corresponding damage value for the damage part ( not added in the trigger above). But, how do I get the corresponding ability number ( index) for the Ability_Damage variable ?
 
Level 19
Joined
Oct 7, 2014
Messages
2,209
First of all the event:
  • Unit - A unit is attacked
is wrong and it should be:
  • Unit - A unit Starts the effect of an ability
and change the
  • Casting Unit
to
  • Target unit of ability being cast

I can't understand the B.) part
 

Ardenian

A

Ardenian

Alright, I will try it, thank you :)

B.) It means that I don't want to write a trigger for each ability ( as the one above is for the Death Coil, for example), but one trigger for all abilities, as they don't differ between each other except damage.

Hero_Ability(X) are the abilities that are used, indexed at map initialization.

Ability_Damage(X) is the corresponding damage of each ability, that means Hero_Ability(1) has Ability_Damage(1) damage, Hero_Ability(2) has Ability_Damage(2) damage and so on.

My question in the B.) part is how do I get the corresponding index. If the trigger runs and the Hero_Ability(A) is checked, how do I set the Ability_Damage(X) to Ability_Damage(A) ?
 
Level 9
Joined
Apr 23, 2011
Messages
527
A. see apcrab's solution.
B. when the ability is checked (which i assume you do using ITEs), set an integer variable to the index number of the ability then when you deal the damage, use Ability_Damage(integervar)
 

Ardenian

A

Ardenian

A. see apcrab's solution.
B. when the ability is checked (which i assume you do using ITEs), set an integer variable to the index number of the ability then when you deal the damage, use Ability_Damage(integervar)

Create if then else function and check if the Hero_Ability(X) is used.

In this case I would have to add a ITE for each ability, wouldn't I ?
I thought about adding it as condition, not in the ITE, but I don't know whether it is possible.

A user said once:
also, you can create those events with a loop in an initialisation trigger:
just do a For Each integer variable my_int loop with the action:
Trigger - Add the event: Player(my_int) selects a unit
you could also use integer A but this is faster

i always used this when i had multiple triggers for all players like chat commands
I wanted to use this for the multiple ability, but to be honest, I don't really understand what he explains nor do I know whether I can refer it to my trigger.
 
Level 9
Joined
Apr 23, 2011
Messages
527
i forgot about the existence of loops :p do it like this.
  • Spell Damage
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
    • Actions
      • For each (Integer loop) from 1 to 10, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Ability being cast) Equal to Ability[loop]
            • Then - Actions
              • Unit - Cause (Casting unit) to damage (Target unit of ability being cast), dealing Ability_Damage[loop] damage of attack type Spells and damage type Normal
            • Else - Actions
the problem in this trigger is that it checks for each ability even if say, Death Coil is the cast ability and it is index number 2. but it's only a minor issue i think. i would put a boolean condition player in player group but do what you wish.
 

Ardenian

A

Ardenian

Alright, thank you! I think I got it now.

Thank you, Light and apcrabnightlive!
 

Ardenian

A

Ardenian

You should set a Integer Variable for the (Integer Loop) part of Light's trigger.

What does this mean ?

Integer A ?

For now I created an integer variable called 'Loop', but it is not set to any value ( testing atm). Does it works ?
 

Ardenian

A

Ardenian

Yes, it works!

But, there is one problem...

The damage and the missile do not hit the target at the same time, any suggestions ?
 

Ardenian

A

Ardenian

I Recommend exit the loop once the appropriate value has been discovered.
Uhm, excuse me ? How do I execute this ?

This honestly inspired me to write something like of ability navigator ^^ but I have no time for that now.
I am surprised this system does not exist ( does it ?)
I mean, I am surely not the first one who triggers an ability damage and additionally the projectile using indexed variables.

@Light: Uhm, and how do I include it into the trigger ? I am so bad with trigger, hu...
 
Level 9
Joined
Apr 23, 2011
Messages
527
triggering a projectile means triggering its ENTIRE movement, which i think could be done by making something similar to a knockback and also checking if its near the target. i've never done this before, so i don't have any examples. try looking in the spell section.

as for incorporating it into the trigger, i'd suggest using another ITE with an OR condition, adding a (Ability being cast) Equal to Ability[x] for each ability that required a projectile, then turning on a loop.
 
At the end of the then (after all action), insert a Skip Remaining Actions action. This forces the loop to close, but also close the entire trigger execution as well (remaining actions below Skip Remaining Actions won't be executed). ONLY use it if it doesn't have actions below the loop (this includes the else is completely empty).

Another way is to use exitwhen, but that's a bit more complicated.

EDIT :
I'm thinking of something where users can define which ability being cast without passing conditional checks (and optimizes GUI triggers).
I can't recall anyone done it yet, though somebody might already did.
 

Ardenian

A

Ardenian

triggering a projectile means triggering its ENTIRE movement, which i think could be done by making something similar to a knockback and also checking if its near the target. i've never done this before, so i don't have any examples. try looking in the spell section.

as for incorporating it into the trigger, i'd suggest using another ITE with an OR condition, adding a (Ability being cast) Equal to Ability[x] for each ability that required a projectile, then turning on a loop.
Hm, I see. Why couldn't I index all projectiles like the abilities and damages and the use it the same way as we did before ?
I hope there is a system in the Spell section...
At the end of the then (after all action), insert a Skip Remaining Actions action. This forces the loop to close, but also close the entire trigger execution as well (remaining actions below Skip Remaining Actions won't be executed). ONLY use it if it doesn't have actions below the loop (this includes the else is completely empty).

EDIT :
I'm thinking of something where users can define which ability being cast without passing conditional checks (and optimizes GUI triggers).
I can't recall anyone done it yet, though somebody might already did.

Hm, but Skip Remaining Actions does not make the projectile fly right, sadly.. ( I think it slightly improves it, but I don't know)

This all is at the very limit of my own trigger skills, I am not sure whether I am able to follow your advices..
 
Well, in that case scrap the Skip Remaining Actions if it bugs. It just an attempt to reduce the loop by stopping once discovering the right value. But if it bugs, then it's not worth it. I myself is uncertain about the exitwhen.

IMO, better have the entire handling of this system in Hashtables, but that would rather over complicate things.

For Projectile, there's a LOT of them ^^
Spell and Jass Sections has some, I prefer to go with Wietlol's (Spell Section), since it's quite easy to use in GUI with the manual and examples given.
 

Ardenian

A

Ardenian

Hm alright, thank you! 'You have given out too many reputation'

Now I will have a hard time adding this system...
By the way, it is pending, is this something I should worry about ?
 

Ardenian

A

Ardenian

not really. if you can apply it to your map and it works, then it's fine.

No, I cannot. I hardly understand the triggering he does ( Wietlol) and it seems his system damages, too, so I don't need all the stuff we spoke about in this thread.

I will pause this part and work on other parts of the map and will request the implementation once I reached a certain stage of work.

Thank you for your help, guys!
 
Pending? I don't recall that in my mind when typing, I'm very sorry about that.
But as memory serves, it works well.

Well, took some time to look for Missile/Projectile Systems :
http://www.hiveworkshop.com/forums/.../?prev=search=Projectile%20System&d=list&r=20
http://www.hiveworkshop.com/forums/.../?prev=search=Projectile%20System&d=list&r=20
http://www.hiveworkshop.com/forums/...438/?prev=search=Missile%20System&d=list&r=20
http://www.hiveworkshop.com/forums/...342/?prev=search=Missile%20System&d=list&r=20
http://www.hiveworkshop.com/forums/...543/?prev=search=Missile%20System&d=list&r=20

Some others I could found ^^
There are TONS of these, and yes, I'm aware the fourth link is in Needs Fix, but that's due to Originality reason, which is not the case of working/not working. Since it works and seems possible to use, why not?
The famous keyword for these, for some reason is Missile System, rather than Projectile System

EDIT :
If only one specific spell needs to use this mechanic, then just code the entire spell.
But if many spells will end up having to do this, then a missile system will be a necessity for the sake of efficiency and ease of use.

Btw, I just remember I code something for my old firebolt spell which triggers after hit, I might take a look into it perhaps (hopefully it's somewhere in my brother's laptop disk).
 

Ardenian

A

Ardenian

Pending? I don't recall that in my mind when typing, I'm very sorry about that.
But as memory serves, it works well.

Well, took some time to look for Missile/Projectile Systems :
http://www.hiveworkshop.com/forums/.../?prev=search=Projectile%20System&d=list&r=20
http://www.hiveworkshop.com/forums/.../?prev=search=Projectile%20System&d=list&r=20
http://www.hiveworkshop.com/forums/...438/?prev=search=Missile%20System&d=list&r=20
http://www.hiveworkshop.com/forums/...342/?prev=search=Missile%20System&d=list&r=20
http://www.hiveworkshop.com/forums/...543/?prev=search=Missile%20System&d=list&r=20

Some others I could found ^^
There are TONS of these, and yes, I'm aware the fourth link is in Needs Fix, but that's due to Originality reason, which is not the case of working/not working. Since it works and seems possible to use, why not?
The famous keyword for these, for some reason is Missile System, rather than Projectile System

EDIT :
If only one specific spell needs to use this mechanic, then just code the entire spell.
But if many spells will end up having to do this, then a missile system will be a necessity for the sake of efficiency and ease of use.

Btw, I just remember I code something for my old firebolt spell which triggers after hit, I might take a look into it perhaps (hopefully it's somewhere in my brother's laptop disk).

Wow, thank you for making the effort!

I think the first one seems good, although I don't know what's UMSWE.

Yes, all spells will need to be triggered due to a special damage formula I created for damage.
I tried to add one of the systems ( the one from Wietlol), but failed and it deactivated all my triggers...
I think I am going to try one of the ones you mentioned.

I would be glad if you have one for me, too.

Is there no way to make the hitting of the target the event ?
Then the problem would be solved without any custom system.
 

Ardenian

A

Ardenian

@Daffa the Mage
Gladly I did copy it before :)

Hm, about the missile problem, couldn't I just use a 'wait' trigger with time: Distance between casting unit and target casted on / projectile speed ?

Or doesn't it work ? Does this solution allows multiple executions at the same time ?
 

Ardenian

A

Ardenian

What do you mean with inaccuracy ?
I thought about creating an indexed variable that is defined for each projectile speed, the same way we did for the armor of each wave. Does this avoid inaccuracy ?
And what do you mean with inaccuracy in multiplayer ?
 
@Ardenian
I'm referring of using waits which is inaccurate.

Handling missiles of spells (like one you want to make) is better with timers, since the damage would be dealt accurately, while wait might have slight error in damage, either a bit delayed or sooner on actual damage hit.
Hence why people recommend and make Missile Systems.

Sorry if I confuse you before, was a bit sleepy when replying last night.

@Light
No, they're that inaccurate it can get annoying sometimes. And indexing with wait would look very terrible. Better go with timers instead.
 

Ardenian

A

Ardenian

Oh, no problem, I am glad that you take the time and be patient with me.

Yes, I thought about using timer and I came to the conclusion that they are also inaccurate because they don't pay attention to a unit's movement speed which will result into inaccuracy.

I feel as if I cannot avoid adding a missile system..
Tho, I will think about whether it is possible to add the movement speed into the wait trigger.
 
Status
Not open for further replies.
Top