The "How do I..." Thread
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
- InsanityBringer
- Posts: 3392
- Joined: Thu Jul 05, 2007 4:53 pm
- Location: opening the forbidden box
Re: The "How do I..." Thread
hmm, disregard my issue. It seems to be a problem with float handling in GDCC, either that or me doing something wrong. I guess I'll have to run the code by Dave when I get a chance. heh
EDIT: crap, even after turning this off, I'm still having problems with the value having its fractional bit dropped off or something as the bullet falls on very specific lines, but I'm not even sure how that could happen. wtffurther edit: this was just because I had dropped the .0 from the / 65536.0 bit. hmm
EDIT: crap, even after turning this off, I'm still having problems with the value having its fractional bit dropped off or something as the bullet falls on very specific lines, but I'm not even sure how that could happen. wtffurther edit: this was just because I had dropped the .0 from the / 65536.0 bit. hmm
-
LogicalFallacy
- Posts: 89
- Joined: Tue May 24, 2016 8:59 am
Re: The "How do I..." Thread
I wasn't aware those were things to do. I'm still pretty new to using DECORATE, and I was attempting to use the PB code for reference, but I had no idea what all I was looking at. I'll give your suggestion a go and see if I can get that to work for me.eppn5 wrote:]
What exactly is the problem? For starters, there's not one A GiveInventory in your code to give ammo.
Edit: You also don't have Weapon.AmmoUse, Ammo.Type, and Ammo.Give properties on your gun. Why don't you just make a new ammo type that has 6 bullets max, and make it jump to a reload once you run out of ammo instead of making the counter you're using right now?
Also, the problem that had me bringing this up here was that the counter doesn't seem to be working at all.
Re: The "How do I..." Thread
I suggest learning DECORATE from the ZDoom wiki and here.LogicalFallacy wrote:I wasn't aware those were things to do. I'm still pretty new to using DECORATE, and I was attempting to use the PB code for reference, but I had no idea what all I was looking at. I'll give your suggestion a go and see if I can get that to work for me.eppn5 wrote: quote stuff
Also, the problem that had me bringing this up here was that the counter doesn't seem to be working at all.
- DoomKrakken
- Posts: 3489
- Joined: Sun Oct 19, 2014 6:45 pm
- Location: Plahnit Urff
- Contact:
Re: The "How do I..." Thread
If I may, this is how I think you should do the revolver... I've added a few comments in the fixes to show you how/why it works. 
If you decide to view this in a word editor, I'd suggest turning on "word wrapping"... the comments are a tad bit lengthy, sorry about that... ^_^;
Let me know if it works!
If you decide to view this in a word editor, I'd suggest turning on "word wrapping"... the comments are a tad bit lengthy, sorry about that... ^_^;
Let me know if it works!
Code: Select all
Actor RevCylinder : Ammo //Changed the name of your ammotype so that it makes sense. Also had it inherit from "Ammo" so that it works like proper ammunition.
{
Inventory.MaxAmount 6
}
Actor Revolver : Pistol 20001
{
Weapon.AmmoType1 RevCylinder //A dummy ammotype that represents the amount of ammo in your revolver.
Weapon.AmmoType2 Clip //We define this so that it yields "Clip" ammo whenever picked up.
Weapon.AmmoGive1 0 //Because it wouldn't make sense for your revolver's cylinder to magically fill back up from simply picking up another revolver...
Weapon.AmmoGive2 6 //This is where the "Clip" ammo comes from. This is why we defined "Clip" as another ammotype for the weapon...
Weapon.SelectionOrder 550
Weapon.SlotNumber 2
-WEAPON.WIMPY_WEAPON
Obituary "%o ate a bullet from %k's revolver."
Inventory.Pickupmessage "You got a revolver."
Tag "Revolver"
States
{
Spawn:
RVIC A -1
Stop
Ready:
REVI A 1 A_WeaponReady
Loop
Deselect:
REVI A 1 A_Lower
Loop
Select:
REVI A 1 A_Raise
Loop
Fire:
TNT1 A 0 A_JumpIfNoAmmo("Reload") //Since it's defined in your "Fire" state, it will check if you have any ammo left in your primary ammo pool, which is "RevCylinder".
REVF A 2 Bright
TNT1 A 0 A_FireCustomMissile("RevolTracer",0,0,8,8,0)
TNT1 A 0 A_PlaySound("2XPFIRE1")
REVF B 2 Bright A_PlaySound("weapons/pistol", CHAN_WEAPON)
REVF CD 3
REVF DC 5
REVI A 5 A_ReFire
Goto Ready
//Okay, now a most useful and efficient way to reload it is to have the weapon take one ammo at a time from your ammo pool and add it to the "RevCylinder" ammo pool.
//It basically loops until the "RevCylinder" ammo pool is completely full. This is how we do it...
Reload:
TNT1 A 0 A_JumpIfInventory("Clip",1,1) //Here, if you have less than 1 "Clip" ammo left BEFORE reloading (which is 0), then it will go to the "NoAmmo" state, rather than jumping over the "Goto NoAmmo" statement and continuing with this animation.
Goto NoAmmo
REVR ABCDEFGHIJKLMFEA 2 //First, let's start with your animation sequence...
REVI A 1
//Now we create a substate to loop the actual reloading part.
//You can name it anything you want... but remember to keep the name simple and descriptive...
ReloadLoop:
TNT1 A 0 A_JumpIfInventory("Clip",1,1) //Here, if you have less than 1 "Clip" ammo left WHILE reloading (which is 0), then it will just go back to the "Ready" state, rather than jumping over the "Goto Ready" statement.
Goto Ready
TNT1 A 0 A_JumpIfInventory("RevCylinder",0,"Ready") //A value of 0 in any inventory-related action refers to the maximum inventory amount an actor has. For "RevCylinder", we defined this as 6, so if you placed 6 in this place, then it will also work. However, whenever working with multiple actors that check for full-capacity inventory, using a value of 0 is much more efficient.
TNT1 A 0 A_TakeInventory("Clip",1)
TNT1 A 0 A_GiveInventory("RevCylinder",1)
Loop
//Another note... since all the state labels in the "ReloadLoop" state have 0-tic delays, then everything that happens in that loop happens pretty much simultaneously. Neat, huh? :D
NoAmmo:
REVI A 2
REVF C 2
REVI A 2
Goto Ready
}
}
-
LogicalFallacy
- Posts: 89
- Joined: Tue May 24, 2016 8:59 am
Re: The "How do I..." Thread
Thank you sir, this works fantastically with only a few minor changes, and is much cleaner than what I was attempting to do. My reference for code right now is mostly PB, which is rather daunting. I do try to use the ZDoom wiki as much as possible as well, but it's tough finding some things without already knowing they're there. Some of the stuff in your comments I already knew, but overall it was quite informative, thank you.DoomKrakken wrote:If I may, this is how I think you should do the revolver... I've added a few comments in the fixes to show you how/why it works.
If you decide to view this in a word editor, I'd suggest turning on "word wrapping"... the comments are a tad bit lengthy, sorry about that... ^_^;
Let me know if it works!
Code: Select all
Actor RevCylinder : Ammo //Changed the name of your ammotype so that it makes sense. Also had it inherit from "Ammo" so that it works like proper ammunition. { Inventory.MaxAmount 6 } Actor Revolver : Pistol 20001 { Weapon.AmmoType1 RevCylinder //A dummy ammotype that represents the amount of ammo in your revolver. Weapon.AmmoType2 Clip //We define this so that it yields "Clip" ammo whenever picked up. Weapon.AmmoGive1 0 //Because it wouldn't make sense for your revolver's cylinder to magically fill back up from simply picking up another revolver... Weapon.AmmoGive2 6 //This is where the "Clip" ammo comes from. This is why we defined "Clip" as another ammotype for the weapon... Weapon.SelectionOrder 550 Weapon.SlotNumber 2 -WEAPON.WIMPY_WEAPON Obituary "%o ate a bullet from %k's revolver." Inventory.Pickupmessage "You got a revolver." Tag "Revolver" States { Spawn: RVIC A -1 Stop Ready: REVI A 1 A_WeaponReady Loop Deselect: REVI A 1 A_Lower Loop Select: REVI A 1 A_Raise Loop Fire: TNT1 A 0 A_JumpIfNoAmmo("Reload") //Since it's defined in your "Fire" state, it will check if you have any ammo left in your primary ammo pool, which is "RevCylinder". REVF A 2 Bright TNT1 A 0 A_FireCustomMissile("RevolTracer",0,0,8,8,0) TNT1 A 0 A_PlaySound("2XPFIRE1") REVF B 2 Bright A_PlaySound("weapons/pistol", CHAN_WEAPON) REVF CD 3 REVF DC 5 REVI A 5 A_ReFire Goto Ready //Okay, now a most useful and efficient way to reload it is to have the weapon take one ammo at a time from your ammo pool and add it to the "RevCylinder" ammo pool. //It basically loops until the "RevCylinder" ammo pool is completely full. This is how we do it... Reload: TNT1 A 0 A_JumpIfInventory("Clip",1,1) //Here, if you have less than 1 "Clip" ammo left BEFORE reloading (which is 0), then it will go to the "NoAmmo" state, rather than jumping over the "Goto NoAmmo" statement and continuing with this animation. Goto NoAmmo REVR ABCDEFGHIJKLMFEA 2 //First, let's start with your animation sequence... REVI A 1 //Now we create a substate to loop the actual reloading part. //You can name it anything you want... but remember to keep the name simple and descriptive... ReloadLoop: TNT1 A 0 A_JumpIfInventory("Clip",1,1) //Here, if you have less than 1 "Clip" ammo left WHILE reloading (which is 0), then it will just go back to the "Ready" state, rather than jumping over the "Goto Ready" statement. Goto Ready TNT1 A 0 A_JumpIfInventory("RevCylinder",0,"Ready") //A value of 0 in any inventory-related action refers to the maximum inventory amount an actor has. For "RevCylinder", we defined this as 6, so if you placed 6 in this place, then it will also work. However, whenever working with multiple actors that check for full-capacity inventory, using a value of 0 is much more efficient. TNT1 A 0 A_TakeInventory("Clip",1) TNT1 A 0 A_GiveInventory("RevCylinder",1) Loop //Another note... since all the state labels in the "ReloadLoop" state have 0-tic delays, then everything that happens in that loop happens pretty much simultaneously. Neat, huh? :D NoAmmo: REVI A 2 REVF C 2 REVI A 2 Goto Ready } }
Of note, the minor changes were: changing the use ammo boolean in A_FireCustomMissile to true, since I had changed it to false to try and get the counter to work; adding the tag WRF_ALLOWRELOAD to A_WeaponReady, something I thankfully learned about looking at the tutorial eppn5 linked; and moving the NoAmmo check to the end of the firing animation, with a new null frame just after it for A_ReFire.
Re: The "How do I..." Thread
Okay so I have another problem; this used to work before I updated to GzDOOM 2.2 dunno what changed but... now I get "VM EXECUTION ABORTED: INVALID SELF POINTER" and the projectile deals no damage.
Basically, in my mod you can deflect projectiles with a skill, deflecting a projectile is supposed to add 100 points of damage to the projectile, like I said, this used to work and you could smoke a Chaos Serpent in a few well-placed deflections. But now I get the VM error listed above.. Is this fixable?
edit: I replaced the user variable references with args[0] and that seems to have fixed it, though for the future I'd like to know how/why this broke..
Basically, in my mod you can deflect projectiles with a skill, deflecting a projectile is supposed to add 100 points of damage to the projectile, like I said, this used to work and you could smoke a Chaos Serpent in a few well-placed deflections. But now I get the VM error listed above.. Is this fixable?
Code: Select all
ACTOR ENEMY_CSERP_FIREBALL1 : Demon1FX1 replaces Demon1FX1
{
damagetype "CSerpFireball1"
var int user_dmg;
damage(random(20,30)+(user_dmg))
+HITTRACER
states
{
Spawn:
DMFX AABBCC 2 bright A_JumpIfInventory("PROJECTILE_DEFLECTED",1,"damageincrease",AAPTR_DEFAULT) //Check to see if the player deflected the projecitle
loop
DamageIncrease:
TNT1 A 0 A_TakeInventory("PROJECTILE_DEFLECTED")
TNT1 A 0 A_SetUserVar("user_dmg",100) //increase the damage dramatically when deflected.
goto Spawn
}
}
actor SHIELD_REFLECT : BASE_SHIELDPART //This is the deflecting actor, quite a few are spawned when the player uses their deflect attack making a wall of sorts.
{
+REFLECTIVE
+AIMREFLECT
States
{
Spawn:
TNT1 A 6
stop
Pain.CSerpFireball1: //When the actor is hit by the Chaos Serpent's fireball it enters this state and radius-gives a dummy actor which *should* increase the damage of the projectile...
TNT1 A 0 A_RadiusGive("PROJECTILE_DEFLECTED",32,RGF_MISSILES,1)
TNT1 A 1 A_PlaySound("FighterHammerHitWall","soundslot5",10.0)
goto death
Death:
TNT1 A 1
stop
}
}
- jazzmaster9
- Posts: 875
- Joined: Wed Apr 18, 2012 11:37 pm
- Contact:
Re: The "How do I..." Thread
How do I make the Doomsphere play the "snd/damage" when I shoot a monster.
I tried this but it doesnt seem to work.
EDIT: Never mind I got it working
I tried this but it doesnt seem to work.
Code: Select all
Actor PowerQuadDamageST : PowerDamage
{
Damagefactor "Normal", 4
}
Actor Doomsphere : PowerupGiver 7818
{
Inventory.MaxAmount 0
Powerup.Type QuadDamageST
Powerup.Color RedMap
Inventory.PickupMessage "Quad Damage!"
+CountItem
+NoGravity
+Inventory.AutoActivate
+Inventory.AlwaysPickup
inventory.usesound "snd/damage" <<<<<<<<<\\\ADDED THIS!
Inventory.PickupSound "dam/up"
States
{
Spawn:
DOOM A -1 Bright
Loop
}
}
- DoomKrakken
- Posts: 3489
- Joined: Sun Oct 19, 2014 6:45 pm
- Location: Plahnit Urff
- Contact:
Re: The "How do I..." Thread
Ah, yes... I figured I missed something...LogicalFallacy wrote:Thank you sir, this works fantastically with only a few minor changes, and is much cleaner than what I was attempting to do. My reference for code right now is mostly PB, which is rather daunting. I do try to use the ZDoom wiki as much as possible as well, but it's tough finding some things without already knowing they're there. Some of the stuff in your comments I already knew, but overall it was quite informative, thank you.DoomKrakken wrote:If I may, this is how I think you should do the revolver... I've added a few comments in the fixes to show you how/why it works.
If you decide to view this in a word editor, I'd suggest turning on "word wrapping"... the comments are a tad bit lengthy, sorry about that... ^_^;
Let me know if it works!
Of note, the minor changes were: changing the use ammo boolean in A_FireCustomMissile to true, since I had changed it to false to try and get the counter to work; adding the tag WRF_ALLOWRELOAD to A_WeaponReady, something I thankfully learned about looking at the tutorial eppn5 linked; and moving the NoAmmo check to the end of the firing animation, with a new null frame just after it for A_ReFire.
Glad to know I helped.
PB, Brutal Doom, and other Brutal Doom-related mods/submods have some really nasty coding practices. I recommend expanding your horizon to other mods, such as Guncaster and Trailblazer, for more coding. God knows how much I've learned from them...
Re: The "How do I..." Thread
How would I go about giving a weapon varying animations upon being fired? I have a machine gun with some visual kickback done using offsets in its firing animation, but it looks a bit silly to have it kick the same way every time. Is there a method of making there be multiple animations for firing and having the game pick one at random?
Re: The "How do I..." Thread
I'd try something like:

_____________________
Question: How can I make a monster to check its target's health?
I was trying the following:
But it seems to not work.
Thanks in advanced.
Code: Select all
Fire:
TNT1 A 0 A_Jump (255, "FireAnimation1", "FireAnimation2", "FireAnimation3"
FireAnimation1:
*Your animation for it*
Goto Ready
FireAnimation2:
*Another animation for it*
Goto Ready
FireAnimation3:
*Yet another animation*
Goto Ready
_____________________
Question: How can I make a monster to check its target's health?
I was trying the following:
Code: Select all
A_JumpIfInTargetInventory ("Health", 1, "Printa", 0)Thanks in advanced.
- InsanityBringer
- Posts: 3392
- Joined: Thu Jul 05, 2007 4:53 pm
- Location: opening the forbidden box
Re: The "How do I..." Thread
Health isn't an inventory item. Use health in a [wiki=DECORATE_expressions]decorate expression[/wiki] insteadRavick wrote:Question: How can I make a monster to check its target's health?
I was trying the following:
But it seems to not work.Code: Select all
A_JumpIfInTargetInventory ("Health", 1, "Printa", 0)
Thanks in advanced.
For example:
Code: Select all
A_JumpIf("health < 35", "MyState")EDIT hey I'm a fuckwit instead just use [wiki]A_JumpIfHealthLower[/wiki] which now has pointers
Re: The "How do I..." Thread
Nice, that works perfectly! Thanks!Ravick wrote:I'd try something like:
.
- Darsycho
- Posts: 864
- Joined: Sat Jul 05, 2008 1:36 pm
- Preferred Pronouns: He/Him
- Operating System Version (Optional): Linux Mint 21.3 Cinnamon, Windows 11
- Graphics Processor: nVidia with Vulkan support
- Contact:
Re: The "How do I..." Thread
How can I make certain textures unable to have decals on them? It's kinda annoying to have a bunch of decals covering up a switch and you dont even know its there.
- Kappes Buur
-

- Posts: 4201
- Joined: Thu Jul 17, 2003 12:19 am
- Graphics Processor: nVidia (Legacy GZDoom)
- Location: British Columbia, Canada
- Contact:
Re: The "How do I..." Thread
In Hexen format use the texture in TEXTURES with the NoDecals propertyDarsycho wrote:How can I make certain textures unable to have decals on them? It's kinda annoying to have a bunch of decals covering up a switch and you dont even know its there.
In UDMF specify the 'No decals' flag for the sidedef.
- Mánibranðr System
- Posts: 179
- Joined: Sun Aug 26, 2012 5:28 pm
- Preferred Pronouns: They/Them
- Location: Hong Kong
Re: The "How do I..." Thread
How do I make it so that I have Health, Armor and And Rechargeable Shield where the Shield always takes 1.0x damage and Armor reduces damage to Health and Health only?
Every method I could think of applies Armor damage reduction to both Health and Shields. The only method I could think of would be to use a script to check for health damage and then reimburse health based on how much armor is supposed to protect, which just sounds janky and could cause problems when the health dips below 0 before reimbursement.
Every method I could think of applies Armor damage reduction to both Health and Shields. The only method I could think of would be to use a script to check for health damage and then reimburse health based on how much armor is supposed to protect, which just sounds janky and could cause problems when the health dips below 0 before reimbursement.
