| Author |
Message |
WLHack
DieHard Wolfer


Joined: 10 Jul 2005
Last Visit: 2:04 ago.
Topics: 60
Posts: 1138
Location: Loppi - Finland

|
Posted: Sun Sep 04, 2005 1:55 pm
Subject: [Help] Problems with weapon and ammo
[ IP : Logged ]
|

 
|
|
I have added new weapon but there is trange bug appearing,
when I pick up the item I can use it like normal weapon but
when I change to another weapon I can't change back the
weapon I added.
I have also added new GiveAmmo routine to support new ammotype
but I cannot shoot with the weapon using it if I haven't got ammo in
the other weapons too (and it seems like there can be unlimited amount
of ammo to this new ammotype).
Can anyone help me solve this/these problem/s? |
|
|
|
 |
Dugtrio17
Code Master

Joined: 12 Mar 2003
Last Visit: 26 Jan 2010
Topics: 45
Posts: 833
Location: North Carolina

|
Posted: Sun Sep 04, 2005 4:47 pm
Subject: Re: [Help] Problems with weapon and ammo
[ IP : Logged ]
|

  
|
|
| Let's have a look at your WL_AGENT.C file. I'd specify a few functions, but for all we know it could be anywhere in it. |
_________________ There's a bomb in my stomach, you think I'm afraid of a little many-mouthed acid demon?
|
|
 |
WLHack
DieHard Wolfer


Joined: 10 Jul 2005
Last Visit: 2:04 ago.
Topics: 60
Posts: 1138
Location: Loppi - Finland

|
Posted: Sun Sep 04, 2005 8:44 pm
Subject: Re: [Help] Problems with weapon and ammo
[ IP : Logged ]
|

  
|
|
Maybe I could sent my WL_AGENT_C file if someone is interested to take
a deeper look on it so the problems could be located and removed. |
|
|
|
 |
WLHack
DieHard Wolfer


Joined: 10 Jul 2005
Last Visit: 2:04 ago.
Topics: 60
Posts: 1138
Location: Loppi - Finland

|
Posted: Mon Sep 05, 2005 7:48 pm
Subject: Re: [Help] Problems with weapon and ammo
[ IP : Logged ]
|

  
|
|
Now nearly all the strange problems with ammo and weapons are solved.
Still I ask if anyone can help the "bug" appearing with the fifth gun
(when I pick up the item I can use it like normal weapon but
when I change to another weapon I can't change back the
weapon I added). |
|
|
|
 |
Codetech84
Code Master

Joined: 12 Mar 2003
Last Visit: 2:12 ago.
Topics: 16
Posts: 1017
Location: Rauma - Finland

|
Posted: Tue Sep 06, 2005 2:55 pm
Subject: Re: [Help] Problems with weapon and ammo
[ IP : Logged ]
|

  
|
|
It seems your bug is in CheckWeaponChange function in WL_AGENT.C...
Let's have a look at it  |
_________________ Click here to visit KFH Games website!
*NEW* Spear of Destiny Reloaded
|
|
 |
WLHack
DieHard Wolfer


Joined: 10 Jul 2005
Last Visit: 2:04 ago.
Topics: 60
Posts: 1138
Location: Loppi - Finland

|
Posted: Tue Sep 06, 2005 4:37 pm
Subject: Re: [Help] Problems with weapon and ammo
[ IP : Logged ]
|

  
|
|
| I haven't done any chances to it. Can you tell how should I chance it. |
|
|
|
 |
Hair Machine
DieHard SS


Joined: 24 Nov 2003
Last Visit: 15 Dec 2009
Topics: 8
Posts: 394
Location: Nodnol, Sdrawkcab

|
|
 |
WLHack
DieHard Wolfer


Joined: 10 Jul 2005
Last Visit: 2:04 ago.
Topics: 60
Posts: 1138
Location: Loppi - Finland

|
Posted: Tue Sep 06, 2005 7:46 pm
Subject: Re: [Help] Problems with weapon and ammo
[ IP : Logged ]
|

  
|
|
Thanks Hair Machine, finally I got rid of that bug.
Thank you again. |
|
|
|
 |
WLHack
DieHard Wolfer


Joined: 10 Jul 2005
Last Visit: 2:04 ago.
Topics: 60
Posts: 1138
Location: Loppi - Finland

|
|
 |
Chris
DieHard Wolfer


Joined: 12 Mar 2003
Last Visit: 08 Feb 2010
Topics: 37
Posts: 1344
Location: Canada

|
Posted: Mon Sep 12, 2005 5:40 pm
Subject: Re: [Help] Problems with weapon and ammo
[ IP : Logged ]
|

  
|
|
Ok man, I'd first recommend that you restrict ammo from subtracting when it's 0, then change the weapon so they can't use it.
Here's an example: http://diehardwolfers.areyep.com/viewtopic.php?t=2181&start=60#7
If you still get the infinate ammo bug, then your code probably isn't reaching parts of your switch at all for some reason (but I don't know how you have gamestate.ammo2 and wp_stengun set up, and how many weapons have this bug, so I probably couldn't be too much help yet in this case). |
|
|
|
 |
WLHack
DieHard Wolfer


Joined: 10 Jul 2005
Last Visit: 2:04 ago.
Topics: 60
Posts: 1138
Location: Loppi - Finland

|
Posted: Mon Sep 12, 2005 6:48 pm
Subject: Re: [Help] Problems with weapon and ammo
[ IP : Logged ]
|

  
|
|
Well this didn't work but thanks anyway. Umm... I also noticed that
this bug appears only if I have a weapon using ammo1 and a weapon
using ammo2 at the same time, otherwise it won't appear.
This I mean that if I only got pistol or machinegun (ammo1) I can shoot
them till I run out of ammo and then the game chances weapon to knife
till I found more ammo.
If I only got chaingun and stengun (ammo2) I can shoot them till I run out of
ammo etc... etc...
My gamestate.ammo2, is nearly a exact copy of gamestate.ammo,
only difference is it use GiveAmmo2 and DrawAmmo2 to handle weapon
firing rate. |
|
|
|
 |
Chris
DieHard Wolfer


Joined: 12 Mar 2003
Last Visit: 08 Feb 2010
Topics: 37
Posts: 1344
Location: Canada

|
Posted: Mon Sep 12, 2005 7:55 pm
Subject: Re: [Help] Problems with weapon and ammo
[ IP : Logged ]
|

  
|
|
I'm still confused about one thing. So you're saying, when you have ammo in both, it doesn't switch to the knife; and instead keeps firing? The ammo still decreases to 0 though right? Or does it not decrease at all for either ammo or ammo2 (or both) when you have ammo in both types?
If it's the former, maybe you have a "!gamestate.ammo && !gamestate.ammo2" if statement somewhere that's suppose to be something else like "||"; or vice versa? If the latter, maybe you have something that also increases the ammo when it decreases it? I don't know, but either of these would be easy to fix; you can even cheat and just add another line of code to restrict those from happening if you really want.
Would be easier to see your entire T_Attack function, and maybe some other sections that you changed; just to see what you did. With a little work at trying to understand what you did (and understanding what everything you did causes), I'm sure you/we can fix this bug pretty easily. |
|
|
|
 |
WLHack
DieHard Wolfer


Joined: 10 Jul 2005
Last Visit: 2:04 ago.
Topics: 60
Posts: 1138
Location: Loppi - Finland

|
|
 |
Chris
DieHard Wolfer


Joined: 12 Mar 2003
Last Visit: 08 Feb 2010
Topics: 37
Posts: 1344
Location: Canada

|
Posted: Mon Sep 12, 2005 10:18 pm
Subject: Re: [Help] Problems with weapon and ammo
[ IP : Logged ]
|

  
|
|
Ok, from what I can tell, your "case -1" should probably start with something more like:
::: CODE :::
case -1:
ob->state = &s_player;
if (!gamestate.ammo || !gamestate.ammo2)
{
if (gamestate.ammo)
if (gamestate.weapon >= wp_chaingun)
gamestate.weapon = wp_pistol;
else
if (!gamestate.ammo2)
gamestate.weapon = wp_knife;
// DrawWeapon ();
}
else
::: CODE :::
case -1:
if (gamestate.ammo < 0) gamestate.ammo = 0;
if (gamestate.ammo2 < 0) gamestate.ammo2 = 0;
ob->state = &s_player;
The blue code just takes into consideration if your ammo is below 0 once you stop shooting (which shouldn't be needed if the other cases work correctly), but I thought I'd post it anyway if you wanted to test it somewhere. The red code will switch your weapon to something lower if you have no ammo in your current weapon (I don't know how you're detecting if a player has gotten the machine gun, so I just kept it as wp_pistol when you run out of ammo2).
I'm not too sure about your "case 4" and "case 1" either; I'd probably change them to something like this:
::: CODE :::
case 4:
if (gamestate.weapon >= wp_chaingun && !gamestate.ammo2)
break;
if (buttonstate[bt_attack])
gamestate.attackframe -= 2;
case 1:
if (gamestate.weapon >= wp_chaingun && !gamestate.ammo2)
{ // can only happen with chain gun
gamestate.attackframe++;
break;
}
GunAttack (ob);
You may want to change the ">= wp_chaingun to "== wp_chaingun" if you find that the stengun isn't acting the way you wanted. At first I would have added some extra "gamestate.weapon < wp_chaingun && !gamestate.ammo" expressions to those if statements, but it doesn't look like it matters for either (since chaingun is the only one that spits out two shots in one sitting and the rest is caught by "case -1").
If you can still press 2 or 4 (for example) when you have 0 ammo, you might need to alter the line Hair Machine posted a little as well:
::: CODE :::
void CheckWeaponChange (void)
{
int i,buttons;
// this check removed because it's detected below
switch (LastScan)
{
case 2:
LastScan=0;
gamestate.weapon = gamestate.chosenweapon = wp_knife;
break;
case 3:
LastScan=0;
if (gamestate.ammo)
gamestate.weapon = gamestate.chosenweapon = wp_pistol;
break;
case 4:
LastScan=0;
if (gamestate.bestweapon >= wp_machinegun && gamestate.ammo)
gamestate.weapon = gamestate.chosenweapon = wp_machinegun;
break;
case 5:
LastScan=0;
if (gamestate.bestweapon >= wp_chaingun && gamestate.ammo2)
gamestate.weapon = gamestate.chosenweapon = wp_chaingun;
break;
case 6:
LastScan=0;
if (gamestate.bestweapon >= wp_stengun && gamestate.ammo2)
gamestate.weapon = gamestate.chosenweapon = wp_stengun;
break;
}
DrawWeapon();
}
Well anyway, let me know if those ideas make things run better, or what happends after you use them.
edit: Somehow I erased this post when trying to make a new one, but managed to recover it from a backup window. Heh. |
Last edited by Chris on Wed Sep 14, 2005 5:34 pm; edited 4 times in total
|
|
 |
WLHack
DieHard Wolfer


Joined: 10 Jul 2005
Last Visit: 2:04 ago.
Topics: 60
Posts: 1138
Location: Loppi - Finland

|
Posted: Tue Sep 13, 2005 2:29 pm
Subject: Re: [Help] Problems with weapon and ammo
[ IP : Logged ]
|

  
|
|
Well, now weapons chaingun and stengun works properly
but pistol and machinegun has still got the same problem,
but again thank Chris. |
|
|
|
 |
Chris
DieHard Wolfer


Joined: 12 Mar 2003
Last Visit: 08 Feb 2010
Topics: 37
Posts: 1344
Location: Canada

|
Posted: Wed Sep 14, 2005 5:27 pm
Subject: Re: [Help] Problems with weapon and ammo
[ IP : Logged ]
|

  
|
|
Ok, cool WLHack.
What happends when you add the lines in blue above "ob->state = &s_player"? Does it make the pistol work any better?
Chris wrote:
At first I would have added some extra "gamestate.weapon < wp_chaingun && !gamestate.ammo" expressions to those if statements, but it doesn't look like it matters for either (since chaingun is the only one that spits out two shots in one sitting and the rest is caught by "case -1").
I don't know if this above idea will help, but if you still want to try it; the code would look something like this:
::: CODE :::
case 4:
if ((gamestate.weapon >= wp_chaingun && !gamestate.ammo2) || (gamestate.weapon < wp_chaingun && !gamestate.ammo))
break;
if (buttonstate[bt_attack])
gamestate.attackframe -= 2;
case 1:
if ((gamestate.weapon >= wp_chaingun && !gamestate.ammo2) || (gamestate.weapon < wp_chaingun && !gamestate.ammo))
{ // can only happen with chain gun
gamestate.attackframe++;
break;
}
GunAttack (ob);
Any more luck yet? If not, I'm sure we can just use a similar line as the blue one somewhere else to restrict them. |
|
|
|
 |
WLHack
DieHard Wolfer


Joined: 10 Jul 2005
Last Visit: 2:04 ago.
Topics: 60
Posts: 1138
Location: Loppi - Finland

|
Posted: Wed Sep 14, 2005 6:05 pm
Subject: Re: [Help] Problems with weapon and ammo
[ IP : Logged ]
|

 
|
|
Thanks Chris, now the weapons works without major bugs,
this really helped me so Thanks again. |
_________________ False Spear fullversion...
Trail of Schabbs-blog
|
|
 |
|
|