Hello Guest, please login or register.
Did you miss your activation email?
Login with username, password and session length.

Pages: [1]   Go Down

Author Topic: AI Help  (Read 971 times)

0 Members and 1 Guest are viewing this topic.
AI Help
« on: November 25, 2007, 09:38:12 pm »
  • The king of Awesome
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Posts: 198
Create Event:
Code: [Select]
dir="d"
chase_hero=true
image_speed=0.2
movespeed=2
near_hero=false
Step Event
Code: [Select]
if point_distance(x,y,objhero.x + 2,objhero.y + 3) < 2
speed = 0
else
if point_distance(x,y,objhero.x + 2,objhero.y + 3) < 228{
near_hero=true
move_towards_point(objhero.x+12,objhero.y+3,movespeed)
}
if point_distance(x,y,objhero.x + 2,objhero.y + 3) > 229{
hspeed = 0
vspeed = 0
near_hero=false
}
else {
if point_distance(x,y,objhero.x,objhero.y ) < 48 {
hspeed = 0
vspeed = 0
near_hero=false
}}
depth = objhero.depth-2
Begin Step
Code: [Select]
if near_hero=false
{
if dir="d" {
sprite_index=kuririn_stand_d
}
if dir="r" {
sprite_index=kuririn_stand_r
}
if dir="l" {
sprite_index=kuririn_stand_l
}
if dir="u" {
sprite_index=kuririn_stand_u
}
}
End Step
Code: [Select]
if chase_hero=true && near_hero=true {
{
 var n;
 n = radtodeg(arctan2(Kuririn.y-objhero.y,objhero.x-Kuririn.x));
 if (n < -135 || n >= 135)sprite_index=kuririn_walk_left
 if (n >= -135 && n < -45)sprite_index=kuririn_walk_down
 if (n >= -45 && n < 45)sprite_index=kuririn_walk_right
 if (n >= 45 && n < 135)sprite_index=kuririn_walk_up
}
}
User Defined 0
Code: [Select]
dir=point_direction(objhero.x,objhero.y,x,y)

Basically it works but as you can see in the create event, the dir variable is to "d" and when the ai stops it ALWAYS stops facing down.

Can anyone help?
Logged
Re: AI Help
« Reply #1 on: November 25, 2007, 10:20:20 pm »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Posts: 2245
Because you aren't setting the direction?
Logged
Re: AI Help
« Reply #2 on: November 25, 2007, 10:39:02 pm »
  • The king of Awesome
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Posts: 198
It's pointed to objhero so that's how it finds the directions... just doesn't work when it stops.
Logged
Re: AI Help
« Reply #3 on: November 25, 2007, 11:03:53 pm »
  • MetalRidley was here
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 235
He means in the End Step event you forgot to set dir along with the sprite; right now it's just changing the sprite. So technically dir never changes from d.
Logged



THE MUSIC IS REVERSIBLE, BUT TIME IS NOT. TURN BACK... turn back... turn back...
Re: AI Help
« Reply #4 on: November 26, 2007, 10:13:10 pm »
  • The king of Awesome
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Posts: 198
Oops.. I forgot about that, thanks!

Now I can modify this into an ally script!
Logged
Pages: [1]   Go Up

 


Contact Us | Legal | Advertise Here
2013 © ZFGC, All Rights Reserved



Page created in 0.035 seconds with 47 queries.