//////////////////////////////
/// Great Book of Cheating ///
/// v0.1.2 for ZC 2.55 ///
/// 26th March, 2019 ///
/// By: ZoriaRPG ///
//////////////////////////////
/*
D[0] : The turn off / run out of energy SFX
D[1] : The modulus factor for the movement speed frame timer.
D[2] : The modulus factor for the upkeep cost frame timer.
Sprites[4] : The sprite for the black hole weapon.
*/
item script GreatBookOfCheating
{
void run(int sfxoff, int speedmod, int upkeep_frames)
{
speedmod = ( speedmod > 0 ) ? speedmod : 2;
sfxoff = ( sfxoff > 0 ) ? sfxoff : 64;
Link->Invisible = true;
Link->CollDetection = false;
int frame; int dir; lweapon blackhole;
blackhole = Screen->CreateLWeapon(LW_SCRIPT);
blackhole->X = 1;
blackhole->Y = 1;
blackhole->DrawXOffset = -32768;
blackhole->DrawYOffset = -32768;
blackhole->CollDetection = false;
blackhole->Script = this->WeaponScript;
int pos;
for ( int q = 0; q < 8; ++q ) blackhole->InitD[q] = this->WeaponInitD[q];
//sprite is blac hold from Sprites[4];
while(1)
{
//If the player taes this item out of its slot, or it is removed from inventory
//end the effect.
if ( Hero->ItemA != this->ID && Hero->ItemB != this->ID ) end(blackhole);
if ( !Hero->Item[this->ID] ) end(blackhole);
++frame;
if ( frame%speedmod )
{
if ( Input->Hold[CB_UP] )
{
dir = DIR_UP;
if ( Input->Hold[CB_LEFT] ) dir+=4;
if ( Input->Hold[CB_RIGHT] ) dir+=5;
}
else if ( Input->Hold[CB_DOWN] )
{
dir = DIR_DOWN;
if ( Input->Hold[CB_LEFT] ) dir+=5;
if ( Input->Hold[CB_RIGHT] ) dir+=6;
}
else if ( Input->Hold[CB_RIGHT] )
{
dir = DIR_RIGHT;
}
else if ( Input->Hold[CB_LEFT] )
{
dir = DIR_LEFT;
}
else dir = -1;
switch(dir)
{
case DIR_UP: --Hero->Y; break;
case DIR_DOWN: ++Hero->Y; break;
case DIR_LEFT: --Hero->X; break;
case DIR_RIGHT: ++Hero->X; break;
case DIR_LEFTUP: --Hero->X; --Hero->Y; break;
case DIR_RIGHTUP: ++Hero->X; --Hero->Y; break;
case DIR_LEFTDOWN: --Hero->X; ++Hero->Y; break;
case DIR_RIGHTDOWN: ++Hero->X; ++Hero->Y; break;
default break;
}
}
if ( upkeep_frames > 0 ) //if we have an upeep timer
{
if ( !(frame%upkeep_frames) ) //cost in upeep
{
if ( Game->Counter[this->CostCounter] < this->Cost )
{
end(blackhole,sfxoff);
}
else Game->DCounter[this->CostCounter] -= this->Cost;
}
}
if ( Hero->ItemA == this->ID )
{
if ( Hero->PressA ) end(blackhole,sfxoff);
}
if ( Hero->ItemB == this->ID )
{
if ( Hero->PressB ) end(blackhole,sfxoff);
}
if ( CanWalk(Hero->X, Hero->Y, Hero->Dir, 0) ) pos = ComboAt(CenterLinkX(), CenterLinkY());
blackhole->DrawXOffset = Link->X - 1;
blackhole->DrawYOffset = Link->Y - 1;
Waitframe();
}
if ( CanWalk(Hero->X, Hero->Y, Hero->Dir, 0) )
{
//Hero is stuck in solid
Hero->X = ComboX(pos);
Hero->Y = ComboY(pos);
blackhole->DrawXOffset = Link->X - 1;
blackhole->DrawYOffset = Link->Y - 1;
//or use Adjacentcombo to find the closest nonsolid and push him back out?
}
}
void end(lweapon hole, int sfxoff)
{
Link->Invisible = false;
Link->CollDetection = true;
Audio->PlaySound(sfxoff);
Remove(hole);
Quit();
}
}
Comments