PDA

View Full Version : Is it just me or...



Majora
10-16-2012, 07:20 PM
Is scripting prone to getting bogged down? I only have three global scripts but one in particular just tanks completely. I have a gameboy shield script (assigning it to R), the global script from ghost.zh, and a roc's feather script (Basically, make link jump if some conditions are met). The latter just shits itself spectacularly and is incredibly laggy and makes the game impossible to play in places that rely on the feather for things.

Siiiiiiigh. @_@

EDIT: Oh man I'm just all kinds of retarded. Note to self: more than one waitframe in a script is BAD. ;_; Let this post serve as a warning to those who come after me!

oh right here's my global script:



//Change these values to match your item setup
const int GBS_SMALL=93;
const int GBS_MAGIC=8;
const int GBS_MIRROR=37;
const int GBS_FAKESMALL=209;
const int GBS_FAKEMAGIC=208;
const int GBS_FAKEMIRROR=207;
const int SFX_GBSHIELD=89;
const int JUMP_POWER = 2; //Adjust this if you want.




//Gameboy shield: To use, set up three custom items that look like shields. Assign them levels 1-3
// as appropriate and make them equipment items. Make any of them consumable by enemies if you
// want. You can also give them an LTM that makes it look like Link is carrying a shield beside
// him. Next go to the real shields and change each of them to level 4 (and keep their equipment
// item status enabled). Set up the LTM's for them (if they are not done already) to look like
// Link is holding the shield out in front of him. Give players the fake shields during the game,
// not the real ones. Remove the small shield from the initial data, and if you want Link to start
// with one of the shields, just give him the fake version in the initial data as well. If you want
// strafing to work correctly, you have to enable Z3 diagonal movement (in Graphics->Sprites->Link).
// Make sure that the above global variables are correct (if you don't want a sound when Link uses
// the shield, leave it as 0), and then attach this script to global slot 2.
global script slot_2
{
void run()
{
//Initializations
bool inputl=false;
bool inputr=false;
bool shieldon=false;
int lastdir;
int gbsound;

while(true)
{
StartClock();
//Turn off inputs "L" and "R".
inputl=Link->InputL;
inputr=Link->InputR;
Link->InputL=false;
Link->InputR=false;
UpdateEWeapons();
UpdateClock();
CleanUpGhostFFCs();


Waitdraw();
AutoGhost();


Waitframe();
//Code for gameboy shield
lastdir=Link->Dir; //used for strafing
if(inputr && !shieldon) //Enable shield when L is pressed
{
shieldon=true;
gbsound=SFX_GBSHIELD;
if(Link->Item[GBS_FAKEMIRROR]) Link->Item[GBS_MIRROR]=true;
else if(Link->Item[GBS_FAKEMAGIC]) Link->Item[GBS_MAGIC]=true;
else if(Link->Item[GBS_FAKESMALL]) Link->Item[GBS_SMALL]=true;
else
{
gbsound=0;
shieldon=false;
}
if(gbsound>0) Game->PlaySound(SFX_GBSHIELD);
}
//else if(inputr && shieldon) //Strafe while L is held down
//{
// Waitdraw();
// Link->Dir=lastdir;
//}
else if(!inputr && shieldon) //Remove shield when L is released
{
Link->Item[GBS_MIRROR]=false;
Link->Item[GBS_MAGIC]=false;
Link->Item[GBS_SMALL]=false;
shieldon=false;
}
//end of gameboy shield

//Add any other code that needs to be in a global script here...
//--------------------------------------------------------------------------------------------------------------------------------------------------------------


if(Link->Item[I_ROCSFEATHER])


{

if(IsSideview() && (Link->PressEx1 && OnSidePlatform(Link->X, Link->Y) || Link->PressEx1 && OnSidePlatform(Link->X+8, Link->Y) || Link->PressEx1 && OnSidePlatform(Link->X+15, Link->Y)))
{
Link->Jump = JUMP_POWER;
Game->PlaySound(45);

}

else if (Link->PressEx1 && !IsSideview() && Link->Z == 0)
{
Link->Jump = JUMP_POWER;
Game->PlaySound(45);
}

}
//--------------------------------------------------------------------------------------------------------------------------------------------------------------





Waitframe();
}
}
}