Difference between revisions of "Test"
From Project X Wiki
Line 1: | Line 1: | ||
<source lang="eax"> | <source lang="eax"> | ||
− | // test | + | // test 3 |
require utils; | require utils; | ||
Revision as of 17:08, 20 January 2012
// test 3
require utils;
CAntiGlitch* ggAg;
void antiglitch_s::Init()
{
ggAg = new CAntiGlitch;
}
CAntiGlitch::CAntiGlitch()
{
lTime = 0;
cState = 0;
gTime = 0;
rTime = 0;
}
void CAntiGlitch::Frame()
{
if ( (lTime == Root->Timer) && (rTime == Root->RetreatTimer) )
{
gTime += 20;
if (gTime > 20000)
{
if (cState == 0)
{
//shake all objects first
ShowMessage("Antiglitch Stage One");
for (local i = 1; i < Env->Objs.Count; i++)
{
local obj = CGObject(Env->Objs.Objs[i]);
if (obj == NullObj) continue;
local shake = obj->IsMoving();
if (!shake) continue;
if (obj is CMissile)
{
missile = CMissile(obj);
missile->ExplodeAt(missile->PosX, missile->PosY);
missile->Free(true);
continue;
}
obj->SpX = GS->GetRandom() % 200 - 100;
obj->SpY = GS->GetRandom() % 200 - 100;
}
cState = 1;
gTime = 10000;
} else if (cState == 1)
{
ShowMessage("Antiglitch Stage Two");
//delete objects to hell
for (local i = 1; i < Env->Objs.Count; i++)
{
local obj = CGObject(Env->Objs.Objs[i]);
if (obj == NullObj) continue;
if (obj->ClType == OC_Worm) continue;
if (!obj->IsMoving()) continue;
obj->Free(true);
}
cState = 2;
gTime = 10000;
} else if (cState == 2)
{
ShowMessage("Antiglitch Stage Three");
//shake everything
for (local i = 1; i < Env->Objs.Count; i++)
{
local obj = CGObject(Env->Objs.Objs[i]);
if (obj == NullObj) continue;
obj->SpX = GS->GetRandom() % 200 - 100;
obj->SpY = GS->GetRandom() % 200 - 100;
if (obj is CMissile)
{
missile = CMissile(obj);
missile->Free(true);
continue;
}
}
cState = 3;
gTime = 10000;
} else if (cState == 3)
{
cState = 4;
ShowMessage("Antiglitch Stage Four");
Root->Message( Root, M_SKIPTURN, 0, NullObj);
}
}
} else {
gTime = 0;
cState = 0;
lTime = Root->Timer;
rTime = Root->RetreatTimer;
}
}
override void CWorm::FireFinal(CWeapon* Weap,CShootDesc* Desc)
{
super;
ggAg->gTime = 0;
ggAg->cState = 0;
}
override void CWorm::SetState(EObjState State)
{
if (State == WS_DEAD)
{
ggAg->gTime = 0;
ggAg->cState = 0;
}
super;
}
override void CTurnGame::Message(CObject* sender,EMType Type,int MSize,CMessageData* MData)
{
super;
if (Type == M_FRAME)
{
ggAg->Frame();
}
}