I'm making a game with detection. The guards move around randomly until they detect you.
It works, except that the guard bypasses ALL the walls, and gets to you within .5 seconds; he basically blazes across the screen.
I need help. I'll show you the script I'm using for detection:
http://img4.imageshack.us/img4/4291/detectionacgame2.png
http://img854.imageshack.us/img854/9722/detectionacgame.png
Yes, I know, it's an AC game.
I don't plan to sell it nor share it, I'm doing it for a class.
Offline
aegisrunestone wrote:
I'm making a game with detection. The guards move around randomly until they detect you.
It works, except that the guard bypasses ALL the walls, and gets to you within .5 seconds; he basically blazes across the screen.
I need help. I'll show you the script I'm using for detection:
http://img4.imageshack.us/img4/4291/detectionacgame2.png
http://img854.imageshack.us/img854/9722/detectionacgame.png
Yes, I know, it's an AC game.I don't plan to sell it nor share it, I'm doing it for a class.
He's probably blazing across the screen because it keeps sending and receiving [detected] and so the "detected" script never has time to run all the way through, it just keeps getting reset.
Offline
So, what would your recommendation be?
Offline
I would suggest,
forever if <(distance to [Ezio v]) < [200]> broadcast [detected v] end endIs that ok?
when I recieve [detected v]
forever
if <touching [wall v]>
turn (90) degrees
move (5) steps
else
Point towards [Ezio v]
Move (5) steps
end
end
Hope this helps if this isn't what your looking for tell me and I'll alter the code.Last edited by P110 (2012-04-09 16:06:51)
Offline
I think I am using sprite sensing.
Anyway, that stops him from moving through the wall, but if he's next to it, he'll bounce around really fast and never get to Ezio.
And if he's away from a wall, he'll still blaze toward Ezio once he's detected him, giving you no time to hide.
Offline
Okay, one thing I decided to do with being Hidden and Detected was to use variables since I don't think you can turn off a broadcast. I might have to make a variable for "BeginPatrol," too.
when i receive [BeginPatrol] forever if <(distance to [Ezio v]) < [200]> if <(Hidden) = [0]> say [!] for [2] secs set <[Detected v] to (1)> //Detected is a variable else say [?] for [2] secs set <[Detected v] to (0)>That's the first detection script, here's the one that's below it.
when i receive [BeginPatrol] if <(Detected) = [1]> forever if <touching (MazeMainLvl v) ?> turn cw (90) degrees move [5] steps wait [0.5] secs else point towards [Ezio v] move [5] steps wait [0.5] secs end end end if <(Detected) = [0]> stop scriptThis doesn't seem to work very well. The guard seems to behave as if he's detected you already, though the "!" doesn't appear over him. Also, when chasing Ezio, the guard can sometimes go through the wall.
Offline
I'm sorry to triple post, but please, I need help!
Offline
On your broadcast variables, I suggest that instead of using the normal:
broadcast [whatever you're broadcasting v]I suggest you use a:
broadcast [whatever you're broadcasting v] and waitNow instead of the script continuing to repeat itself, the script broadcasting will now wait until the detected script is done and so doesn't continue to repeat itself.
forever if < (distance to [Ezio v] ) < [200] > broadcast [Detected v] and wait
when I receive [Detected v] forever point towards [Ezio v] move (5) steps say [!] for (2) secs endNow this should work.
Last edited by SOScratch (2012-04-09 22:18:59)
Offline
Okay, but what if I want it to make sure so that when Ezio is out of range or hiding in a haystack that it stops the broadcast: "Detected," and makes the guard go back to "BeginPatrol"?
Thanks to everyone who's responded so far, BTW.
Offline
Update! (I wish there was an edit button)
Here's my guard script: http://img441.imageshack.us/img441/2816/acguard1.gif
Before, for some odd reason, he wouldn't rush me.
Now, I added a sprite that is an "!" that appears on him. Now, he blazes toward Ezio, and well, I die.
Offline
http://img593.imageshack.us/img593/2816/acguard1.gif
This is the new guard script.
I made it so that the guard doesn't rush you. But I'm trying to get him to go to between two way points. It doesn't work. Sometimes, he goes up instead of going down. And then when he hits the second waypoint, he doesn't go back up.
I'm sorry for all the double/triple posting, but I really need help! This is for a class, and I need to finish it to turn it in.
Offline
Simply start with your, when green flag is clicked script. Put a forever block down, and then an if block in the forever block. in this if block it should say, if distance to Ezio is greater than, 200, for example, and then in the block say, glide to x-wherever y-wherever. Wherever your first way point is. then put in another if block. This one should read, if distance to Ezio is less than 200, and then move towards him, however far you want him to move. After this, there should be a copy of the first if block, with the coordinates of the way point being the only thing changed. Then add a replica of the second if block. How far the guard moves, for how long, is up to you. You also said you had walls, you will have to add separate scripts to keep him from going through them. Other than that, and changing costumes for walking and running, that should work. The only downside is that the guard only notices Ezio if he is at a way point. But he will go back to his post if Ezio gets to far away. To add anther way point to his patrol, simply copy the first and second if blocks again, only changing the glide coordinates to your new point. I hope this helps you finish you project
Offline
Okay, thanks. Though, when you press the Green Flag, you are taken to the start screen, where you have to press the start button to start the game. But that shouldn't make a difference, right?
Offline
It depends on what part of the game you want this guard in. You could have him wait a certain amount of time before starting his rounds, or you could put down a, when I recieve script instead of the flag. If you do that, you need to make sure something else broadcasts this message at the appropriate time.
Offline
aegisrunestone wrote:
Okay, but what if I want it to make sure so that when Ezio is out of range or hiding in a haystack that it stops the broadcast: "Detected," and makes the guard go back to "BeginPatrol"?
Thanks to everyone who's responded so far, BTW.![]()
I haven't read this entire thread, but just modify SOScratch's script a little, so it becomes this:
forever if < (distance to [Ezio v] ) < [200] > broadcast [Detected v] and wait end
when I receive [Detected v] repeat until < not <(distance to [Ezio v]) < [200]>> point towards [Ezio v] move (5) steps say [!] for (2) secs end broadcast [BeginPatrol]
Last edited by Greenatic (2012-04-11 09:04:41)

Offline
I don't really know what kind of game you are creating, but it could be interesting to make the guard(s) walk along a path instead of continuously moving towards the player.
when green flag clicked forever glide (3) secs to x: (-150) y: (-150) glide (3) secs to x: (150) y: (-150) glide (3) secs to x: (150) y: (150) glide (3) secs to x: (-150) y: (150) end when green flag clicked forever if <(distance to [player v]) < (100)> broadcast [caught v] and wait end end
Offline
sonicfan12p wrote:
Simply start with your, when green flag is clicked script. Put a forever block down, and then an if block in the forever block. in this if block it should say, if distance to Ezio is greater than, 200, for example, and then in the block say, glide to x-wherever y-wherever. Wherever your first way point is. then put in another if block. This one should read, if distance to Ezio is less than 200, and then move towards him, however far you want him to move. After this, there should be a copy of the first if block, with the coordinates of the way point being the only thing changed. Then add a replica of the second if block. How far the guard moves, for how long, is up to you. You also said you had walls, you will have to add separate scripts to keep him from going through them. Other than that, and changing costumes for walking and running, that should work. The only downside is that the guard only notices Ezio if he is at a way point. But he will go back to his post if Ezio gets to far away. To add anther way point to his patrol, simply copy the first and second if blocks again, only changing the glide coordinates to your new point. I hope this helps you finish you project
Okay, it's working, except the guard is gliding through the level walls. How do I fix that?
Thanks so much, BTW.
Offline
If he's gliding through walls to get to a waypoint, the you should have more than two waypoints to make sure he doesn't hit walls on his way to the next one. You should also make a separate script that says, forever, if guard is touching(color of wall) if the wall is part of the stage background, or if the wall is a separate sprite(which usualy works best)then change, if touching color to, if touching wall, or whatever the sprites name is. In the if block you should then put something like, move - 10 steps, to get him off the wall. That should solve the problem.
Offline
A separate script? So, something like...
when I receive [BeginPatrol] forever if touching (Wall) turn cw (90) degrees move (-10) stepsLike that?
Offline
Kay. It's not working, the guard is still floating through the maze walls.
The maze walls are all one sprite, BTW.
Offline
Another thing. I do want to use variables because Ezio can hide in Haystacks, making detection worthless.
http://img832.imageshack.us/img832/8546/acgaurd12.gif
http://img268.imageshack.us/img268/3007/haystackscript.gif
How do I work with this? Or I am being too complex?
Offline
It is a bit complex. I don't really have an answer right off the bat, but I'll try and look into it. It might take a bit, because I'm in the middle of making the next level of Tanks.
When is this supposed to be due? I'll try and figure out this problem before then.
Offline
One more thing, to figure this out, I'm going to try and make one of the levels. If you could tell me the objective of a level, and if Ezio has any special abilities, that would help a lot.
Offline
The point is to get the Scroll of Altair. Ezio has lost his Hidden Blades, so he can't kill any guards. He has to avoid being detected. There are three guards in the level, and three haystacks. If Ezio needs to, he can use a haystack to avoid getting detection. If the guards touch him, he loses a Health Square. If he loses all his Health Squares, he dies (You only get 2 Health Squares). If he gets the scroll, he wins.
The game is overhead view. And the game is due Tuesday.
Thanks.
Offline
Okay!
I'll get started on it as soon as possible. When I'm done, I'll post a link on here, and you can download it and look.
Offline