I had a good script for a gun (just your average pistol), but it was along with a whole bunch of other script components for a quest called "The Dead Forest". Robin gave me the script. It's somewhere around here. I don't know what in the script is for the gun, or how to use global scripts, or much about scripting itself. Basically this is a far-fetched way to ask:
Can anyone make a laser rifle script for me? I have sound effects and everything! And if you want something to base how the laser acts... Uh, lets just say I want it to be like the Moonraker Laser from Goldeneye on the old Nintendo 64
- Current Location:
- PureZC
- » PureZC Forums
- » Zelda Classic
- » Scripting Discussion
- » Script Requests
A gun?
Started by
Rex-Leviathan
, May 15 2011 01:18 PM
- Please log in to reply
4 replies to this topic
#1 Rex-Leviathan
Rex-Leviathan
- Members
Lost, Loneliness, Liberation!
- Location:Assorted Locations
#2 Isdrakthül
Isdrakthül
- Members
Apprentice
Posted 15 May 2011 - 01:43 PM
If you post the text of the script here, I could try to remove the others.
#3 Rex-Leviathan
Rex-Leviathan
- Members
Lost, Loneliness, Liberation!
- Location:Assorted Locations
Posted 15 May 2011 - 03:39 PM
Okay, but it's pretty long, so I'll put it in this:
Script
import "std.zh"
//Input Constants
const int PipeTile = 11040;//Tile for Pipe to use
const int PipeAFrames = 8; //Number of animation frames of Pipe
const int PipeCSet = 7; //CSet for Pipe to use
const int PipeDamage = 1; //Damage for Pipe to deal
const int PipeSFX = 68; //Sound effect when used
const int GrenadeTile = 10860;
const int GrenadeCSet = 7;
const int GrenadeDamage = 8;
const int GrenadeSFX = 67;
const int ThrowDistance = 20;
const int PistolTile = 10862;
const int PistolCSet = 7;
const int PistolDamage = 2;
const int PistolSFX = 65;
const int ShotgunTile = 10866;
const int ShotgunCSet = 7;
const int ShotgunDamage = 4;
const int ShotgunRange = 54;
const int ShotgunSFX1 = 63;
const int ShotgunSFX2 = 64;
const int MachinegunTile = 10870;
const int MachinegunCSet = 7;
const int MachinegunDamage = 2;
const int MachinegunRate = 6;
const int MachinegunSFX = 66;
const int BulletTile = 10861;
const int BulletCSet = 11;
const int HealthTile = 10904;
const int HealthMeterTile = 10905;
const int PauseTile = 11000;
const int GameOverTile = 11080;
const int ScoreBoardTile = 11091;
const int TryAgainTile = 11140;
const int PressStartTile = 11120;
const int ZeroTile = 10909;
const int GunSpawnSFX = 71;
const int DeathTile = 10852;
const int SelectSFX = 72;
const int TextUpSFX = 73;
const int AutoWarpCombo = 196;
//Global Utility Variables
int GunLevel;
int Score;
int ScoreMax;
int HiScore;
int Time;
int EndTime;
bool Pause;
bool End;
bool reStart;
//Stops Link from being able to do anything
void NoAction(){
Link->InputR = false;
Link->InputL = false;
Link->InputA = false;
Link->InputB = false;
Link->InputLeft = false;
Link->InputRight = false;
Link->InputUp = false;
Link->InputDown = false;
Link->InputStart = false;
}
//Weapons, Subscreen functions, Pause screen, Re-Start Screen
global script The_Dead_Forest{
void run(){
//General Utility
bool lastA;
bool lastL;
bool lastB;
bool lastStart;
int lastDir;
int AttackDelay;
int AttackDelayMax;
int endcount;
int i;
bool f;
int x; int y;
lweapon pause[50];
int step[50];
//Pipe Utility
int PipeAttack;
lweapon pipe;
int PipeLayer;
//Gun Utility
Link->Item[123] = true;
int GunAttack;
lweapon pistol;
lweapon shotgun[3];
lweapon machine;
int gund;
int gunx;
int guny;
int MachineDelay;
int GunGFXDelay;
//Grenade Utility
int GrenadeAttack;
int grenaded;
int grenadex;
int grenadey;
lweapon grenade;
lweapon explosion;
while(true){
//Game Over
while(End){
//Hide Link
if(endcount == 0){
x = Link->X;
y = Link->Y;
Link->X = 240;
Link->Y = 48;
}
//Draw Link death graphic
if(endcount < 12) Screen->DrawTile(2,x,y,DeathTile+Floor(endcount/3),1,1,8,1,0,0,0,0,true,128);
endcount++;
//Drawing functions for game over screen
Screen->DrawTile(6,48,32,GameOverTile,11,2,0,1,0,0,0,0,true,128);
Screen->DrawTile(6,48,64,ScoreBoardTile,4,3,0,1,0,0,0,0,true,128);
RunTime(246,-8,1);
RunTime(164,94,1);
RunScore(108,-46,108,-35);
RunScore(140,67,140,80);
RunHealth();
//'Press Start to Try again' drawing functions
if(endcount >= 160){
if(endcount == 160) Game->PlaySound(TextUpSFX);
if(endcount%40 == 0) f = !f;
if(f) Screen->DrawTile(6,32,112,TryAgainTile,13,2,0,1,0,0,0,0,true,128);
if(endcount == 320) endcount = 201;
//Reset the game's variables after pressing start
if(Link->InputStart){
Link->X = 120;
Link->Y = 80;
Score = 0;
ScoreMax = 0;
GunLevel = 0;
Link->Item[123] = true;
Link->Item[124] = false;
Link->Item[125] = false;
Link->HP = Link->MaxHP;
Game->Counter[1] = 100;
Game->Counter[2] = 3;
End = false;
endcount = 0;
lastStart = true;
reStart = true;
Game->PlaySound(SelectSFX);
}
}
NoAction();
Waitframe();
}
//Lead Pipe
//Set up the pipe to start
if(Link->InputA && !lastA && PipeAttack == 0 && AttackDelay == 0){
Game->PlaySound(PipeSFX+Rand(3));
Link->Action = LA_ATTACKING;
PipeAttack++;
AttackDelay++;
AttackDelayMax = 20;
}
//Attack functions
if(PipeAttack>0){
//Make Link invincible
if(PipeAttack > 2) Link->Action = LA_FROZEN;
PipeAttack++;
//Create the actual pipe weapon
if(!pipe->isValid()){
pipe = Screen->CreateLWeapon(31);
pipe->Damage = PipeDamage;
pipe->OriginalTile = 84;
pipe->Tile = 84;
pipe->NumFrames = 1;
pipe->Dir = Link->Dir;
}
//Move the pipe in an arc
if(Link->Dir<1){
pipe->X = Link->X-16+2*PipeAttack;
pipe->Y = Link->Y-14+0.06*Pow((2*PipeAttack-16),2);
PipeLayer = 2;
}else if(Link->Dir<2){
pipe->X = Link->X-16+2*PipeAttack;
pipe->Y = Link->Y+16-0.06*Pow((2*PipeAttack-16),2);
PipeLayer = 3;
}else if(Link->Dir<3){
pipe->X = Link->X-14+0.06*Pow((2*PipeAttack-16),2);
pipe->Y = Link->Y-18+2*PipeAttack;
PipeLayer = 3;
}else{
pipe->X = Link->X+14-0.06*Pow((2*PipeAttack-16),2);
pipe->Y = Link->Y-18+2*PipeAttack;
PipeLayer = 3;
}
//Draw the pipe's graphic
Screen->DrawTile(PipeLayer,pipe->X,pipe->Y,PipeTile + PipeAFrames*Link->Dir + (PipeAttack-2)/2,1,1,PipeCSet,1,0,0,0,0,true,128);
//End attack
if(PipeAttack >= 16){
pipe->DeadState = 0;
PipeAttack = 0;
Link->Action = 0;
}
}
//Grenades
//Set up the grenades to start
if(Link->InputL && !lastL && Game->Counter[2] > 0 && GrenadeAttack == 0 && AttackDelay == 0){
//Create the grenade, put it next to Link
Game->Counter[2]--;
grenaded = Link->Dir;
grenade = Screen->CreateLWeapon(31);
grenade->CSet = PipeCSet;
grenade->NumFrames = 1;
grenade->Dir = grenaded;
grenadex = 0; grenadey = 0;
if(grenaded>1){grenadex = (((grenaded-2)*2)-1)*8; grenadey = -4;}
if(grenaded<2) grenadey = ((grenaded*2)-1)*8;
grenade->X = Link->X+grenadex;
grenade->Y = Link->Y+grenadey;
grenade->OriginalTile = GrenadeTile;
grenade->Step = 2;
Game->PlaySound(GrenadeSFX);
Link->Action = LA_ATTACKING;
GrenadeAttack++;
AttackDelay++;
AttackDelayMax = 20;
}
if(GrenadeAttack > 0){
//Move the grenade in an arc
grenade->Z = (-0.05*GrenadeAttack)*(GrenadeAttack-20);
//Remove grenade once it's at the end of the arc
if(GrenadeAttack == ThrowDistance) grenade->DeadState = 0;
GrenadeAttack++;
//Create explosion weapon once grenade reaches end of arc
if(grenade->isValid()){
grenadex = grenade->X;
grenadey = grenade->Y;
}else{
explosion = Screen->CreateLWeapon(LW_BOMB);
explosion->Damage = GrenadeDamage;
explosion->X = grenadex;
explosion->Y = grenadey;
GrenadeAttack = 0;
}
}
//Guns
if(Link->InputB){
//Pistol set up
if(GunLevel == 0 && !lastB && Game->Counter[1] > 0 && AttackDelay == 0){
Game->Counter[1]--;
Link->Action = LA_ATTACKING;
GunGFXDelay++;
GunAttack++;
AttackDelay++;
AttackDelayMax = 20;
}
//Shotgun set up
if(GunLevel == 1 && !lastB && Game->Counter[1] > 2 && AttackDelay == 0 && GunAttack == 0){
Game->Counter[1] -= 3;
Game->PlaySound(ShotgunSFX1);
Link->Action = LA_ATTACKING;
GunGFXDelay++;
GunAttack++;
AttackDelay++;
AttackDelayMax = 35;
}
//Machine gun
if(GunLevel == 2 && Game->Counter[1] > 0 && AttackDelay == 0){
//Create and fire bullet functions
if(MachineDelay == 0){
Game->Counter[1]--;
gund = Link->Dir;
machine = Screen->CreateLWeapon(31);
machine->CSet = BulletCSet;
machine->NumFrames = 1;
machine->Dir = gund;
gunx = 0; guny = 0;
if(gund>1){gunx = (((gund-2)*2)-1)*16; guny = -3;}
if(gund<2){
guny = ((gund*2)-1)*4;
gunx = ((gund*2)-1)*-8;
}
machine->X = Link->X+gunx;
machine->Y = Link->Y+guny;
machine->OriginalTile = BulletTile;
machine->Step = 2;
machine->Damage = MachinegunDamage;
Game->PlaySound(MachinegunSFX);
}
//Draw the machinegun
if(Link->Dir<1) Screen->DrawTile(3,Link->X,Link->Y-5,MachinegunTile+Link->Dir,1,1,MachinegunCSet,1,0,0,0,0,true,128);
else if(Link->Dir<2) Screen->DrawTile(3,Link->X,Link->Y,MachinegunTile+Link->Dir,1,1,MachinegunCSet,1,0,0,0,0,true,128);
else if(Link->Dir<3) Screen->DrawTile(3,Link->X-13,Link->Y-1,MachinegunTile+Link->Dir,1,1,MachinegunCSet,1,0,0,0,0,true,128);
else Screen->DrawTile(3,Link->X+13,Link->Y-1,MachinegunTile+Link->Dir,1,1,MachinegunCSet,1,0,0,0,0,true,128);
//Allow the machine gun to fire only every 'MachinegunRate' frames
MachineDelay++;
MachineDelay %= MachinegunRate;
}
}else MachineDelay = 0;
if(GunAttack > 0){
GunAttack++;
//Pistol
if(GunLevel == 0){
//Make Link invincible while firing
if(GunAttack > 2) Link->Action = LA_FROZEN;
//Fire the bullet
if(GunAttack == 5){
gund = Link->Dir;
pistol = Screen->CreateLWeapon(31);
pistol->CSet = BulletCSet;
pistol->NumFrames = 1;
pistol->Dir = gund;
gunx = 0; guny = 0;
if(gund>1){gunx = (((gund-2)*2)-1)*8; guny = -3;}
if(gund<2){
guny = ((gund*2)-1)*4;
gunx = ((gund*2)-1)*-8;
}
pistol->X = Link->X+gunx;
pistol->Y = Link->Y+guny;
pistol->OriginalTile = BulletTile;
pistol->Step = 2;
pistol->Damage = PistolDamage;
Game->PlaySound(PistolSFX);
}
//End the attack
if(GunAttack == 15){
GunAttack = 0;
Link->Action = 0;
}
}
//Shotgun
if(GunLevel == 1){
if(GunAttack > 2) Link->Action = LA_FROZEN;
//Fire the bullet
if(GunAttack == 27){
gund = Link->Dir;
gunx = 0; guny = 0;
if(gund>1){gunx = (((gund-2)*2)-1)*16; guny = -3;}
if(gund<2){
guny = ((gund*2)-1)*4;
gunx = ((gund*2)-1)*-8;
}
for(i=0;i<3;i++){
shotgun[i] = Screen->CreateLWeapon(31);
shotgun[i]->CSet = BulletCSet;
shotgun[i]->NumFrames = 1;
shotgun[i]->X = Link->X+gunx;
shotgun[i]->Y = Link->Y+guny;
shotgun[i]->OriginalTile = BulletTile;
shotgun[i]->Step = 3;
shotgun[i]->Damage = ShotgunDamage;
if(i<2) shotgun[i]->Angular = true;
else shotgun[i]->Dir = gund;
}
//Spread the three bullets apart
if(Link->Dir<1){
shotgun[0]->Angle = 4.9;
shotgun[1]->Angle = 10.8;
}else if(Link->Dir<2){
shotgun[0]->Angle = 1.8;
shotgun[1]->Angle = 7.6;
}else if(Link->Dir<3){
shotgun[0]->Angle = 3.4;
shotgun[1]->Angle = 9.2;
}else{
shotgun[0]->Angle = 0.3;
shotgun[1]->Angle = 5.9;
}
Game->PlaySound(ShotgunSFX2);
}
//Stop the bullets once they reach the end of their range
if(GunAttack >= ShotgunRange){
for(i=0;i<3;i++) shotgun[i]->DeadState = 0;
GunAttack = 0;
Link->Action = 0;
}
}
}
//Draw graphics for shotgun and pistol
if(GunGFXDelay > 0){
GunGFXDelay++;
//Pistol
if(GunLevel == 0){
if(Link->Dir<1) Screen->DrawTile(3,Link->X,Link->Y-5,PistolTile+Link->Dir,1,1,PistolCSet,1,0,0,0,0,true,128);
else if(Link->Dir<2) Screen->DrawTile(3,Link->X,Link->Y,PistolTile+Link->Dir,1,1,PistolCSet,1,0,0,0,0,true,128);
else if(Link->Dir<3) Screen->DrawTile(3,Link->X-15,Link->Y,PistolTile+Link->Dir,1,1,PistolCSet,1,0,0,0,0,true,128);
else Screen->DrawTile(3,Link->X+15,Link->Y,PistolTile+Link->Dir,1,1,PistolCSet,1,0,0,0,0,true,128);
if(GunGFXDelay == 15) GunGFXDelay = 0;
}
//Shotgun
else if(GunLevel == 1){
if(Link->Dir<1) Screen->DrawTile(3,Link->X,Link->Y-5,ShotgunTile+Link->Dir,1,1,ShotgunCSet,1,0,0,0,0,true,128);
else if(Link->Dir<2) Screen->DrawTile(3,Link->X,Link->Y,ShotgunTile+Link->Dir,1,1,ShotgunCSet,1,0,0,0,0,true,128);
else if(Link->Dir<3) Screen->DrawTile(3,Link->X-13,Link->Y-1,ShotgunTile+Link->Dir,1,1,ShotgunCSet,1,0,0,0,0,true,128);
else Screen->DrawTile(3,Link->X+13,Link->Y-1,ShotgunTile+Link->Dir,1,1,ShotgunCSet,1,0,0,0,0,true,128);
if(GunGFXDelay == 50) GunGFXDelay = 0;
}
}
//Timer to stop repeated attacks
if(AttackDelay > 0){
AttackDelay++;
if(AttackDelay >= AttackDelayMax) AttackDelay = 0;
}
//Health-bar, Time and Scoring functions
RunHealth();
RunScore(108,-46,108,-35);
RunTime(246,-8,0);
//Pause Screen functions
//Set up pause
if(Link->InputStart && !lastStart){
Pause = true;
//Stop bullets when paused
for(i=0;i<Screen->NumLWeapons();i++){
pause[i] = Screen->LoadLWeapon(i+1);
step[i] = pause[i]->Step;
pause[i]->Step = 0;
}
lastStart = Link->InputStart;
Link->InputStart = false;
}
while(Pause){
//Stop Link from moving
Link->Action = LA_FROZEN;
Waitframe();
//Check to see if pause should be turned off
if(Link->InputStart && !lastStart){
Pause = false;
//Start bullets again
for(i=0;i<Screen->NumLWeapons();i++) pause[i]->Step = step[i];
}
//Stop the subscreen from opening
if(Pause){
lastStart = Link->InputStart;
Link->InputStart = false;
}
//Draw on the pause tile and subscreen functions
Screen->DrawTile(6,64,64,PauseTile,8,2,0,1,0,0,0,0,true,128);
RunScore(108,-46,108,-35);
RunHealth();
RunTime(246,-8,0);
Link->Action = 0;
}
//Utility
//Stop repeated attacks from pipe, grenade, shotgun, pistol if button held down
lastB = Link->InputB;
lastA = Link->InputA;
lastL = Link->InputL;
lastDir = Link->Dir;
//Don't open up pause screen when pressing start after resetting game
if(reStart){
lastStart = true;
reStart = false;
}else lastStart = Link->InputStart;
//Don't allow Link to drop bombs or open up the subscreen
Link->InputB = false;
Link->InputStart = false;
Waitdraw();
//Strafe
if(Link->InputR) Link->Dir = lastDir;
Waitframe();
}
}
//Scoring
void RunScore(int x1, int y1, int x2, int y2){
int HiScoreMax;
int i;
if(Score >= 99999){
Score = 99999;
ScoreMax = 9;
HiScoreMax = 9;
}
//High Score functions
if(Score > HiScore) HiScore = Score;
for(i=0;i<5;i++){
//Draw on the score and high score
Screen->DrawTile(6,x1-i*8,y1,ZeroTile+(Floor(Score/Pow(10,i))%10),1,1,0,1,0,0,0,0,true,128);
Screen->DrawTile(6,x2-i*8,y2,ZeroTile+(Floor(HiScore/Pow(10,i))%10),1,1,0,1,0,0,0,0,true,128);
if(i<3){
//Add the extra 3 zeros at the end
Screen->DrawTile(6,x1+8+i*8,y1,ZeroTile+ScoreMax,1,1,0,1,0,0,0,0,true,128);
Screen->DrawTile(6,x2+8+i*8,y2,ZeroTile+HiScoreMax,1,1,0,1,0,0,0,0,true,128);
}
}
}
//Health-Bar
void RunHealth(){
int HP;
int i;
//Work out a value for HP
HP = Ceiling((Link->HP-64)/8);
//Reset the game if Link 'dies'
if(HP <= 0) End = true;
//Draw on the health bar
for(i=0;i<HP;i++) Screen->DrawTile(6,76+i*4,-19,HealthTile,1,1,8,1,0,0,0,0,true,128);
//Draw on the frame on top
Screen->DrawTile(6,76,-19,HealthMeterTile,4,1,8,1,0,0,0,0,true,128);
}
//Timer
void RunTime(int x, int y, int check){
int i;
int spacer;
int t;
//Check whether to draw the time for the game, or the time once the game has finished
if(check==0) t = Time;
else t = EndTime;
for(i=0;i<6;i++){
if(i<2){
spacer = 0;
//Draw on the colons
Screen->DrawTile(6,x-16-i*24,y,ZeroTile+10,1,1,0,1,0,0,0,0,true,128);
}else if(i<4) spacer = 8;
else spacer = 16;
//Draw the time
Screen->DrawTile(6,x-spacer-i*8,y,ZeroTile+(Floor(t/Pow(10,i))%10),1,1,0,1,0,0,0,0,true,128);
}
}
}
//Change which gun Link has
item script Gun_Level{
void run(int l){
GunLevel = l;
//Remove other guns when he gains a new one
if(l<1){
Link->Item[124] = false;
Link->Item[125] = false;
}else if(l<2){
Link->Item[123] = false;
Link->Item[125] = false;
}else{
Link->Item[123] = false;
Link->Item[124] = false;
}
}
}
//Spawn the zombies
ffc script Zombie_Spawner{
void run(){
//Enemy-spawn point locations
int location[6];
location[0] = ComboAt(80,16);
location[1] = ComboAt(208,16);
location[2] = ComboAt(16,48);
location[3] = ComboAt(224,122);
location[4] = ComboAt(48,144);
location[5] = ComboAt(144,144);
//Declare the enemies
npc e[20];
//Store their locations for when the game is paused
int x[20]; int y[20];
int dir[20];
int hp[20];
int step[20];
int rate[20];
bool Stop[20];
bool Go[20];
//Make sure their tiles are only moved along once when they're damaged
bool hpcheck[20];
int i;
//Increasing number of enemy functions
int RandomLevel;
int RandomLocation;
int Level;
int NextLevel;
int LevelFactor = 2;
int MaxNPCs;
while(true){
//Reset variables when game restarts
while(End){
Level = 0;
NextLevel = 0;
MaxNPCs = 0;
LevelFactor = 2;
Waitframe();
}
//Increase current number of zombies level
Level++;
if(Level > 3) LevelFactor = 3;
else if(Level > 10) LevelFactor = 2;
//Number of zombies to be killed to reach the next level
NextLevel += Pow(Level,2)*LevelFactor;
//Random factor
RandomLevel = Rand(Level*4);
//Work out how many zombies to have based on current level
if(Level < 2) MaxNPCs = 1;
else if(Level < 7) MaxNPCs = (Level-1)*2;
else if(Level < 16) MaxNPCs = Level+4;
else MaxNPCs = 20;
//Add zombies
while(Score < NextLevel+RandomLevel){
for(i=0;i<MaxNPCs;i++){
//Zombie Spawning
if(!e[i]->isValid()){
e[i] = Screen->CreateNPC(177+Rand(2));
//Increase to 16x32
e[i]->Extend = 3;
e[i]->TileHeight = 2;
e[i]->HitYOffset = 8;
//Place at random location
RandomLocation = Rand(6);
e[i]->X = (location[RandomLocation]%16)*16;
e[i]->Y = (Floor(location[RandomLocation]/16))*16;
hpcheck[i] = false;
}
//Remove head when HP less than half
if(e[i]->HP <= 4 && !hpcheck[i]){
e[i]->Tile = e[i]->Tile+40;
hpcheck[i] = true;
}
//Stop movement if game is paused
if(Pause){
if(Stop[i]){
e[i]->Tile = e[i]->Tile-160;
hp[i] = e[i]->HP;
e[i]->HP = 30;
step[i] = e[i]->Step;
rate[i] = e[i]->Rate;
e[i]->Step = 0;
e[i]->Rate = 0;
Stop[i] = false;
}
Go[i] = true;
Waitdraw();
e[i]->X = x[i];
e[i]->Y = y[i];
e[i]->Dir = dir[i];
}else{
if(Go[i]){
e[i]->Tile = e[i]->Tile+160;
e[i]->HP = hp[i];
e[i]->Step = step[i];
e[i]->Rate = rate[i];
Go[i] = false;
}
Stop[i] = true;
x[i] = e[i]->X;
y[i] = e[i]->Y;
dir[i] = e[i]->Dir;
}
}
Waitframe();
//Increase score once zombies die
for(i=0;i<MaxNPCs;i++){
if(!e[i]->isValid()) Score++;
if(End) e[i]->HP = 0;
}
//Break loop if game ends
if(End) break;
}
}
}
}
//Spawn the guns
ffc script Gun_Spawner{
void run(){
item gun;
int GunCount = 8+Rand(4);
int GunTimer;
int x; int y;
while(true){
//Idle whilst not enough zombies have been killed. Remove guns if they remain on-screen for too long
while(GunCount > Score){
if(gun->isValid() && !Pause) GunTimer++;
if((GunTimer >= 600 || End) && gun->isValid()){
gun->X = -16;
gun->Y = -16;
}
//Break loop if game ends
if(End) break;
Waitframe();
}
//Stop spawning guns whilst game ends
while(End){
//Remove any enemy drops whilst game end screen is up
Screen->ClearSprites(1);
Screen->ClearSprites(3);
GunCount = 8+Rand(4);
Waitframe();
}
if(Score > 0){
//Spawn guns
GunTimer = 0;
//Create the gun
gun = Screen->CreateItem(123+Rand(3));
//Place it at a random location...
do{
x = 48+Rand(144);
y = 48+Rand(64);
//Which is not too close to Link
}while(Abs(Link->X-x) < 32 && Abs(Link->Y-y) < 32)
gun->X = x;
gun->Y = y;
Game->PlaySound(GunSpawnSFX);
//Number of enemies to be killed before next gun is spawned
GunCount += 20+Rand(10);
}
}
}
}
//Work out how long the game has been running for
ffc script Game_Timer{
void run(){
//Store the variables
int frame;
int second;
int minute;
int hour;
while(true){
//Increase the variables
while(!Pause && !End){
frame++;
if(frame==60){
second++;
frame = 0;
}
if(second==60){
minute++;
second = 0;
}
if(minute==60){
hour++;
minute = 0;
}
//Sotore them in one variable
Time = second+100*minute+10000*hour;
EndTime = Time;
Waitframe();
}
//Idle the script whilst the game is re-starting
while(End){
frame = 0;
second = 0;
minute = 0;
hour = 0;
Time = 0;
Waitframe();
}
//Idle the script whilst the game is paused
while(Pause) Waitframe();
}
}
}
//Don't allow Link to move on the title screen
ffc script No_Action{
void run(){
while(true){
NoAction();
Waitframe();
}
}
}
//Draw the 'Press Start' graphic and warp Link
ffc script Title_Screen{
void run(){
int i; bool f;
//Wait
Waitframes(75);
//Draw the tile on untill Link presses start
Game->PlaySound(TextUpSFX);
while(!Link->InputStart){
Draw();
Waitframe();
}
//Flash the tile for 40 frames
Game->PlaySound(SelectSFX);
for(i=0;i<40;i++){
if(i%4 == 0) f = !f;
if(f) Draw();
Waitframe();
}
//Stop the pause menu from opening up if Link holds down start
reStart = true;
//Warp Link
this->Data = AutoWarpCombo;
}
//Draw the tile
void Draw(){
Screen->DrawTile(6,80,128,PressStartTile,7,1,0,1,0,0,0,0,true,128);
}
}
//Input Constants
const int PipeTile = 11040;//Tile for Pipe to use
const int PipeAFrames = 8; //Number of animation frames of Pipe
const int PipeCSet = 7; //CSet for Pipe to use
const int PipeDamage = 1; //Damage for Pipe to deal
const int PipeSFX = 68; //Sound effect when used
const int GrenadeTile = 10860;
const int GrenadeCSet = 7;
const int GrenadeDamage = 8;
const int GrenadeSFX = 67;
const int ThrowDistance = 20;
const int PistolTile = 10862;
const int PistolCSet = 7;
const int PistolDamage = 2;
const int PistolSFX = 65;
const int ShotgunTile = 10866;
const int ShotgunCSet = 7;
const int ShotgunDamage = 4;
const int ShotgunRange = 54;
const int ShotgunSFX1 = 63;
const int ShotgunSFX2 = 64;
const int MachinegunTile = 10870;
const int MachinegunCSet = 7;
const int MachinegunDamage = 2;
const int MachinegunRate = 6;
const int MachinegunSFX = 66;
const int BulletTile = 10861;
const int BulletCSet = 11;
const int HealthTile = 10904;
const int HealthMeterTile = 10905;
const int PauseTile = 11000;
const int GameOverTile = 11080;
const int ScoreBoardTile = 11091;
const int TryAgainTile = 11140;
const int PressStartTile = 11120;
const int ZeroTile = 10909;
const int GunSpawnSFX = 71;
const int DeathTile = 10852;
const int SelectSFX = 72;
const int TextUpSFX = 73;
const int AutoWarpCombo = 196;
//Global Utility Variables
int GunLevel;
int Score;
int ScoreMax;
int HiScore;
int Time;
int EndTime;
bool Pause;
bool End;
bool reStart;
//Stops Link from being able to do anything
void NoAction(){
Link->InputR = false;
Link->InputL = false;
Link->InputA = false;
Link->InputB = false;
Link->InputLeft = false;
Link->InputRight = false;
Link->InputUp = false;
Link->InputDown = false;
Link->InputStart = false;
}
//Weapons, Subscreen functions, Pause screen, Re-Start Screen
global script The_Dead_Forest{
void run(){
//General Utility
bool lastA;
bool lastL;
bool lastB;
bool lastStart;
int lastDir;
int AttackDelay;
int AttackDelayMax;
int endcount;
int i;
bool f;
int x; int y;
lweapon pause[50];
int step[50];
//Pipe Utility
int PipeAttack;
lweapon pipe;
int PipeLayer;
//Gun Utility
Link->Item[123] = true;
int GunAttack;
lweapon pistol;
lweapon shotgun[3];
lweapon machine;
int gund;
int gunx;
int guny;
int MachineDelay;
int GunGFXDelay;
//Grenade Utility
int GrenadeAttack;
int grenaded;
int grenadex;
int grenadey;
lweapon grenade;
lweapon explosion;
while(true){
//Game Over
while(End){
//Hide Link
if(endcount == 0){
x = Link->X;
y = Link->Y;
Link->X = 240;
Link->Y = 48;
}
//Draw Link death graphic
if(endcount < 12) Screen->DrawTile(2,x,y,DeathTile+Floor(endcount/3),1,1,8,1,0,0,0,0,true,128);
endcount++;
//Drawing functions for game over screen
Screen->DrawTile(6,48,32,GameOverTile,11,2,0,1,0,0,0,0,true,128);
Screen->DrawTile(6,48,64,ScoreBoardTile,4,3,0,1,0,0,0,0,true,128);
RunTime(246,-8,1);
RunTime(164,94,1);
RunScore(108,-46,108,-35);
RunScore(140,67,140,80);
RunHealth();
//'Press Start to Try again' drawing functions
if(endcount >= 160){
if(endcount == 160) Game->PlaySound(TextUpSFX);
if(endcount%40 == 0) f = !f;
if(f) Screen->DrawTile(6,32,112,TryAgainTile,13,2,0,1,0,0,0,0,true,128);
if(endcount == 320) endcount = 201;
//Reset the game's variables after pressing start
if(Link->InputStart){
Link->X = 120;
Link->Y = 80;
Score = 0;
ScoreMax = 0;
GunLevel = 0;
Link->Item[123] = true;
Link->Item[124] = false;
Link->Item[125] = false;
Link->HP = Link->MaxHP;
Game->Counter[1] = 100;
Game->Counter[2] = 3;
End = false;
endcount = 0;
lastStart = true;
reStart = true;
Game->PlaySound(SelectSFX);
}
}
NoAction();
Waitframe();
}
//Lead Pipe
//Set up the pipe to start
if(Link->InputA && !lastA && PipeAttack == 0 && AttackDelay == 0){
Game->PlaySound(PipeSFX+Rand(3));
Link->Action = LA_ATTACKING;
PipeAttack++;
AttackDelay++;
AttackDelayMax = 20;
}
//Attack functions
if(PipeAttack>0){
//Make Link invincible
if(PipeAttack > 2) Link->Action = LA_FROZEN;
PipeAttack++;
//Create the actual pipe weapon
if(!pipe->isValid()){
pipe = Screen->CreateLWeapon(31);
pipe->Damage = PipeDamage;
pipe->OriginalTile = 84;
pipe->Tile = 84;
pipe->NumFrames = 1;
pipe->Dir = Link->Dir;
}
//Move the pipe in an arc
if(Link->Dir<1){
pipe->X = Link->X-16+2*PipeAttack;
pipe->Y = Link->Y-14+0.06*Pow((2*PipeAttack-16),2);
PipeLayer = 2;
}else if(Link->Dir<2){
pipe->X = Link->X-16+2*PipeAttack;
pipe->Y = Link->Y+16-0.06*Pow((2*PipeAttack-16),2);
PipeLayer = 3;
}else if(Link->Dir<3){
pipe->X = Link->X-14+0.06*Pow((2*PipeAttack-16),2);
pipe->Y = Link->Y-18+2*PipeAttack;
PipeLayer = 3;
}else{
pipe->X = Link->X+14-0.06*Pow((2*PipeAttack-16),2);
pipe->Y = Link->Y-18+2*PipeAttack;
PipeLayer = 3;
}
//Draw the pipe's graphic
Screen->DrawTile(PipeLayer,pipe->X,pipe->Y,PipeTile + PipeAFrames*Link->Dir + (PipeAttack-2)/2,1,1,PipeCSet,1,0,0,0,0,true,128);
//End attack
if(PipeAttack >= 16){
pipe->DeadState = 0;
PipeAttack = 0;
Link->Action = 0;
}
}
//Grenades
//Set up the grenades to start
if(Link->InputL && !lastL && Game->Counter[2] > 0 && GrenadeAttack == 0 && AttackDelay == 0){
//Create the grenade, put it next to Link
Game->Counter[2]--;
grenaded = Link->Dir;
grenade = Screen->CreateLWeapon(31);
grenade->CSet = PipeCSet;
grenade->NumFrames = 1;
grenade->Dir = grenaded;
grenadex = 0; grenadey = 0;
if(grenaded>1){grenadex = (((grenaded-2)*2)-1)*8; grenadey = -4;}
if(grenaded<2) grenadey = ((grenaded*2)-1)*8;
grenade->X = Link->X+grenadex;
grenade->Y = Link->Y+grenadey;
grenade->OriginalTile = GrenadeTile;
grenade->Step = 2;
Game->PlaySound(GrenadeSFX);
Link->Action = LA_ATTACKING;
GrenadeAttack++;
AttackDelay++;
AttackDelayMax = 20;
}
if(GrenadeAttack > 0){
//Move the grenade in an arc
grenade->Z = (-0.05*GrenadeAttack)*(GrenadeAttack-20);
//Remove grenade once it's at the end of the arc
if(GrenadeAttack == ThrowDistance) grenade->DeadState = 0;
GrenadeAttack++;
//Create explosion weapon once grenade reaches end of arc
if(grenade->isValid()){
grenadex = grenade->X;
grenadey = grenade->Y;
}else{
explosion = Screen->CreateLWeapon(LW_BOMB);
explosion->Damage = GrenadeDamage;
explosion->X = grenadex;
explosion->Y = grenadey;
GrenadeAttack = 0;
}
}
//Guns
if(Link->InputB){
//Pistol set up
if(GunLevel == 0 && !lastB && Game->Counter[1] > 0 && AttackDelay == 0){
Game->Counter[1]--;
Link->Action = LA_ATTACKING;
GunGFXDelay++;
GunAttack++;
AttackDelay++;
AttackDelayMax = 20;
}
//Shotgun set up
if(GunLevel == 1 && !lastB && Game->Counter[1] > 2 && AttackDelay == 0 && GunAttack == 0){
Game->Counter[1] -= 3;
Game->PlaySound(ShotgunSFX1);
Link->Action = LA_ATTACKING;
GunGFXDelay++;
GunAttack++;
AttackDelay++;
AttackDelayMax = 35;
}
//Machine gun
if(GunLevel == 2 && Game->Counter[1] > 0 && AttackDelay == 0){
//Create and fire bullet functions
if(MachineDelay == 0){
Game->Counter[1]--;
gund = Link->Dir;
machine = Screen->CreateLWeapon(31);
machine->CSet = BulletCSet;
machine->NumFrames = 1;
machine->Dir = gund;
gunx = 0; guny = 0;
if(gund>1){gunx = (((gund-2)*2)-1)*16; guny = -3;}
if(gund<2){
guny = ((gund*2)-1)*4;
gunx = ((gund*2)-1)*-8;
}
machine->X = Link->X+gunx;
machine->Y = Link->Y+guny;
machine->OriginalTile = BulletTile;
machine->Step = 2;
machine->Damage = MachinegunDamage;
Game->PlaySound(MachinegunSFX);
}
//Draw the machinegun
if(Link->Dir<1) Screen->DrawTile(3,Link->X,Link->Y-5,MachinegunTile+Link->Dir,1,1,MachinegunCSet,1,0,0,0,0,true,128);
else if(Link->Dir<2) Screen->DrawTile(3,Link->X,Link->Y,MachinegunTile+Link->Dir,1,1,MachinegunCSet,1,0,0,0,0,true,128);
else if(Link->Dir<3) Screen->DrawTile(3,Link->X-13,Link->Y-1,MachinegunTile+Link->Dir,1,1,MachinegunCSet,1,0,0,0,0,true,128);
else Screen->DrawTile(3,Link->X+13,Link->Y-1,MachinegunTile+Link->Dir,1,1,MachinegunCSet,1,0,0,0,0,true,128);
//Allow the machine gun to fire only every 'MachinegunRate' frames
MachineDelay++;
MachineDelay %= MachinegunRate;
}
}else MachineDelay = 0;
if(GunAttack > 0){
GunAttack++;
//Pistol
if(GunLevel == 0){
//Make Link invincible while firing
if(GunAttack > 2) Link->Action = LA_FROZEN;
//Fire the bullet
if(GunAttack == 5){
gund = Link->Dir;
pistol = Screen->CreateLWeapon(31);
pistol->CSet = BulletCSet;
pistol->NumFrames = 1;
pistol->Dir = gund;
gunx = 0; guny = 0;
if(gund>1){gunx = (((gund-2)*2)-1)*8; guny = -3;}
if(gund<2){
guny = ((gund*2)-1)*4;
gunx = ((gund*2)-1)*-8;
}
pistol->X = Link->X+gunx;
pistol->Y = Link->Y+guny;
pistol->OriginalTile = BulletTile;
pistol->Step = 2;
pistol->Damage = PistolDamage;
Game->PlaySound(PistolSFX);
}
//End the attack
if(GunAttack == 15){
GunAttack = 0;
Link->Action = 0;
}
}
//Shotgun
if(GunLevel == 1){
if(GunAttack > 2) Link->Action = LA_FROZEN;
//Fire the bullet
if(GunAttack == 27){
gund = Link->Dir;
gunx = 0; guny = 0;
if(gund>1){gunx = (((gund-2)*2)-1)*16; guny = -3;}
if(gund<2){
guny = ((gund*2)-1)*4;
gunx = ((gund*2)-1)*-8;
}
for(i=0;i<3;i++){
shotgun[i] = Screen->CreateLWeapon(31);
shotgun[i]->CSet = BulletCSet;
shotgun[i]->NumFrames = 1;
shotgun[i]->X = Link->X+gunx;
shotgun[i]->Y = Link->Y+guny;
shotgun[i]->OriginalTile = BulletTile;
shotgun[i]->Step = 3;
shotgun[i]->Damage = ShotgunDamage;
if(i<2) shotgun[i]->Angular = true;
else shotgun[i]->Dir = gund;
}
//Spread the three bullets apart
if(Link->Dir<1){
shotgun[0]->Angle = 4.9;
shotgun[1]->Angle = 10.8;
}else if(Link->Dir<2){
shotgun[0]->Angle = 1.8;
shotgun[1]->Angle = 7.6;
}else if(Link->Dir<3){
shotgun[0]->Angle = 3.4;
shotgun[1]->Angle = 9.2;
}else{
shotgun[0]->Angle = 0.3;
shotgun[1]->Angle = 5.9;
}
Game->PlaySound(ShotgunSFX2);
}
//Stop the bullets once they reach the end of their range
if(GunAttack >= ShotgunRange){
for(i=0;i<3;i++) shotgun[i]->DeadState = 0;
GunAttack = 0;
Link->Action = 0;
}
}
}
//Draw graphics for shotgun and pistol
if(GunGFXDelay > 0){
GunGFXDelay++;
//Pistol
if(GunLevel == 0){
if(Link->Dir<1) Screen->DrawTile(3,Link->X,Link->Y-5,PistolTile+Link->Dir,1,1,PistolCSet,1,0,0,0,0,true,128);
else if(Link->Dir<2) Screen->DrawTile(3,Link->X,Link->Y,PistolTile+Link->Dir,1,1,PistolCSet,1,0,0,0,0,true,128);
else if(Link->Dir<3) Screen->DrawTile(3,Link->X-15,Link->Y,PistolTile+Link->Dir,1,1,PistolCSet,1,0,0,0,0,true,128);
else Screen->DrawTile(3,Link->X+15,Link->Y,PistolTile+Link->Dir,1,1,PistolCSet,1,0,0,0,0,true,128);
if(GunGFXDelay == 15) GunGFXDelay = 0;
}
//Shotgun
else if(GunLevel == 1){
if(Link->Dir<1) Screen->DrawTile(3,Link->X,Link->Y-5,ShotgunTile+Link->Dir,1,1,ShotgunCSet,1,0,0,0,0,true,128);
else if(Link->Dir<2) Screen->DrawTile(3,Link->X,Link->Y,ShotgunTile+Link->Dir,1,1,ShotgunCSet,1,0,0,0,0,true,128);
else if(Link->Dir<3) Screen->DrawTile(3,Link->X-13,Link->Y-1,ShotgunTile+Link->Dir,1,1,ShotgunCSet,1,0,0,0,0,true,128);
else Screen->DrawTile(3,Link->X+13,Link->Y-1,ShotgunTile+Link->Dir,1,1,ShotgunCSet,1,0,0,0,0,true,128);
if(GunGFXDelay == 50) GunGFXDelay = 0;
}
}
//Timer to stop repeated attacks
if(AttackDelay > 0){
AttackDelay++;
if(AttackDelay >= AttackDelayMax) AttackDelay = 0;
}
//Health-bar, Time and Scoring functions
RunHealth();
RunScore(108,-46,108,-35);
RunTime(246,-8,0);
//Pause Screen functions
//Set up pause
if(Link->InputStart && !lastStart){
Pause = true;
//Stop bullets when paused
for(i=0;i<Screen->NumLWeapons();i++){
pause[i] = Screen->LoadLWeapon(i+1);
step[i] = pause[i]->Step;
pause[i]->Step = 0;
}
lastStart = Link->InputStart;
Link->InputStart = false;
}
while(Pause){
//Stop Link from moving
Link->Action = LA_FROZEN;
Waitframe();
//Check to see if pause should be turned off
if(Link->InputStart && !lastStart){
Pause = false;
//Start bullets again
for(i=0;i<Screen->NumLWeapons();i++) pause[i]->Step = step[i];
}
//Stop the subscreen from opening
if(Pause){
lastStart = Link->InputStart;
Link->InputStart = false;
}
//Draw on the pause tile and subscreen functions
Screen->DrawTile(6,64,64,PauseTile,8,2,0,1,0,0,0,0,true,128);
RunScore(108,-46,108,-35);
RunHealth();
RunTime(246,-8,0);
Link->Action = 0;
}
//Utility
//Stop repeated attacks from pipe, grenade, shotgun, pistol if button held down
lastB = Link->InputB;
lastA = Link->InputA;
lastL = Link->InputL;
lastDir = Link->Dir;
//Don't open up pause screen when pressing start after resetting game
if(reStart){
lastStart = true;
reStart = false;
}else lastStart = Link->InputStart;
//Don't allow Link to drop bombs or open up the subscreen
Link->InputB = false;
Link->InputStart = false;
Waitdraw();
//Strafe
if(Link->InputR) Link->Dir = lastDir;
Waitframe();
}
}
//Scoring
void RunScore(int x1, int y1, int x2, int y2){
int HiScoreMax;
int i;
if(Score >= 99999){
Score = 99999;
ScoreMax = 9;
HiScoreMax = 9;
}
//High Score functions
if(Score > HiScore) HiScore = Score;
for(i=0;i<5;i++){
//Draw on the score and high score
Screen->DrawTile(6,x1-i*8,y1,ZeroTile+(Floor(Score/Pow(10,i))%10),1,1,0,1,0,0,0,0,true,128);
Screen->DrawTile(6,x2-i*8,y2,ZeroTile+(Floor(HiScore/Pow(10,i))%10),1,1,0,1,0,0,0,0,true,128);
if(i<3){
//Add the extra 3 zeros at the end
Screen->DrawTile(6,x1+8+i*8,y1,ZeroTile+ScoreMax,1,1,0,1,0,0,0,0,true,128);
Screen->DrawTile(6,x2+8+i*8,y2,ZeroTile+HiScoreMax,1,1,0,1,0,0,0,0,true,128);
}
}
}
//Health-Bar
void RunHealth(){
int HP;
int i;
//Work out a value for HP
HP = Ceiling((Link->HP-64)/8);
//Reset the game if Link 'dies'
if(HP <= 0) End = true;
//Draw on the health bar
for(i=0;i<HP;i++) Screen->DrawTile(6,76+i*4,-19,HealthTile,1,1,8,1,0,0,0,0,true,128);
//Draw on the frame on top
Screen->DrawTile(6,76,-19,HealthMeterTile,4,1,8,1,0,0,0,0,true,128);
}
//Timer
void RunTime(int x, int y, int check){
int i;
int spacer;
int t;
//Check whether to draw the time for the game, or the time once the game has finished
if(check==0) t = Time;
else t = EndTime;
for(i=0;i<6;i++){
if(i<2){
spacer = 0;
//Draw on the colons
Screen->DrawTile(6,x-16-i*24,y,ZeroTile+10,1,1,0,1,0,0,0,0,true,128);
}else if(i<4) spacer = 8;
else spacer = 16;
//Draw the time
Screen->DrawTile(6,x-spacer-i*8,y,ZeroTile+(Floor(t/Pow(10,i))%10),1,1,0,1,0,0,0,0,true,128);
}
}
}
//Change which gun Link has
item script Gun_Level{
void run(int l){
GunLevel = l;
//Remove other guns when he gains a new one
if(l<1){
Link->Item[124] = false;
Link->Item[125] = false;
}else if(l<2){
Link->Item[123] = false;
Link->Item[125] = false;
}else{
Link->Item[123] = false;
Link->Item[124] = false;
}
}
}
//Spawn the zombies
ffc script Zombie_Spawner{
void run(){
//Enemy-spawn point locations
int location[6];
location[0] = ComboAt(80,16);
location[1] = ComboAt(208,16);
location[2] = ComboAt(16,48);
location[3] = ComboAt(224,122);
location[4] = ComboAt(48,144);
location[5] = ComboAt(144,144);
//Declare the enemies
npc e[20];
//Store their locations for when the game is paused
int x[20]; int y[20];
int dir[20];
int hp[20];
int step[20];
int rate[20];
bool Stop[20];
bool Go[20];
//Make sure their tiles are only moved along once when they're damaged
bool hpcheck[20];
int i;
//Increasing number of enemy functions
int RandomLevel;
int RandomLocation;
int Level;
int NextLevel;
int LevelFactor = 2;
int MaxNPCs;
while(true){
//Reset variables when game restarts
while(End){
Level = 0;
NextLevel = 0;
MaxNPCs = 0;
LevelFactor = 2;
Waitframe();
}
//Increase current number of zombies level
Level++;
if(Level > 3) LevelFactor = 3;
else if(Level > 10) LevelFactor = 2;
//Number of zombies to be killed to reach the next level
NextLevel += Pow(Level,2)*LevelFactor;
//Random factor
RandomLevel = Rand(Level*4);
//Work out how many zombies to have based on current level
if(Level < 2) MaxNPCs = 1;
else if(Level < 7) MaxNPCs = (Level-1)*2;
else if(Level < 16) MaxNPCs = Level+4;
else MaxNPCs = 20;
//Add zombies
while(Score < NextLevel+RandomLevel){
for(i=0;i<MaxNPCs;i++){
//Zombie Spawning
if(!e[i]->isValid()){
e[i] = Screen->CreateNPC(177+Rand(2));
//Increase to 16x32
e[i]->Extend = 3;
e[i]->TileHeight = 2;
e[i]->HitYOffset = 8;
//Place at random location
RandomLocation = Rand(6);
e[i]->X = (location[RandomLocation]%16)*16;
e[i]->Y = (Floor(location[RandomLocation]/16))*16;
hpcheck[i] = false;
}
//Remove head when HP less than half
if(e[i]->HP <= 4 && !hpcheck[i]){
e[i]->Tile = e[i]->Tile+40;
hpcheck[i] = true;
}
//Stop movement if game is paused
if(Pause){
if(Stop[i]){
e[i]->Tile = e[i]->Tile-160;
hp[i] = e[i]->HP;
e[i]->HP = 30;
step[i] = e[i]->Step;
rate[i] = e[i]->Rate;
e[i]->Step = 0;
e[i]->Rate = 0;
Stop[i] = false;
}
Go[i] = true;
Waitdraw();
e[i]->X = x[i];
e[i]->Y = y[i];
e[i]->Dir = dir[i];
}else{
if(Go[i]){
e[i]->Tile = e[i]->Tile+160;
e[i]->HP = hp[i];
e[i]->Step = step[i];
e[i]->Rate = rate[i];
Go[i] = false;
}
Stop[i] = true;
x[i] = e[i]->X;
y[i] = e[i]->Y;
dir[i] = e[i]->Dir;
}
}
Waitframe();
//Increase score once zombies die
for(i=0;i<MaxNPCs;i++){
if(!e[i]->isValid()) Score++;
if(End) e[i]->HP = 0;
}
//Break loop if game ends
if(End) break;
}
}
}
}
//Spawn the guns
ffc script Gun_Spawner{
void run(){
item gun;
int GunCount = 8+Rand(4);
int GunTimer;
int x; int y;
while(true){
//Idle whilst not enough zombies have been killed. Remove guns if they remain on-screen for too long
while(GunCount > Score){
if(gun->isValid() && !Pause) GunTimer++;
if((GunTimer >= 600 || End) && gun->isValid()){
gun->X = -16;
gun->Y = -16;
}
//Break loop if game ends
if(End) break;
Waitframe();
}
//Stop spawning guns whilst game ends
while(End){
//Remove any enemy drops whilst game end screen is up
Screen->ClearSprites(1);
Screen->ClearSprites(3);
GunCount = 8+Rand(4);
Waitframe();
}
if(Score > 0){
//Spawn guns
GunTimer = 0;
//Create the gun
gun = Screen->CreateItem(123+Rand(3));
//Place it at a random location...
do{
x = 48+Rand(144);
y = 48+Rand(64);
//Which is not too close to Link
}while(Abs(Link->X-x) < 32 && Abs(Link->Y-y) < 32)
gun->X = x;
gun->Y = y;
Game->PlaySound(GunSpawnSFX);
//Number of enemies to be killed before next gun is spawned
GunCount += 20+Rand(10);
}
}
}
}
//Work out how long the game has been running for
ffc script Game_Timer{
void run(){
//Store the variables
int frame;
int second;
int minute;
int hour;
while(true){
//Increase the variables
while(!Pause && !End){
frame++;
if(frame==60){
second++;
frame = 0;
}
if(second==60){
minute++;
second = 0;
}
if(minute==60){
hour++;
minute = 0;
}
//Sotore them in one variable
Time = second+100*minute+10000*hour;
EndTime = Time;
Waitframe();
}
//Idle the script whilst the game is re-starting
while(End){
frame = 0;
second = 0;
minute = 0;
hour = 0;
Time = 0;
Waitframe();
}
//Idle the script whilst the game is paused
while(Pause) Waitframe();
}
}
}
//Don't allow Link to move on the title screen
ffc script No_Action{
void run(){
while(true){
NoAction();
Waitframe();
}
}
}
//Draw the 'Press Start' graphic and warp Link
ffc script Title_Screen{
void run(){
int i; bool f;
//Wait
Waitframes(75);
//Draw the tile on untill Link presses start
Game->PlaySound(TextUpSFX);
while(!Link->InputStart){
Draw();
Waitframe();
}
//Flash the tile for 40 frames
Game->PlaySound(SelectSFX);
for(i=0;i<40;i++){
if(i%4 == 0) f = !f;
if(f) Draw();
Waitframe();
}
//Stop the pause menu from opening up if Link holds down start
reStart = true;
//Warp Link
this->Data = AutoWarpCombo;
}
//Draw the tile
void Draw(){
Screen->DrawTile(6,80,128,PressStartTile,7,1,0,1,0,0,0,0,true,128);
}
}
#4 Isdrakthül
Isdrakthül
- Members
Apprentice
Posted 15 May 2011 - 04:08 PM
Okay, I'll try to do this as soon as possible. Do you want the pistol, the shotgun, the machine gun, or all three?
EDIT: Your first post said pistol, but I missed it.
EDIT2: This is giving me a bit more trouble than anticipated. I'll keep trying, but don't hold your breath or anything.
EDIT: Your first post said pistol, but I missed it.
EDIT2: This is giving me a bit more trouble than anticipated. I'll keep trying, but don't hold your breath or anything.
Edited by Isdrakthül, 21 May 2011 - 08:09 PM.
#5 Rex-Leviathan
Rex-Leviathan
- Members
Lost, Loneliness, Liberation!
- Location:Assorted Locations
Posted 22 May 2011 - 03:53 PM
Maybe a few more specifics should be added:
I want it to shoot like a pistol (even though it will be modeled after 007 Goldeneye's Moonraker Laser).
It should not have an ammo limit (So, infinite. right? ).
And also, I do want it to act as a melee weapon (as if "can't use wand as melee weapon" rule was off).
All those I want in the script, plus all the stuff that kinda has to be in there . I can do the tiles for the laser beam, the gun, and also the SFX. All I can't do is the script . Someday...
Edit: I know you said this is taking time, but I want it done, so I am going to try too. This is probably a bad idea. Oh well .
I want it to shoot like a pistol (even though it will be modeled after 007 Goldeneye's Moonraker Laser).
It should not have an ammo limit (So, infinite. right? ).
And also, I do want it to act as a melee weapon (as if "can't use wand as melee weapon" rule was off).
All those I want in the script, plus all the stuff that kinda has to be in there . I can do the tiles for the laser beam, the gun, and also the SFX. All I can't do is the script . Someday...
Edit: I know you said this is taking time, but I want it done, so I am going to try too. This is probably a bad idea. Oh well .
Edited by mamavader, 25 May 2011 - 08:09 PM.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users
Reply to quoted posts Clear