[Spell Request] Spike Trap

Arcane

You can change this now in User CP.
Reaction score
87
Set an invisible Spike Trap at the target location. Once activated, it becomes visible for 1 second before viciously impaling the victim over 3 seconds. Only 3 traps may be out at once, and each trap area needs to be 200 units away from each other and enemy units/structures. Spike traps cover an area of 150 units. This ability has a cooldown of 45 seconds.

Level 1: Spikes deal 60 damage per second.
Level 2: Spikes deal 90 damage per second.
Level 3: Spikes deal 120 damage per second.

That's what I want, but unfortunately, I have absolutely no idea how to do it, well, I do actually, but they don't work. Spike Traps may be activated individually via a button on each trap, or activated in unison from the hero. Spikes dart up and down when activated, repeatedly impaling the enemy, and though it says "per second", I'd really prefer to have it be per 0.2 seconds or whatnot for realism. I've been stuck with this for a long time, help would be appreciated. Credit will be given of course.
 

Sim

Forum Administrator
Staff member
Reaction score
534
If it can be of any help:

Here's a link to the Traps contest by Uareanoob.

You might want to check in there if there is any trap doing the same job as the one you want :)
 

Arcane

You can change this now in User CP.
Reaction score
87
Thanks a lot, some of those might prove to be useful for reference, though sadly, none of them do what I want my spell to do. People are too eager to create super unique abilities. Nobody wants a boring Spike Trap.

Right now, I'm stuck on how to get several trap areas to be damaged per second at the same time and how to check if there are other traps or enemy units in the "limit radius". I suppose checking out one of those Trap Contest spells might help me figure out the first point, but I don't think any of them stopped overlapping traps, or setting traps straight under enemies.

It's just so... argh...

I feel like I could learn all of this much easier by looking at somebody else's code rather than fumbling my way through trying to do it myself.
 

Sim

Forum Administrator
Staff member
Reaction score
534
Well, you could, when a unit comes within 200 range of your trap, pick every units within x of the trap and if they're traps too, skip remaining actions.

To make it so the unit comes within range of the trap, you might want to "add" to the trigger the event when the unit first sets the trap.

Code:
Spiked Trap init
    Events
        Unit - A unit enters (Playable map area)
    Conditions
        ((Entering unit) Unit-type) Equal to Spike Trap
    Actions
        Trigger - Add to Spike Trap <gen> the event: (Unit - A unit comes within 150.00 of (Triggering unit))

Then, if there are no traps around, you can then proceed to loop 3 times, waiting 1 seconds between each, and pick every unit near the trap and damage them (once every second).
 

Arcane

You can change this now in User CP.
Reaction score
87
Tried, and failed.

Sorry I don't quite get what you mean for me to do. All I have right now are the Spike Trap creation and limiting triggers. I'm stumped by the damaging. I mean, you need three different areas (max) damaged per second (0.1 seconds or 0.25 seconds, depends on whether 0.1 lags or not), possibly at the same time, possibly at different slightly overlapping times.

-.-

The only ways I can work out now would probably only work with one trap.

Example trigger please?


My limiting and creation triggers are here if they are needed at all:

Code:
Spike Trap Limit
    Events
        Unit - A unit Begins casting an ability
    Conditions
        (Ability being cast) Equal to Spike Trap 
    Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Number of units in (Units owned by (Owner of (Triggering unit)) of type Spike Trap)) Greater than or equal to 3
            Then - Actions
                Unit - Order (Triggering unit) to Stop
                Game - Display to (All players matching ((Number of units in (Units owned by (Owner of (Triggering unit)) of type Spike Trap)) Greater than or equal to 1)) the text: |cffffcc00You may o...
            Else - Actions

Code:
Spike Trap Creation
    Events
        Unit - A unit Starts the effect of an ability
    Conditions
    Actions
        Set SpikeTrapLoc = (Target point of ability being cast)
        Unit - Create 1 Spike Trap for (Owner of (Triggering unit)) at SpikeTrapLoc facing Default building facing degrees
        Unit Group - Add (Last created unit) to SpikeTrapsGroup
        Wait 0.10 seconds
        Custom script:   call RemoveLocation(udg_SpikeTrapLoc)
 

NapaHero

Back from the dead...
Reaction score
43
Code:
Game - Display to (All players matching ((Number of units in (Units owned by (Owner of (Triggering unit)) of type Spike Trap)) Greater than or equal to 1)) the text: |cffffcc00You may o...

Why you need the matching part, if you already used a condition to check the amount of units?

Code:
If - Conditions
                (Number of units in (Units owned by (Owner of (Triggering unit)) of type Spike Trap)) Greater than or equal to 3
 

Sim

Forum Administrator
Staff member
Reaction score
534
Code:
Spike Trap Creation
    Events
        Unit - A unit Starts the effect of an ability
    Conditions
    Actions
        Set SpikeTrapLoc = (Target point of ability being cast)
        Unit - Create 1 Spike Trap for (Owner of (Triggering unit)) at SpikeTrapLoc facing Default building facing degrees
        Unit Group - Add (Last created unit) to SpikeTrapsGroup
        Wait 0.10 seconds
        Custom script:   call RemoveLocation(udg_SpikeTrapLoc)

You should add these actions inside the other trigger, not create a new trigger for it.

Once it is created, you need to make sure that any unit that comes within range of your trap will make it explode.

Try something ;) Base yourself off the trigger I gave you above.
 

Arcane

You can change this now in User CP.
Reaction score
87
@waaaks!: Hm... may work, but the graphics would still be a problem then, I'd rather have them all triggered, including the damage.

@NapaHero: Because there is no "triggering player" option, or whatever. Only players 1-12 and neutral passive and hostile.

@Daxtreme: The limiting trigger has to stop you from casting the moment you cast so the cooldown isn't fired, so I used "begin's casting". If I used that for the creation trigger as well, then the players could cancel casting and still have the trap - thus no cooldown.

Once it is created, you need to make sure that any unit that comes within range of your trap will make it explode.
No, no, no. The traps don't explode by themselves. They ONLY EVER "explode" when you activate them. Well, they don't really "explode" at all, but you get what I mean.
 

Pyrogasm

There are some who would use any excuse to ban me.
Reaction score
134
Using my method, I see.

Mind posting the periodic trigger? In fact, what is the problem?
 

Arcane

You can change this now in User CP.
Reaction score
87
That's the problem. HOW do I do the periodic trigger? If there could only ever be one trap I could do it, but with three traps... I mean, the only triggers I can come up with would probably be messed up due to two traps being activated one after another, or all three activated at once. How do you get a trigger to do the same thing at three different places periodicly?
 

Pyrogasm

There are some who would use any excuse to ban me.
Reaction score
134
That's what the unit-group is for:

Code:
Periodic Trigger
    Events
        Time - Every 0.20 seconds of game-time
    Conditions
        (Number of Units in (SpikeTrapsGroup)) greater than 0
    Actions
    Unit Group - Pick every unit in (SpikeTrapsGroups) and do (Actions)
            Loop - Actions
                If (All conditions are true) then do (Then actions) else do (else actions)
                    If - Conditions
                        ((Picked Unit) is alive) equal to true
                    Then - Actions
                        Set TempPoint = (Position of (Picked Unit))
                        Set TempGroup = (Units within 150.00 of TempPoint matching ((Matching Unit) is an enemy of (Owner of (Picked Unit)) equal to true))
                        ----- - -----
                        Custom script: loop
                        Custom script: set udg_SpikeUnitToDamage = FirstOfGroup(udg_TempGroup)
                        Custom script: exitwhen udg_SpikeUnitToDamage == null
                        Unit - Cause (Picked Unit) to damage SpikeUnitToDamage dealing ((30 + ((Level of SPIKE ACTIVATION ABILITY for (Picked Unit)) x 30.00)) x 0.20) damage of attack type Chaos and damage type Universal
                        Unit Group - Remove SpikeUnitToDamage from TempGroup
                        Custom script: endloop
                        ----- - -----
                        Custom script: call DestroyGroup(udg_TempGroup)
                        Custom script: call RemoveLocation(udg_TempPoint)
                    Else - Actions
                        Unit Group - Remove (Picked Unit) from SpikeTrapsGroup
The reason for all the Custom Script stuff is because you can have nested Group Loops in GUI. The Custom Script is a JASS workaround.
 

Arcane

You can change this now in User CP.
Reaction score
87
I knew it! I tried using unit groups, but I couldn't get anything that actually worked.

Thanks.

And... er, how much damage exactly does your code deal per second?

Edit: Oh nevermind.
 

Pyrogasm

There are some who would use any excuse to ban me.
Reaction score
134
60, 90, or 120 depending on the level: 30+(Level*30)

But because it happens periodically, you must figure out what to divide by to get it to deal less damage in smaller chunks:
DPS = TotalDamage/(1.00/Interval) = TotalDamage*Interval
 

Arcane

You can change this now in User CP.
Reaction score
87
Hm... what about individual activation?

Drat! The spike graphics keep screwing up as well. The impale buff leaves this nasty black blotch in the ground and only ever appears if there are actually enemy units on the trap.

Ugh! You can cast activate and then cast the trap, and it would still work. I hate this ability. -.-


...Pyrogasm, was it your Spell Request Thread on Wc3c? Is the offer still on?
 

Pyrogasm

There are some who would use any excuse to ban me.
Reaction score
134
Offer still stands. Wc3c, however, is offline.
I'll merge your post in when the website comes back online.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top