Page 1 of 2

The perfect Anti moonwalk for RPG's Version 1.2

PostPosted: Thu Feb 11, 2010 4:42 pm
by Hblade
UPDATES:
Allow only 4 way movement
Wall Collision

Hey guys, I've finally did it! no moonwalk, no glitches, the perfect anti-moonwalk for RPG games :) First, make your player, add event ->Draw Actor -> Script Editor, and put this script in.

First, make a variable called STATE, then place this code in Draw Actor
Code: Select all
char *key=GetKeyState();

if (key[KEY_UP] == 1 && key[KEY_DOWN] == 0){
    if (STATE!=90){
        if (STATE!=10){
        STATE = 10;
        ChangeAnimation("Event Actor", "WalkUp", FORWARD);
                  }
    y-=3;
                  }
    if (STATE == 90){
        ChangeAnimation("Event Actor", "StandingUp", FORWARD);
                    }
                                           }
if (key[KEY_UP] == 0 && key[KEY_DOWN] == 1){
    if (STATE!=91){
        if (STATE!=11){
        STATE = 11;
        ChangeAnimation("Event Actor", "WalkingDown", FORWARD);
                  }
    y+=3;
                  }
    if (STATE == 91){
           ChangeAnimation("Event Actor", "StandingDown", FORWARD);
                       }
                                           }
if (key[KEY_LEFT] == 1 && key[KEY_RIGHT] == 0 && key[KEY_UP] == 0 && key[KEY_DOWN] == 0){
    if (STATE!=92){
        if (STATE!=12){
        STATE = 12;
        ChangeAnimation("Event Actor", "WalkingLeft", FORWARD);
                  }
                  x-=3;
                  }
                  if (STATE == 92){
                      ChangeAnimation("Event Actor", "StandingLeft", FORWARD);
                                  }
                                              }
if (key[KEY_LEFT] == 0 && key[KEY_RIGHT] == 1 && key[KEY_UP] == 0 && key[KEY_DOWN] == 0){
    if (STATE!=93){
        if (STATE!=13){
        STATE = 13;
        ChangeAnimation("Event Actor", "WalkRight", FORWARD);
                  }
                  x+=3;
                  }
                  if (STATE == 93){
                      ChangeAnimation("Event Actor", "StandingRight", FORWARD);
                                  }
                                              }
if (key[KEY_UP] == 1 && key[KEY_DOWN] == 1 && STATE == 10){
    STATE = 40;
                                                          }
if (key[KEY_UP] == 1 && key[KEY_DOWN] == 1 && STATE == 11){
    STATE = 41;
                                                          }
if (key[KEY_LEFT] == 1 && key[KEY_RIGHT] == 1 && STATE == 12){
    STATE = 42;
                                                             }
if (key[KEY_LEFT] == 1 && key[KEY_RIGHT] == 1 && STATE == 13){
    STATE = 43;
                                                             }
if (STATE == 40){
    ChangeAnimation("Event Actor", "StandingUp", FORWARD);
                }
if (STATE == 41){
    ChangeAnimation("Event Actor", "StandingDown", FORWARD);
                }
if (STATE == 42){
    ChangeAnimation("Event Actor", "StandingLeft", FORWARD);
                }
if (STATE == 43){
    ChangeAnimation("Event Actor", "StandingRight", FORWARD);
                }


There you have it! I'm enhancing it as well so keep looking for the updates

Here's an Example of Version 1.2
Example.zip
(140.25 KiB) Downloaded 178 times

Re: The perfect Anti moonwalk for RPG's (Get code here)

PostPosted: Thu Feb 11, 2010 4:59 pm
by MrJolteon
Sweet.

Re: The perfect Anti moonwalk for RPG's (Get code here)

PostPosted: Thu Feb 11, 2010 4:59 pm
by Hblade
Thanks :D Updated

Re: The perfect Anti moonwalk for RPG's Version 1.2

PostPosted: Thu Feb 11, 2010 8:35 pm
by Bee-Ant
Thats pretty long...and too much of IF on draw actor. Thats bad for performance.
I have a simpler version

- make integer variables : "direct", "walk", "anim"
- player-DrawActor :
Code: Select all
if(walk==1){
if(direct==0){
y-=3;
if(anim==0){ChangeAnimation("Event Actor","walk_up",FORWARD);anim=1;}}
if(direct==1){
x+=3;
if(anim==0){ChangeAnimation("Event Actor","walk_right",FORWARD);anim=1;}}
if(direct==2){
y+=3;
if(anim==0){ChangeAnimation("Event Actor","walk_down",FORWARD);anim=1;}}
if(direct==3){
x-=3;
if(anim==0){ChangeAnimation("Event Actor","walk_left",FORWARD);anim=1;}}}

- player-Keydown :
Code: Select all
direct=0; //for up key
//or
direct=1; //for right key
walk=1;

- player-Keyup :
Code: Select all
walk=0;
//add the stop animation depend on direct value here

- player-AnimationFinish :
Code: Select all
anim=0;


This is my standard method. Used on most my game, as well as Winter Blast

Re: The perfect Anti moonwalk for RPG's Version 1.2

PostPosted: Thu Feb 11, 2010 8:52 pm
by Hblade
Yes but your method does have one moonwalk glitch. If you press a key before his animation is done he will float in that direction for a few frames before he switches his animation :P It's still nice for such a small script :D congrats bee :)

Re: The perfect Anti moonwalk for RPG's Version 1.2

PostPosted: Thu Feb 11, 2010 9:06 pm
by Bee-Ant
Ohh...that one. its easy to fix.
Maybe something like this :
Player-Keydown-Up
Code: Select all
direct=0;
walk=1;
ChangeAnimation("Event Actor","walk up",NO_CHANGE);

Etc for the other keydown, but
Dunno...
Im away of computer :P

Re: The perfect Anti moonwalk for RPG's Version 1.2

PostPosted: Thu Feb 11, 2010 9:33 pm
by Hblade
k :D Anyways hope the script comes in handy for people :)

Re: The perfect Anti moonwalk for RPG's Version 1.2

PostPosted: Fri Feb 12, 2010 3:38 am
by Bee-Ant
Im not going to fix and publish it...

Re: The perfect Anti moonwalk for RPG's Version 1.2

PostPosted: Fri Feb 12, 2010 2:09 pm
by Hblade
Oh :(... your script is much simpler though :O, Anyways, BeeAnt, any idea how I can make a 1-grid movement system with this script? :D

Re: The perfect Anti moonwalk for RPG's Version 1.2

PostPosted: Fri Feb 12, 2010 2:57 pm
by thunderios
If you use Bee-Ant's script, you might want to click on 'wait for frame action' when you click add, that way it will only walk the way you want when the animation is finished, right?

Re: The perfect Anti moonwalk for RPG's Version 1.2

PostPosted: Fri Feb 12, 2010 3:03 pm
by Bee-Ant
Hblade wrote:Oh :(... your script is much simpler though :O

:D
I'm not Mr. nice guy who will publish his code to everyone (only for certain people)
I'm wicked :(

HBlade wrote:Anyways, BeeAnt, any idea how I can make a 1-grid movement system with this script? :D

Talking about pokemon huh???
Im also going to use that system for the new Winter Blast :P

It may be :
1. Remove the KeyUp event
2. Add this code to the AnimationFinish
Code: Select all
walk=0;

3. Add this code to Draw Actor
Code: Select all
if(walk==0)
{
if(direct==0)ChangeAnimation("Event Actor", "stop up",FORWARD);
if(direct==1)ChangeAnimation("Event Actor", "stop right",FORWARD);
if(direct==2)ChangeAnimation("Event Actor", "stop down",FORWARD);
if(direct==3)ChangeAnimation("Event Actor", "stop left",FORWARD);
}

Re: The perfect Anti moonwalk for RPG's Version 1.2

PostPosted: Fri Feb 12, 2010 5:49 pm
by Hblade
Hey nice bee O.O

Re: The perfect Anti moonwalk for RPG's Version 1.2

PostPosted: Fri Feb 12, 2010 6:22 pm
by Bee-Ant
Really? I havent tested it yet.
Also, edit your Keydown event to :
Code: Select all
if(walk==0){
direct=yourdirectvalue;
walk=1;}

To avoid a direct turn.

The next job is how you adjust your walking animation to be finished in 1 tile lenght.

Good luck :D

Re: The perfect Anti moonwalk for RPG's Version 1.2

PostPosted: Fri Feb 12, 2010 6:59 pm
by Hblade
Thanks :D

Re: The perfect Anti moonwalk for RPG's Version 1.2

PostPosted: Wed Feb 17, 2010 12:21 am
by jimmynewguy
This is what i usually use. not made by me though Novie made it a ways back :) 2 .geds ones with diagoanol movement the other is 4 way (only faces 4 ways just actual movement)