wc3campaigns
WC3C Homepage - www.wc3c.netUser Control Panel (Requires Log-In)Engage in discussions with other users and join contests in the WC3C forums!Read one of our many tutorials, ranging in difficulty from beginner to advanced!Show off your artistic talents in the WC3C Gallery!Download quality models, textures, spells (vJASS/JASS), systems, and scripts!Download maps that have passed through our rigorous approval process!

Go Back   Wc3C.net > Resources > Code Resources > Samples
User Name
Password
Register Rules Get Hosted! Chat Pastebin FAQ and Rules Members List Calendar



Reply
 
Thread Tools Search this Thread
Old 07-16-2008, 01:40 AM   #1
Strilanc
User
 
Strilanc's Avatar
 
Join Date: Jun 2007
Posts: 917

Submissions (4)

Strilanc has a spectacular aura about (131)

2008 Spell olympics - Fire - Gold

Default AWall - Wall Detection System

Summary
A very common problem for tower defense games is detecting when a player is taking advantage of unit pathing. The typical solution involves hoping units attack if they are walled and is very easy to defeat. AWall detects when units have been walled.

The system currently uses HAIL and SUEL [included in the example map], and requires vJass. The example map includes a GUI extension for people who can't write JASS.

Explanation
AWall does various checks to runners that have been added to the system. It periodically checks if runners are stopped, attacking, or stuck, it drops 'breadcrumb' rects behind runners to see if they backtrack, it catches runners attacking towers, etc.

When you create a runner you want wall detection on, add it to the system using AWall_AddRunner. When a player builders a tower use AWall_AddTower on it [only necessary if you use attack prevention]. When a runner reaches a waypoint, use AWall_ResetRunner [backtracking is possible after waypoints, this removes the currently dropped bread crumbs for that unit].

When it detects that a runner has been walled, it runs callbacks registered using AWall_RegisterForWalled. It sets the globals AWall_unit to the runner, and AWall_reason to the reason it believes the unit was walled. For example, if the unit was attacking, reason will be set to AWALL_REASON_ATTACKING. It is the maps job to punish the player, save the unit or whatever else the maker wants. AWall only does detection.

If a unit is/was recently snared or stunned, the wall detection will still activate, but it will have a reason set to AWALL_REASON_PREVENT. When you get PREVENT, you should usually not punish the player, but simply re-order the unit [it may have just been released and started attacking].

Code
Expand JASS:

History
None
Attached Images
File Type: png AWall.PNG (17.1 KB, 909 views)
Attached Files
File Type: w3x AWall beta4.w3x (51.1 KB, 224 views)
__________________
Don't pay attention to this signature, it's self-contradictory.

Last edited by Strilanc : 08-01-2008 at 07:51 PM.
Strilanc is offline   Reply With Quote
Sponsored Links - Login to hide this ad!
Old 07-16-2008, 02:55 AM   #2
DioD
obey
 
DioD's Avatar
 
Join Date: Feb 2006
Posts: 1,532

Submissions (4)

DioD is a jewel in the rough (220)DioD is a jewel in the rough (220)DioD is a jewel in the rough (220)DioD is a jewel in the rough (220)

Send a message via ICQ to DioD
Default

native IssuePointOrder takes unit whichUnit, string order, real x, real y returns boolean

Code:
if not IssuePointOrder(Unit,SomeRB("move"),x,y) then
call Echo("Unit cannot complete this order")
endif
DioD is offline   Reply With Quote
Old 07-16-2008, 03:03 AM   #3
Strilanc
User
 
Strilanc's Avatar
 
Join Date: Jun 2007
Posts: 917

Submissions (4)

Strilanc has a spectacular aura about (131)

2008 Spell olympics - Fire - Gold

Default

Quote:
Originally Posted by DioD
native IssuePointOrder takes unit whichUnit, string order, real x, real y returns boolean

Code:
if not IssuePointOrder(Unit,SomeRB("move"),x,y) then
call Echo("Unit cannot complete this order")
endif

I'm not exactly sure what your point is. Do you think IssuePointOrder will detect walls? It won't.

- Even if a unit can't reach the destination it will move to a closer point, so the order still succeeds [tested and confirmed, please don't state things like this unless you've tested them].
- Even if the order returned false if the destination wasn't reachable, units can be walled after they are ordered.
- Even if you could detect the destination becoming unreachable, juggling units only requires switching maze exits back and forth (never closing both, therefore the end is always reachable).

You _need_ backtrack detection if you want to stop juggling [*without severely interfering with players like blocking building during rounds].
__________________
Don't pay attention to this signature, it's self-contradictory.

Last edited by Strilanc : 07-16-2008 at 03:11 AM.
Strilanc is offline   Reply With Quote
Old 08-02-2008, 12:22 AM   #4
moyack
Evil Emoticon
 
moyack's Avatar


Respected User
Project Leader: PoC
 
Join Date: Jan 2006
Posts: 3,267

Submissions (17)

moyack is a splendid one to behold (661)moyack is a splendid one to behold (661)moyack is a splendid one to behold (661)moyack is a splendid one to behold (661)

AI Tournament #2 - 2nd PlaceHero Contest - Second place

Send a message via MSN to moyack
Default

This system is simply elegant. I must confess that at the beginning I didn't understand its purpose but now that I tested it it looks great and useful, not only for Tower defense.

One thing that I noticed is this:

Collapse JASS:
function AWall_AddRunner takes unit u returns nothing
    call Runner.create(u)
endfunction

just set those functions as public and you won't need to set the prefix

Collapse JASS:
public function AddRunner takes unit u returns nothing
    call Runner.create(u)
endfunction

Do this and I'll put this submission in the right place.
moyack is offline   Reply With Quote
Old 08-04-2008, 04:12 PM   #5
d07.RiV
User
 
d07.RiV's Avatar
 
Join Date: May 2008
Posts: 239

Submissions (1)

d07.RiV is on a distinguished road (10)

Default

Also
Collapse JASS:
        public method report takes integer reason, string reasonName returns nothing
            if .wasHeld or .isHeld and reason != AWALL_REASON_PREVENT then
                call .report(AWALL_REASON_PREVENT, reasonName + "(prevented)")
                return
            endif
            call .reset() //avoid double-catch
can be changed to
Collapse JASS:
        public method report takes integer reason, string reasonName returns nothing
            if .wasHeld or .isHeld and reason != AWALL_REASON_PREVENT then
                set reason = AWALL_REASON_PREVENT
                set reasonName = reasonName + "(prevented)"
            endif
            call .reset() //avoid double-catch
Doesn't really affect performance, just a tip.

I'll try it if I ever make a map that involves any kind of runners/creeps (I suppose it can also be used for AoS with some modifications?)
__________________
d07.RiV is offline   Reply With Quote
Old 08-04-2008, 06:27 PM   #6
Strilanc
User
 
Strilanc's Avatar
 
Join Date: Jun 2007
Posts: 917

Submissions (4)

Strilanc has a spectacular aura about (131)

2008 Spell olympics - Fire - Gold

Default

It doesn't work if the runners are attackers.
__________________
Don't pay attention to this signature, it's self-contradictory.
Strilanc is offline   Reply With Quote
Old 08-04-2008, 06:41 PM   #7
moyack
Evil Emoticon
 
moyack's Avatar


Respected User
Project Leader: PoC
 
Join Date: Jan 2006
Posts: 3,267

Submissions (17)

moyack is a splendid one to behold (661)moyack is a splendid one to behold (661)moyack is a splendid one to behold (661)moyack is a splendid one to behold (661)

AI Tournament #2 - 2nd PlaceHero Contest - Second place

Send a message via MSN to moyack
Default

meh.

my tip is just aesthetic, so moved to scripts systems.

Last edited by moyack : 08-04-2008 at 06:43 PM.
moyack is offline   Reply With Quote
Old 08-06-2008, 06:51 PM   #8
D.V.D
User
 
Join Date: Jun 2008
Posts: 60

Submissions (2)

D.V.D has little to show at this moment (8)

Default

Could this detect cliffs too?
D.V.D is offline   Reply With Quote
Old 08-06-2008, 11:12 PM   #9
Strilanc
User
 
Strilanc's Avatar
 
Join Date: Jun 2007
Posts: 917

Submissions (4)

Strilanc has a spectacular aura about (131)

2008 Spell olympics - Fire - Gold

Default

It detects when a runner is walled, whether or not it's buildings doing it.
__________________
Don't pay attention to this signature, it's self-contradictory.
Strilanc is offline   Reply With Quote
Old 08-07-2008, 12:10 AM   #10
Kam
User
 
Kam's Avatar
 
Join Date: Jan 2004
Posts: 465

Kam will become famous soon enough (32)Kam will become famous soon enough (32)

Default

Could this be modified to stop submerged units from entering shallow water?
__________________
Beyond the Throne: Tides of Darkness

I need help with AI for my project, please post if you are interested.
Kam is offline   Reply With Quote
Old 08-07-2008, 12:19 AM   #11
Strilanc
User
 
Strilanc's Avatar
 
Join Date: Jun 2007
Posts: 917

Submissions (4)

Strilanc has a spectacular aura about (131)

2008 Spell olympics - Fire - Gold

Default

What exactly do you think the system does? It detects if a runner is acting like it was walled, it doesn't look at the terrain in any way.
__________________
Don't pay attention to this signature, it's self-contradictory.
Strilanc is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off


All times are GMT. The time now is 09:33 AM.


Donate

Affiliates
The Hubb http://bylur.com - Warcraft, StarCraft, Diablo and DotA Blog & Forums The JASS Vault Clan WEnW Campaign Creations Clan CBS GamesModding Flixreel Videos

Powered by vBulletin (Copyright ©2000 - 2014, Jelsoft Enterprises Ltd).
Hosted by www.OICcam.com
IT Support and Services provided by Executive IT Services