The tutorial assumes you have WSJ's In-game Messages feature working. But the code can easily be changed to accomodate a different feature.
First, go into WL_AGENT.CPP. Do a search for "elevatorok". You should see this code:
- Code: Select all
void Cmd_Use (void)
{
int checkx,checky,doornum,dir;
boolean elevatorok;
Insert this code just below it:
- Code: Select all
int32_t dist=0x7fffffff;
objtype *closest = NULL;
for (objtype *check=player->next; check; check=check->next)
{
if ( (check->flags & FL_SHOOTABLE) && (check->flags & FL_VISABLE)
&& abs(check->viewx-centerx) < shootdelta)
{
if (check->transx < dist)
{
dist = check->transx;
closest = check;
}
}
}
Now do a search for "leveldone". You should see this code:
- Code: Select all
SD_PlaySound (LEVELDONESND);
SD_WaitSoundDone();
}
Insert this code just below it:
- Code: Select all
else if (closest && dist <= 0x18000l && !buttonheld[bt_use])
{
switch (closest->obclass)
{
case guardobj:
buttonheld[bt_use] = true;
GetMessage("I'm a guard.");
break;
case officerobj:
buttonheld[bt_use] = true;
GetMessage("I'm an Officer.");
break;
case mutantobj:
buttonheld[bt_use] = true;
GetMessage("I'm a Mutant.");
break;
case ssobj:
buttonheld[bt_use] = true;
GetMessage("I'm an SS.");
break;
case dogobj:
buttonheld[bt_use] = true;
GetMessage("Woof!");
break;
}
}
Note that if you don't have WSJ's In-game Messages feature enabled, just replace each "GetMessage" line with something else.
This routine is actually just a cheap hack of the T_KnifeAttack code, but I optimized it somewhat. Hope it's useful to someone.