Since Ive decided to make enemies in draw your game 2 I AI scripts. They would be like the AIs you find in fighting games. I plan to make the something like this:
right of player:move left
left of player:move right
close to player: Begin attack script, pick random attack
sense item: go to item when touching pick it up
This of course is very rough and I also need to make different difficulty settings which will probably be created with wait X secs and randoms X to Y.
If you have any ideas for making this kind of AI or others please post.
Offline
Capital has the best AI I have seen in a scratch game.
http://scratch.mit.edu/projects/jmgibson/7644
The ships and missles can follow you all over space and use real physics to calculate forces. I'm sure there is stuff you can learn from it.
Last edited by technomage (2007-06-07 15:02:59)
Offline
Your badguy can use "point towards" to always know where the goodguy is, and then "move 10" will always move him forwards.
Use "distance to" to check how close you are.
Forever
Point towards Goodguy
wait 0.1
If (distance to goodguy)<50
- (use attack routine)
- Else
Move 10
Offline
I'm going to have to thank technomage for the nod to Capital, but please, if you are going to look at my script for any education, don't look at the enemy ship. It's attack looks smart and complex but its embarrassingly simple and uses the missile to hide what its really doing in the game. Instead look at the physics I've built into the missile. I consider that much more clever.
Offline
i have AI opponents in two of my games. 1player ping pong and pacman. both are fairly straightforward but affective. feel free to look. pingpong may be more appropriate for you.
Offline
I need something more simple then jmgibson. All I want is an enemy that will shot at you. What is the script for shooting in basic.
Offline
Well, Al's are not that hard to make. My Al's In my super awesome game named "Super Smash Brothers Brawl" that is coming out on March 9th (because the actual game will come out in America that day) are going to be pretty good. If there is an item it will go after it and stuff. Lots of stuff of course is from archmage's Merry Smashmas though it is not a remix. I literally put the blocks together and spent my work. Though I bet it will be better. Not sure if it will have the scrolling part with the zooming out though I am working on it. This is how the main stage will look, Basically the main battle field.
|\ _ ___________
| | / \ ___________ | | | | | |
| | ________ / \ | | _______
| | \ / | | | | | |
________________________________________________________
|_______________________________________________________|
Eh, looks horrible, it is hard to make pictures.
Offline
Well, a permanently running loop would constantly check for relative position, direction...
Scratch could easily use a "heuristics" point counting AI for decision making, example:
Set the heuristics:
================
forever
if distance to sprite < 50
set "choose to move" to 10
else
set "choose to move" to 5
if speed of sprite > 10
change "choose to move" by -7
else
change "choose to move" by 7
end forever
Use the heuristics:
================
forever
if "choose to move" > 8
point to sprite
move forward
end forever
You can have variables for a lot of decision making - choose to move, to shoot, pick a direction rather than another. By tweaking the factors that affect the decision (the points added or taken away), you arrive at very subtle difference of behaviour. That's how the Pacman ghosts do it.
Enjoy
Charles
Offline
Err, my heuristics are rubbish, try again:
boisvert wrote:
forever
if distance to sprite < 50
set "choose to move" to 10
else
set "choose to move" to 5
if speed of sprite > 10
change "choose to move" by -7
end forever
Like that "choose to move" is positive if the sprite is near and slow, negative otherwise.
Offline
Makh wrote:
Can someone tell me how to make spaceships shoot at each other.
It all depends on how complicated you want to get...are you trying to make a computer opponent that can fire back at you? Or something simpler like a video where you just need the ships to shoot at each other?
Have you already figured out how to make bullets shoot? You will need to know how to do that first. Here's a shooting tutorial you might want to look at...
http://scratch.mit.edu/projects/News-guy/263160
Offline
how do i do the thing if the guy is within range he attacks?
Offline
RPGmasterSilent wrote:
how do i do the thing if the guy is within range he attacks?
if abs( hero x position - enemy x position)<attackRange
broadcast fight
something like this
Offline
dude no mother flipping way
Offline
I think I done this kind of thing before... Alright... maybe try
<when green flag clicked>
<forever>
<if> <( x position of player <<> x position of enemy )>
<move( -However many )steps>
<end>
<if> <( x position of player <>> x position of enemy )>
<move( How ever many steps )steps>
<end>
It's that or the opposite way.
Last edited by Oneandonly (2009-07-15 12:45:21)
Offline
I know how to make enemy AL scripts. My game "Super Scratch Brawl" contains these scripts.
Offline