• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Second map sys +rep

Status
Not open for further replies.
Level 12
Joined
Dec 17, 2009
Messages
951
in my second map 'plants vs zombies:

Zombies spawn - Zombies walk down their lane - You kill sombies by constructing towers and walls that will stop them from destroying your farm.
pvzh.png

This is my first REAL project and everything have worked out fine... until now.
Problem:
I want my towers to only attack the zombies on their own lane.
pvz2.png

At the moment, towers do attack closest zombie and dosen't care if it is on its own lane or not.
I can't solve this problem on my own, so i ask you for help. Do you have a tip or a solution?
This is the problem:
pvzcurrent.png

And this is what i need help with to accomplish my vision:
pvzhelp.png


If you guys can help me i will give +rep and special thanks
ty.
 
Level 37
Joined
Mar 6, 2006
Messages
9,243
You could trigger it by comparing the angle and the distance from attacker to target. That way you could plot the edges of the lane in a way. Very much possible.

However here's a bit more simple solution:


  • Stop Attack
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • (Unit-type of (Attacking unit)) Equal to Guard Tower
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • And - All (Conditions) are true
                • Conditions
                  • (Region 003 <gen> contains (Triggering unit)) Equal to True
                  • (Region 003 <gen> contains (Attacking unit)) Equal to True
              • And - All (Conditions) are true
                • Conditions
                  • (Region 004 <gen> contains (Triggering unit)) Equal to True
                  • (Region 004 <gen> contains (Attacking unit)) Equal to True
        • Then - Actions
        • Else - Actions
          • Unit - Order (Attacking unit) to Stop
          • Game - Display to Player Group - Player 1 (Red) the text: Stop


It only works well if the lanes are horizontal or vertical, since regions can then cover the lane in a better way.

There might be another ways too, I'm trying to think this problem further.

@defskull
Please crop and/or put the image in hidden tags.
 

Attachments

  • TD_Attack_System.w3x
    19.5 KB · Views: 39
Level 33
Joined
Mar 27, 2008
Messages
8,035
You could trigger it by comparing the angle and the distance from attacker to target. That way you could plot the edges of the lane in a way. Very much possible.

However here's a bit more simple solution:


  • Stop Attack
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • (Unit-type of (Attacking unit)) Equal to Guard Tower
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • And - All (Conditions) are true
                • Conditions
                  • (Region 003 <gen> contains (Triggering unit)) Equal to True
                  • (Region 003 <gen> contains (Attacking unit)) Equal to True
              • And - All (Conditions) are true
                • Conditions
                  • (Region 004 <gen> contains (Triggering unit)) Equal to True
                  • (Region 004 <gen> contains (Attacking unit)) Equal to True
        • Then - Actions
        • Else - Actions
          • Unit - Order (Attacking unit) to Stop
          • Game - Display to Player Group - Player 1 (Red) the text: Stop


It only works well if the lanes are horizontal or vertical, since regions can then cover the lane in a better way.

There might be another ways too, I'm trying to think this problem further.

@defskull
Please crop and/or put the image in hidden tags.

Done
And I know it HAS to do with Stop order through trigger, LOL + Regions covered, pretty much same as my prevent attack region trigger from the recent thread
 
Status
Not open for further replies.
Top