Quad damage sound

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Post Reply
User avatar
Korni27
Posts: 46
Joined: Sun Jan 31, 2021 9:18 am
Preferred Pronouns: No Preference
Operating System Version (Optional): Windows 10
Location: Poland
Contact:

Quad damage sound

Post by Korni27 »

I am trying to use ZSCRIPT to play the Quake Quad Damage sound effect while the player has the quad damage power-up active.
I found a way of doing it through DECORATE, but honestly, it was kinda messy, and weapons in my mod already support smooth and non-smooth animations through CVARs, so the code is long enough, adding this solution would bloat it further.

I have rarely done ZScript, and I'm not the best at it, but I have some knowledge

Code: Select all

class ENTRY_Weapon : Weapon
{
	void A_PlaySoundAndCheckForQuad(String SoundName)
    {
        if (CheckInventory("PowerHellups",1))
        {
            A_StartSound("quaddamage", CHAN_WEAPON);
            return;
        }
         A_StartSound(SoundName, CHAN_AUTO);
    }
}
When I plug it into the weapons in DECORATE it breaks

Code: Select all

#Include "ZSCRIPT"
...
ACTOR NewShotgun : ENTRY_Weapon replaces Shotgun //Game spits out errors
{
...
Fire:
	...
	ESH1 B 2 BRIGHT {
	A_FireBullets (4.8, 1.9, 10, 5, "BulletPuff");
	A_SetPitch(pitch-0.5);
	A_PlaySoundAndCheckForQuad("weapon/shotgunf");
	}
	...
}
Before I added the "#Include "ZSCRIPT"" the "ENTRY_Weapon" worked as a parent for the shotgun, but after adding the include line, GZDoom spits out this error
Script error, "Project E.N.T.R.Y. 0.8.9.wad:ZSCRIPT" line 1:
Expected '{', got 'ENTRYWeapon'.
Thank you in advance.
Ac!d
Posts: 348
Joined: Tue Apr 02, 2019 5:13 am

Re: Quad damage sound

Post by Ac!d »

In a WAD or a pk3, you must include your files in a file called DECORATE for Decorate files, and ZSCRIPT for Zscript files.

NewShotgun is coded in Decorate, while ENTRY_Weapon is coded in ZScript.
User avatar
Korni27
Posts: 46
Joined: Sun Jan 31, 2021 9:18 am
Preferred Pronouns: No Preference
Operating System Version (Optional): Windows 10
Location: Poland
Contact:

Re: Quad damage sound

Post by Korni27 »

Yeah, I know, both the NewShothgun and ENTRY_Weapon are in separate DECORATE and ZSCRIPT files, but the code in the ZSCRIPT file doesn't seem to wok
Ac!d
Posts: 348
Joined: Tue Apr 02, 2019 5:13 am

Re: Quad damage sound

Post by Ac!d »

Did you indicate the version of GZDoom you're using in ZScript ?

Code: Select all

Version "4.6.1"

#Include "..."
The best way should be to send me your code.
User avatar
Korni27
Posts: 46
Joined: Sun Jan 31, 2021 9:18 am
Preferred Pronouns: No Preference
Operating System Version (Optional): Windows 10
Location: Poland
Contact:

Re: Quad damage sound

Post by Korni27 »

I've added the version number and it spits out this error
Script error, "Project E.N.T.R.Y. 0.8.9.wad:ZSCRIPT" line 1:
Expected '{', got '4.8.2'.

Code: Select all

Version "4.8.2"

class ENTRYWeapon : Weapon abstract
{
	action void A_PlaySoundAndCheckForQuad(String SoundName)
    {
        if (CheckInventory("PowerHellups",1))
        {
            A_StartSound("quaddamage", CHAN_WEAPON);
            return;
        }
         A_StartSound(SoundName, CHAN_AUTO);
    }
}
and this is the full ZSCRIPT code,

Code: Select all

ACTOR NewShotgun : Weapon replaces Shotgun
{
  Weapon.SelectionOrder 1300
  Weapon.AmmoUse 1
  Weapon.AmmoGive 8
  Weapon.AmmoType "Shell"
  Inventory.PickupMessage "$GOTSHOTGUN"
  Obituary "$OB_MPSHOTGUN"
  States
  {
  Ready:
    TNT1 A 0 A_JumpIf(GetCvar("ENTRY_smooth") == 1, "Ready_NoSmooth")
    
    ESH1 A 1 A_WeaponReady
    Loop
  Ready_NoSmooth:
    TNT1 A 0 A_JumpIf(GetCvar("ENTRY_smooth") == 0, "Ready")
    
    SHTG A 1 A_WeaponReady
    Loop
  Deselect:
    TNT1 A 0 A_JumpIf(GetCvar("ENTRY_smooth") == 1, "Deselect_NoSmooth")
    
    ESH1 A 1 A_Lower
	NULL AA 0 A_Lower
    Loop
  Deselect_NoSmooth:
    TNT1 A 0 A_JumpIf(GetCvar("ENTRY_smooth") == 0, "Deselect")

    SHTG A 1 A_Lower
	NULL AA 0 A_Lower
    Loop
  Select:
    TNT1 A 0 A_JumpIf(GetCvar("ENTRY_smooth") == 1, "Select_NoSmooth")
    
    ESH1 A 1 A_Raise
    NULL AA 0 A_Raise
    Loop
  Select_NoSmooth:
    TNT1 A 0 A_JumpIf(GetCvar("ENTRY_smooth") == 0, "Select")

    SHTG A 1 A_Raise
    NULL AA 0 A_Raise
    Loop
  Fire:
    TNT1 A 0 A_JumpIf(GetCvar("ENTRY_smooth") == 1, "Fire_NoSmooth")
    TNT1 A 0 A_JumpIfInventory("Powersync_thecrusible",1,"Fire_Speed")
    ESH1 A 3
    ESH1 B 2 BRIGHT {
	A_FireBullets (4.8, 1.9, 7, 8, "BulletPuff");
	A_SetPitch(pitch-0.5);
	A_PlaySound("weapons/shotgf",CHAN_WEAPON);
	}
	ESH1 CD 2 BRIGHT A_SetPitch(pitch-0.25)
	ESH1 E 1 BRIGHT A_SetPitch(pitch+0.25)
	ESH1 F 2 A_SetPitch(pitch+0.25)
	ESH1 GH 1 A_SetPitch(pitch+0.25)
	ESH1 IJKLM 1 A_SetRoll(roll-0.24)
	ESH1 N 1 A_SetPitch(pitch+0.25)
	ESH1 OP 2 A_SetPitch(pitch+0.25)
    ESH1 Q 1 { A_FireCustomMissile("ShotShell",random(-20,-60),False,10); A_SetPitch(pitch-0.25); }
	ESH1 R 2 A_SetPitch(pitch-0.25)
    ESH1 S 1 A_SetPitch(pitch-0.25)
	ESH1 TUVWX 1 A_SetRoll(roll+0.24)
	ESH1 YZ 1 
    ESH1 A 1
    ESH1 A 7 A_ReFire
    Goto Ready

  Fire_Speed:
    TNT1 A 0 A_JumpIf(GetCvar("ENTRY_smooth") == 1, "Fire_NoSmooth")

    ESH1 A 3
    ESH1 B 2 BRIGHT {
	A_FireBullets (4.8, 1.9, 10, 5, "BulletPuff");
	A_PlaySound ("weapons/shotgf", CHAN_WEAPON);
	A_SetPitch(pitch-0.5);
	}
	ESH1 C 2 BRIGHT A_SetPitch(pitch-0.5)
	ESH1 E 1 BRIGHT A_SetPitch(pitch+0.25)
	ESH1 F 2 A_SetPitch(pitch+0.25)
	ESH1 G 1 A_SetPitch(pitch+0.5)
	ESH1 IKM 1 A_SetRoll(roll-0.48)
	ESH1 N 1 A_SetPitch(pitch+0.25)
	ESH1 OP 2 A_SetPitch(pitch+0.25)
    ESH1 Q 1 { A_FireCustomMissile("ShotShell",random(-20,-60),False,10); A_SetPitch(pitch-0.25); }
	ESH1 R 2 A_SetPitch(pitch-0.25)
    ESH1 S 1 A_SetPitch(pitch-0.25)
	ESH1 TUW 1 A_SetRoll(roll+0.48)
	ESH1 YZ 1
    ESH1 A 4
    ESH1 A 7 A_ReFire
    Goto Ready

  Fire_NoSmooth:
    SHTG A 3
    SHTG A 7 {
	A_FireBullets (5.6, 0, 8, 5, "BulletPuff");
	A_PlaySound ("weapons/shotgf", CHAN_WEAPON);
    A_GunFlash;
	}
    SHTG BC 5
    SHTG D 4 A_FireCustomMissile("ShotShell",random(-20,-60),False,10)
    SHTG CB 5
    SHTG A 3
    SHTG A 7 A_ReFire
    Goto Ready
  Flash:
    SHTF A 4 Bright A_Light1
    SHTF B 3 Bright A_Light2
    Goto LightDone
  Spawn:
    SHOT A -1
    Stop
  Spawn:
    SHOT A -1
    Stop
  }
}
Here is the full DECORATE
Ac!d
Posts: 348
Joined: Tue Apr 02, 2019 5:13 am

Re: Quad damage sound

Post by Ac!d »

I've tried it and your ZScript code doesn't have any error. All I did was copy and paste your code to see if I could detect that error.
User avatar
Korni27
Posts: 46
Joined: Sun Jan 31, 2021 9:18 am
Preferred Pronouns: No Preference
Operating System Version (Optional): Windows 10
Location: Poland
Contact:

Re: Quad damage sound

Post by Korni27 »

Ac!d wrote: Wed Jun 21, 2023 2:47 pm I've tried it and your ZScript code doesn't have any error. All I did was copy and paste your code to see if I could detect that error.
Did you try It in a pk3 or wad, I am using a WAD and for some reason it want's something on line 1, but idk what
Ac!d
Posts: 348
Joined: Tue Apr 02, 2019 5:13 am

Re: Quad damage sound

Post by Ac!d »

Tried both. Also, your decorate code contains the "Spawn" state twice.
Attachments
test.wad
(4.24 KiB) Downloaded 17 times
test.pk3
(2.05 KiB) Downloaded 16 times
User avatar
Korni27
Posts: 46
Joined: Sun Jan 31, 2021 9:18 am
Preferred Pronouns: No Preference
Operating System Version (Optional): Windows 10
Location: Poland
Contact:

Re: Quad damage sound

Post by Korni27 »

It still doesn't wok, alight, I think ima scrap that concept, and maybe come back to it, I gotta focus on different things in the mod
User avatar
R4L
Global Moderator
Posts: 425
Joined: Fri Mar 03, 2017 9:53 am
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 11 Pro
Graphics Processor: ATI/AMD with Vulkan/Metal Support
Contact:

Re: Quad damage sound

Post by R4L »

First of all, this is not completely converted to ZScript. You have missing semicolons, a missing Default block and the syntax to define your class is using Decorate's method:

Code: Select all

ACTOR NewShotgun : Weapon replaces Shotgun //This should read as Class instead of ACTOR
{
  //Default block should start here for your properties
  Weapon.SelectionOrder 1300
  Weapon.AmmoUse 1
  Weapon.AmmoGive 8
  Weapon.AmmoType "Shell"
  Inventory.PickupMessage "$GOTSHOTGUN"
  Obituary "$OB_MPSHOTGUN"
  //Default block should end here
  States
  {
  Ready:
    TNT1 A 0 A_JumpIf(GetCvar("ENTRY_smooth") == 1, "Ready_NoSmooth")
    
    ESH1 A 1 A_WeaponReady
    Loop
  Ready_NoSmooth:
    TNT1 A 0 A_JumpIf(GetCvar("ENTRY_smooth") == 0, "Ready")
    
    SHTG A 1 A_WeaponReady
    Loop
  Deselect:
    TNT1 A 0 A_JumpIf(GetCvar("ENTRY_smooth") == 1, "Deselect_NoSmooth")
    
    ESH1 A 1 A_Lower
	NULL AA 0 A_Lower
    Loop
  Deselect_NoSmooth:
    TNT1 A 0 A_JumpIf(GetCvar("ENTRY_smooth") == 0, "Deselect")

    SHTG A 1 A_Lower
	NULL AA 0 A_Lower
    Loop
  Select:
    TNT1 A 0 A_JumpIf(GetCvar("ENTRY_smooth") == 1, "Select_NoSmooth")
    
    ESH1 A 1 A_Raise
    NULL AA 0 A_Raise
    Loop
  Select_NoSmooth:
    TNT1 A 0 A_JumpIf(GetCvar("ENTRY_smooth") == 0, "Select")

    SHTG A 1 A_Raise
    NULL AA 0 A_Raise
    Loop
  Fire:
    TNT1 A 0 A_JumpIf(GetCvar("ENTRY_smooth") == 1, "Fire_NoSmooth")
    TNT1 A 0 A_JumpIfInventory("Powersync_thecrusible",1,"Fire_Speed")
    ESH1 A 3
    ESH1 B 2 BRIGHT {
	A_FireBullets (4.8, 1.9, 7, 8, "BulletPuff");
	A_SetPitch(pitch-0.5);
	A_PlaySound("weapons/shotgf",CHAN_WEAPON);
	}
	ESH1 CD 2 BRIGHT A_SetPitch(pitch-0.25)
	ESH1 E 1 BRIGHT A_SetPitch(pitch+0.25)
	ESH1 F 2 A_SetPitch(pitch+0.25)
	ESH1 GH 1 A_SetPitch(pitch+0.25)
	ESH1 IJKLM 1 A_SetRoll(roll-0.24)
	ESH1 N 1 A_SetPitch(pitch+0.25)
	ESH1 OP 2 A_SetPitch(pitch+0.25)
    ESH1 Q 1 { A_FireCustomMissile("ShotShell",random(-20,-60),False,10); A_SetPitch(pitch-0.25); }
	ESH1 R 2 A_SetPitch(pitch-0.25)
    ESH1 S 1 A_SetPitch(pitch-0.25)
	ESH1 TUVWX 1 A_SetRoll(roll+0.24)
	ESH1 YZ 1 
    ESH1 A 1
    ESH1 A 7 A_ReFire
    Goto Ready

  Fire_Speed:
    TNT1 A 0 A_JumpIf(GetCvar("ENTRY_smooth") == 1, "Fire_NoSmooth")

    ESH1 A 3
    ESH1 B 2 BRIGHT {
	A_FireBullets (4.8, 1.9, 10, 5, "BulletPuff");
	A_PlaySound ("weapons/shotgf", CHAN_WEAPON);
	A_SetPitch(pitch-0.5);
	}
	ESH1 C 2 BRIGHT A_SetPitch(pitch-0.5)
	ESH1 E 1 BRIGHT A_SetPitch(pitch+0.25)
	ESH1 F 2 A_SetPitch(pitch+0.25)
	ESH1 G 1 A_SetPitch(pitch+0.5)
	ESH1 IKM 1 A_SetRoll(roll-0.48)
	ESH1 N 1 A_SetPitch(pitch+0.25)
	ESH1 OP 2 A_SetPitch(pitch+0.25)
    ESH1 Q 1 { A_FireCustomMissile("ShotShell",random(-20,-60),False,10); A_SetPitch(pitch-0.25); }
	ESH1 R 2 A_SetPitch(pitch-0.25)
    ESH1 S 1 A_SetPitch(pitch-0.25)
	ESH1 TUW 1 A_SetRoll(roll+0.48)
	ESH1 YZ 1
    ESH1 A 4
    ESH1 A 7 A_ReFire
    Goto Ready

  Fire_NoSmooth:
    SHTG A 3
    SHTG A 7 {
	A_FireBullets (5.6, 0, 8, 5, "BulletPuff");
	A_PlaySound ("weapons/shotgf", CHAN_WEAPON);
    A_GunFlash;
	}
    SHTG BC 5
    SHTG D 4 A_FireCustomMissile("ShotShell",random(-20,-60),False,10)
    SHTG CB 5
    SHTG A 3
    SHTG A 7 A_ReFire
    Goto Ready
  Flash:
    SHTF A 4 Bright A_Light1
    SHTF B 3 Bright A_Light2
    Goto LightDone
  Spawn:
    SHOT A -1
    Stop
  Spawn:
    SHOT A -1
    Stop
  }
}
This is what it should look like:

Code: Select all

Class NewShotgun : Weapon replaces Shotgun
{
	Default
	{
		Weapon.SelectionOrder 1300;
		Weapon.AmmoUse 1;
		Weapon.AmmoGive 8;
		Weapon.AmmoType "Shell";
		Inventory.PickupMessage "$GOTSHOTGUN";
		Obituary "$OB_MPSHOTGUN";
	}
	
	States
	{
		Ready:
			TNT1 A 0 A_JumpIf(GetCvar("ENTRY_smooth") == 1, "Ready_NoSmooth");
			ESH1 A 1 A_WeaponReady;
			Loop;
			
		Ready_NoSmooth:
			TNT1 A 0 A_JumpIf(GetCvar("ENTRY_smooth") == 0, "Ready");
			SHTG A 1 A_WeaponReady;
			Loop;
	  
		Deselect:
			TNT1 A 0 A_JumpIf(GetCvar("ENTRY_smooth") == 1, "Deselect_NoSmooth");
			ESH1 A 1 A_Lower;
			TNT1 AA 0 A_Lower;
			Loop;
			
		Deselect_NoSmooth:
			TNT1 A 0 A_JumpIf(GetCvar("ENTRY_smooth") == 0, "Deselect");
			SHTG A 1 A_Lower;
			TNT1 AA 0 A_Lower;
			Loop;
			
		Select:
			TNT1 A 0 A_JumpIf(GetCvar("ENTRY_smooth") == 1, "Select_NoSmooth");
			ESH1 A 1 A_Raise;
			TNT1 AA 0 A_Raise;
			Loop;
			
		Select_NoSmooth:
			TNT1 A 0 A_JumpIf(GetCvar("ENTRY_smooth") == 0, "Select");
			SHTG A 1 A_Raise;
			TNT1 AA 0 A_Raise;
			Loop;
			
		Fire:
			TNT1 A 0 A_JumpIf(GetCvar("ENTRY_smooth") == 1, "Fire_NoSmooth");
			TNT1 A 0 A_JumpIfInventory("Powersync_thecrusible",1,"Fire_Speed");
			ESH1 A 3;
			ESH1 B 2 BRIGHT {
				A_FireBullets (4.8, 1.9, 7, 8, "BulletPuff");
				A_SetPitch(pitch-0.5);
				A_PlaySound("weapons/shotgf",CHAN_WEAPON);
			}
			ESH1 CD 2 BRIGHT A_SetPitch(pitch-0.25);
			ESH1 E 1 BRIGHT A_SetPitch(pitch+0.25);
			ESH1 F 2 A_SetPitch(pitch+0.25);
			ESH1 GH 1 A_SetPitch(pitch+0.25);
			ESH1 IJKLM 1 A_SetRoll(roll-0.24);
			ESH1 N 1 A_SetPitch(pitch+0.25);
			ESH1 OP 2 A_SetPitch(pitch+0.25);
			ESH1 Q 1 { 
				A_FireCustomMissile("ShotShell",random(-20,-60),False,10); 
				A_SetPitch(pitch-0.25); 
			}
			ESH1 R 2 A_SetPitch(pitch-0.25);
			ESH1 S 1 A_SetPitch(pitch-0.25);
			ESH1 TUVWX 1 A_SetRoll(roll+0.24);
			ESH1 YZ 1;
			ESH1 A 1;
			ESH1 A 7 A_ReFire;
			Goto Ready;

		Fire_Speed:
			TNT1 A 0 A_JumpIf(GetCvar("ENTRY_smooth") == 1, "Fire_NoSmooth");
			ESH1 A 3;
			ESH1 B 2 BRIGHT {
				A_FireBullets (4.8, 1.9, 10, 5, "BulletPuff");
				A_PlaySound ("weapons/shotgf", CHAN_WEAPON);
				A_SetPitch(pitch-0.5);
			}
			ESH1 C 2 BRIGHT A_SetPitch(pitch-0.5);
			ESH1 E 1 BRIGHT A_SetPitch(pitch+0.25);
			ESH1 F 2 A_SetPitch(pitch+0.25);
			ESH1 G 1 A_SetPitch(pitch+0.5);
			ESH1 IKM 1 A_SetRoll(roll-0.48);
			ESH1 N 1 A_SetPitch(pitch+0.25);
			ESH1 OP 2 A_SetPitch(pitch+0.25);
			ESH1 Q 1 { 
				A_FireCustomMissile("ShotShell",random(-20,-60),False,10); 
				A_SetPitch(pitch-0.25); 
			}
			ESH1 R 2 A_SetPitch(pitch-0.25);
			ESH1 S 1 A_SetPitch(pitch-0.25);
			ESH1 TUW 1 A_SetRoll(roll+0.48);
			ESH1 YZ 1;
			ESH1 A 4;
			ESH1 A 7 A_ReFire;
			Goto Ready;

		Fire_NoSmooth:
			SHTG A 3;
			SHTG A 7 {
				A_FireBullets (5.6, 0, 8, 5, "BulletPuff");
				A_PlaySound ("weapons/shotgf", CHAN_WEAPON);
				A_GunFlash;
			}
			SHTG BC 5;
			SHTG D 4 A_FireCustomMissile("ShotShell",random(-20,-60),False,10);
			SHTG CB 5;
			SHTG A 3;
			SHTG A 7 A_ReFire;
			Goto Ready;
		Flash:
			SHTF A 4 Bright A_Light1;
			SHTF B 3 Bright A_Light2;
			Goto LightDone;
		Spawn:
			SHOT A -1;
			Stop;
		Spawn:
			SHOT A -1;
			Stop;
	}
}
You should also remove A_FireCustomMissile and use A_FireProjectile instead. Also, NULL is not really recommended for use. You should use TNT1 instead.
User avatar
Korni27
Posts: 46
Joined: Sun Jan 31, 2021 9:18 am
Preferred Pronouns: No Preference
Operating System Version (Optional): Windows 10
Location: Poland
Contact:

Re: Quad damage sound

Post by Korni27 »

Will the custom function, that played the quad damage sound, work?

and, is it possible to keep the weapons already coded, inside DECORATE?
I mean, it isn't hard to convert it, but it's just busy work.
User avatar
Player701
 
 
Posts: 1710
Joined: Wed May 13, 2009 3:15 am
Graphics Processor: nVidia with Vulkan support
Contact:

Re: Quad damage sound

Post by Player701 »

Korni27 wrote: Wed Jun 21, 2023 5:57 amWhen I plug it into the weapons in DECORATE it breaks

Code: Select all

#Include "ZSCRIPT"
...
You cannot #include ZScript lumps in DECORATE files - this is likely the cause of all your problems. Furthermore, if your ZScript lump is already named ZSCRIPT, GZDoom will load it automatically.

The typical usage pattern for #include is to have one top-level DECORATE or ZSCRIPT lump as well as multiple second-level DECORATE/ZScript lumps (they can be arbitrarily-named) #included from the core lump. You can have both DECORATE and ZScript code in your WAD/PK3, but you cannot #include one from the other (or vice-versa). Your DECORATE code already has access to all ZScript-based classes by default (but not the other way around).
Korni27 wrote: Fri Jun 23, 2023 4:18 pm is it possible to keep the weapons already coded, inside DECORATE?
Yes, it is - see above.
Korni27 wrote: Fri Jun 23, 2023 4:18 pm Will the custom function, that played the quad damage sound, work?
I don't see why not.
Post Reply

Return to “Scripting”