Help - Plants vs Zombies

Sabretooth

New Member
Reaction score
0
Heya!

So i'm currently working on a project i call Ancient vs Undead based on the popular mini-game Plants vs Zombies
Basic plot:
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?
Please and thank you :)
 

Accname

2D-Graphics enthusiast
Reaction score
1,462
the zombies of each lane have to belong to different players.
it would be better to do it this way not just because of the towers but because of the standard wc3 ai which will bug if more then 200 units belong to the same player.
 

X-maul

AKA: Demtrod
Reaction score
201
you could do that simply by addin pathing blocker line of sight ;)

EDIT:
misread - you can trigger it to shot a missile (dummy unit) to the right every X second, and when they get in 50 range of an enemy unit, make it deal damage to the unit.
 

Accname

2D-Graphics enthusiast
Reaction score
1,462
you could do that simply by addin pathing blocker line of sight ;)
this wont work if you can see the lane of the other players in any way. however, if you couldnt see it i doubt there would be alot of sense playing multiplayer td maps.

EDIT:
misread - you can trigger it to shot a missile (dummy unit) to the right every X second, and when they get in 50 range of an enemy unit, make it deal damage to the unit.
and this would be such an overkill in a tower defense that his map most likely wouldnt be played much longer then 5 minutes because of the extensive lag it will cause if houndres of towers are shooting thousands of dummy missles.
 

Laiev

Hey Listen!!
Reaction score
188
use regions... (5)

then check the region of attacked unit if is different then attacking unit, order to attack random unit in the current region and stop if has no unit in region
 

Sim

Forum Administrator
Staff member
Reaction score
534
How many players are actually going to be "Defending" in your TD?
 

Tom_Kazansky

--- wraith it ! ---
Reaction score
157
assume that each lane is a region

how about:
- add "worker" class to all your tower so they won't auto-acquire targets
- for each tower, periodically pick a nearest enemy within its attack range and in the region that's its lane
- order it to attack this enemy

this is un-tested but it's worth trying ;)
 

Accname

2D-Graphics enthusiast
Reaction score
1,462
use regions... (5)

then check the region of attacked unit if is different then attacking unit, order to attack random unit in the current region and stop if has no unit in region
this will glitch the towers attack, they will not always attack the right way and most probably screw the gameplay. cause nobody wants his towers in a td map to "stop" every now and then when re-quiring a new target. (after a unit is ordered the "stop" order it will take a little time until it auto-aquires a new target)

assume that each lane is a region

how about:
- add "worker" class to all your tower so they won't auto-acquire targets
- for each tower, periodically pick a nearest enemy within its attack range and in the region that's its lane
- order it to attack this enemy

this is un-tested but it's worth trying ;)

will 1). make a pretty ugly worker icon for every tower and 2). it might cause lag depending on the amount of towers, it will drop the performance for sure.
 

Sim

Forum Administrator
Staff member
Reaction score
534
The solution is located somewhere in post #2.

Have a maximum of 6 players defending, and 6 players (computer players) controlling the zombies. Make every defending player the enemy of the zombie player corresponding to his lane. Make every defending player allied with all the other zombie players.
 

Mahrloc

New Member
Reaction score
5
the thing i would do is to make every tower shoot dummy units, which are moved by triggers. i think the performance should be fine if you don't move them too often...
 

Sim

Forum Administrator
Staff member
Reaction score
534
> i think the performance should be fine if you don't move them too often...

It's the dummy units themselves that create lag, not the fact that they move. The game has an odd way of handling units. A mass of dummy units almost always lags.
 

Accname

2D-Graphics enthusiast
Reaction score
1,462
> i think the performance should be fine if you don't move them too often...

It's the dummy units themselves that create lag, not the fact that they move. The game has an odd way of handling units. A mass of dummy units almost always lags.

daxtreme is right, but not just that, creating a unit is the most slowest function of all in wc3. units just have this incredible amount of information they need. all those values they save. its just heavy overkill to use them in the very most circumstances and it should be avoided at any cost.
 

Bogrim

y hello thar
Reaction score
154
For missiles, make your units cast a cone type of spell (e.g. Shockwave) instead of attacking. You can use an invisible non-damaging attack if you want the attack to trigger the spell and order the unit to cast the spell in the appropriate direction whenever it attacks. But I would suggest making some form of combat trigger that auto-casts the spell while "combat" is active.
 

Sabretooth

New Member
Reaction score
0
I tried this:
1) For every square on map i created a "building" based on Circle of Power that wont efect the walking zombies and named it Plant. You then upgrade this "building" to a tower.

2) I created 3 types of towers, and 3 types of zombies.
Tower1
Tower2
Tower3

Zombie1
Zombie2
Zombie3


3) I set the "target" and "targets as" to:
Tower1 - Target -> Ward
Tower2 - Target -> Ground
Tower3 - Target -> Neutral

Zombie1 - Target as -> Ward
Zombie2 - Target as -> Ground
Zombie3 - Target as -> Neutral


4) I then created 2 more types of Plant buildings.
Plant1 - Upgrades to Tower1
Plant2 - Upgrades to Tower2
Plant3 - Upgrades to Tower3


5) Then I set:
Lane1 - Has Plant1 and spawn zombies of type Zombie1
Lane2 - Has Plant2 and spawn zombies of type Zombie2
Lane3 - Has Plant3 and spawn zombies of type Zombie3
Lane4 - Has Plant1 and spawn zombies of type Zombie1
Lane5 - Has Plant2 and spawn zombies of type Zombie2



This worked out pretty good except that Tower2 doesn't target its type of Zombie. So i tried to set "Target" and "Target as" to diffrent but it still doesn't work.
pvz.png
Do you think this is solvable problem and will this solution work later on?
 

Accname

2D-Graphics enthusiast
Reaction score
1,462
how many players / lanes are in your game? because if possible i would really advice you to give each lane an own zombie owning player.
 

Sabretooth

New Member
Reaction score
0
how many players / lanes are in your game? because if possible i would really advice you to give each lane an own zombie owning player.

At the moment there's only 1 player. But once i get this thing going, there is going to be 2 playfields so 2 players can compete against each other.
So, 1 player for each gamefield.

Zombies that spawn are Neutral Hostile atm while i'm still testing, but is suposed to spawn for the other team later on.
Player1 - Playfield 1 - Zombies belongs to Player2
Player2 - Playfield 2 - Zombies belongs to Player1


Edit: Picture added to last post
 

Accname

2D-Graphics enthusiast
Reaction score
1,462
then why you dont use player 3 for the zombies at player 1's lane and player 4 for the zombies at player 2's lane? then make player 1 and 4 allies and player 2 and 3. make your towers only able to attack enemys (not allies) and you are done. i dont see why you need those complex overkill systems for a thing as easy as this.
 

Sabretooth

New Member
Reaction score
0
I'm afraid i don't understand or that we are misunderstanding :eek:
I think that it might have worked if the zombies could choose what ever path they wanted.

This is my vision:
pvzwant.png


This is the problem:
pvzis.png


This is where I am atm (I feel that it is unnecessary to add other players yet, when all i need to to is to do is copy-paste when this is fixed):
pvzcurrent.png


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



I'm sorry if i don't understand ^^ But i just want make sure (and show of my paint skills :cool:)
 

Accname

2D-Graphics enthusiast
Reaction score
1,462
well, look. if you just say that the zombies of each lane are owned by a particular computer player you can always know to which lane which zombie belongs.

more over, you could make each player allied with the zombie computer players which are NOT on his own lane.

furthermore you could make the towers only be able to attack enemy units, and no allies.

that means, the towers of each player could only target those zombies which are owned by an enemy computer. and because ALL computers exept ONE are allied with you it means that your towers can only target the zombies owned by ONE computer player. and that computer player is exactly that one which is spawning zombies on your lane.

that means its absolutely impossible that either your towers attack zombies at an other lane and that those zombies from an other lane attack your tower.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top