This is a really easy tutorial...
Though I suppose in this tutorial that you have enabled WSJs
in-game messages and Flamer46s timer display.
We start from WL_Def.H. Add these lines in the end of the file:
Now open WL_Agent.C (the main code is implemented here),
and search for "Thrust" (without quotes). Now in the end of the
function add these lines:
This code activates the bombs... Now to make them "defusable",
go to the Cmd_Use function (still in WL_Agent.C)
and underneath this block:
Add these lines (note: this is based partly on Dugtrios "opening crates"
code, so remember to credit him too) directly under it:
Note: "SPR_STAT_X1" and "SPR_STAT_X2" are the definitions for
the active bomb and the defused bomb... Change the X1,X2 to match
the sprite you have selected (make sure they're blocking ones in WL_Act1.C)...
Or you can just define new sprites in the source.
Then the final touchups. Open WL_Play.C, and scroll down to "Playloop" and add
these lines in to it:
Now last thing to do is to add these line:
"Died" - function in WL_Game.C...
Now you just need to compile and you're ready to go...
In case I didn't forgot to mention something.
Though I suppose in this tutorial that you have enabled WSJs
in-game messages and Flamer46s timer display.
We start from WL_Def.H. Add these lines in the end of the file:
- Code:
//--Bomb variables
int bombs;
int bombcount;
int active;
int deact;
int test;
//--
Now open WL_Agent.C (the main code is implemented here),
and search for "Thrust" (without quotes). Now in the end of the
function add these lines:
- Code:
if(*(mapsegs[1] + offset) == 399) //399 is the objects ID
{
if(!test) //Well, this isn't really needed
{
switch(gamestate.mapon) //If you want the object to act differently
{ //from level to level
case 1:
if(deact==true){} //Do nothing...
else //Bombs defused
{
if(!active) //Bombs activated?
{
active = true;
test = true;
gamestate.finaltime = 70l*70; //Set TimerDisplay: 2min
GetMessage("2 minutes time to defuse the bombs");
}
}
break;
default: break; //If map isn't defined
}
}
}
This code activates the bombs... Now to make them "defusable",
go to the Cmd_Use function (still in WL_Agent.C)
and underneath this block:
- Code:
//
// use elevator
//
buttonheld[bt_use] = true;
//--
gamestate.finaltime = 0; //Remember to add this!!!
//--
tilemap[checkx][checky]++; // flip switch
if (*(mapsegs[0]+farmapylookup[player->tiley]+player->tilex) == ALTELEVATORTILE)
playstate = ex_secretlevel;
else
playstate = ex_completed;
SD_PlaySound (LEVELDONESND);
SD_WaitSoundDone();
}
Add these lines (note: this is based partly on Dugtrios "opening crates"
code, so remember to credit him too) directly under it:
- Code:
for(statptr = &statobjlist[0]; statptr != laststatobj; statptr++)
{
if(statptr->tilex == checkx && statptr->tiley == checky &&
statptr->shapenum == SPR_STAT_X1 && !buttonheld[bt_use])
{
buttonheld[bt_use] = true;
statptr->shapenum = SPR_STAT_X2;
SD_PlaySound(BONUS1UPSND);
bombs = bombs+1; //also bombs++; works
switch(bombs) // for different messages
{
case 1: GetMessage("Bombs defused 1/4"); break;
case 2: GetMessage("Bombs defused 2/4"); break;
case 3: GetMessage("Bombs defused 3/4"); break;
case 4: GetMessage("All bombs are now defused.");
deact=true; break;
}
if(bombs >3) // All bombs defused... No need for timer
gamestate.finaltime=0;
}
}
Note: "SPR_STAT_X1" and "SPR_STAT_X2" are the definitions for
the active bomb and the defused bomb... Change the X1,X2 to match
the sprite you have selected (make sure they're blocking ones in WL_Act1.C)...
Or you can just define new sprites in the source.
Then the final touchups. Open WL_Play.C, and scroll down to "Playloop" and add
these lines in to it:
- Code:
if(active)
{
bombcount += tics;
if(bombs <4) //Check wether all bombs are defused in time.
{
if(bombcount > 70l*70) //two minutes
{ playstate = ex_died;//kill player
active = false;
}
}
else //Player made it on time
{
bombcount = 0;
active = false;
deact = true;
}
}
#endif
Now last thing to do is to add these line:
- Code:
active = false;
gamestate.finaltime=0;
bombcount=0;
bombs = 0;
deact = false;
"Died" - function in WL_Game.C...
Now you just need to compile and you're ready to go...
In case I didn't forgot to mention something.