Spike trap, need help

Kazuga

Let the game begin...
Reaction score
110
Hi, I'm making a spike trap spell, and I need some help. This is as far as I have got:

Code:
Spike trap setup
    Events
        Unit - A unit Starts the effect of an ability
    Conditions
        (Ability being cast) Equal to Spike trap 
    Actions
        Set SpikeTrapCaster = (Casting unit)
        Unit - Create 1 EarthSpike mine dummy for (Owner of SpikeTrapCaster) at (Position of SpikeTrapCaster) facing (Position of (Triggering unit))
        Unit - Turn collision for (Last created unit) Off
        Unit - Order (Last created unit) to Undead Crypt Fiend - Burrow
        Unit - Create 1 Spike trap A for (Owner of SpikeTrapCaster) at (Position of SpikeTrapCaster) facing (Position of (Triggering unit))
        Set SpikeTrap = (Last created unit)
        Set SpikeTrapPoint = (Position of SpikeTrap)
        Unit - Turn collision for SpikeTrap Off
        Unit - Add Permanent Invisibility to SpikeTrap
        Animation - Change SpikeTrap's vertex coloring to (100.00%, 100.00%, 100.00%) with 100.00% transparency

Code:
Spike trap activate
    Events
        Unit - A unit Is attacked
    Conditions
        ((Attacking unit) is in (Units of type Spike trap A)) Equal to True
    Actions
        Set SpikeTrapvictim = (Attacked unit)
        Unit - Pause SpikeTrapvictim
        Unit - Move SpikeTrap instantly to (Position of SpikeTrapvictim)
        Unit - Remove Permanent Invisibility from SpikeTrap
        Wait 0.50 game-time seconds
        Unit - Add Earth spikes dummy  to SpikeTrap
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Level of Spike trap  for SpikeTrapCaster) Equal to 1
            Then - Actions
                Unit - Cause SpikeTrapCaster to damage SpikeTrapvictim, dealing 300.00 damage of attack type Pierce and damage type Normal
            Else - Actions


The trap is like a mine, it digs underground waiting for an enemy to pass by then it's going to dig up and trap the fool and spike him! (I just love spiking things^^) The trap model file is an orc burrow btw. The real problem right now is that I have no idea how to make the trap event when a unit comes close, I tried with an aura as you can see above, the spike trap aura. It is a buff who only can buff enemy units but I still don't get it how to make the next trigger event to work correctly, hopw you understand what I mean with all this...:p
 

Tyrulan

Ultra Cool Member
Reaction score
37
First of all you need to know how many traps you have, or can have a maximum of.

Set the traps to array and use a "Unit comes within range of" accompanied with "Unit is enemy of owner of trap equal to false"

You may also want to add something like

"If trap = >7 then kill trap[1]

Good luck. It sounds cool.
 

Kazuga

Let the game begin...
Reaction score
110
Thanks^^ I will try that :rolleyes:
>Edit: I'm not that good with arrays since I don't really know what it does. When I ty to set the variable as an array I can't take the trap as an option...
 

N2o)

Retired.
Reaction score
51
An alternative way, is to check units within the position of the trap, every say 0.25 seconds.
 
N

needshelpplz

Guest
ok

an array is a set of the same vairable (real, boolean, integer, units, whatever).
 

Kazuga

Let the game begin...
Reaction score
110
argh it still doesn't work, take a look at it and see if you can find what's wrong...

Code:
Spike trap setup
    Events
        Unit - A unit Starts the effect of an ability
    Conditions
        (Ability being cast) Equal to Spike trap 
    Actions
        Set SpikeTrapCaster = (Casting unit)
        Unit - Create 1 EarthSpike mine dummy for (Owner of SpikeTrapCaster) at (Position of SpikeTrapCaster) facing (Position of (Triggering unit))
        Unit - Turn collision for (Last created unit) Off
        Unit - Order (Last created unit) to Undead Crypt Fiend - Burrow
        Unit - Create 1 EarthSpike mine for (Owner of SpikeTrapCaster) at (Position of SpikeTrapvictim) facing (Position of (Triggering unit))
        Set SpikeTrap = (Last created unit)
        Set SpikeTrapPoint = (Position of SpikeTrap)
        Unit - Turn collision for SpikeTrap Off
        Unit - Hide SpikeTrap

Code:
Spike trap activate
    Events
        Time - Every 0.25 seconds of game time
    Conditions
    Actions
        Unit Group - Pick every unit in (Units within 50.00 of (Position of SpikeTrap)) and do (Actions)
            Loop - Actions
                Set SpikeTrapvictim = (Picked unit)
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (SpikeTrapvictim belongs to an enemy of (Owner of SpikeTrapCaster)) Equal to True
                    Then - Actions
                        Unit - Pause SpikeTrapvictim
                        Unit - Move SpikeTrap instantly to (Position of SpikeTrapvictim)
                        Unit - Unhide SpikeTrap
                        Wait 0.50 game-time seconds
                        Unit - Add Earth spikes dummy  to SpikeTrap
                    Else - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Level of Spike trap  for SpikeTrapCaster) Equal to 1
            Then - Actions
                Unit - Cause SpikeTrapCaster to damage SpikeTrapvictim, dealing 300.00 damage of attack type Pierce and damage type Normal
            Else - Actions
 

Almighty11

New Member
Reaction score
5
You did not order the damage to the units inside that range; because that action is not inside the 'pick every player...' action. Put it in and it should work fine; that if you will have only one trap.
 

Flare

Stops copies me!
Reaction score
662
You did not order the damage to the units inside that range; because that action is not inside the 'pick every player...' action. Put it in and it should work fine; that if you will have only one trap.

it is within the UG loop from what i can see (hold LMB before at start of Damage action, and scroll directly up. it will be indented the same distance as the Set spiketrapvictim action, which is in the UG loop)

edit: nvm that, forgot that if/then/else indented as well. only problem with that trigger is that units will take huge damage if they stay on the trap sine the trap doesnt seem to be removed
 

Kazuga

Let the game begin...
Reaction score
110
it is within the UG loop from what i can see (hold LMB before at start of Damage action, and scroll directly up. it will be indented the same distance as the Set spiketrapvictim action, which is in the UG loop)

edit: nvm that, forgot that if/then/else indented as well. only problem with that trigger is that units will take huge damage if they stay on the trap sine the trap doesnt seem to be removed

Well, I haven't got to that point yet to remove it since the first part doesn't work yet. But a problem is that they don't take damage at all since the activate trigger doesn't activate
 
W

whatismyname

Guest
You did not order the damage to the units inside that range; because that action is not inside the 'pick every player...' action. Put it in and it should work fine; that if you will have only one trap.

Order the "units"? Didn't he say that the trap entraps "the unit" and not "units"?
 

R@i_no_Wyrm

New Member
Reaction score
43
Hmm, changing all the system, make the trap so it can attack. Say 500 - 600 chaos damage.

Then add another trigger so if any unit is damaged and the damage source unit-type is a spike trap, kill the damage source.
 

Kazuga

Let the game begin...
Reaction score
110
Hmm, changing all the system, make the trap so it can attack. Say 500 - 600 chaos damage.

Then add another trigger so if any unit is damaged and the damage source unit-type is a spike trap, kill the damage source.

Hm could work but then, the damage needs to be around 1-2 because it's still the caster of the mine who has to get the kill and not the mine. But then, can a unit with locust attack? andwhat happens if he get time enough to attack twice? And, a unit who has used burrow can't attack can it?
 

Kazuga

Let the game begin...
Reaction score
110
add permanent invisibility to make it so that trap cant be seen

why must caster get kill?

locust units can atk

set cooldown to a high value to ensure 2nd atk wont occur, but thats no issue tbh since if u remove the dummy after it deals damage, it cant atk again.

Caster must get kill because this spell is going to be used in my hero arena and in it you get a kill if you kill another player..

with permanent invisibility the trap will be seen by the caster...
 

Kazuga

Let the game begin...
Reaction score
110
set its transparency to 100% and use permanent invis to hide its shadow (if it has one)

make it so that anything owned by the player can score a kill for that player, not just the hero

ok thanks I will try that
 

Almighty11

New Member
Reaction score
5
Ok I've made triggers for you that should be working fine. If you want to add it to kills, just check the life when you are about to explode the trap. If it is going to kill it, just add a kill to Player(Integer B).
P.S.: I made this one so you can use this spell with various players at same time and various traps.

Note: You just have to set up Max_spikes to the max number of traps each player can lay at a time.

Its abit long because it checks if each player has a trap; and if he does, checks his traps.

http://www.epicwar.com/maps/download/42073/trap-halp.w3x

Casting

Code:
Cast
    Events
        Unit - A unit Finishes casting an ability
    Conditions
        (Ability being cast) Equal to War Stomp
    Actions
        -------- Just one auxiliary variable here to help me detecting traps owner. --------
        Set aux[(Player number of (Owner of (Triggering unit)))] = (aux[(Player number of (Owner of (Triggering unit)))] + 1)
        Set SpikeTrapCaster[(Player number of (Owner of (Triggering unit)))] = (Owner of (Triggering unit))
        -------- Creating the spike trap just where caster is. --------
        Unit - Create 1 Footman for (Owner of (Triggering unit)) at (Position of (Triggering unit)) facing Default building facing degrees
        Set SpikeTrap[(((Player number of (Owner of (Triggering unit))) x MaxNumb_of_spikes) + aux[(Player number of (Owner of (Triggering unit)))])] = (Last created unit)


Checking

Code:
Detect
    Events
        Time - Every 0.40 seconds of game time
    Conditions
    Actions
        -------- Loops for checking if each player has traps. --------
        For each (Integer B) from 1 to (Player number of (Player((Number of players in (All players controlled by a User player))))), do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        aux[(Integer B)] Greater than 0
                    Then - Actions
                        -------- If he has, check if there is anything (enemy) in its area. --------
                        For each (Integer A) from 1 to aux[(Integer B)], do (Actions)
                            Loop - Actions
                                Unit Group - Pick every unit in (Units within 512.00 of (Position of SpikeTrap[(((Integer B) x MaxNumb_of_spikes) + (Integer A))])) and do (Actions)
                                    Loop - Actions
                                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                            If - Conditions
                                                ((Player((Integer B))) is an enemy of (Owner of (Picked unit))) Equal to True
                                            Then - Actions
                                                -------- Whatever you want trap to do here, for 'Picked unit' (Victim!) --------
                                                Unit - Remove SpikeTrap[(Integer A)] from the game
                                                Set aux[(Integer B)] = (aux[(Integer B)] - 1)
                                            Else - Actions
                    Else - Actions


hope it works fine :)
 

Kazuga

Let the game begin...
Reaction score
110
I don't really understand how you made this one, would be nice with comments here and there that explained why you did what you did :rolleyes:

>Edit: I found the problem to why the trap didn't spawn wich made the other trigger unable to work, so that's fixed but it still don't work correctly. The trap can still be seen even with 100% transperancy and it doesn't want to attack

>Edit: Ok the triggers work expect that you still can see the trap that is going to attack, the other one is the one is the dummy who digs down and creates the little pile. Updated code
 

Almighty11

New Member
Reaction score
5
Well basically you just have to edit the actions (where I put the comment for 'Whatever you want trap to do here' ) and the Max_spikes default variable.

>Edit: Ok the triggers work expect that you still can see the trap that is going to attack, the other one is the one is the dummy who digs down and creates the little pile. Updated code

Himm are you talking about my triggers? If you need any big changes to it, just say. And what I did basically was just that:

1- Add trap to (array) unit variable;
2- Check if players have traps;
3- If they have, check traps area for someone;
4- If there is, do action.
4b If there isnt, loop.

If you really need more detailed explanation, I'll surely add.
 

Kazuga

Let the game begin...
Reaction score
110
Well basically you just have to edit the actions (where I put the comment for 'Whatever you want trap to do here' ) and the Max_spikes default variable.



Himm are you talking about my triggers? If you need any big changes to it, just say. And what I did basically was just that:

1- Add trap to (array) unit variable;
2- Check if players have traps;
3- If they have, check traps area for someone;
4- If there is, do action.
4b If there isnt, loop.

If you really need more detailed explanation, I'll surely add.

> Himm are you talking about my triggers?
No I was talking about mine :rolleyes:
1- Add trap to (array) unit variable;
2- Check if players have traps;
3- If they have, check traps area for someone;
4- If there is, do action.
4b If there isnt, loop.
I don't really know what arrays does, only know that the regular is array 1 of some reason still I have seen people using 2700... I also ain't really familiar with "for each Integer A then do..." same with B ofcourse... Would be nice if you could explain a little more detailed :eek:
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top