
|
|
Author |
Message |
jamez
I am Death Incarnate


Joined: 16 Mar 2003
Last Visit: 17 Jan 2019
Topics: 13
Posts: 186
Location: Yorkshire, UK

|
Posted: Sat Apr 10, 2004 9:43 am
Subject: Reloading weapons... Same ammo / Seperate ammo (tutorial)
[ IP : Logged ]
|

 
|
|
Hey,
Just wondering if anyone wants me to post my tutorial on this...
if you don't want it i wont waste time posting it.... |
_________________ ~ James
|
|
 |
KyleRTCW
DieHard Officer

Joined: 30 Jul 2003
Last Visit: 05 Aug 2018
Topics: 45
Posts: 510
Location: Ohio

|
Posted: Sat Apr 10, 2004 1:58 pm
Subject: Re: Reloading weapons... Same ammo / Seperate ammo (tutorial
[ IP : Logged ]
|

  
|
|
Yeah post it. I was interested in this some time ago. I'd really want to add this to my TC, especialy the pistol .
And BrotherTank can put it up in the Code Tutorials Section. But please make sure it works. Thanks. |
_________________ Steam: http://steamcommunity.com/id/stormx312
|
|
 |
Codetech84
Code Master

Joined: 12 Mar 2003
Last Visit: 27 Aug 2018
Topics: 22
Posts: 1284
Location: Rauma - Finland

|
|
 |
jamez
I am Death Incarnate


Joined: 16 Mar 2003
Last Visit: 17 Jan 2019
Topics: 13
Posts: 186
Location: Yorkshire, UK

|
Posted: Sat Apr 17, 2004 8:02 am
Subject: Re: Reloading weapons... Same ammo / Seperate ammo (tutorial
[ IP : Logged ]
|

  
|
|
OK, the tutorial on "same ammo", will be ready soon...
A quick note... Same ammo means that when playing, ammo will be saved to the unloaded amount... then any weapon will load from the unloaded amount, unlike seperate ammo (Like in PV II) where different weapons load up from different ammo types, for example (from PVII)
Ammo Type 1 loads the Pistol and Machinegun
Ammo Type 2 loads the chain gun & double chaingun
Ammo Type 3 loads the sten and sniper
Ammo Type 4 loads the panzerfaust
(please no comments about weapons in PVII, they will be diffferent when the game is released (in like 2 years )) |
_________________ ~ James
|
|
 |
WSJ
Guest

Last Visit:
|
Posted: Sat Apr 17, 2004 1:17 pm
Subject: My Findings on the "Reloading Weapons" Feature
[ IP : Logged ]
|

  
|
|
Hi, this is Wolf Skevos-Jones (WSJ). I just came here because I found out my own method of "reloading weapons" and thought that it might be a good idea to share it with the community. I'd have posted it in the "Code Crackers" section but I can't post there because I'm not a member.
Here's what I had written:
-----
In most modern 3D shooters, weapons "reload" whenever the player has emptied an entire "clip." This feature was meant to be a more realistic approach to the gameplay. Though I think that this is somewhat unnecessary for an old shooter like Wolf3D, a lot of people wanted it for their add-ons, so I decided to share what I came up with.
In this example, you'll get 3 weapons with different reloadable clips and one of them will have a new type of ammo. The pistol reloads with an 8-round clip, the machinegun reloads with a 32-round clip (like the German MP-40), and the chaingun uses a 100-round clip. The pistol and machinegun use the same ammo, and the chaingun uses its own ammo. The knife never reloads because it never uses any ammo.
WARNING: This is a COMPLICATED tutorial and definitely not for people who are new to Wolf3D source hacking. There are many code changes involved and you'll need to already have some understanding of the Wolf3D source code if you want to use this tutorial to your advantage. If you're new to the code, I'd strongly advise you to go over the more basic tutorials and familiarize yourself with Wolf3D's source code before trying this tutorial. Also, this hasn't been fully tested yet, so there may be a few bugs.
First of all, start with a fresh, working copy of the source code. You may also need to free up some memory (see MCS's "Abnormal Program Termination" tutorial.) And it might be a good idea to make some backups of your game.
Next, add your reloading images of the weapons to your game. In this example, I added 5 frames for each weapon except the knife.
In WL_DEF.H:
::: CODE :::
SPR_CHAINREADY,SPR_CHAINATK1,SPR_CHAINATK2,SPR_CHAINATK3,
SPR_CHAINATK4,
// added reloading sprites here
SPR_PISTOL_RLOAD1,SPR_PISTOL_RLOAD2,SPR_PISTOL_RLOAD3,SPR_PISTOL_RLOAD4,
SPR_PISTOL_RLOAD5,
SPR_MACHINEGUN_RLOAD1,SPR_MACHINEGUN_RLOAD2,SPR_MACHINEGUN_RLOAD3,SPR_MACHINEGUN_RLOAD4,
SPR_MACHINEGUN_RLOAD5,
SPR_CHAINGUN_RLOAD1,SPR_CHAINGUN_RLOAD2,SPR_CHAINGUN_RLOAD3,SPR_CHAINGUN_RLOAD4,
SPR_CHAINGUN_RLOAD5,
Also, add some new sounds to your game if you want a "lock and load" noise to be played when a weapon is reloaded.
Now, in WL_DEF.H, look for:
::: CODE :::
#define STARTAMMO 8
Beneath that, add these lines:
::: CODE :::
#define PISTOLCLIP 8
#define MACHINEGUNCLIP 32
#define CHAINGUNCLIP 100
Here we're defining the amount of ammo held in each weapon's clip. Change these values to your liking.
Next, go down until you see this:
::: CODE :::
#define NUMWEAPONS 5
typedef enum {
wp_knife,
wp_pistol,
wp_machinegun,
wp_chaingun
} weapontype;
Below that, add this:
::: CODE :::
typedef enum {
ammo1,
ammo2
} ammotype;
I used this as a way of telling the "GiveAmmo" routine which type of ammo to give, since I'm adding a second type of ammo. "ammo1" adds to the regular ammo type, and "ammo2" adds to the new ammo type. If you want more ammo types later, add new lines like "ammo3" and so on.
Go down a little further until you see:
::: CODE :::
//---------------
//
// gamestate structure
//
//---------------
typedef struct
{
int difficulty;
int mapon;
long oldscore,score,nextextra;
int lives;
int health;
int ammo;
Right beneath "int ammo;" add these lines:
::: CODE :::
int ammo2; // new ammo type
int weapon2clip;
int weapon3clip;
int weapon4clip;
boolean reloading;
Here I've added variables for the second ammo type, the amount of ammo in each weapon's clip, and a boolean which is set to "true" while a weapon is reloading.
Now, search for:
::: CODE :::
void GiveAmmo (int ammo);
Change it to:
::: CODE :::
void GiveAmmo (int ammo, int ammotype);
This is so that the "GiveAmmo" routine can be told which type of ammo to give in addition to the amount of ammo to give.
Now in WL_DRAW.C, look for:
::: CODE :::
int weaponscale[NUMWEAPONS] = {SPR_KNIFEREADY,SPR_PISTOLREADY
,SPR_MACHINEGUNREADY,SPR_CHAINREADY};
Below it, add this:
::: CODE :::
int reloadscale[NUMWEAPONS] = {SPR_KNIFEREADY,SPR_PISTOL_RLOAD1
,SPR_MACHINEGUN_RLOAD1,SPR_CHAINGUN_RLOAD1};
This is the for the reloading animation. Since the knife never reloads, I just used "SPR_KNIFEREADY" for the first one.
Next, scroll down until you see this:
::: CODE :::
if (gamestate.weapon != -1)
{
shapenum = weaponscale[gamestate.weapon]+gamestate.weaponframe;
SimpleScaleShape(viewwidth/2,shapenum,viewheight+1);
}
Replace it with this:
::: CODE :::
if (gamestate.weapon != -1)
{
if (gamestate.reloading)
shapenum = reloadscale[gamestate.weapon]+gamestate.weaponframe;
else
shapenum = weaponscale[gamestate.weapon]+gamestate.weaponframe;
SimpleScaleShape(viewwidth/2,shapenum,viewheight+1);
}
Now in WL_AGENT.C, look for these two lines:
::: CODE :::
void T_Player (objtype *ob);
void T_Attack (objtype *ob);
Add this line:
::: CODE :::
void T_Reload (objtype *ob);
Go down until you see:
::: CODE :::
struct atkinf
{
char tics,attack,frame; // attack is 1 for gun, 2 for knife
} attackinfo[4][14] =
{
{ {6,0,1},{6,2,2},{6,0,3},{6,-1,4} },
{ {6,0,1},{6,1,2},{6,0,3},{6,-1,4} },
{ {6,0,1},{6,1,2},{6,3,3},{6,-1,4} },
{ {6,0,1},{6,1,2},{6,4,3},{6,-1,4} },
};
Below that, add this:
::: CODE :::
struct rloadinf
{
char tics,attack,frame;
} reloadinfo[4][14] =
// attack 1 plays reloading sound
// attack 2 reloads weapon
// -1 goes back to first weapon frame
{
{ {0,-1,0} }, // not used - knife doesn't reload
{ {20,1,0},{20,0,1},{20,0,2},{20,2,3},{20,-1,4} },
{ {20,1,0},{20,0,1},{20,0,2},{20,2,3},{20,-1,4} },
{ {20,1,0},{20,0,1},{20,0,2},{20,2,3},{20,-1,4} },
};
This defines the sequence for the reloading animation. It's very similar to the weapon animation, except that it uses different actions instead of "attacks." If your reloading animation uses more frames, you'll need to add more "{#,#,#}"s. See MCS's "Controlling the Weapon Behavior" tutorial for a better understanding.
Now look for:
::: CODE :::
void GiveAmmo (int ammo);
Change it to:
::: CODE :::
void GiveAmmo (int ammo, int ammotype);
Then add these two lines underneath:
::: CODE :::
void ReloadWeapon ();
void Cmd_Reload (void);
Now find this block:
::: CODE :::
void CheckWeaponChange (void)
{
int i,buttons;
if (!gamestate.ammo) // must use knife with no ammo
return;
for (i=wp_knife ; i<=gamestate.bestweapon ; i++)
if (buttonstate[bt_readyknife+i-wp_knife])
{
gamestate.weapon = gamestate.chosenweapon = i;
DrawWeapon ();
return;
}
}
Remove all of this and replace it with this block:
::: CODE :::
void CheckWeaponChange (void)
{
if (gamestate.reloading)
return; // don't change weapon while reloading
if (!gamestate.ammo && !gamestate.ammo2
&& !gamestate.weapon2clip && !gamestate.weapon3clip
&& !gamestate.weapon4clip)
{ // use knife when out of ammo
gamestate.weapon = gamestate.chosenweapon = wp_knife;
}
switch (LastScan)
{
case 2:
gamestate.weapon = gamestate.chosenweapon = wp_knife;
break;
case 3:
if (gamestate.bestweapon >= wp_pistol
&& (gamestate.ammo || gamestate.weapon2clip))
{
if (!gamestate.weapon2clip)
Cmd_Reload ();
gamestate.weapon =
gamestate.chosenweapon = wp_pistol;
}
break;
case 4:
if (gamestate.bestweapon >= wp_machinegun
&& (gamestate.ammo || gamestate.weapon3clip))
{
if (!gamestate.weapon3clip)
Cmd_Reload ();
gamestate.weapon =
gamestate.chosenweapon = wp_machinegun;
}
break;
case 5:
if (gamestate.bestweapon >= wp_chaingun
&& (gamestate.ammo2 || gamestate.weapon4clip))
{
if (!gamestate.weapon4clip)
Cmd_Reload ();
gamestate.weapon =
gamestate.chosenweapon = wp_chaingun;
}
break;
}
DrawWeapon ();
DrawAmmo ();
}
This is the new code for changing weapons. If there's ammo for a weapon but its clip is empty, the weapon will automatically reload when you switch to it. The player won't be able to change weapons while reloading a clip.
Now look for this:
::: CODE :::
void DrawWeapon (void)
{
StatusDrawPic (32,8,KNIFEPIC+gamestate.weapon);
}
Replace it with this:
::: CODE :::
void DrawWeapon (void)
{
switch (gamestate.weapon)
{
case wp_knife: // no ammo used
LatchNumber (32,16,3,0);
break;
case wp_pistol:
case wp_machinegun:
LatchNumber (32,16,3,gamestate.ammo);
break;
case wp_chaingun:
LatchNumber (32,16,3,gamestate.ammo2);
break;
}
}
In this example, the "DrawWeapon" routine no longer draws the weapon image. Instead, it will be used to display the the selected weapon's "ammo in reserve" on the status bar. You can change where the number is displayed by changing the "32,16" to some other number like "30,16".
Next, find this block:
::: CODE :::
void GiveWeapon (int weapon)
{
GiveAmmo (6);
if (gamestate.bestweapon<weapon)
gamestate.bestweapon = gamestate.weapon
= gamestate.chosenweapon = weapon;
DrawWeapon ();
}
Replace it with this:
::: CODE :::
void GiveWeapon (int weapon)
{
switch (weapon)
{
case wp_pistol: // give pistol
if (gamestate.bestweapon<wp_machinegun)
gamestate.weapon2clip = PISTOLCLIP;
else
GiveAmmo (PISTOLCLIP,ammo1);
break;
case wp_machinegun: // give machinegun
if (gamestate.bestweapon<wp_machinegun)
gamestate.weapon3clip = MACHINEGUNCLIP;
else
GiveAmmo (MACHINEGUNCLIP,ammo1);
break;
case wp_chaingun: // give chaingun
if (gamestate.bestweapon<wp_chaingun)
gamestate.weapon4clip = CHAINGUNCLIP;
else
GiveAmmo (CHAINGUNCLIP,ammo2);
break;
}
if (gamestate.bestweapon<weapon)
{
gamestate.bestweapon = weapon;
if (!gamestate.reloading)
gamestate.weapon = gamestate.chosenweapon = weapon;
}
}
The new "GiveWeapon" code is modified to give different amounts of ammo depending on which weapon is picked. If the player picks up a weapon he doesn't have, it will automatically hold a full clip. If he picks up a weapon he already has, it'll just add more to his reserve ammo. In this example, the weapon will always have ammo equal to its clip. You can change this by using a number other instead of "PISTOLCLIP" etc.
Now find:
::: CODE :::
void DrawAmmo (void)
{
LatchNumber (27,16,2,gamestate.ammo);
}
Replace it with"
::: CODE :::
void DrawAmmo (void)
{
switch (gamestate.weapon)
{
case wp_knife: // no ammo used
LatchNumber (26,16,3,0);
break;
case wp_pistol:
LatchNumber (26,16,3,gamestate.weapon2clip);
break;
case wp_machinegun:
LatchNumber (26,16,3,gamestate.weapon3clip);
break;
case wp_chaingun:
LatchNumber (26,16,3,gamestate.weapon4clip);
break;
}
}
This routine had been changed to display the ammo in the selected weapon's clip. Again, you can change where the number is displayed the same way as in "DrawWeapon."
Go down to this block:
::: CODE :::
void GiveAmmo (int ammo)
{
if (!gamestate.ammo) // knife was out
{
if (!gamestate.attackframe)
{
gamestate.weapon = gamestate.chosenweapon;
DrawWeapon ();
}
}
gamestate.ammo += ammo;
if (gamestate.ammo > 99)
gamestate.ammo = 99;
DrawAmmo ();
}
Replace all of it with:
::: CODE :::
void GiveAmmo (int ammo, int ammotype)
{
switch (ammotype)
{
case ammo1: // give regular ammo
{
gamestate.ammo += ammo;
if (gamestate.ammo > 99)
gamestate.ammo = 99;
}
break;
case ammo2: // give new ammo
{
gamestate.ammo2 += ammo;
if (gamestate.ammo2 > 300)
gamestate.ammo2 = 300;
}
break;
}
DrawWeapon ();
}
As I stated before, the "GiveAmmo" routine has been modified to give two different ammo types. The second type is used for the chaingun.
Search for every "GiveAmmo (#)" case and replace it with "GiveAmmo (#,ammo1)". This tells it to give the first type of ammo. If you have an item which gives the second ammo type, use "ammo2" instead of "ammo1".
Having done that, go to:
::: CODE :::
void Cmd_Fire (void)
{
buttonheld[bt_attack] = true;
gamestate.weaponframe = 0;
player->state = &s_attack;
gamestate.attackframe = 0;
gamestate.attackcount =
attackinfo[gamestate.weapon][gamestate.attackframe].tics;
gamestate.weaponframe =
attackinfo[gamestate.weapon][gamestate.attackframe].frame;
}
Change it to:
::: CODE :::
void Cmd_Fire (void)
{
if (gamestate.reloading)
return; // don't fire while reloading
buttonheld[bt_attack] = true;
gamestate.weaponframe = 0;
player->state = &s_attack;
gamestate.attackframe = 0;
gamestate.attackcount =
attackinfo[gamestate.weapon][gamestate.attackframe].tics;
gamestate.weaponframe =
attackinfo[gamestate.weapon][gamestate.attackframe].frame;
}
This is so that the player can't shoot while he's reloading the weapon.
Below that block, add this one:
::: CODE :::
/*
===============
=
= Cmd_Reload
=
===============
*/
void Cmd_Reload (void)
{
if (gamestate.reloading)
return; // ignore command if already reloading
switch (gamestate.weapon)
{ // don't reload if clip is full or if no ammo left
case wp_pistol:
if (!gamestate.ammo || gamestate.weapon2clip == PISTOLCLIP)
return;
break;
case wp_machinegun:
if (!gamestate.ammo || gamestate.weapon3clip == MACHINEGUNCLIP)
return;
break;
case wp_chaingun:
if (!gamestate.ammo2 || gamestate.weapon4clip == CHAINGUNCLIP)
return;
break;
}
gamestate.weaponframe = 0;
player->state = &s_reload;
gamestate.attackframe = 0;
gamestate.attackcount =
reloadinfo[gamestate.weapon][gamestate.attackframe].tics;
gamestate.weaponframe =
reloadinfo[gamestate.weapon][gamestate.attackframe].frame;
}
This is the command to reload the weapon. It is called whenever the player has emptied a clip or if he has pressed the "R" key. The command is ignored if the clip is already full or if the player has no stored ammo left.
Now go down to the "T_Attack" function. Look for this:
::: CODE :::
switch (cur->attack)
{
case -1:
ob->state = &s_player;
if (!gamestate.ammo)
{
gamestate.weapon = wp_knife;
DrawWeapon ();
}
else
{
if (gamestate.weapon != gamestate.chosenweapon)
{
gamestate.weapon = gamestate.chosenweapon;
DrawWeapon ();
}
};
gamestate.attackframe = gamestate.weaponframe = 0;
return;
case 4:
if (!gamestate.ammo)
break;
if (buttonstate[bt_attack])
gamestate.attackframe -= 2;
case 1:
if (!gamestate.ammo)
{ // can only happen with chain gun
gamestate.attackframe++;
break;
}
GunAttack (ob);
gamestate.ammo--;
DrawAmmo ();
break;
case 2:
KnifeAttack (ob);
break;
case 3:
if (gamestate.ammo && buttonstate[bt_attack])
gamestate.attackframe -= 2;
break;
}
Replace all of it with:
::: CODE :::
switch (cur->attack)
{
case -1:
ob->state = &s_player;
if ((!gamestate.ammo && !gamestate.weapon2clip
&& gamestate.weapon == wp_pistol)
|| (!gamestate.ammo && !gamestate.weapon3clip
&& gamestate.weapon == wp_machinegun)
|| (!gamestate.ammo2 && !gamestate.weapon4clip
&& gamestate.weapon == wp_chaingun))
{
gamestate.weapon = gamestate.chosenweapon = wp_knife;
DrawWeapon ();
}
else
{
if (gamestate.weapon != gamestate.chosenweapon)
{
gamestate.weapon = gamestate.chosenweapon;
DrawWeapon ();
}
};
gamestate.attackframe = gamestate.weaponframe = 0;
switch (gamestate.weapon)
{
case wp_pistol:
if (!gamestate.weapon2clip
&& gamestate.ammo)
Cmd_Reload ();
break;
case wp_machinegun:
if (!gamestate.weapon3clip
&& gamestate.ammo)
Cmd_Reload ();
break;
case wp_chaingun:
if (!gamestate.weapon4clip
&& gamestate.ammo2)
Cmd_Reload ();
break;
}
return;
case 4:
if (!gamestate.weapon4clip)
break;
if (buttonstate[bt_attack])
gamestate.attackframe -= 2;
case 1:
if (!gamestate.weapon4clip
&& gamestate.weapon == wp_chaingun)
{ // can only happen with chain gun
gamestate.attackframe++;
break;
}
GunAttack (ob);
switch (gamestate.weapon)
{
case wp_pistol:
gamestate.weapon2clip--;
break;
case wp_machinegun:
gamestate.weapon3clip--;
break;
case wp_chaingun:
gamestate.weapon4clip--;
break;
}
DrawAmmo ();
break;
case 2:
KnifeAttack (ob);
break;
case 3:
if (gamestate.weapon3clip && buttonstate[bt_attack])
gamestate.attackframe -= 2;
break;
}
I've modified the different "attacks" to use ammo in the clip instead of the stored ammo. If the clip is emptied and there's ammo left, the reload command (Cmd_Reload) is called.
After the "T_Attack" routine, add this one:
::: CODE :::
/*
===============
=
= T_Reload
=
===============
*/
void T_Reload (objtype *ob)
{
struct rloadinf *cur;
UpdateFace ();
if (gamestate.victoryflag) // watching the BJ actor
{
VictorySpin ();
return;
}
ControlMovement (ob);
if (gamestate.victoryflag) // watching the BJ actor
return;
plux = player->x >> UNSIGNEDSHIFT; // scale to fit in unsigned
pluy = player->y >> UNSIGNEDSHIFT;
player->tilex = player->x >> TILESHIFT; // scale to tile values
player->tiley = player->y >> TILESHIFT;
buttonheld[bt_attack] = false;
buttonstate[bt_attack] = false;
gamestate.reloading = true;
//
// change frame and fire
//
gamestate.attackcount -= tics;
while (gamestate.attackcount <= 0)
{
cur = &reloadinfo[gamestate.weapon][gamestate.attackframe];
switch (cur->attack)
{
case -1: // go back to first frame
ob->state = &s_player;
gamestate.reloading = false;
gamestate.attackframe = gamestate.weaponframe = 0;
return;
case 1:
switch (gamestate.weapon)
{
case wp_pistol:
SD_PlaySound (RELOADPISTOLSND);
break;
case wp_machinegun:
SD_PlaySound (RELOADMACHINESND);
break;
case wp_chaingun:
SD_PlaySound (RELOADCHAINGUNSND);
break;
}
break;
case 2:
ReloadWeapon ();
break;
}
gamestate.attackcount += cur->tics;
gamestate.attackframe++;
gamestate.weaponframe =
reloadinfo[gamestate.weapon][gamestate.attackframe].frame;
}
}
This is for the reloading animation. It's basically the same as the "T_Attack" routine, but it has some different actions. "case -1" puts the weapon back to the first frame, "case 1" plays a reloading sound for each weapon, and "case 2" reloads the clip.
Now add another routine below:
::: CODE :::
/*
===============
=
= ReloadWeapon
=
===============
*/
void ReloadWeapon (void)
{
int fullclip,oldclip,newclip,ammotaken,ammostored;
// select type of clip to reload
switch (gamestate.weapon)
{
case wp_pistol:
{
fullclip = PISTOLCLIP;
ammostored = gamestate.ammo;
oldclip = gamestate.weapon2clip;
}
break;
case wp_machinegun:
{
fullclip = MACHINEGUNCLIP;
ammostored = gamestate.ammo;
oldclip = gamestate.weapon3clip;
}
break;
case wp_chaingun:
{
fullclip = CHAINGUNCLIP;
ammostored = gamestate.ammo2;
oldclip = gamestate.weapon4clip;
}
break;
}
// calculate ammo for new clip
ammotaken = fullclip - oldclip;
if (ammotaken > ammostored)
ammotaken = ammostored;
newclip = oldclip + ammotaken;
// load new clip
switch (gamestate.weapon)
{
case wp_pistol:
gamestate.ammo -= ammotaken;
gamestate.weapon2clip = newclip;
break;
case wp_machinegun:
gamestate.ammo -= ammotaken;
gamestate.weapon3clip = newclip;
break;
case wp_chaingun:
gamestate.ammo2 -= ammotaken;
gamestate.weapon4clip = newclip;
break;
}
DrawWeapon ();
DrawAmmo ();
}
This routine calculates how much ammo to put into the clip and how much to subtract from the stored ammo.
Next, in the "T_Player" routine, scroll down to:
::: CODE :::
if ( buttonstate[bt_use] )
Cmd_Use ();
if ( buttonstate[bt_attack] && !buttonheld[bt_attack])
Cmd_Fire ();
Beneath that, add these two lines:
::: CODE :::
if ( Keyboard[sc_R] )
Cmd_Reload ();
This is so that the player can reload his clip whenever he presses the "R" key.
OK, we've gotten far, but we're not done yet!
Open WL_GAME.C and search for:
::: CODE :::
gamestate.ammo = STARTAMMO;
Delete this line and add these:
::: CODE :::
gamestate.ammo = 0;
gamestate.ammo2 = 0;
gamestate.weapon2clip = PISTOLCLIP;
gamestate.weapon3clip = 0;
gamestate.weapon4clip = 0;
gamestate.reloading = false;
Open WL_MAIN.C and repeat the last step. What I've done here is made it so the player starts with one full clip in his pistol and no stored ammo.
Well, that's it for this tutorial! Adding new weapons and ammo types shouldn't be too difficult if you understand how this code works. I hope this information will be useful to someone or at least give them an idea.
Keep Wolfing,
WSJ. |
|
|
 |
KyleRTCW
DieHard Officer

Joined: 30 Jul 2003
Last Visit: 05 Aug 2018
Topics: 45
Posts: 510
Location: Ohio

|
Posted: Sat Apr 17, 2004 2:03 pm
Subject: Re: My Findings on the "Reloading Weapons" Feature
[ IP : Logged ]
|

  
|
|
I'll test it tomorrow probably. Can you make an Exe and an Vswap example? |
_________________ Steam: http://steamcommunity.com/id/stormx312
|
|
 |
KyleRTCW
DieHard Officer

Joined: 30 Jul 2003
Last Visit: 05 Aug 2018
Topics: 45
Posts: 510
Location: Ohio

|
|
 |
jamez
I am Death Incarnate


Joined: 16 Mar 2003
Last Visit: 17 Jan 2019
Topics: 13
Posts: 186
Location: Yorkshire, UK

|
Posted: Sat Apr 17, 2004 3:37 pm
Subject: Re: My Findings on the "Reloading Weapons" Feature
[ IP : Logged ]
|

  
|
|
thats very long compared to mine
i'm planning on releasing it soon |
_________________ ~ James
|
|
 |
KyleRTCW
DieHard Officer

Joined: 30 Jul 2003
Last Visit: 05 Aug 2018
Topics: 45
Posts: 510
Location: Ohio

|
Posted: Sat Apr 17, 2004 4:23 pm
Subject: Re: My Findings on the "Reloading Weapons" Feature
[ IP : Logged ]
|

  
|
|
Current UP Date:
Game Crash and Bugs cause by this tutorial:
- Black and Gray Ceiling
- Game Locks Up Right Before it shoots. Something might be wrong with T_Attack
Current Status: Not Working
UPDATE: I fixed this, solution may not work
I got an error in WL_AGENT.C Undefined symbol '&s_reload'
UPDATE: a possible solution:
Search for
::: CODE :::
statetype s_player = {false,0,0,T_Player,NULL,NULL};
statetype s_attack = {false,0,0,T_Attack,NULL,NULL};
Add beneath that:
::: CODE :::
statetype s_reload = {false,0,0,T_Reload,NULL,NULL};
|
_________________ Steam: http://steamcommunity.com/id/stormx312
|
|
 |
jamez
I am Death Incarnate


Joined: 16 Mar 2003
Last Visit: 17 Jan 2019
Topics: 13
Posts: 186
Location: Yorkshire, UK

|
Posted: Sat Apr 17, 2004 4:55 pm
Subject: Re: Reloading weapons... Same ammo / Seperate ammo (tutorial
[ IP : Logged ]
|

  
|
|
NOTE: There is one error which is when you're firing with the machinegun or chaingun; the weapon keeps on firing and i can't remember how to stop this...
Change the following, explanations at the end
Open wl_agent.c and change the red lines:
::: CODE :::
/*
=============================================================================
LOCAL VARIABLES
=============================================================================
*/
void T_Player (objtype *ob);
void T_Attack (objtype *ob);
void T_Load (objtype *ob);
statetype s_player = {false,0,0,T_Player,NULL,NULL};
statetype s_attack = {false,0,0,T_Attack,NULL,NULL};
statetype s_load = {false,0,0,T_Load,NULL,NULL};
long playerxmove,playerymove;
struct atkinf
{
char tics,attack,frame; // attack is 1 for gun, 2 for knife
} attackinfo[4][14] =
{
{ {6,0,1},{6,2,2},{6,0,3},{6,-1,4} },
{ {6,0,1},{6,1,2},{6,0,3},{6,-1,4} },
{ {6,0,1},{6,1,2},{6,3,3},{6,-1,4} },
{ {6,0,1},{6,1,2},{6,4,3},{6,-1,4} },
},
loadinfo[4][14] =
{
{ {20,0,5},{20,0,6},{20,0,7},{10,-1,8} },
{ {20,0,5},{20,0,6},{20,0,7},{10,-1,8} },
{ {20,0,5},{20,0,6},{20,0,7},{10,-1,8} },
{ {20,0,5},{20,0,6},{20,0,7},{10,-1,8} },
};
In Check weapon change, change the red lines
::: CODE :::
/*
======================
=
= CheckWeaponChange
=
= Keys 1-4 change weapons
=
======================
*/
void CheckWeaponChange (void)
{
int i,buttons;
// if (!gamestate.ammo) // must use knife with no ammo
// return;
for (i=wp_knife ; i<=gamestate.bestweapon ; i++)
if (buttonstate[bt_readyknife+i-wp_knife])
{
gamestate.weapon = gamestate.chosenweapon = i;
DrawWeapon ();
return;
}
if(Keyboard[sc_L]) //Change sc_L to your preferred key
{
if(gamestate.weapon == wp_pistol && gamestate.ammo <= FULLAMMO-1)
{
if(gamestate.ammo2 >=1)
{
if(gamestate.ammo2 >= FULLAMMO-gamestate.ammo)
{
gamestate.oldammo = gamestate.ammo;
gamestate.ammo = FULLAMMO;
gamestate.ammo3 = gamestate.ammo-FULLAMMO;
gamestate.oldammo2 = gamestate.ammo2;
gamestate.ammo2 = (gamestate.oldammo2-(FULLAMMO-gamestate.oldammo));
gamestate.weaponframe=0;
player->state = &s_load;
gamestate.attackframe = 0;
gamestate.attackcount = loadinfo[gamestate.weapon][gamestate.attackframe].tics;
gamestate.weaponframe = loadinfo[gamestate.weapon][gamestate.attackframe].frame;
// SD_PlaySound(YOURSOUNDFORRELOADING);
}
else if(gamestate.ammo3 >= gamestate.ammo2 && gamestate.ammo2!=0)
{
gamestate.oldammo = gamestate.ammo;
gamestate.ammo = gamestate.oldammo+gamestate.ammo2;
gamestate.ammo2 = 0;
gamestate.ammo3 = FULLAMMO-gamestate.ammo;
gamestate.weaponframe=0;
player->state = &s_load;
gamestate.attackframe = 0;
gamestate.attackcount = loadinfo[gamestate.weapon][gamestate.attackframe].tics;
gamestate.weaponframe = loadinfo[gamestate.weapon][gamestate.attackframe].frame;
// SD_PlaySound(YOURSOUNDFORRELOADING);
}
}
}
else if(gamestate.weapon == wp_machinegun && gamestate.ammo4 <= FULLAMMO2-1)
{
if(gamestate.ammo2 >=1)
{
if(gamestate.ammo2 >= FULLAMMO2-gamestate.ammo4)
{
gamestate.oldammo4 = gamestate.ammo4;
gamestate.ammo4 = FULLAMMO2;
gamestate.ammo5 = gamestate.ammo4-FULLAMMO2;
gamestate.oldammo2 = gamestate.ammo2;
gamestate.ammo2 = (gamestate.oldammo2-(FULLAMMO2-gamestate.oldammo4));
gamestate.weaponframe=0;
player->state = &s_load;
gamestate.attackframe = 0;
gamestate.attackcount = loadinfo[gamestate.weapon][gamestate.attackframe].tics;
gamestate.weaponframe = loadinfo[gamestate.weapon][gamestate.attackframe].frame;
// SD_PlaySound(YOURSOUNDFORRELOADING);
}
else if(gamestate.ammo5 >= gamestate.ammo2 && gamestate.ammo2!=0)
{
gamestate.oldammo4 = gamestate.ammo4;
gamestate.ammo4 = gamestate.oldammo4+gamestate.ammo2;
gamestate.ammo2 = 0;
gamestate.ammo5 = FULLAMMO2-gamestate.ammo4;
gamestate.weaponframe=0;
player->state = &s_load;
gamestate.attackframe = 0;
gamestate.attackcount = loadinfo[gamestate.weapon][gamestate.attackframe].tics;
gamestate.weaponframe = loadinfo[gamestate.weapon][gamestate.attackframe].frame;
// SD_PlaySound(YOURSOUNDFORRELOADING);
}
}
}
else if(gamestate.weapon == wp_chaingun && gamestate.ammo6 <= FULLAMMO3-1)
{
if(gamestate.ammo2 >=1)
{
if(gamestate.ammo2 >= FULLAMMO3-gamestate.ammo6)
{
gamestate.oldammo6 = gamestate.ammo6;
gamestate.ammo6 = FULLAMMO3;
gamestate.ammo7 = gamestate.ammo6-FULLAMMO3;
gamestate.oldammo2 = gamestate.ammo2;
gamestate.ammo2 = (gamestate.oldammo2-(FULLAMMO3-gamestate.oldammo6));
gamestate.weaponframe=0;
player->state = &s_load;
gamestate.attackframe = 0;
gamestate.attackcount = loadinfo[gamestate.weapon][gamestate.attackframe].tics;
gamestate.weaponframe = loadinfo[gamestate.weapon][gamestate.attackframe].frame;
// SD_PlaySound(YOURSOUNDFORRELOADING);
}
else if(gamestate.ammo7 >= gamestate.ammo2 && gamestate.ammo2!=0)
{
gamestate.oldammo6 = gamestate.ammo6;
gamestate.ammo6 = gamestate.oldammo6+gamestate.ammo2;
gamestate.ammo2 = 0;
gamestate.ammo7 = FULLAMMO3-gamestate.ammo6;
gamestate.weaponframe=0;
player->state = &s_load;
gamestate.attackframe = 0;
gamestate.attackcount = loadinfo[gamestate.weapon][gamestate.attackframe].tics;
gamestate.weaponframe = loadinfo[gamestate.weapon][gamestate.attackframe].frame;
// SD_PlaySound(YOURSOUNDFORRELOADING);
}
}
}
DrawAmmo();
}
} //Check weapon change
In draw ammo, you'll need to find a neat space for the ammo counters to sit.. These numbers should be changed but this can be easily set up like so:
::: CODE :::
/*
===============
=
= DrawAmmo
=
===============
*/
void DrawAmmo (void)
{
#define PLACEX1 22
#define PLACEY1 8
#define PLACEX2 28
#define PLACEY2 18
switch(gamestate.weapon){
case wp_pistol:
LatchNumber (PLACEX1,PLACEY1,2,gamestate.ammo);
break;
case wp_machinegun:
LatchNumber (PLACEX1,PLACEY1,2,gamestate.ammo4);
break;
case wp_chaingun:
LatchNumber (PLACEX1,PLACEY1,2,gamestate.ammo6);
break;
}
LatchNumber (PLACEX2,PLACEY2,2,gamestate.ammo2);
}
Change this in GiveAmmo
::: CODE :::
/*
===============
=
= GiveAmmo
=
===============
*/
void GiveAmmo (int ammo2)
{
if (!gamestate.ammo2) // knife was out
{
if (!gamestate.attackframe)
{
gamestate.weapon = gamestate.chosenweapon;
DrawWeapon ();
}
}
gamestate.ammo2 += ammo2;
if (gamestate.ammo2 > 99)
gamestate.ammo2 = 99;
DrawAmmo ();
}
And in the GetBonus:
::: CODE :::
case bo_clip:
if (gamestate.ammo2 == 99)
return;
SD_PlaySound (GETAMMOSND);
GiveAmmo (8);
break;
case bo_clip2:
if (gamestate.ammo2 == 99)
return;
SD_PlaySound (GETAMMOSND);
GiveAmmo (4);
break;
The whole of CMD_FIRE needs to be changed like so:
::: CODE :::
/*
===============
=
= Cmd_Fire
=
===============
*/
void Cmd_Fire (void)//verdammt
{
switch (gamestate.weapon)
{
case wp_pistol:
if(!gamestate.ammo)
{
if(gamestate.ammo==0)
{
if(gamestate.ammo2 >= FULLAMMO)
{
gamestate.oldammo2 = gamestate.ammo2;
gamestate.ammo2 = gamestate.oldammo2-FULLAMMO;
gamestate.ammo = FULLAMMO;
gamestate.ammo3 = 0;
gamestate.weaponframe=0;
player->state = &s_load;
gamestate.attackframe = 0;
gamestate.attackcount = loadinfo[gamestate.weapon][gamestate.attackframe].tics;
gamestate.weaponframe = loadinfo[gamestate.weapon][gamestate.attackframe].frame;
// SD_PlaySound(YOURSOUNDFORRELOADING);
}
else if(gamestate.ammo2 <= FULLAMMO-1)
{
if(!gamestate.ammo2)
{
gamestate.ammo3 = FULLAMMO;
}
else
{
gamestate.ammo3 = FULLAMMO-gamestate.ammo2;
gamestate.oldammo2 = gamestate.ammo2;
gamestate.ammo2 = gamestate.oldammo2-(FULLAMMO-gamestate.ammo3);
gamestate.ammo = FULLAMMO-gamestate.ammo3;
gamestate.weaponframe=0;
player->state = &s_load;
gamestate.attackframe = 0;
gamestate.attackcount = loadinfo[gamestate.weapon][gamestate.attackframe].tics;
gamestate.weaponframe = loadinfo[gamestate.weapon][gamestate.attackframe].frame;
// SD_PlaySound(YOURSOUNDFORRELOADING);
}
}
}
if(gamestate.ammo==0 && gamestate.ammo2 == 0)
{
gamestate.weapon = gamestate.chosenweapon=wp_knife;
DrawWeapon();
// SD_PlaySound(WEAPONCLICKSND);
}
DrawAmmo();
return;
}
break;
case wp_machinegun:
if(!gamestate.ammo4)
{
if(gamestate.ammo4==0)
{
if(gamestate.ammo2 >= FULLAMMO2)
{
gamestate.oldammo2 = gamestate.ammo2;
gamestate.ammo2 = gamestate.oldammo2-FULLAMMO2;
gamestate.ammo4 = FULLAMMO2;
gamestate.ammo5 = 0;
gamestate.weaponframe=0;
player->state = &s_load;
gamestate.attackframe = 0;
gamestate.attackcount = loadinfo[gamestate.weapon][gamestate.attackframe].tics;
gamestate.weaponframe = loadinfo[gamestate.weapon][gamestate.attackframe].frame;
// SD_PlaySound(YOURSOUNDFORRELOADING);
}
else if(gamestate.ammo2 <= FULLAMMO2-1)
{
if(!gamestate.ammo2)
{
gamestate.ammo5 = FULLAMMO2;
}
else
{
gamestate.ammo5 = FULLAMMO2-gamestate.ammo2;
gamestate.oldammo2 = gamestate.ammo2;
gamestate.ammo2 = gamestate.oldammo2-(FULLAMMO2-gamestate.ammo5);
gamestate.ammo = FULLAMMO2-gamestate.ammo5;
gamestate.weaponframe=0;
player->state = &s_load;
gamestate.attackframe = 0;
gamestate.attackcount = loadinfo[gamestate.weapon][gamestate.attackframe].tics;
gamestate.weaponframe = loadinfo[gamestate.weapon][gamestate.attackframe].frame;
// SD_PlaySound(YOURSOUNDFORRELOADING);
}
}
}
if(gamestate.ammo4==0 && gamestate.ammo2 == 0)
{
gamestate.weapon = gamestate.chosenweapon=wp_knife;
DrawWeapon();
// SD_PlaySound(WEAPONCLICKSND);
}
DrawAmmo();
return;
}
break;
case wp_chaingun:
if(!gamestate.ammo6)
{
if(gamestate.ammo6==0)
{
if(gamestate.ammo2 >= FULLAMMO3)
{
gamestate.oldammo2 = gamestate.ammo2;
gamestate.ammo2 = gamestate.oldammo2-FULLAMMO3;
gamestate.ammo6 = FULLAMMO3;
gamestate.ammo7 = 0;
gamestate.weaponframe=0;
player->state = &s_load;
gamestate.attackframe = 0;
gamestate.attackcount = loadinfo[gamestate.weapon][gamestate.attackframe].tics;
gamestate.weaponframe = loadinfo[gamestate.weapon][gamestate.attackframe].frame;
// SD_PlaySound(YOURSOUNDFORRELOADING);
}
else if(gamestate.ammo2 <= FULLAMMO3-1)
{
if(!gamestate.ammo2)
{
gamestate.ammo7 = FULLAMMO3;
}
else
{
gamestate.ammo7 = FULLAMMO3-gamestate.ammo2;
gamestate.oldammo2 = gamestate.ammo2;
gamestate.ammo2 = gamestate.oldammo2-(FULLAMMO3-gamestate.ammo7);
gamestate.ammo6 = FULLAMMO3-gamestate.ammo7;
gamestate.weaponframe=0;
player->state = &s_load;
gamestate.attackframe = 0;
gamestate.attackcount = loadinfo[gamestate.weapon][gamestate.attackframe].tics;
gamestate.weaponframe = loadinfo[gamestate.weapon][gamestate.attackframe].frame;
// SD_PlaySound(YOURSOUNDFORRELOADING);
}
}
}
if(gamestate.ammo6==0 && gamestate.ammo2 == 0)
{
gamestate.weapon = gamestate.chosenweapon=wp_knife;
DrawWeapon();
// SD_PlaySound(WEAPONCLICKSND);
}
DrawAmmo();
return;
}
break;
} //switch weapon
if(!buttonheld[bt_attack]){
buttonheld[bt_attack] = true;
gamestate.weaponframe = 0;
player->state = &s_attack;
gamestate.attackframe = 0;
gamestate.attackcount =
attackinfo[gamestate.weapon][gamestate.attackframe].tics;
gamestate.weaponframe =
attackinfo[gamestate.weapon][gamestate.attackframe].frame;
}}
T_Attack needs a few changes:
::: CODE :::
case -1:
ob->state = &s_player;
if (!gamestate.ammo[color="red] || !gamestate.ammo4 || !gamestate.ammo6[/color])
{
gamestate.weapon = wp_knife;
DrawWeapon ();
}
..........
case 4:
if (!gamestate.ammo6)
if (!gamestate.ammo4)
if (!gamestate.ammo)
break;
if (buttonstate[bt_attack])
gamestate.attackframe -= 2;
case 1:
if(!gamestate.ammo6)
if(!gamestate.ammo4)
if(!gamestate.ammo)
{ // can only happen with chain gun
gamestate.attackframe++;
break;
}
GunAttack (ob);
switch (gamestate.weapon)
{
case wp_pistol:
gamestate.ammo--;
gamestate.ammo3++;//verdammt
break;
case wp_machinegun:
gamestate.ammo4--;
gamestate.ammo5++;
break;
case wp_chaingun:
gamestate.ammo6--;
gamestate.ammo7++;
break;
}
DrawAmmo ();
break;
And fianally for wl_agent.c, T_Load. This needs to be added somewhere at the bottom like after T_Attack or T_Player
::: CODE :::
void T_Load (objtype *ob)
{
struct atkinf *cur;
UpdateFace ();
if (gamestate.victoryflag) // watching the BJ actor
{
VictorySpin ();
return;
}
ControlMovement (ob);
if (gamestate.victoryflag) // watching the BJ actor
return;
plux = player->x >> UNSIGNEDSHIFT; // scale to fit in unsigned
pluy = player->y >> UNSIGNEDSHIFT;
player->tilex = player->x >> TILESHIFT; // scale to tile values
player->tiley = player->y >> TILESHIFT;
//
// change frame and fire
//
gamestate.loadcount -= tics;
while (gamestate.loadcount <= 0)
{
cur = &loadinfo[gamestate.weapon][gamestate.attackframe];
switch (cur->attack)
{
case -1:
ob->state = &s_player;
gamestate.attackframe = gamestate.weaponframe=0;
return;
}
gamestate.loadcount += cur->tics;
gamestate.attackframe++;
gamestate.weaponframe =
loadinfo[gamestate.weapon][gamestate.attackframe].frame;
}
}
Now open wl_def.h and search for STARTAMMO... Add the lines:
::: CODE :::
#define STARTAMMO 8
#define FULLAMMO 8
#define FULLAMMO2 16
#define FULLAMMO3 32
In the gamestate structure...
::: CODE :::
//---------------
//
// gamestate structure
//
//---------------
typedef struct
{
int ammo2;
int ammo3;
int ammo4;
int ammo5;
int ammo6;
int ammo7;
int oldammo;
int oldammo2;
int oldammo3;
int oldammo4;
int oldammo5;
int oldammo6;
int oldammo7;
int difficulty;
...........
int attackframe,attackcount,weaponframe,loadframe,loadcount;
Now thats it, although we need to set up some SPRITES... So open wl_def.h again and locate these lines:
::: CODE :::
//
// player attack frames
//
SPR_KNIFEREADY,SPR_KNIFEATK1,SPR_KNIFEATK2,SPR_KNIFEATK3,
SPR_KNIFEATK4,
SPR_PISTOLREADY,SPR_PISTOLATK1,SPR_PISTOLATK2,SPR_PISTOLATK3,
SPR_PISTOLATK4,
SPR_MACHINEGUNREADY,SPR_MACHINEGUNATK1,SPR_MACHINEGUNATK2,MACHINEGUNATK3,
SPR_MACHINEGUNATK4,
SPR_CHAINREADY,SPR_CHAINATK1,SPR_CHAINATK2,SPR_CHAINATK3,
SPR_CHAINATK4,
And now add the red lines:
::: CODE :::
SPR_KNIFEREADY,SPR_KNIFEATK1,SPR_KNIFEATK2,SPR_KNIFEATK3,
SPR_KNIFEATK4,
SPR_PISTOLREADY,SPR_PISTOLATK1,SPR_PISTOLATK2,SPR_PISTOLATK3,
SPR_PISTOLATK4,SPR_PRELOAD1,SPR_PRELOAD2,SPR_KPELOAD3,
SPR_PRELOAD4,
SPR_MACHINEGUNREADY,SPR_MACHINEGUNATK1,SPR_MACHINEGUNATK2,MACHINEGUNATK3,
SPR_MACHINEGUNATK4,SPR_MRELOAD1,SPR_MRELOAD2,SPR_MRELOAD3,
SPR_MRELOAD4,
SPR_CHAINREADY,SPR_CHAINATK1,SPR_CHAINATK2,SPR_CHAINATK3,
SPR_CHAINATK4,SPR_CRELOAD1,SPR_CRELOAD2,SPR_CRELOAD3,
SPR_CRELOAD4,
You will also need to have in your VSWAP images like so:
"WEAPONREADY - WEAPONFIRE1 - WEAPONFIRE2 - WEAPONFIRE3 - WEAPONFIRE4 - WEAPONRELOAD1 - WEAPONRELOAD2 - WEAPONRELOAD3 - WEAPONRELOAD4"
Now thats over here's what you need to know:
- When you set cheats, never define what gamestate.ammo or gamestate.ammo(3/4/5/6/7) are... Just define what gamestate.ammo2 is... This included wl_play.c
- To change the position of the counters on the status bar - change the 'defines' in DrawAmmo
- To change the max amount to be loaded, change the define in wl_def.h like so:
- FULLAMMO - FOr the pistol
- FULLAMMO2 - For the machinegun
- FULLAMMO3 - For the chaingun
- To activate a reloading sound, where ever it says:
Quote:
// SD_PlaySound(YOURSOUNDFORRELOADING);
Take out the "//" and change the "YOURSOUNDFORRELOADING" to .. er your sound for reloading! This is the same for WEAPONCLICKSND... (thats when you have no ammo and you switch to the knife...)
- To change how many reloads for a certain weapon change the sprites and change loadinfo like so:
::: CODE :::
loadinfo[4][14] =
{
{ {20,0,5},{20,0,6},{20,0,7},{20,0,8},{10,-1,9} }, - This does 5 reloads...
{ {20,0,5},{20,0,6},{20,0,7},{20,0,8},{10,0,9},{10,-1,10} }, - This does 6
{ {20,0,5},{10,-1,6} }, - This does 2
{ {20,0,5},{20,0,6},{20,0,7},{10,-1,8} }, - This does 4
};
There are bound to be errors or typos, please post up here if there are any.... This will be rewritten again (again) for my new site.. The new version will have exes and images etc...
Edited 3 Times by Jamez |
_________________ ~ James
|
|
 |
jamez
I am Death Incarnate


Joined: 16 Mar 2003
Last Visit: 17 Jan 2019
Topics: 13
Posts: 186
Location: Yorkshire, UK

|
|
 |
KyleRTCW
DieHard Officer

Joined: 30 Jul 2003
Last Visit: 05 Aug 2018
Topics: 45
Posts: 510
Location: Ohio

|
|
 |
jamez
I am Death Incarnate


Joined: 16 Mar 2003
Last Visit: 17 Jan 2019
Topics: 13
Posts: 186
Location: Yorkshire, UK

|
|
 |
KyleRTCW
DieHard Officer

Joined: 30 Jul 2003
Last Visit: 05 Aug 2018
Topics: 45
Posts: 510
Location: Ohio

|
Posted: Sun Apr 18, 2004 5:11 am
Subject: Re: Reloading weapons... Same ammo / Seperate ammo (tutorial
[ IP : Logged ]
|

  
|
|
Ok the code didn't work.
First, the code doesn't even give you a chance to reload, which is what this whole tutorial is about.
The code doesn't stop the ammo from going below 0 when hold down the fire key.
I hope we can get this fixed. |
_________________ Steam: http://steamcommunity.com/id/stormx312
|
|
 |
jamez
I am Death Incarnate


Joined: 16 Mar 2003
Last Visit: 17 Jan 2019
Topics: 13
Posts: 186
Location: Yorkshire, UK

|
Posted: Sun Apr 18, 2004 5:17 am
Subject: Re: My Findings on the "Reloading Weapons" Feature
[ IP : Logged ]
|

  
|
|
I don't see it in your code, but when you run out of loaded ammo and press Ctrl, does it reload automatically, or can you only reload by pressing R? |
_________________ ~ James
|
|
 |
jamez
I am Death Incarnate


Joined: 16 Mar 2003
Last Visit: 17 Jan 2019
Topics: 13
Posts: 186
Location: Yorkshire, UK

|
Posted: Sun Apr 18, 2004 5:53 am
Subject: Re: Reloading weapons... Same ammo / Seperate ammo (tutorial
[ IP : Logged ]
|

  
|
|
Quote:
The code doesn't even give you a chance to reload
Well this exact code works for me
Quote:
The code doesn't stop the ammo from going below 0
I said that, that's what my last post was supposed to stop, although it wasn't tested
And ammo3/5/7 are kinda like the opposite of ammo, ammo4 and ammo6
The pistol is set to 8, so when you start you have 8 loaded (ammo), 0 unloaded (ammo2) and 0 hidden (ammo3)
When you fire ammo3 goes up 1 so you have this:
Ammo | ammo3
8 / 0
7 / 1
6 / 2
5 / 3
4 / 4
3 / 5
2 / 6
1 / 7
0 / 8
This is how the code knows how many to "reload"...
So if your ammo is 3 and therefore ammo3 is 5 - The code loads up 5 onto the ammo, turns ammo3 back to 0 and takes 5 away from ammo2... But if ammo2 doesn't have 5 to load, it will load what ever it has, so another example:
You have:
Pistol (8 max loaded):
3 loaded ammo (ammo)
3 unloaded ammo (ammo2)
5 hidden (ammo3)
you press L to load and it does this:
loads the 3 unloaded to the 3 loaded - giving 6 and then takes 3 off the hidden so that it's now 2; so if you collect some more ammo - say 6, it's ready for a full reload..
I'm sorry if this is too hard to understand... you need to think it up your self when it's as confusing as this to know whats going on |
_________________ ~ James
|
|
 |
KyleRTCW
DieHard Officer

Joined: 30 Jul 2003
Last Visit: 05 Aug 2018
Topics: 45
Posts: 510
Location: Ohio

|
Posted: Sun Apr 18, 2004 6:01 am
Subject: Re: Reloading weapons... Same ammo / Seperate ammo (tutorial
[ IP : Logged ]
|

  
|
|
whoa, you are genuis jamez, how could you do that? That was hard to understand.
I'll keep searching for my typos. Thanks for the tutorial! |
_________________ Steam: http://steamcommunity.com/id/stormx312
|
|
 |
jamez
I am Death Incarnate


Joined: 16 Mar 2003
Last Visit: 17 Jan 2019
Topics: 13
Posts: 186
Location: Yorkshire, UK

|
Posted: Sun Apr 18, 2004 6:42 am
Subject: Re: Reloading weapons... Same ammo / Seperate ammo (tutorial
[ IP : Logged ]
|

  
|
|
Yea, you think tahts confusing, my once for seperate ammo is far worse...  |
_________________ ~ James
|
|
 |
WSJ
DieHard Officer

Joined: 17 Apr 2004
Last Visit: 30 Nov 2017
Topics: 24
Posts: 521

|
|
 |
Codetech84
Code Master

Joined: 12 Mar 2003
Last Visit: 27 Aug 2018
Topics: 22
Posts: 1284
Location: Rauma - Finland

|
|
 |
jamez
I am Death Incarnate


Joined: 16 Mar 2003
Last Visit: 17 Jan 2019
Topics: 13
Posts: 186
Location: Yorkshire, UK

|
Posted: Tue May 11, 2004 2:29 pm
Subject: Re: Reloading weapons... Same ammo / Seperate ammo (tutorial
[ IP : Logged ]
|

  
|
|
maybe ill write a non rushed and a user friendly 'all in one' version  |
_________________ ~ James
|
|
 |
Codetech84
Code Master

Joined: 12 Mar 2003
Last Visit: 27 Aug 2018
Topics: 22
Posts: 1284
Location: Rauma - Finland

|
Posted: Fri May 14, 2004 1:06 am
Subject: Re: Reloading weapons... Same ammo / Seperate ammo (tutorial
[ IP : Logged ]
|

  
|
|
I think Haunted House reloading code was even longer than this one...
I did reloading and inventory back in 2001 or something, we just wanted to utilise them in Haunted House. |
_________________ Click here to visit KFH Games website!
*UPDATED* Spear of Destiny Reloaded
KFH Games on Facebook
|
|
 |
lucky_foot
Don't Hurt Me


Joined: 05 Nov 2004
Last Visit: 19 Sep 2010
Topics: 13
Posts: 69
Location: Pennsylvania

|
Posted: Thu Apr 28, 2005 8:02 am
Subject: Re: My Findings on the "Reloading Weapons" Feature
[ IP : Logged ]
|

  
|
|
So, if I follow the direction to the letter and make the changes that are stated, then the code should work? |
_________________ JonathanS
Lucky foot Productions
www.luckyfootproductions.jtworld.net
|
|
 |
WSJ
DieHard Officer

Joined: 17 Apr 2004
Last Visit: 30 Nov 2017
Topics: 24
Posts: 521

|
Posted: Thu Apr 28, 2005 1:43 pm
Subject: Re: My Findings on the "Reloading Weapons" Feature
[ IP : Logged ]
|

  
|
|
Which code are you talking about? Mine or Jamez's? |
|
|
 |
lucky_foot
Don't Hurt Me


Joined: 05 Nov 2004
Last Visit: 19 Sep 2010
Topics: 13
Posts: 69
Location: Pennsylvania

|
Posted: Thu Apr 28, 2005 2:34 pm
Subject: Re: My Findings on the "Reloading Weapons" Feature
[ IP : Logged ]
|

  
|
|
I believe it was yours, WSJ. |
_________________ JonathanS
Lucky foot Productions
www.luckyfootproductions.jtworld.net
|
|
 |
WSJ
DieHard Officer

Joined: 17 Apr 2004
Last Visit: 30 Nov 2017
Topics: 24
Posts: 521

|
Posted: Thu Apr 28, 2005 6:14 pm
Subject: Re: My Findings on the "Reloading Weapons" Feature
[ IP : Logged ]
|

  
|
|
Well, it's been a little over a year since I wrote it, but I think it will work... except there was one small code change I made but forgot to include in the tutorial. Kyle points it out here...
KyleRTCW wrote:
Search for
::: CODE :::
statetype s_player = {false,0,0,T_Player,NULL,NULL};
statetype s_attack = {false,0,0,T_Attack,NULL,NULL};
Add beneath that:
::: CODE :::
statetype s_reload = {false,0,0,T_Reload,NULL,NULL};
Also, like I said in the tutorial, you want to be careful when adding all this stuff, because there's a TON of changes involved... But I tested the tutorial myself and it worked for me. |
|
|
 |
wolf3dbreaker
I am Death Incarnate


Joined: 09 Jun 2003
Last Visit: 29 Sep 2009
Topics: 31
Posts: 196
Location: Philippines

|
Posted: Sun May 01, 2005 4:55 am
Subject: Re: My Findings on the "Reloading Weapons" Feature
[ IP : Logged ]
|

  
|
|
To tell you the truth, I kept asking codetech on helping me out with this. Unfortunately, he refused so I came up with my own way. It's shorter than yours WSJ. |
_________________ Gone from the community for a while. Will be back on July
|
|
 |
thellt
Bring 'em On

Joined: 21 Jan 2008
Last Visit: 12 May 2009
Topics: 11
Posts: 85
Location: bloodgulch

|
Posted: Fri Jun 13, 2008 10:30 am
Subject: "Reloading Weapons" Feature
[ IP : Logged ]
|

  
|
|
is the tutorial even compatible with the weapon bobbers and other weapon tutorials? (by bobbers i mean the one where you walk and it moves AND the switch weapon bob?)
(i need to do some more c++ this s*** is complicated!) |
_________________ }{even or }{ellt?
look for helt3d
|
|
 |
RichterBelmont12
DieHard Wolfer


Joined: 14 Aug 2004
Last Visit: 12:15 ago.
Topics: 98
Posts: 1516
Location: New Jersey

|
|
 |
thellt
Bring 'em On

Joined: 21 Jan 2008
Last Visit: 12 May 2009
Topics: 11
Posts: 85
Location: bloodgulch

|
Posted: Mon Jul 07, 2008 4:08 pm
Subject: Re: My Findings on the "Reloading Weapons" Feature
[ IP : Logged ]
|

 
|
|
i just tried it with a new weapon and other tutorials i got earlier last school year and got 158209480.....etc. (you get the picture...) errors... lol i should print my compiler screeenshot here... (noooo! i want reload in my game but dont know how to incorperate it with the "start with knife tutorial", and other fun tutorials... halp me someone!) { |
_________________ }{even or }{ellt?
look for helt3d
|
|
 |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum
|
|
You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
Copyright ©2003-2008 DieHard Wolfers
A Modified subBunker Theme by BrotherTank
Powered by phpBB © 2001, 2005 phpBB Group
|