It is currently 22 May 2013, 21:52

Post new topic Reply to topic  Page 1 of 1
 [ 7 posts ] 

Low on ammo/out of ammo script help


Author Message
 Post subject: Low on ammo/out of ammo script help
PostPosted: 13 Sep 2011, 03:45 
Offline
Chaingunner  We Are The Lamb
User avatar
Joined: 10 Jan 2011, 21:14
Posts: 140
Location: Alberta, Canada
So, I've been thinking about doing this for a long time, but I just have no idea on how I'm going to accomplish this task. I want to have it so when the player is getting low on ammo, the player's character will say something like 'Getting low on ammo here,' 'Need to round up some rounds,' etc. And when the player does run out of ammo, the character will would say stuff like 'No ammo!' 'Sh*t, no ammo!' etc. Anyone care to help me figure out a way? And if possible, as simple as possible. I though I better figure this out now and have it done.
"The one to help us fail. The one to let us grow
The torch is passed on. We are the lamb"

Imminent Firestorm Creator


Top
 Profile  
 
 Post subject: Re: Low on ammo/out of ammo script help
PostPosted: 13 Sep 2011, 09:46 
Offline
Cyberdemon  Approved Adder
User avatar
Joined: 01 Feb 2011, 20:07
Posts: 857
I would advise using ACS with decorate for more flexibility, but here is a decorate-only basic example that should give you some idea.

Code:
ACTOR NC_Pistol : Pistol
{
  Weapon.SlotNumber 8
  States
  {
  Fire:
    PISG A 4
    PISG B 6 A_FirePistol
    TNT1 A 0 A_JumpIfInventory("Clip", 50, 4)
    TNT1 A 0 A_JumpIfInventory("Clip", 49, 5)
    TNT1 A 0 A_JumpIfInventory("Clip", 1, 2)
    TNT1 A 0 A_PlaySound("misc/w_pkup", CHAN_VOICE) // No ammo sound
    PISG C 4
    PISG B 5 A_ReFire
    Goto Ready
    TNT1 A 0 A_PlaySound("misc/p_pkup", CHAN_VOICE) // Low ammo sound
    Goto Fire+6
  }
}


This is a pistol that when it gets low on ammo it plays a sound (low ammo sound) and when it runs out of ammo it plays a different sound (no ammo sound). In other words, when you have 49 bullets after the last shot you shot, the low ammo sound will be played and when you have zero bullets after the last shot you shot, the no ammo sound will be played in this case.

If you are interested why I chose 49 as "low", that is because of ZDoom's alternative hud displaying the ammo counter in red if you have 49 bullets or less and no backpack.


Top
 Profile  
 
 Post subject: Re: Low on ammo/out of ammo script help
PostPosted: 13 Sep 2011, 20:24 
Offline
Chaingunner  We Are The Lamb
User avatar
Joined: 10 Jan 2011, 21:14
Posts: 140
Location: Alberta, Canada
Blue Shadow wrote:
I would advise using ACS with decorate for more flexibility, but here is a decorate-only basic example that should give you some idea.
Code:
ACTOR NC_Pistol : Pistol
{
  Weapon.SlotNumber 8
  States
  {
  Fire:
    PISG A 4
    PISG B 6 A_FirePistol
    TNT1 A 0 A_JumpIfInventory("Clip", 50, 4)
    TNT1 A 0 A_JumpIfInventory("Clip", 49, 5)
    TNT1 A 0 A_JumpIfInventory("Clip", 1, 2)
    TNT1 A 0 A_PlaySound("misc/w_pkup", CHAN_VOICE) // No ammo sound
    PISG C 4
    PISG B 5 A_ReFire
    Goto Ready
    TNT1 A 0 A_PlaySound("misc/p_pkup", CHAN_VOICE) // Low ammo sound
    Goto Fire+6
  }
}
This is a pistol that when it gets low on ammo it plays a sound (low ammo sound) and when it runs out of ammo it plays a different sound (no ammo sound). In other words, when you have 49 bullets after the last shot you shot, the low ammo sound will be played and when you have zero bullets after the last shot you shot, the no ammo sound will be played in this case.

If you are interested why I chose 49 as "low", that is because of ZDoom's alternative hud displaying the ammo counter in red if you have 49 bullets or less and no backpack.
That will work just fine. Thanks Blue Shadow!


Top
 Profile  
 
 Post subject: Re: Low on ammo/out of ammo script help
PostPosted: 16 Sep 2011, 23:24 
Offline
Arachnotron  Really?
User avatar
Joined: 04 Mar 2010, 21:30
Posts: 373
Location: Florida
Blugh, ugly DECORATE like that is why I use ACS for such things. :shifty: But I suppose if it works...


Top
 Profile  
 
 Post subject: Re: Low on ammo/out of ammo script help
PostPosted: 16 Sep 2011, 23:43 
Offline
Icon of Sin  O'Neill with it.
User avatar
Joined: 13 Dec 2009, 20:48
Posts: 1164
Location: IN SPACE
It really helps to use named states instead of offsets, the latter of which can break horribly if code is changed slightly (and can be hard to spot in the process).
Douglas Adams wrote:
Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so.


Top
 Profile  
 
 Post subject: Re: Low on ammo/out of ammo script help
PostPosted: 01 Dec 2011, 13:08 
Offline
Suicide Bomber  Suicide Bomber
Joined: 17 Jul 2011, 14:54
Posts: 34
That's neat.. I could use something similiar in my wad also, but I had an idea.. that I would like to accomplish.. what if the player could yell variable statements after killing an enemy? Ya know, like in duke3d? :D any ideas? I tought that maybe the players decorate could be altered likewise.. but I highly doubt thats gonna work.. :D and if the monsters decorate is altered, the sound is too far away.. :D or can you set sound samples volume in sndinfo? Ideas?


Top
 Profile  
 
 Post subject: Re: Low on ammo/out of ammo script help
PostPosted: 05 Dec 2011, 18:30 
Offline
Chaingunner  We Are The Lamb
User avatar
Joined: 10 Jan 2011, 21:14
Posts: 140
Location: Alberta, Canada
Bloodfury wrote:
That's neat.. I could use something similiar in my wad also, but I had an idea.. that I would like to accomplish.. what if the player could yell variable statements after killing an enemy? Ya know, like in duke3d? :D any ideas? I tought that maybe the players decorate could be altered likewise.. but I highly doubt thats gonna work.. :D and if the monsters decorate is altered, the sound is too far away.. :D or can you set sound samples volume in sndinfo? Ideas?
Already asked that =:3l

viewtopic.php?f=25&t=1639


Top
 Profile  
 
Display posts from previous:  Sort by  

Post new topic Reply to topic  Page 1 of 1
 [ 7 posts ] 


Who is online

Users browsing this forum: No registered users and 2 guests


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 post attachments in this forum

Search for:
Jump to: