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: Making the ai move backwards after it's hit  (Read 1650 times)

0 Members and 1 Guest are viewing this topic.
Making the ai move backwards after it's hit
« on: July 11, 2008, 04:36:53 am »
  • The king of Awesome
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Posts: 198
Ok, I generally have it working, but sometimes when I'm really close to the enemy it'll go over me and not backwards(opposite x/y of it's direction).

This doesn't happen often, but it's a bug that's really annoying me... sometimes it will happen allot.

Code(Not this is from the step event, all variables are set up in the scripts)
Code: [Select]
if global.hit=true {
depth=-y
if place_free(x+lengthdir_x(8,direction),y+lengthdir_y(8,direction))
if place_free(x+lengthdir_x(8,direction),y+lengthdir_y(8,direction))
x=min(max(x,0),room_width)
y=min(max(y,0),room_height)
if (place_meeting(x,y,atc_mask)){speed=2;direction=point_direction(global.herox,global.heroy,x,y)
hero_is="l"
}}
global.hit_timer+=1
if global.hit_timer>12 {
can_move=false;
speed=0
instance_change(ai_goku,0)
global.hit_timer=0
global.hit=false
}

Note it's generally the same in all 4 objects, but only hero_is is actually changed.

Here's a demo as well, it might help with the problem visually.

Z is to do Melee attacks
X is to do Ki based attacks(only ki blast as of now, haven't coded any others yet, or implemented)

http://www.mediafire.com/?ixylfpyx5i2

Also, since it's an action battle system(ABS) it will move in diagonal movements depending on where you strike the ai, that's one of my favorite things about GM, Pixel Perferctness!
Logged
Re: Making the ai move backwards after it's hit
« Reply #1 on: July 11, 2008, 05:50:51 am »
  • You're the yellow bird that I've been waiting for.
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 242
Just so you know, the link is screwed up, you have to copy/paste it. I'm downloading the example now, I'll get back to you if I come up with something :]

EDIT: Actually, I can't seem to recreate the problem. I did find a small movement bug. If you move diagonally one way, and then move in the opposite direction the hero's sprite doesn't update and it looks like you're moonwalking. That's an easy fix though. I'll keep trying for the original problem.

EDITEDIT: Also there seems to be a random 0 in the top left corner of the map that changes colors along with the damage color. It seems to be counting down something whenever I shoot the beam thing. I don't know if that's supposed to be there or not :huh:
« Last Edit: July 11, 2008, 06:05:15 am by whitechapel »
Logged
Re: Making the ai move backwards after it's hit
« Reply #2 on: July 11, 2008, 06:41:34 am »
  • *
  • Reputation: +3/-0
  • Offline Offline
  • Gender: Male
  • Posts: 6629
Personally I wouldn't reverse its direction for this, that seems a very shoddy way of doing it. When the enemy is hit you should take a vector between its position and the position of the weapon that hit it, then increase the position by the inverse of the vector each frame afterwards. Produces a perfect backwards movement.
Logged
Re: Making the ai move backwards after it's hit
« Reply #3 on: July 11, 2008, 01:32:10 pm »
  • The king of Awesome
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Posts: 198
Hmm, I've seen this done before. I think it was in an example or tutorial in a zelda engine. If it is can you direct me to it?
Logged
Re: Making the ai move backwards after it's hit
« Reply #4 on: July 11, 2008, 01:45:01 pm »
  • *
  • Reputation: +3/-0
  • Offline Offline
  • Gender: Male
  • Posts: 6629
Hmm, I've seen this done before. I think it was in an example or tutorial in a zelda engine. If it is can you direct me to it?
I don't use GM so I'm afraid not, I'm sure someone else here will be able to direct you though.
Logged
Re: Making the ai move backwards after it's hit
« Reply #5 on: July 11, 2008, 02:16:14 pm »
  • Metal Up Your Ass.
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 56
This could be useful. It's a very good engine, credit Goodnight :)

http://www.zfgc.com/forum/index.php?topic=11182.0
Logged
Re: Making the ai move backwards after it's hit
« Reply #6 on: July 12, 2008, 10:52:46 pm »
  • The king of Awesome
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Posts: 198
The only problem with that engine, as it's very close to mine and even when I change the speed to .5 it's still to fast.
Logged
Pages: [1]   Go Up

 


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



Page created in 0.189 seconds with 49 queries.

anything