int life=3; int enemylife=3; int position; int field; int playerfield; int currentlevel=1; int n; bool attackable=false; |
function room_AfterFadeIn()
{
field=Random(1); //decide which field will be attacked.
position=Random(1); //decide from which position/direction the enemy attacks
if(position==0)
? {gattack.x=...; //place the attackgui in the corresponding field.
? cEnemy.LockView(...);//Lock enemy into the right frame to attack from that position
? cEnemy.x=...;
? cEnemy.y=...;}//place the Enemy to attack from the right direction
else
? {gattack.x=...;
? cEnemy.LockView(...);
? cEnemy.x=...;
? cEnemy.y=...;}
Level[1]=Timer.Start(120);//Set Timer "Level" array 1 (stands for Level 1) to three seconds before the enemy attacks.
}
// main global script file
Timer*Level[10];//Timer called "Level" to define time before enemy attacks for each level, created with Crimson Wizard's module. Level timer is exported to Global Header script
Timer*Hit;// Timer used define how long enemy stays in hitting/attack view
Timer*Waittimer[10];//Timer used when I want non-blocking Waiting time
bool avoidwrongtrigger[100];//this bool will help me differentiate different functions that are set off when the enemy finds himself on specific coordinates (see below)
function? repeatedly_execute_always()
{
if(Timer.IsExpired(Level[1]))
? {gattack.x=-1000;//put gui out of screen
? if(field==0)
? ? {cEnemy.move(x0,y0,eNoBlock...);//move enemy to attackpoint of field 0. The main character still has to be able to move around, so I need to do it non-blocking.
? ? avoidwrongtrigger[0]=true;}
? else
? ? {cEnemy.move(x1,y1,eNoBlock...);//move enemy to attackpoint of field 1.
? ? avoidwrongtrigger[1]=true;}
? }
if((cEnemy.x==x0&&cEnemy.y==y0&&avoidwrongtrigger[0]==true)||(cEnemy.x==x1&&cEnemy.y==y1&&avoidwrongtrigger[1]==true))//if the enemy crosses x[sub]0[/sub],y[sub]0[/sub] or x[sub]1[/sub],y[sub]1[/sub] at any other point in the game accidentally I don't want this function to be triggered, that's why I use the avoidoverlap bool
? {
? for(n=0;n!=2;n? )
? {avoidwrongtrigger[n]=false;} //set all avoid bool arrays to false (important for later levels with more fields)
? if(field==playerfield)life=life-1;//if the character finds himself in the same field as the the attacked field he looses a life
? attackable=true;
? cEnemy.LockView(...);//Lock enemy into hitting/attacking view
? Bite=Timer.Start(40);//Start timer to unlock hit/attack view after 1 second
? cEnemy.Move(x2,y2,eNoBlock);//move enemy out of screen again
? }
//defining in which field the player finds himself in:
//level on is very easy. The screen resolution is 1600x900,so:
if(currentlevel==1)//the fields change for the upcoming levels
?? {if(cm.x<801) playerfield=0;
?? else playerfield=1;}
//how to proceed after the attack
//If both still have lifes:
if(life!=0&&enemylife!=0) Waittimer[1]=Timer.Start(40);
if(Timer.IsExpired(Waittimer[1]))
{//same script as above
field=Random(1); //decide which field will be attacked.
position=Random(1); //decide from which position/direction the enemy attacks
if(position==0)
? {gattack.x=...; //place the attackgui in the corresponding field.
? cEnemy.LockView(...);//Lock enemy into the right frame to attack from that position
? cEnemy.x=...;
? cEnemy.y=...;}
else
? {gattack.x=...;
? cEnemy.LockView(...);
? cEnemy.x=...;
? cEnemy.y=...;}
attackable=false;//make it so that you cannot attack the enemy again, until he reaches the attack point.
Level[1]=Timer.Start(120);//Set Timer "Level" array 1 (stands for Level 1) to three seconds before the enemy attacks.
}
//if player looses
if(life==0)gLoose.Visible=true;//Shows a full screen gui that pauses the game when visible. You have a funny YOU LOST image and two buttons: Quit or Retry. When you quit you change to the menu room. And when you click retry:
function Retrybutton_OnClick(GUIControl *control, MouseButton button)
{
life=3;
enemylife=3;
Waittimer=Timer.Start(1);
}
//if enemy looses
gWin.Visible=true; //Full screen gui that is as well a button. Any click on the gui will start Level two. (resetting lifes and everyting, and now starting Level[currentlevel 1]-timer)
function cEnemy_Mode8()
{
if(attackable==true)
{
cplayer.Lockview(attackviewID);
cplayer.SetWalkspeed(50,50);
cplayer.Walk(cEnemy.x,cEnemy.y,eBlock);
aEnemyscream.Play(...);
enemylife=enemylife-1;
cplayer.Lockview(normalflyviewID);
cplayer.Walk(cEnemy.x,cEnemy.y,eBlock);
cplayer.Animte(cplayer.Loop...,eRepeat);//keep flapping the wings while in the air
}
else{}
function repeatedly_execute_always()
{
if(life==0)
? {Button1.Visible=false;}
else
? {Button1.Visible=true;
? if(life==1)
? ? {Button2.Visible=false;}
? else
? ? {Button2.Visible=true;
? ? if(life==2)
? ? ? ? {Button3.Visible=false;}
? ? else
? ? ? ? {Button3.Visible=true;}
? ? }
? }
}