Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Conscription

Can you prevent bullet damage from being randomized?

Recommended Posts

"The damage formula is damage * ((random()%3)+1). For example, if damage is 4, the possible results are 4, 8 or 12. The average damage actually dealt by each bullet will therefore be damage * 2."

http://zdoom.org/wiki/A_FireBullets

The wiki does not seem to indicate whether or not there is a way to cause a hitscan weapon to inflict an absolute amount of damage instead of subjecting the integer you input to this formula.

Share this post


Link to post

Coupled with A_BulletAttack?

The page for A_BulletAttack indicates the number of bullets to be fired is defined in the damage property. Yet the wiki entry for "damage" under Actor Properties doesn't indicate how to delineate between "int numbullets" and "int damage". It simply states that both number of bullets fired and the damage inflicted are to be specified within the value for this property.

As an example of what I'm talking about, on the page for A_FireBullets, the wiki states that the associated parameters should be formatted in this way: "(angle spread_horz, angle spread_vert, int numbullets, int damage [, string pufftype [,bool UseAmmo [, float range]]])". But the page for A_BulletAttack reads "no parameters", since the parameters are supposed to be defined using the damage property.

What is the correct combination of numbers and parentheses which will allow the damage property function?

Also, "attacksound" stopped working when I used the property you suggested. Any idea how I get the gun to start making noise again?

Share this post


Link to post

Stick with A_FireBullets, just use the damage property to write a new damage equation. Something like:

damage (X)
With X being what you multiply the damage by, that way, there's no randomization for how much damage that monster's attack does.

If you wanted randomization, you could do something like:
damage (Random(2,4)+1)
Whatever, it's up to you. As long as it's totally enclosed in parentheses, you can use whatever equation works for you.

As far as attacksound not working, I'm not sure, but you can try redefining the sound in SNDINFO if it's an original Doom sound, I had the same problem once with "pistol/fire," and after redefining it in SNDINFO it worked.

Share this post


Link to post

Yeah, it's the pistol that's being edited here, too. I'm just switching back and forth between the weapons, trying out all these different functions in order to get a handle on them.

When I changed it back to A_FireBullets, the attack sound started working again. Didn't realize it until after I'd already redefined the sound in the sndinfo lump, but when I removed the new definition it worked fine.

The only problem now is that the damage property does not prevent the bullet damage from being randomized. GZDoom seems to be ignoring it altogether, because the amount of damage being dealt by the weapon is "1* or 2* or 3*(int damage)", like always.

I have another question about ammo use in punch attacks; should I create another thread for that separate topic, or just post it in here?

Share this post


Link to post

For the sake of expediency, I'll just post that question here. There's a Boolean parameter correlated with the "A_CustomPunch" attack function which is described in the wiki with the words "useammo". I wanted to try out a punch attack that would deliver a one-hit deathblow, and use a new form of ammunition in the process.

I've managed to make the ammunition appear in my level. An ACS entry spawns the player with a weapon called "Fist2" that is set to slot 1 in the KEYCONF file. The ammunition added to the player's inventory when the new item is picked up appears, just like it ought to, when "Fist2" is equipped. Attacking with the new weapon delivers the desired amount of damage.

However, regardless of the setting of the bool variable in the CustomPunch attack function, punching uses up no ammunition. How do I cause the attack to expend ammunition?

Edit: Just to be certain I'm not doing anything wrong, I created a new entry for the SSG that used ammunition called "NewShell". It worked perfectly fine. Afterward, I tried tying Fist2 to "Shell". The player's shell count was displayed when Fist2 was equipped, but that amount not diminished when the melee attack was performed. So this problem must have something to do with the punch attack function itself. I've tried messing with all the parameters to no avail, and at this point I don't know what else to do.

Share this post


Link to post

Hmmmmm... It may be that A_FireBullets uses a special damage code. I suspect it's something like that since it mentions an unusual formula on the wiki page.

You could try A_CustomBulletAttack which doesn't look like it uses a special damage code, although if that doesn't work, I'm stumped.

Looking at A_CustomBulletAttack's page now, there's a parameter "damageperbullet" which you could play around with.

I don't know what's going on with A_CustomPunch. I've added new ammo types before as well and never had trouble. If you post your code with the (code) and (/code) tags, I can try to take a look. Note: Use square brackets for the code tags like you normally would, I just needed a way to show you in case you don't know how to use tags.

Share this post


Link to post

That A_CustomBullet command just doesn't want to operate the way the wiki explains that it should.

"A_CustomBulletAttack (0, 0, 1, 15, "BulletPuff", 1, 0 or 1)"
I don't even know what to set the last variable to, so I tried both possibilities on for size. When I attack with the weapon, in either case, no bullet is fired, no puff appears, no sound is played, and no ammo is expended.

Obviously the randomized damage issue is going to become the least of my worries, if this code won't even fire the gun at all. I'd post the rest of the DECORATE definition, except that it's just the pistol entry from the Wiki with " attacksound "weapons/pistol" " added in.

I'll put up the code for the custom punch later on if I still need help with that. I'll work on it some more first to see if I can fix it.

Share this post


Link to post

Setting up a custom attack looks to be a little more involved. Sorting out the problems meant setting the range, defining a weapon sound, adding a gunflash and nominating the type (and quantity) of ammo to use. Starting with the ZDoom wiki's pistol - here's what I wound up with for the Fire state -

  Fire:
    PISG A 4
    PISG B 0 A_CustomBulletAttack (5, 3, 5, 15, "BulletPuff", 2000, 1)
    PISG B 0 A_PlaysoundEx("Weapons/Pistol","Weapon")
    PISG B 6 A_GunFlash
    PISG C 0 A_TakeInventory (Clip, 5)
    PISG C 4
    PISG B 5 A_ReFire
    Goto Ready
This nasty little piece of work fires five bullets at once in a shotgun-like spread and has a range of 2000.

Your custom punch probably also needs the A_TakeInventory function. Hope this helps.

Share this post


Link to post

I never knew you could use 'Take Inventory' anywhere but in ACS. It works perfectly; the new punch is functional now. Thanks GreyGhost.

The bullet damage on the pistol is still being subjected to that internal (1/2/3*) formula, though. Unfortunately, switching to A_CustomBulletAttack doesn't appear to have made a difference in that respect.

Share this post


Link to post

Well, instead of a hitscan attack, you could use a very fast projectile, like the Rifle Zombie in the Monster Resource Wad uses. Here's a section of its DECORATE:

Missile:
  RFPO E 18 A_FaceTarget
  RFPO F 8 A_CustomMissile("ZombieBullet",32,0,0)
  RFPO E 5
  goto See
And then the projectile:
ACTOR ZombieBullet
{
  Speed 85
  Damage 20
  Radius 6
  Height 8
  PROJECTILE
  +STRIFEDAMAGE
  Seesound "RifleZombie/Fire"
  states
  {
    Spawn:
      BULL A 1
      loop
    Death:
      PUFF ABCD 4
      stop
  }
}
Of course you'd use a custom damage formula that doesn't have randomization and not include the +STRIFEDAMAGE flag in your "bullet."

Now, I'm not sure if you'd have two damage properties in the projectile, or put the damage property with the new formula in the actor that fires the projectile or what, so you'll have to play around with that unless someone else knows.

Share this post


Link to post

I've been working with it. The weapon doesn't make a sound despite the attack sound entry, it doesn't fire any projectile despite the A_CustomMissile entry, and because no projectile is fired, there is no damage dealt or no bulletpuff produced on the target.

actor Pistol : DoomWeapon 5010 //The definition as of the development of Skulltag.
{
  Weapon.SelectionOrder 1900
  Weapon.AmmoUse 1
  Weapon.AmmoGive 20
  Weapon.AmmoType "Clip"
  attacksound "weapons/pistol"
  Obituary "%k capped %o."
  States
  {
  Ready:
    PISG A 1 A_WeaponReady
    Loop
  Deselect:
    PISG A 1 A_Lower
    Loop
  Select:
    PISG A 1 A_Raise
    Loop
  Fire:
    PISG A 4 A_CustomMissile ("ZombieBullet",32,0,0,0,0)
    PISG B 6 A_GunFlash 
    PISG C 4
    PISG B 5 
    Goto Ready
  Flash:
    PISF A 7 Bright A_Light1
    Goto LightDone
    PISF A 7 Bright A_Light0
    Goto LightDone
  Spawn:
    PIST A -1
    Stop
  }
}




ACTOR ZombieBullet
{
  Speed 85
  Damage 20
  Radius 6
  Height 8
  PROJECTILE
  states
  {
    Spawn:
      BULL A 1
      loop
    Death:
      PUFF ABCD 4
      stop
  }
}

Pistol entry taken directly from the wiki; modifications include the aforementioned in addition to the removal of the +WIMPYWEAPON flag, the weapon pickup message, and the alteration of an obituary entry.

Because the weapon delivers no damage in its present state, I have not yet continued experimenting with the damage property.

Share this post


Link to post

Sorry, I forgot to mention that since it's a weapon, you'll need to use the weapon version of A_CustomMissile, A_FireCustomMissile, which has different arguments and works with weapons.

http://www.zdoom.org/wiki/A_FireCustomMissile

Edit: Looks like

PISG A 4 A_FireCustomMissile("ZombieBullet",0,1,0,0,0,0)
will work.

Share this post


Link to post

It almost looks like there's no way to prevent that function from firing the projectile on a plane that passes perpendicular through the player's z-axis. I haven't found it yet, anyway. I see how to change spawn angle, but the way it talks about autoaim, it makes me wonder if it's designed not to be used with freelook on the mouse. This line especially: "You cannot turn off vertical autoaim with this function." Why would that be the case, unless this is not designed to be used in a wad you'll play with mouse-look enabled?

Or is there a way to enable it to fire at the reticule, like any other weapon?

I'm having this weird issue with setslot and cyclic weapon toggling. I made a thread about it down below, but I'm encountering the same problem again right now, so I thought I'd mention it here. For details, visit that thread:

http://www.doomworld.com/vb/doom-editing/45325-setslot-and-cyclic-weapon-toggling/

To put it simply, I can't cycle, and often can't select by number button push, new DECORATE defined weapons. Nothing's wrong with the DECORATE or KEYCONF files. The weapon definitions are all very slight alterations of copy pasted wiki entries. The new fist, a perfectly accurate chaingun, a modified pistol. Only the very top one in the keyconf file will work with cyclic toggling. It doesn't matter which one is on top.

What am I missing there?

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×