PDA

View Full Version : Utility Script #4 Auto Mover



HeroOfFire
06-10-2007, 07:23 PM
An interesting utility script I made. Last tested in build 364.
Update: Last Tested in build 478.

Script #4 Auto Mover
Constantly moves Link either in the direction he is facing or the opposite direction.


//Various Scripts, by HeroOfFire

//NOTE: When I say activation of a script, I mean setting its CSet to 0.
//This is how I tell a script its been activated, triggered, etc.

import "std.zh"

//FFC Script AutoMover
//Simple script to move Link around the screen
//Stops running while activated
//Since this script is sometimes dependant on Link's facing, charging for a spin attack can abuse this script.
//However, the spin attack can also be the only way to get through a room.
//D0 = FFC Number (starts at 1)
//D1 = Link's Movement Type. 0 = None. 1 = Forward. 2 = Backwards. 3 = Always Up. 4 = Always Down.
//5 = Always Left. 6 = Always Right.
//D2 = Movement Delay. THe smaller the value, the more often Link will be moved.
//If set to 1, Link cannot move against the direction he is getting moved
//Also, Link cannot change direction as easily when set to 1. Proceed with caution when set to 1.
//Setting to 1 may be good for a room that requires the charging of the spin attack to manuever.
ffc script AutoMover {

void run(float projNum, int moveType, int moveDelay) {
int moveTime;
ffc this1 = Screen->LoadFFC(projNum);
if (moveDelay < 1)
{
moveDelay = 1;
}
while (true)
{
if (this1->CSet != 0)
{
for (moveTime = moveDelay; moveTime > 0; moveTime--)
{
if (moveTime == moveDelay)
{
if ((Link->Dir == DIR_UP && moveType == 1) || (Link->Dir == DIR_DOWN && moveType == 2) || moveType == 3)
{
if (is_walkable(Link->X, Link->Y + 7) && is_walkable(Link->X + 15, Link->Y + 7))
{
Link->Y--;
}
}
else if ((Link->Dir == DIR_DOWN && moveType == 1) || (Link->Dir == DIR_UP && moveType == 2) || moveType == 4)
{
if (is_walkable(Link->X, Link->Y + 17) && is_walkable(Link->X + 15, Link->Y + 17))
{
Link->Y++;
}
}
if ((Link->Dir == DIR_LEFT && moveType == 1) || (Link->Dir == DIR_RIGHT && moveType == 2) || moveType == 5)
{
if (is_walkable(Link->X - 1, Link->Y + 8) && is_walkable(Link->X - 1, Link->Y + 15))
{
Link->X--;
}
}
else if ((Link->Dir == DIR_RIGHT && moveType == 1) || (Link->Dir == DIR_LEFT && moveType == 2) || moveType == 6)
{
if (is_walkable(Link->X + 17, Link->Y + 8) && is_walkable(Link->X + 17, Link->Y + 15))
{
Link->X++;
}
}
}
Waitframe();
}
}
else
{
Waitframe();
}
}
}
bool is_walkable(int checkX, int checkY)
{
int targetLoc = 0;
if(checkX < 0 || checkX > 240 || checkY < 0 || checkY > 160)
{
return false;
}
targetLoc = ((checkX - (checkX &#37; 16)) / 16) + (checkY - (checkY % 16));
return Screen->ComboS[targetLoc] == 0;
}
}

Quick Overview:
This script has just 3 parameters.
The first is the FFC number.
The second is the direction Link will move.
1: The direction Link is facing.
2: The opposite direction Link is facing.
AnyOther: This script will do nothing.
The third is the delay between each move. The script will floor the value at 1, but a large delay is allowed (although too large may render the script useless if it moves Link once every 5 seconds or so).

Basic Uses:
None. Really, it just makes it harder to move through a room.

Cool Things:
At delay value 1, Link cannot move against the push.
The script may look at Link's facing. You can trick it by charging a spin attack.
The FFC only moves Link if not activated. While activated (CSet = 0), it simply remains 'dormant'. This means you could turn this effect on and off with secret combos.
Collision actually works!

Interesting Things: If the script is pushing you backwards, moving floors may become impassible when moving against them.
At lower delay values, Link will not always change direction correctly. This creates challenge and potentially a problem depending on the room setup.

Update Completed: Script can now constantly move Link in the same direction (instead of just based on facing). Could prove useful.

Definite Updates:
I will eventually make a script that applies this effect only to select combos on the screen. This could also be adjusted to make true one-way moving floors.