Triggered Spells Help

N(O.O)B

New Member
Reaction score
27
So, I used to play around in the Warcraft 3 Editor quite a bit, so I'm used to basing spells off of a dummy spell (channel) and triggering the entire spell as this was much more fluent and allowed for a lot more unique spells. After I tried doing this in the Galaxy Editor, I ran into a few problems, though.

In Warcraft 3, the editor had two very useful actions that made this easier:
Unit - Damage Unit
Allowed for one unit to damage another unit instantly
Special Effect - Create Special Effect
Creates a model at a target location.

Now I've looked everywhere and I really can't figure out how to do these.

Edit: Figured them out myself, nevermind.
 

touchpad

New Member
Reaction score
0
Wait, you figured this out? I've been working on this all day. How did you get instant damage to work?
 

touchpad

New Member
Reaction score
0
I found a method for doing this, but I hope there is a better one. I defined a function with the arguments damager, damagee, and amount that handles the damage dealing and scoring if the damage causes a kill. Now, whenever I want to deal damage I create an if/then/else action in the appropriate trigger and call this function in the condition, and leave the then and else blank.


If:
Conditions:
Deal damage to target(damager,damagee,amount) == True
Then:
Else:


I'm guessing that there is an action that handles damage buried somewhere in the trigger editor, but I have not found it. This should work for most purposes though.

Edit: The 'damage' aspect of the function is just setting the health of damagee to its current value minus the damage amount.
 

touchpad

New Member
Reaction score
0
I have found something that I can't do using this method. If the damage function kills the unit it damages, the unit that would be dealing the damage does not have a kill added to its kill count in the UI. If I were making a hero map, a hero using a triggered ability would presumably not get experience from getting a kill through an ability that calls the damage function.

If anyone knows of a function to give a unit credit for a kill, that would be awesome. If anyone knows how to access a built in function that makes a unit deal damage to a unit, that would be more awesome still.
 

N(O.O)B

New Member
Reaction score
27
I created a function called "Damage Unit" that uses a simple repeated function to deal damage to the unit.

First, you will need 4 (or more) effects, called:
Damage - 1 (deals 1 damage)
Damage - 10 (deals 10 damage)
Damage - 100 (deals 100 damage)
Damage - 1000 (deals 1000 damage)

Then you will need to make 3 global variables:
- Damaging Unit (Unit Variable)
- Damage Group (Unit Group Variable)
- Damage Amount (Real Variable)

Then, in the trigger (I named it Function: Damage Unit), make it look like this:
damageunitfunction.png


Then, whenever you want to deal damage, enter the following values:
examplelo.png


Basically, whenever you run the trigger, it will deal Damage Amount damage to every unit inside Damage Group from source unit Damaging Unit.
 

Frozenwind

System maker
Reaction score
99
I gotta admit, that's rather smartly done. I'd have done it a little bit different, but using multiple powers of damage is nice to reduce the lag of a repeating loop.
I don't quite understand why you use a unitgroup though, as there should only be one unit in your group anyway.


So basically, we are stuck to effects to deal damage, special effects etc.? So we have to use the data editor far more for triggered skills as in wc3?
 

N(O.O)B

New Member
Reaction score
27
I gotta admit, that's rather smartly done. I'd have done it a little bit different, but using multiple powers of damage is nice to reduce the lag of a repeating loop.
I don't quite understand why you use a unitgroup though, as there should only be one unit in your group anyway.


So basically, we are stuck to effects to deal damage, special effects etc.? So we have to use the data editor far more for triggered skills as in wc3?

It's so you only have to run the trigger once if you want to damage multiple units (for instance, for an area of effect ability).
 

Frozenwind

System maker
Reaction score
99
As it happens instantly, you can use a global unit variable to pass the unit instead of a global unitgroup variable?
The looping is caused by the integer and while loop anyway.
 

Frozenwind

System maker
Reaction score
99
I was only trying to understand why you was using a unitgroup rather then a unit var, but I guess it doesn't matter.
I won't edit it btw, the only thing I'll ever ask is functions, not systems. It's more fun creating them by myself. In this case it'd be the fact you have to use data editor's effects to deal damage through triggers.
 

Sgqvur

FullOfUltimateTruthsAndEt ernalPrinciples, i.e shi
Reaction score
62
I am not sure if this works(not tested) but I'll post it anyway : P
JASS:
void UnitDamageTarget(unit attacker, fixed damage_amount, unit target)
{
    UnitSetPropertyFixed(targer, c_unitPropLife, UnitGetPropertyFixed(target, c_unitPropLife, true) - damage_amount)

    // did we kill it?
    if (UnitTestState(target, c_unitStateIsDead))
    {
        UnitSetPropertyInt(attacker, c_unitPropKills, UnitGetPropertyInit(attacker, c_unitPropKills, true) + 1)
    }
    // what about xp? -> idk : )
}
 

touchpad

New Member
Reaction score
0
There is a potential issue with using global variables rather than function arguments. If you had two abilities cast at around the same time and both set global variables, you might have a global variable changed while it is being used by another function. This might be avoided if you chose "wait" rather than "don't wait" when you call the trigger, but I'm not sure.

I of course have not tested Noob's implementation, and is entirely possible that it works just fine. I'm just pointing this out for other people in the forum, as it holds true for other uses in addition to dealing damage.

I will post the function method, just so it is understood.

damagefunction.png


To call the function, you create an if/then/else action:

If:
Damagetarget(<desired damage dealer>,<desired damage target>,<desired damage amount>) == True
Then:
<leave blank>
Else:
<leave blank>
 

Arkless

New Member
Reaction score
31
The methods abouve kinda lack, don't they? How about armor? In case your unit has 2 armor and you want to deal 8 dmg, the result would be 6 dmg.
First method with 1 dmg, 10 dmg etc. effects:
1 dmg = 0
1 dmg = 0
1 dmg = 0
...
result = 0 dmg

Set hp method:
hp = hp - 8
=> 8 dmg delt



Using a dmg effect and changing the value via catalog action would be the solution, but i do not know how fast that method is (might cause the game to slow down/lag).
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top