Clear Pathing when Building blocks.

xAnaMorphine

Active Member
Reaction score
43
Hello guys,

My friend and I are trying to create a Tower Defense. Now a Problem occured since when you build a straight line of towers, the creeps can't walk through, thus resulting in winning the game since not a single creep can pass. My Idea now was to create a trigger which checks wether a creep is able to pass or not.
For example:

------------------------------------------x

x stands for the empty spot, creeps are able to pass

-------------------------------------------

Player build a Building on x, the building will be killed and the gold will be refund.

Is it possible to create something like this?
 

Bloodydood

New Member
Reaction score
14
Would the creeps simply stop? If so, run a repetitive check, (Every 0.1 seconds event). Then pick every unit in Region <gen>, (Or playable map area), owned by neutral hostile. If picked unit current order is equal to stop, then order picked unit to attack-move to Destination Point.

Once the path is made by force, have another trigger with event Unit - A unit Dies. In conditions just specify that it's a tower from a player. If the conditions are true, then pick every unit in same region as triggering unit and order picked unit to move to Destination Point. This should stop the creeps from inflicting further damage.

If the towers made a wall that's more than 1 tower thick, the process should repeat itself.

I hope you can read that.
 

xAnaMorphine

Active Member
Reaction score
43
Well, I see your point but I was thinking about something diffrent. Imagine the Creeps don't have an attack, what now?
 

Rushhour

New Member
Reaction score
46
I have a suggestion: Might not work for your mazing TD but maybe you can change the basic idea for your needs.
This works for a "straight" TD like in Line tower wars or something like that.
|xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx|
|xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx|
|xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx|
|xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx|
|xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx|
|xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx|
-->when you have a wall at the left and right side. Then you simply need to check the x-values of the towers in a "chain" and if this chain reaches both walls.
JASS:
scope Antiblock initializer AntiblockBase
globals
private group MazeChain=CreateGroup()
private boolean bool
private real min
private real max
private group LoopG=CreateGroup()
endglobals

private function DistanceTest takes nothing returns boolean
local unit f=GetFilterUnit()
local real x1=GetUnitX(GetEnumUnit())
local real y1=GetUnitY(GetEnumUnit())
local real x2=GetUnitX(f)
local real y2=GetUnitY(f)
local real r=SquareRoot((x2 - x1) * (x2 - x1) +  (y2 - y1) *  (y2 - y1))
 if GetOwningPlayer(f)==GetOwningPlayer(GetTriggerUnit()) and IsUnitInGroup(f, MazeChain) == false and (r &lt;255 or r ==271.534) then
    call GroupAddUnit(  MazeChain,f)
    if ( x2 &lt; min ) then
        set min = x2
    endif
    if ( x2 &gt; max ) then
        set max = x2
    endif
    set bool = true
 endif
set f=null

    return false
endfunction

private function EnumNeighbours takes nothing returns nothing
    call GroupEnumUnitsOfType(LoopG,UnitId2String(&#039;o00A&#039;),Condition(function DistanceTest))
endfunction

private function TestMazeChain takes nothing returns nothing
    call GroupClear(MazeChain)
    call GroupAddUnit( MazeChain,GetTriggerUnit() )
    set min = GetUnitX(GetTriggerUnit())
    set max = min
    loop
            set bool = false
            call ForGroup( MazeChain, function EnumNeighbours )
        exitwhen bool==false
    endloop
        if (max - min ) &gt;= 860.00 then
            call DestroyEffect(AddSpecialEffect(&quot;Abilities\\Spells\\Human\\DispelMagic\\DispelMagicTarget.mdl&quot;,GetUnitX(GetTriggerUnit()),GetUnitY(GetTriggerUnit())))
            call RemoveUnit( GetTriggerUnit() )
        endif
endfunction

private function IsMazingTower takes nothing returns boolean
   return GetUnitTypeId(GetConstructingStructure()) == &#039;o00A&#039;
endfunction

private function AntiblockBase takes nothing returns nothing
local trigger t=CreateTrigger()
    call TriggerRegisterPlayerUnitEvent(t, Player(6), EVENT_PLAYER_UNIT_CONSTRUCT_START, null)
    call TriggerRegisterPlayerUnitEvent(t, Player(7), EVENT_PLAYER_UNIT_CONSTRUCT_START, null)
    call TriggerAddCondition( t, Condition( function IsMazingTower ) )
    call TriggerAddAction( t, function TestMazeChain )
endfunction
endscope

If you know some jass then you will understand this, if not feel free to ask. I will add some comments later on (sorry no time atm^^) and set some more globals to make editing easier.
This fits for my map and the pathing map of my mazing tower. It checks only for one tower at the moment, you will probably have different towers. Could edit this if you told me what you need in detail (if pathing map= arcane tower pathing map, ...)
 

xAnaMorphine

Active Member
Reaction score
43
Yes it is exactly what I need, can't test at the moment because I dont have JNGP because of Kaspersky :(

Off-Topic: Schreib es mir per private message oder so ^.^, so viel versteh ich auch nicht von jass ^^
 

Azlier

Old World Ghost
Reaction score
461
That X check thing won't exactly work. What if my wall looks like this?

Code:
X           X
 X         X
  X       X
   X     X
    X   X
     XXX
 

Rushhour

New Member
Reaction score
46
yes I know Azlier, but since most TDs have a symmetrical build with straight walls this could be used. Easiest would be ofc to add an attack to the creeps but sometimes you can't because of your map style.
 

xAnaMorphine

Active Member
Reaction score
43
rush, take a look at this example:

24o9d3b.jpg
 

xAnaMorphine

Active Member
Reaction score
43
I have a suggestion: Might not work for your mazing TD but maybe you can change the basic idea for your needs.
This works for a "straight" TD like in Line tower wars or something like that.
|xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx|
|xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx|
|xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx|
|xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx|
|xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx|
|xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx|
-->when you have a wall at the left and right side. Then you simply need to check the x-values of the towers in a "chain" and if this chain reaches both walls.
JASS:

scope Antiblock initializer AntiblockBase
globals
private group MazeChain=CreateGroup()
private boolean bool
private real min
private real max
private group LoopG=CreateGroup()
endglobals

private function DistanceTest takes nothing returns boolean
local unit f=GetFilterUnit()
local real x1=GetUnitX(GetEnumUnit())
local real y1=GetUnitY(GetEnumUnit())
local real x2=GetUnitX(f)
local real y2=GetUnitY(f)
local real r=SquareRoot((x2 - x1) * (x2 - x1) +  (y2 - y1) *  (y2 - y1))
 if GetOwningPlayer(f)==GetOwningPlayer(GetTriggerUnit()) and IsUnitInGroup(f, MazeChain) == false and (r &lt;255 or r ==271.534) then
    call GroupAddUnit(  MazeChain,f)
    if ( x2 &lt; min ) then
        set min = x2
    endif
    if ( x2 &gt; max ) then
        set max = x2
    endif
    set bool = true
 endif
set f=null

    return false
endfunction

private function EnumNeighbours takes nothing returns nothing
    call GroupEnumUnitsOfType(LoopG,UnitId2String(&#039;o00A&#039;),Condition(function DistanceTest))
endfunction

private function TestMazeChain takes nothing returns nothing
    call GroupClear(MazeChain)
    call GroupAddUnit( MazeChain,GetTriggerUnit() )
    set min = GetUnitX(GetTriggerUnit())
    set max = min
    loop
            set bool = false
            call ForGroup( MazeChain, function EnumNeighbours )
        exitwhen bool==false
    endloop
        if (max - min ) &gt;= 860.00 then
            call DestroyEffect(AddSpecialEffect(&quot;Abilities\\Spells\\Human\\DispelMagic\\DispelMagicTarget.mdl&quot;,GetUnitX(GetTriggerUnit()),GetUnitY(GetTriggerUnit())))
            call RemoveUnit( GetTriggerUnit() )
        endif
endfunction

private function IsMazingTower takes nothing returns boolean
   return GetUnitTypeId(GetConstructingStructure()) == &#039;o00A&#039;
endfunction

private function AntiblockBase takes nothing returns nothing
local trigger t=CreateTrigger()
    call TriggerRegisterPlayerUnitEvent(t, Player(6), EVENT_PLAYER_UNIT_CONSTRUCT_START, null)
    call TriggerRegisterPlayerUnitEvent(t, Player(7), EVENT_PLAYER_UNIT_CONSTRUCT_START, null)
    call TriggerAddCondition( t, Condition( function IsMazingTower ) )
    call TriggerAddAction( t, function TestMazeChain )
endfunction
endscope

If you know some jass then you will understand this, if not feel free to ask. I will add some comments later on (sorry no time atm^^) and set some more globals to make editing easier.
This fits for my map and the pathing map of my mazing tower. It checks only for one tower at the moment, you will probably have different towers. Could edit this if you told me what you need in detail (if pathing map= arcane tower pathing map, ...)

Okay so I downloaded JNGP and tried to install the Script. Since my Jass Knowledge is so small I would like you to aid me a bit.

What I have done: Nothing.

I am thinking about changing these lines;

JASS:
call GroupEnumUnitsOfType(LoopG,UnitId2String(&#039;o00A&#039;),Condition(function DistanceTest))


and

JASS:
return GetUnitTypeId(GetConstructingStructure()) == &#039;o00A&#039;


the 'o00A', is it my Tower that should be affected by the Script?
 

Nenad

~Choco Coronet~ Omnomnom
Reaction score
137
Well, it's a bit of a silly answer really but give em an ability based of storm bolt that they can cast instead of attacking, call it DestroyBlockTower and do what BloodyDood said? ^^ I know it's not the best of ideas but it's a quick fix xD
 

xAnaMorphine

Active Member
Reaction score
43
Well, it's a bit of a silly answer really but give em an ability based of storm bolt that they can cast instead of attacking, call it DestroyBlockTower and do what BloodyDood said? ^^ I know it's not the best of ideas but it's a quick fix xD

Thanks for the help, I really appreciate it.

But I don't want to do this, I know I am really selective :O
 

Nenad

~Choco Coronet~ Omnomnom
Reaction score
137
How about this, make a dummy that will run your course and time the time it takes via a trigger. Then use that time as a wait and run the dummy before each wave. If the dummy does not pass in the wait time, destroy the last built...but it wouldn't work if the player builds more then one tower now would it? >.<

How bout you just give IT the ability to destroy towers, and if it cannot pass it uses it's towerdestroyability, and a message pops up saying you can't block with towers, maze instead! x)

Heh, i'm really keen on solving this without JASS or extensive triggering xP
 

avalya

New Member
Reaction score
37
Can't you use a trigger that checks if the creeps' current order is Stop, if it is, then turn off their collision and order them to move through the towers?
 

Rushhour

New Member
Reaction score
46
I already told you, just describe what you want, or send me the map, I won't steal anything :D

JASS:
call GroupEnumUnitsOfType(LoopG,UnitId2String(&#039;o00A&#039;),Condition(function DistanceTest))


Yeah 'o00A' is my tower, but this would only work on my map since I have one tower doing the pathing.
You will probably need: call GroupEnumUnitsInRange(LoopG,500.,GetUnitX(u),GetUnitY(u),Condition(function DistanceTest))
but I'm not sure about the order of the arguments^^ and the range could probably be decreased, depending on the maximum distance a neighbor-tower can have.

GIMME INFO :D
 

N(O.O)B

New Member
Reaction score
27
Can't you just check whether the unit has moved and if it didn't, you make it collision free? Might not be perfect but it'll work and it doesn't even require extensive jass :p

Edit: here's an example map I quickly made, it's not perfect yet but it kinda works :p
 

Rushhour

New Member
Reaction score
46
Yeah I changed this native anyway, since it's much more efficient to enum units in range. But stupid bug, not sure if I used OrderId2String somewhere :/
 

xAnaMorphine

Active Member
Reaction score
43
How about I just give you the map? :O
 

Attachments

  • Nightmare of Alliance TD v0.01 #0001.w3x
    104.8 KB · Views: 174

Rushhour

New Member
Reaction score
46
here it is, handed back magically completed :rolleyes:
:D
Didn't you do any changes in units/triggers/whatever or was this just a testmap ? I made a builder/starting gold/testrigger (can be removed) /some towers.
You have to set the pointvalue of the tower to its goldcost because it will restore the unit point value as gold when the tower is misplaced.#
It works for all of your players as long as the ways have the same widths.
The special effect can be changed too ofc.
Edit: Ah I forgot: you need JassHelper (comes with Jass NewGen Pack) to compile this. Look at the sticky thread.
View attachment Nightmare of Alliance TD v0.01 #0001.w3x
 
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