This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2008-03-31 12:04:28

teguki
Scratcher
Registered: 2008-03-06
Posts: 72

the right enemy?

how do i make the hidden "enemy finder" only point to whichever enemy is closest to the character and vice-versa.

its a top-veiw war game

Offline

 

#2 2008-03-31 12:49:38

Mayhem
Scratcher
Registered: 2007-05-26
Posts: 1000+

Re: the right enemy?

Hide
set "enemydistance" to distance to "Enemy1"
Point towards enemy1
If "enemydistance" > distance to "Enemy2"
-> set "enemydistance" to distance to "Enemy2"
-> Point towards "enemy2"
If "enemydistance" > distance to "Enemy3"
-> set "enemydistance" to distance to "Enemy3"
-> Point towards "enemy3"
Show

Copy the "if" part as many times as you need for your enemies.


Web-spinning Spider:  http://scratch.mit.edu/projects/Mayhem/18456
3D Dungeon Adventure:  http://scratch.mit.edu/projects/Mayhem/23570
Starfighter X: http://scratch.mit.edu/projects/Mayhem/21825
Wandering Knight: http://scratch.mit.edu/projects/Mayhem/28484

Offline

 

#3 2008-03-31 16:15:31

teguki
Scratcher
Registered: 2008-03-06
Posts: 72

Re: the right enemy?

thanx!

Offline

 

#4 2008-04-18 06:32:13

teguki
Scratcher
Registered: 2008-03-06
Posts: 72

Re: the right enemy?

oooo... kay... A PROBLAM HUS ARISAN!

how do i do this so it will point to the closest enemy that is NOT hidden behind a wall/tree (and when a character is on the tower (usually the sniper) that it will see over the wall but not see down through the canopy)

Offline

 

#5 2008-04-24 17:17:56

teguki
Scratcher
Registered: 2008-03-06
Posts: 72

Re: the right enemy?

it makes it easy to set traps, but i dont want the soldiers to be able to see through walls...

sooo... how do i cancle out those who are behind walls/trees?  big_smile

Offline

 

#6 2008-04-24 18:23:52

Paddle2See
Scratch Team
Registered: 2007-10-27
Posts: 1000+

Re: the right enemy?

That's an interesting problem.  You want to exclude enemy that are not in line-of-sight.  One approach would be to send a helper sprite (with ghost effect set to 100% so it was invisible) between the enemy and the viewer and see if it contacts any cover sprites or cover background.  If it does, set a variable so that the enemy is excluded from the distance calculation.  This approach would be fairly slow.


http://i39.tinypic.com/2nav6o7.gif

Offline

 

#7 2008-04-25 18:23:45

teguki
Scratcher
Registered: 2008-03-06
Posts: 72

Re: the right enemy?

i have invisible L.O.S. sprites so that the soldiers react to each other, and the L.O.S.'s also determine wether the character is close enough to fire. so, how does this help me exclude hidden enemys?

do you mean a second sprite that travels along the L.O.S.?

and, how do i set up a variable to exclude only some of the enemies?

Offline

 

#8 2008-04-26 10:12:10

teguki
Scratcher
Registered: 2008-03-06
Posts: 72

Re: the right enemy?

P.S. how do i get those enemies back into the equation?

Offline

 

Board footer