| 06-28-2004, 06:10 PM | #1 |
I want to script a spell trigger that instantly kills the targeted unit of an ability after a certain number of attack strikes. That is, once cast, it will store how many times the unit attacks or casts spells until an integer of, say, 10, after which point it dies a messy death. However, I am relatively new to variables and arrays so I am not clear on how to accomplish this. My first thought was to create an integer array and then script a trigger that stores the number of times the unit acquires a target (in a cruel irony, WE does not have "a unit attacks" as an event response), and when the variable reaches the full array of 10, the trigger fires and the enemy goes boom. The variable would then clear the array and start over again once the same spell was cast. My problem is with converting the order strings to integers, which I know must be done but so far has not worked. Also, I think I need some type of looping action to continually store the number of attacks. If anybody has some thought as to how this may be accomplished, post your theories or experiences here. It's not essential to my project, but man, it would be pretty cool. |
| 06-28-2004, 06:55 PM | #2 |
I think it would just be easier to have the skill hurt the caster instead of using triggers to make the caster die after so many casts. This way would probably be better as then you won't have a large amount of unnessisary code (as you would need a load for each unit with the skill) also it wouldn't mean you'd have to remember how many times the skill has been cast. Fiddle about with the spells, though you might need to use one of the enhanced world editors to make the going easier. |
| 06-28-2004, 07:32 PM | #3 |
Heres how I think you can do it. Event Unit - A unit Is attacked Condition (Unit-type of (Attacking unit)) Equal to (Your Unit) Action Set NumberofAttacks = (NumberofAttacks + 1) If (All Conditions are True) then do (Then Actions) else do (Else Actions) If - Conditions NumberofAttacks Greater than or equal to 10 Then - Actions Set NumberofAttacks = 0 (Add whatever actions in here to kill the unit instantly. Else - Actions Do nothing |
| 06-28-2004, 08:43 PM | #4 |
Well, must admit that i got rather lost thinking about this, everything complicates if the caster decides to change targets in the middle of the process. Ergo, the above won't work, or, it would, although not very satisfying. |
| 06-28-2004, 09:21 PM | #5 | |
Quote:
I think you misunderstood me. The skill will not kill the caster, but rather the targeted unit of the caster's ability. This makes things tricky as I have to coordinate the ability comparison with the integer comparison of the number of attack strikes. And as the poster before me mentioned, I would have to set up a trigger to prevent the caster from using the ability on more than one unit at a time. In any case, I appreciate the help so far, and welcome any further contributions to how this might be feasible. |
| 06-28-2004, 09:32 PM | #6 |
Just a note (no time to help, sorry maybe later): Unit is attacked fires at the time a unit begins its attack animation. THis way the attacker can, if he knows it, begin its animation, move away and move close again and make animation start again. You can reach 10 attacks in a few sec with this method. |
| 06-28-2004, 11:17 PM | #7 |
Update: With your help, I've managed to get a preliminary trigger set up for the ability I want to do, which I've just named Curse for the time being. It took me an hour of fooling around, but here's what I came up with. First, I created a hollow ability based off of the Necromancer's Cripple. I then set up two variables, one for the unit of the targeted ability (CurseTarget) and an integer variable to keep track of the attacks (CurseAttacks). I had to create two triggers. ----CurseEnable---- Event Unit begins casting an ability Condition Ability equal to Curse Actions Set CurseTarget = target unit of ability being cast Turn on "Curse" ------------------- ------Curse------- Event Unit is attacked Condition Attacking unit = CurseTarget Actions Set CurseAttacks = CurseAttacks + 1 If CurseAttacks equal to or great than 10, then do Unit = kill CurseTarget Set CurseAttacks = 0 Turn off this trigger Else, do nothing ----------------- Here is an image of a very unfortunate Grunt: ![]() Known issues: As someone mentioned before, the attack check fires each time a unit begins its animation, so to make it attack 10 times before dying, I'd have to set the integer limit to 11. I'll have to live with the chance of this being exploited as there is no (damaging unit) event response. Once this ability is cast on an enemy, it will stay active until either the enemy dies or another unit is targeted. In other words, there is no real duration time. I can probably accomplish this via another trigger or an If/Then statement within the existing one that waits for the condition for, say, 60 seconds before cancelling the actions. However, I am wary about putting in wait commands, especially since this will probably be in a multiplayer map. |
| 06-28-2004, 11:55 PM | #8 |
one bit of advice, on the curse trigg, once the unit dies use variable = set variable CurseTarget=nothing |
| 06-29-2004, 01:39 AM | #9 |
If you want to add in a wait then you want to do a looping wait. people tell it lags but i think its really cooll and makes me feel smart. Loop 1 - 60 If CurseAttacks equal to or great than 10, then do Unit = kill CurseTarget Set CurseAttacks = 0 Turn off This Trigger else wait 1 seconds endloop |
