The RPG Maker Resource Kit

Other Game Creation => Program Troubleshooting => Topic started by: Rukiri89 on June 29, 2011, 08:45:13 AM

Title: RMVX sensitive push backs (diagonal pushing)
Post by: Rukiri89 on June 29, 2011, 08:45:13 AM
Hello, it's certainly been awhile since I've used RPG Maker and I'm not certain if it's capable of doing what I want it to do..

My project is an a-rpg so obviously pixel-movement is involved or a very low grid base (8X8 is pretty low).  I will be using RPG Maker VX based on the sole reason that rgss has been updated or hidden classes have been released from xp(or so I've heard).

Now the type of ABS I'm trying to do is similar to seiken densetsu 3, the only problem I have is the push back(when you hit the enemy) the enemy moves back depending on where you're standing.  If you're slightly under the enemy it moves diagonal-up, center is directly back, and on top is obviously diagonally-down.  And I even know the math for it! 

Code: [Select]
degree = radtodeg(arctan2(vec1.y - vec2.y, vec2.x - vec1.x));
to keep it simple, or a small script.

Code: [Select]
x1 = argument0;
y1 = argument1;
x2 = argument2;
y2 = argument3;

dt = sqrt(sqr(x2 - x1) + sqr(y2 - y1));
dir = 0;

if (x2 > x1){
   if (y2 > y1){
       dir = ceil(arcsin((y2 - y1)/dt));
   }else{
       dir = ceil(360 - arcsin((x2 - x1)/dt));
   }
}else{
   if (y2 > y1){
       dir = ceil(180 - arcsin((y2 - y1)/dt));
   }else{
       dir = ceil(180 + arcsin((x2 - x1)/dt));
   }
}
return (((arctan2(argument0-argument2,argument1-argument3)* (180/pi))) + 450) mod 360;

The above code is obviously affiliated with game maker, the only reason I'm not using game maker is because of time.  And I prefer ruby over gml to be honest..

Now the only problem I'm seeing is, is how do I actually move the enemy(event) back?  I have tried using a advanced event script, the script function in the set_move_rout and even tried writing a hit detection script(which failed..) 

Anyone got any ideas?..