Is there any tutorial for this (except Poet's one, which is writen for DOS), or can anyone write a step-by-step tutorial?
Because i didn't seem to find a proper one.
A friendly Wolfenstein 3D community, about Wolfenstein 3D, the game that gave birth to first person shooters...
void GiveWeapon (int weapon)
{
if (weapon != wp_rocket) {
switch (weapon) {
case wp_pistol: GiveAmmo (4); break;
case wp_machinegun: GiveAmmo (6); break;
case wp_chaingun: GiveAmmo (12); break;
case wp_rifle: GiveAmmo (6); break;
}
}
else { // weapon == wp_mlauncher
/**
if (!gamestate.gotmlauncher) {
gamestate.extraammo = 1;
// GiveAmmo (1);
gamestate.ammo++ ;
}
**/
gamestate.gotmlauncher = -1;
GiveAmmo2 (2);
if (gamestate.weapon != weapon /* wp_mlauncher */) {
gamestate.weapon = gamestate.chosenweapon = weapontype;
if (!gamestate.ammo) {
gamestate.extraammo = 1 ;
gamestate.ammo++ ;
}
}
return;
}
if (gamestate.bestweapon<weapon)
gamestate.bestweapon = gamestate.weapon
= gamestate.chosenweapon = weapontype;
DrawWeapon ();
}
void GunAttack (objtype *ob)
{
objtype *check,*closest,*oldclosest;
int damage;
int dx,dy,dist;
int32_t viewdist;
if (gamestate.weapon == wp_mlauncher)
{
MissileAttack (ob);
return; // return to calling routine, stop processing GunAttack
}
switch (gamestate.weapon)
{
case wp_pistol:
SD_PlaySound (ATKPISTOLSND);
break;
case wp_machinegun:
SD_PlaySound (ATKMACHINEGUNSND);
break;
case wp_chaingun:
SD_PlaySound (ATKGATLINGSND);
break;
}
gamestate.ammo--; // decrease regular ammo by 1
madenoise = true;
//
// find potential targets
//
viewdist = 0x7fffffffl;
closest = NULL;
extern statetype s_rocket;
{ {6,0,1},{6,1,2},{6,0,3},{6,-1,4} }, // missile launcher
// MAC6 77 BrotherTank routine
// Checks to make sure you have ammo for weapon
// APN: and that you also have the weapon
// returns "true" if yes and "false" if no
int ChkAtkAmmo (int weapon)
{
switch (weapon)
{
case wp_knife: return 1;
case wp_pistol:
if (gamestate.ammo > 0) return 1;
break;
case wp_machinegun:
if (gamestate.gotmachinegun && gamestate.ammo > 0) return 1;
break;
case wp_chaingun:
if (gamestate.gotgatgun && gamestate.ammo > 0) return 1;
break;
case wp_mlauncher:
if (gamestate.gotmlauncher && gamestate.missile > 0) return 1;
break;
}
return 0;
}
void CheckWeaponChange (void)
{
int i,buttons;
int j;
if (Keyboard[sc_5] && gamestate.gotmlauncher && (gamestate.missile > 0))
{
gamestate.chosenweapon = gamestate.weapon = wp_mlauncher ;
if (!extraammo)
extraammo = 1;
DrawAmmo ();
return ;
}
if (Keyboard[sc_1] && gamestate.weapon == wp_knife ||
Keyboard[sc_2] && gamestate.weapon == wp_pistol||
Keyboard[sc_3] && gamestate.weapon == wp_machinegun && gamestate.gotmachinegun ||
Keyboard[sc_4] && gamestate.weapon == wp_chaingun && gamestate.gotgatgun)
if (extraammo)
extraammo = 0 ;
// APN: get best weapon (with ammo) when out of particular ammo
if ((gamestate.weapon == wp_mlauncher) && (gamestate.missile<1))
{
for (j=gamestate.bestweapon; j>=0; j--)
if (ChkAtkAmmo(j))
{
gamestate.weapon = (weapontype) j;
break;
}
}
else if ((gamestate.weapon <= wp_chaingun) && (gamestate.chosenweapon
!= wp_knife) && (gamestate.ammo < 1))
{
for (j=gamestate.bestweapon; j>=0; j--)
if (ChkAtkAmmo(j))
{
gamestate.weapon = (weapontype) j;
break;
}
}
else if ((gamestate.weapon == wp_knife) && (gamestate.chosenweapon
!= wp_knife) && (gamestate.ammo > 0 || gamestate.missile > 0))
{
for (j=gamestate.bestweapon; j>=0; j--)
if (ChkAtkAmmo(j))
{
gamestate.chosenweapon = gamestate.weapon = (weapontype) j;
break;
}
}
// must use knife with no ammo
else if (!gamestate.ammo && !gamestate.missile)
gamestate.weapon = wp_knife; // APN: knife is not "chosen" here
else if (Keyboard[sc_1] && gamestate.bestweapon >= wp_knife && ChkAtkAmmo(0))
gamestate.weapon = gamestate.chosenweapon = wp_knife;
else if (Keyboard[sc_2] && gamestate.bestweapon >= wp_pistol && ChkAtkAmmo(1))
gamestate.weapon = gamestate.chosenweapon = wp_pistol;
else if (Keyboard[sc_3] && gamestate.bestweapon >= wp_machinegun && ChkAtkAmmo(2))
gamestate.weapon = gamestate.chosenweapon = wp_machinegun;
else if (Keyboard[sc_4] && gamestate.bestweapon >= wp_chaingun && ChkAtkAmmo(3))
gamestate.weapon = gamestate.chosenweapon = wp_chaingun;
else if (Keyboard[sc_5] && gamestate.bestweapon >= wp_mlauncher && ChkAtkAmmo(4))
gamestate.weapon = gamestate.chosenweapon = wp_mlauncher;
DrawWeapon();
DrawAmmo ();
}
void GiveWeapon (int weapon)
{
if (weapon != wp_mlauncher)
{
switch (weapon)
{
case wp_machinegun:
GiveAmmo (6);
if ((!gamestate.gotmachinegun && !gamestate.gotgatgun &&
gamestate.weapon != wp_mlauncher) ||
(!gamestate.gotmachinegun && gamestate.weapon <= wp_pistol))
gamestate.weapon = gamestate.chosenweapon = (weapontype) weapon;
gamestate.gotmachinegun = 1;
break;
case wp_chaingun:
GiveAmmo (8);
if (!gamestate.gotgatgun && gamestate.weapon != wp_mlauncher)
gamestate.weapon = gamestate.chosenweapon = (weapontype) weapon;
gamestate.gotgatgun = 1;
break;
}
}
else // weapon == wp_mlauncher
{
if (!gamestate.gotmlauncher)
{
gamestate.weapon = gamestate.chosenweapon = (weapontype) weapon;
extraammo = 1;
gamestate.gotmlauncher = 1; // APN: Poet had -1 here
}
GiveMissile (2); // APN: Missile launcher gives 2 ammo
}
if (gamestate.bestweapon<weapon)
gamestate.bestweapon = gamestate.weapon
= gamestate.chosenweapon = (weapontype) weapon;
DrawWeapon ();
}
/*
==================
=
= GiveMissile
=
==================
*/
void GiveMissile (int missile)
{
gamestate.missile += missile;
if (gamestate.missile > 30)
gamestate.missile = 30;
DrawAmmo ();
}
void DrawAmmo (void)
{
if(viewsize == 21 && ingame) return;
if (gamestate.weapon == wp_mlauncher)
LatchNumber (26,16,3,gamestate.missile);
else
LatchNumber (26,16,3,gamestate.ammo);
}
case bo_mlauncher:
SD_PlaySound (GETGATLINGSND);
facetimes = 38;
GiveWeapon (wp_mlauncher);
if(viewsize != 21)
StatusDrawFace (GOTGATLINGPIC);
facecount = 0;
break;
case bo_missile:
if (gamestate.missile >= 30)
return;
SD_PlaySound (GETAMMOSND);
GiveMissile (1)
break;
/*
===============
=
= MissileAttack // MAC6 67
=
= Poet: adding a missile launcher. This is a new function.
=
===============
*/
void MissileAttack (objtype *ob)
{
if (gamestate.missile<1)
{
// SD_PlaySound (DONOTHINGSND);
return;
}
SD_PlaySound (MISSILEFIRESND);
GetNewActor ();
newobj->state = &s_rocket;
newobj->ticcount = 1;
newobj->x = ob->x ;
newobj->y = ob->y ;
newobj->tilex = newobj->x >> TILESHIFT;
newobj->tiley = newobj->y >> TILESHIFT;
newobj->obclass = rocketobj;
newobj->dir = nodir;
newobj->angle = ob->angle;
newobj->speed = 0x4200l;
// new->flags = FL_NONMARK | FL_BONUS;
// MAC6 75 APN: fix for door held open
newobj->flags = 10000110; // FL_NONMARK | FL_NEVERMARK | FL_BONUS
newobj->active = ac_yes;
madenoise = true;
GiveMissile (-1);
}
void GunAttack (objtype *ob)
{
objtype *check,*closest,*oldclosest;
int damage;
int dx,dy,dist;
int32_t viewdist;
if (gamestate.weapon == wp_mlauncher)
{
MissileAttack (ob);
GiveAmmo (1);
return;
}
case 1:
if (!gamestate.ammo && gamestate.weapon < wp_mlauncher)
{ // can only happen with chain gun
gamestate.attackframe++;
break;
}
GunAttack (ob);
if (!ammocheat)
gamestate.ammo--;
DrawAmmo ();
break;
MLAUNCHER, // 135
ORDERSCREEN=137,
ERRORSCREEN, // 136
T_HELPART, // 137
T_DEMO0, // 138
T_DEMO1, // 139
T_DEMO2, // 140
T_DEMO3, // 141
T_ENDART1, // 142
T_ENDART2, // 143
T_ENDART3, // 144
T_ENDART4, // 145
T_ENDART5, // 146
T_ENDART6, // 147
#define LATCHPICS_LUMP_END 135
#define NUMCHUNKS 152
#define NUMPICS 133
#define STARTPICM 135
#define STARTSPRITES 135
#define STARTTILE8 135
#define STARTTILE8M 136
#define STARTTILE16 136
#define STARTTILE16M 136
#define STARTTILE32 136
#define STARTTILE32M 136
#define STARTEXTERNS 136