Clear Pathing when Building blocks.

xAnaMorphine

Active Member
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
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
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
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('o00A'),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()) == 'o00A'
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
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
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
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
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('o00A'),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()) == 'o00A'
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('o00A'),Condition(function DistanceTest))


and

JASS:


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

Nenad

~Choco Coronet~ Omnomnom
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
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
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
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
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('o00A'),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
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
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 :/
 

Rushhour

New Member
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.
  • Ghan Ghan:
    We can fix that.
  • Ghan Ghan:
    Chat should show on the sidebar when not logged in now.
  • Ghan Ghan:
    (You'll still need to log in to post messages)
  • Ghan Ghan:
    Test!
  • tom_mai78101 tom_mai78101:
    I must be in a test server.
  • tom_mai78101 tom_mai78101:
    Nice, Twitter tweets embedding now works
  • Wizard Wizard:
    Yup.
  • Ghan Ghan:
    Excellent.
  • Ghan Ghan:
    @tom_mai78101 Hello there.
  • Ghan Ghan:
    Tagging works in the chat too.
  • tom_mai78101 tom_mai78101:
    @Ghan Missed it.
  • Wizard Wizard:
    Still fixing things here and there. Added widgets to the portal, will make it match the ones here on the forum index tomorrow.
  • Ghan Ghan:
    The venerable World Editor Tutorials site has been converted to HTTPS at last.
  • jonas jonas:
    cool
  • jonas jonas:
    and I can even edit my messages, nice
  • seph ir oth seph ir oth:
    GENERAL CHIT CHAT, YOU ARE A BOLD ONE
  • Ghan Ghan:
    Hello there
  • The Helper The Helper:
    this new chatbox is great and the forum software update is great too
    +1
  • The Helper The Helper:
    upgrade has fixed forum registration spam problem
  • tom_mai78101 tom_mai78101:
    Something tells me we might be able to customize the chatbox a bit, considering that there's a gap under every message.
  • Wizard Wizard:
    Going to deploy a fix soon, just had to take some time for myself this weekend.
  • Varine Varine:
    Unbelievable. Time for yourself? How dare you!
  • Wizard Wizard:
    xD

    Members online

    No members online now.

    Affiliates

    Hive Workshop
    Top