DieHard Wolfers Forum Index DieHard Wolfers
A Wolfenstein 3d Community


  Hosted by: MCS & Areyep.com - Designed by: BrotherTank

Original Yahoo Forum - Die Hard Archives

AReyeP HomepageAreyep Homepage DieHard Wolfenstein BunkerDieHard Wolfenstein Bunker Log inLog in RegisterRegister Banlist FAQFAQ Search ForumsSearch

  Username:    Password:      Remember me       

[Help] Problems with weapon and ammo
Page 1 of 1
DieHard Wolfers Forum Index -> Code Crackers View Previous TopicRefresh this PageAdd Topic to your Browser FavoritesSearch ForumsPrint this TopicE-mail TopicGoto Page BottomView Next Topic
Post new topicReply to topic
Author Message
WLHack
DieHard Wolfer
DieHard Wolfer


Joined: 10 Jul 2005
Last Visit: 2:04 ago.

Topics: 60
Posts: 1138
Location: Loppi - Finland
finland.gif

PostPosted: Sun Sep 04, 2005 1:55 pm
   Subject: [Help] Problems with weapon and ammo
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Next PostGoto Bottom of Posts

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
Code Master


Joined: 12 Mar 2003
Last Visit: 26 Jan 2010

Topics: 45
Posts: 833
Location: North Carolina
usa.gif

PostPosted: Sun Sep 04, 2005 4:47 pm
   Subject: Re: [Help] Problems with weapon and ammo
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

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
DieHard Wolfer


Joined: 10 Jul 2005
Last Visit: 2:04 ago.

Topics: 60
Posts: 1138
Location: Loppi - Finland
finland.gif

PostPosted: Sun Sep 04, 2005 8:44 pm
   Subject: Re: [Help] Problems with weapon and ammo
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

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
DieHard Wolfer


Joined: 10 Jul 2005
Last Visit: 2:04 ago.

Topics: 60
Posts: 1138
Location: Loppi - Finland
finland.gif

PostPosted: Mon Sep 05, 2005 7:48 pm
   Subject: Re: [Help] Problems with weapon and ammo
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

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
Code Master


Joined: 12 Mar 2003
Last Visit: 2:12 ago.

Topics: 16
Posts: 1017
Location: Rauma - Finland
finland.gif

PostPosted: Tue Sep 06, 2005 2:55 pm
   Subject: Re: [Help] Problems with weapon and ammo
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

It seems your bug is in CheckWeaponChange function in WL_AGENT.C...

Let's have a look at it Geek

_________________
Click here to visit KFH Games website!
*NEW* Spear of Destiny Reloaded
WLHack
DieHard Wolfer
DieHard Wolfer


Joined: 10 Jul 2005
Last Visit: 2:04 ago.

Topics: 60
Posts: 1138
Location: Loppi - Finland
finland.gif

PostPosted: Tue Sep 06, 2005 4:37 pm
   Subject: Re: [Help] Problems with weapon and ammo
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

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


Joined: 24 Nov 2003
Last Visit: 15 Dec 2009

Topics: 8
Posts: 394
Location: Nodnol, Sdrawkcab
uk.gif

PostPosted: Tue Sep 06, 2005 7:02 pm
   Subject: Re: [Help] Problems with weapon and ammo
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Well, there's your answer. If you haven't changed the CheckWeaponChange function, then the game still thinks you can only select four weapons, as you could in the original game.

This is taken from the Wolf3d Dome and probably isn't the most optimised way of doing this, but it should work ok... possibly...

"Now do a search for CheckWeaponChange. Modify the entire little function to this (copy & paste)."
::: CODE :::

void CheckWeaponChange (void)
{
int i,buttons;
if (!gamestate.ammo) // must use knife with no ammo
return;
switch (LastScan)
{
case 2:
LastScan=0;
gamestate.weapon = gamestate.chosenweapon = wp_knife;
break;
case 3:
LastScan=0;
gamestate.weapon = gamestate.chosenweapon = wp_pistol;
break;
case 4:
LastScan=0;
if (gamestate.bestweapon >= wp_machinegun)
{
gamestate.weapon = gamestate.chosenweapon = wp_machinegun;
}
break;
case 5:
LastScan=0;
if (gamestate.bestweapon >= wp_chaingun)
gamestate.weapon = gamestate.chosenweapon = wp_chaingun;
}
break;
case 6:
LastScan=0;
if (gamestate.bestweapon >=wp_saw) // change this to your new gun
gamestate.weapon = gamestate.chosenweapon = wp_saw; // change this to your new gun
}
break;
}
DrawWeapon();
}


If it doesn't work right then... use magic. Or just change stuff until it does Smile

_________________
Rear one!
WLHack
DieHard Wolfer
DieHard Wolfer


Joined: 10 Jul 2005
Last Visit: 2:04 ago.

Topics: 60
Posts: 1138
Location: Loppi - Finland
finland.gif

PostPosted: Tue Sep 06, 2005 7:46 pm
   Subject: Re: [Help] Problems with weapon and ammo
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

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


Joined: 10 Jul 2005
Last Visit: 2:04 ago.

Topics: 60
Posts: 1138
Location: Loppi - Finland
finland.gif

PostPosted: Mon Sep 12, 2005 2:24 pm
   Subject: Re: [Help] Problems with weapon and ammo
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Somehow the "infinite ammo bug" is still appearing
and I can't get rid of it.

I have made some research and I think there is something wrong
with this part of code but if it is not so, could you tell where is the
source of the problem then and how to fix it.

::: CODE :::


GunAttack (ob);
switch (gamestate.weapon)
{
     case wp_pistol:
     case wp_machinegun:
             gamestate.ammo--;          <-- 
             DrawAmmo ();
             break;
     case wp_chaingun:
     case wp_stengun:
             gamestate.ammo2--;        <-- Is these lines causing the bug
             DrawAmmo2 ();
             break;
}
break;


Chris
DieHard Wolfer
DieHard Wolfer


Joined: 12 Mar 2003
Last Visit: 08 Feb 2010

Topics: 37
Posts: 1344
Location: Canada
blank.gif

PostPosted: Mon Sep 12, 2005 5:40 pm
   Subject: Re: [Help] Problems with weapon and ammo
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

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
DieHard Wolfer


Joined: 10 Jul 2005
Last Visit: 2:04 ago.

Topics: 60
Posts: 1138
Location: Loppi - Finland
finland.gif

PostPosted: Mon Sep 12, 2005 6:48 pm
   Subject: Re: [Help] Problems with weapon and ammo
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

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
DieHard Wolfer


Joined: 12 Mar 2003
Last Visit: 08 Feb 2010

Topics: 37
Posts: 1344
Location: Canada
blank.gif

PostPosted: Mon Sep 12, 2005 7:55 pm
   Subject: Re: [Help] Problems with weapon and ammo
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

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
DieHard Wolfer


Joined: 10 Jul 2005
Last Visit: 2:04 ago.

Topics: 60
Posts: 1138
Location: Loppi - Finland
finland.gif

PostPosted: Mon Sep 12, 2005 8:20 pm
   Subject: Re: [Help] Problems with weapon and ammo
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Yes, that is exactly what I am saying. When amount of ammo reaches zero
it starts to increase till it is 99 and then it returns zero again (this is somekind
of a loop).

Here is my T_Attack function, I hope it helps to understand the
situation.


::: CODE :::


/*
===============
=
= T_Attack
=
===============
*/

void   T_Attack (objtype *ob)
{
   struct   atkinf   *cur;

   UpdateFace ();

   if (gamestate.victoryflag)      // watching the BJ actor
   {
      VictorySpin ();
      return;
   }

   if ( buttonstate[bt_use] && !buttonheld[bt_use] )
      buttonstate[bt_use] = false;

   if ( buttonstate[bt_attack] && !buttonheld[bt_attack])
      buttonstate[bt_attack] = false;

   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.attackcount -= tics;
   while (gamestate.attackcount <= 0)
   {
      cur = &attackinfo[gamestate.weapon][gamestate.attackframe];
      switch (cur->attack)
      {
      case -1:
         ob->state = &s_player;
         if (!gamestate.ammo)
         if (!gamestate.ammo2)
         {
            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)
         if (!gamestate.ammo2)
            break;
         if (buttonstate[bt_attack])
            gamestate.attackframe -= 2;
      case 1:
         if (!gamestate.ammo)
         if (!gamestate.ammo2)
         {   // can only happen with chain gun
            gamestate.attackframe++;
            break;
         }
         GunAttack (ob);
         switch (gamestate.weapon)
         {
             case wp_pistol:
             case wp_machinegun:
            gamestate.ammo--;
            DrawAmmo ();
            break;
             case wp_chaingun:
             case wp_stengun:
             gamestate.ammo2--;
             DrawAmmo2 ();
             break;
         }

      case 2:
         KnifeAttack (ob);
         break;

      case 3:
         if (gamestate.ammo && buttonstate[bt_attack])
            gamestate.attackframe -= 2;
         break;
      }

      gamestate.attackcount += cur->tics;
      gamestate.attackframe++;
      gamestate.weaponframe =
         attackinfo[gamestate.weapon][gamestate.attackframe].frame;
   }

}
Chris
DieHard Wolfer
DieHard Wolfer


Joined: 12 Mar 2003
Last Visit: 08 Feb 2010

Topics: 37
Posts: 1344
Location: Canada
blank.gif

PostPosted: Mon Sep 12, 2005 10:18 pm
   Subject: Re: [Help] Problems with weapon and ammo
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

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. Think

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
DieHard Wolfer


Joined: 10 Jul 2005
Last Visit: 2:04 ago.

Topics: 60
Posts: 1138
Location: Loppi - Finland
finland.gif

PostPosted: Tue Sep 13, 2005 2:29 pm
   Subject: Re: [Help] Problems with weapon and ammo
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

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
DieHard Wolfer


Joined: 12 Mar 2003
Last Visit: 08 Feb 2010

Topics: 37
Posts: 1344
Location: Canada
blank.gif

PostPosted: Wed Sep 14, 2005 5:27 pm
   Subject: Re: [Help] Problems with weapon and ammo
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

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
DieHard Wolfer


Joined: 10 Jul 2005
Last Visit: 2:04 ago.

Topics: 60
Posts: 1138
Location: Loppi - Finland
finland.gif

PostPosted: Wed Sep 14, 2005 6:05 pm
   Subject: Re: [Help] Problems with weapon and ammo
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Bottom of Posts

Thanks Chris, now the weapons works without major bugs,
this really helped me so Thanks again.

_________________
False Spear fullversion...
Trail of Schabbs-blog
Display posts from previous:   
Post new topicReply to topic Time synchronized with the forum server time
DieHard Wolfers Forum Index -> Code Crackers View Previous TopicRefresh this PageAdd Topic to your Browser FavoritesSearch ForumsPrint this TopicE-mail TopicGoto Page TopView Next Topic
Page 1 of 1
Jump to:  

Related topics
 Topics   Replies   Views   Last Post 
No new posts Sticky: [Info] Help for newbie coders! C++ Tutorial
Author: Dugtrio17
20 1419 Sun Jan 10, 2010 8:26 pm
Fragstein3D View latest post
No new posts [Help] Setting RocketLauncher: Explosive Range...?
Author: KyleRTCW
17 658 Thu Jun 03, 2004 10:21 am
Codetech84 View latest post
No new posts [Info] Tricks - Dogs that shoot - Modifying Behaviour
Author: Guest
19 276 Sat Mar 20, 2004 3:31 pm
Dugtrio17 View latest post
No new posts [Help] Berserk mode
Author: wolf3dbreaker
2 425 Wed Feb 04, 2004 7:01 am
Xarkon View latest post
No new posts [Info] Assigning Static Objects problem.
Author: Guest
1 96 Sun Jul 06, 2003 8:25 pm
Guest View latest post
 
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 subSilver Theme by BrotherTank
Powered by phpBB © 2001, 2005 phpBB Group