[ZScript] Weapon code error

Archive of the old editing forum
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.
Locked
User avatar
potetobloke
Posts: 246
Joined: Wed Dec 07, 2016 12:07 am
Graphics Processor: nVidia (Modern GZDoom)
Location: In a chemical world

[ZScript] Weapon code error

Post by potetobloke »

Hi, I was just converting some weapon code from decorate to ZScript and suddenly, I ran across a few errors.

Line of code

Code: Select all

//SPAS-12
Class PB_Spas12 : Weapon
{
    Default
    {
  Weapon.Kickback 100;
  Weapon.BobStyle InverseAlpha;
  Weapon.BobSpeed 0.9;
  Weapon.BobRangeX 0.5;
  Weapon.BobRangeY 0.5;
  Weapon.UpSound "items/weaponswap1";
  Tag "SPAS-12";
  Inventory.Pickupmessage "Picked up a Franchi SPAS-12.";
  Inventory.PickupSound "Weapons/Pickup";
  Weapon.AmmoType "PB_ShotgunDummy";
  Weapon.AmmoType2 "PB_ShellNew";
  Weapon.AmmoGive2 8;
  Weapon.AmmoUse 1;
  Weapon.AmmoUse2 0;
  Obituary "%o was pumped with 12 Gauge pellets by %k.";
  +AMMO_OPTIONAL;
  +NOALERT;
  +NoAutoFire;
}
States
{
Ready:
SPS1 A 1;
{
A_WeaponReady (WRF_ALLOWRELOAD);
A_WeaponOffset (CallACS ("Script_GetGunOffsetX"), CallACS("Script_GetGunOffsetY"),WOF_INTERPOLATE);
}
TNT1 A 0;
Loop;
Deselect:
TNT1 A 0 A_Lower;
SPS1 A 1 A_Lower;
Loop;
Select:
TNT1 A 0 A_Raise;
SPS1 A 1 A_Raise;
Loop;
Fire:
TNT1 A 0 A_JumpIfNoAmmo ("Ready");
TNT1 A 0 A_JumpIfInventory ("PB_SPAS_SA_Mode",1,"SemiAutoFire");
TNT1 A 0 A_PlaySound ("weapons/shotgun/fire1",CHAN_WEAPON,12);
TNT1 A 0 A_AlertMonsters;
SPS2 A 1 Bright;
{
A_FireCustomMissile("12GPellet", frandom(-0.1, 0.1), 1, 0, 0, 0, frandom(-0.1, 0.1));
A_FireCustomMissile("12GPellet", frandom(-1.2, 1.2), 0, 0, 0, 0, frandom(-1.2, 1.2));
A_FireCustomMissile("12GPellet", frandom(-1.2, 1.2), 0, 0, 0, 0, frandom(-1.2, 1.2));
A_FireCustomMissile("12GPellet", frandom(-1.2, 1.2), 0, 0, 0, 0, frandom(-1.2, 1.2));
A_FireCustomMissile("12GPellet", frandom(-1.2, 1.2), 0, 0, 0, 0, frandom(-1.2, 1.2));
A_FireCustomMissile("12GPellet", frandom(-1.2, 1.2), 0, 0, 0, 0, frandom(-1.2, 1.2));
A_FireCustomMissile("12GPellet", frandom(-1.2, 1.2), 0, 0, 0, 0, frandom(-1.2, 1.2));
A_FireCustomMissile("12GPellet", frandom(-1.2, 1.2), 0, 0, 0, 0, frandom(-1.2, 1.2));
A_FireCustomMissile("12GPellet", frandom(-1.2, 1.2), 0, 0, 0, 0, frandom(-1.2, 1.2));
A_FireCustomMissile("12GPellet", frandom(-1.2, 1.2), 0, 0, 0, 0, frandom(-1.2, 1.2));
A_WeaponReady (WRF_NOSWITCH|WRF_NOFIRE);
A_SetPitch(pitch-1);
A_WeaponOffset (CallACS ("Script_GetGunOffsetX"), CallACS("Script_GetGunOffsetY"),WOF_INTERPOLATE);
}
SPS2 BCDE 1;
{
A_SetPitch(pitch+0.25);
A_WeaponReady (WRF_NOFIRE|WRF_NOSWITCH);
A_WeaponOffset (CallACS ("Script_GetGunOffsetX"), CallACS("Script_GetGunOffsetY"),WOF_INTERPOLATE);
}
Goto Pump;
SemiAutoFire:
TNT1 A 0 A_PlaySound ("weapons/shotgun/fire1",CHAN_WEAPON,12);
TNT1 A 0 A_AlertMonsters;
SPS2 A 1 Bright;
{
A_FireCustomMissile("12GPellet", frandom(-2.5, 2.5), 1, 0, 0, 0, frandom(-2.5, 2.5));
A_FireCustomMissile("12GPellet", frandom(-2.5, 2.5), 0, 0, 0, 0, frandom(-2.5, 2.5));
A_FireCustomMissile("12GPellet", frandom(-2.5, 2.5), 0, 0, 0, 0, frandom(-2.5, 2.5));
A_FireCustomMissile("12GPellet", frandom(-2.5, 2.5), 0, 0, 0, 0, frandom(-2.5, 2.5));
A_FireCustomMissile("12GPellet", frandom(-2.5, 2.5), 0, 0, 0, 0, frandom(-2.5, 2.5));
A_FireCustomMissile("12GPellet", frandom(-2.5, 2.5), 0, 0, 0, 0, frandom(-2.5, 2.5));
A_FireCustomMissile("12GPellet", frandom(-2.5, 2.5), 0, 0, 0, 0, frandom(-2.5, 2.5));
A_FireCustomMissile("12GPellet", frandom(-2.5, 2.5), 0, 0, 0, 0, frandom(-2.5, 2.5));
A_FireCustomMissile("12GPellet", frandom(-2.5, 2.5), 0, 0, 0, 0, frandom(-2.5, 2.5));
A_FireCustomMissile("12GPellet", frandom(-2.5, 2.5), 0, 0, 0, 0, frandom(-2.5, 2.5));
A_WeaponReady (WRF_NOSWITCH|WRF_NOFIRE);
A_SetPitch(pitch-1.75);
A_SetAngle(angle + frandom(-0.45, 0.45));
A_WeaponOffset (CallACS ("Script_GetGunOffsetX"), CallACS("Script_GetGunOffsetY"),WOF_INTERPOLATE);
}
TNT1 A 0 A_FireCustomMissile ("PB_casingspawner1", 0,0,frandom(7.6,7.2),-9, FPF_NOAUTOAIM);
SPS2 BCDE 1;
{
A_SetPitch(pitch-0.15);
A_WeaponReady (WRF_NOFIRE|WRF_NOSWITCH);
A_WeaponOffset (CallACS ("Script_GetGunOffsetX"), CallACS("Script_GetGunOffsetY"),WOF_INTERPOLATE);
}
Goto Ready;
Pump:
SPS3 ACEFGH 1;
{
A_WeaponReady (WRF_NOFIRE|WRF_NOSWITCH);
A_WeaponOffset (CallACS ("Script_GetGunOffsetX"), CallACS("Script_GetGunOffsetY"),WOF_INTERPOLATE);
}
TNT1 A 0 A_PlaySound ("weapons/shotgun/pump1",CHAN_7);
SPS3 IKL 1;
{
A_WeaponReady (WRF_NOFIRE|WRF_NOSWITCH);
A_WeaponOffset (CallACS ("Script_GetGunOffsetX"), CallACS("Script_GetGunOffsetY"),WOF_INTERPOLATE);
}
TNT1 A 0 A_FireCustomMissile ("PB_casingspawner1", 0,0,frandom(7.6,7.2),-9, FPF_NOAUTOAIM)
SPS3 MNPNMLKJIHGFECA 1
{
A_WeaponReady (WRF_NOFIRE|WRF_NOSWITCH);
A_WeaponOffset (CallACS ("Script_GetGunOffsetX"), CallACS("Script_GetGunOffsetY"),WOF_INTERPOLATE);
}
TNT1 A 0 A_Refire ("Fire");
goto ready;
Spawn:
SPSD Z -1
Loop;
Reload:
TNT1 A 0 A_JumpIfInventory ("PB_ShotgunDummy",8,"Ready");
TNT1 A 0 A_JumpIfInventory ("PB_ShellNew",1,"ReloadDo");
Goto Ready;
ReloadDo:
SPS3 ABCDE 1;
{
A_WeaponReady (WRF_NOFIRE|WRF_NOSWITCH);
A_WeaponOffset (CallACS ("Script_GetGunOffsetX"), CallACS("Script_GetGunOffsetY"),WOF_INTERPOLATE);
}
Goto ReloadLoop;
	ReloadLoop:
	TNT1 A 0 A_JumpIfInventory ("PB_ShotgunDummy",8,"ReloadEnd");
SPS4 AABBCCDDEE 1;
{
A_WeaponReady (WRF_NOFIRE|WRF_NOSWITCH);
A_WeaponOffset (CallACS ("Script_GetGunOffsetX"), CallACS("Script_GetGunOffsetY"),WOF_INTERPOLATE);
}
		TNT1 A 0 A_GiveInventory ("PB_ShotgunDummy",1);
		TNT1 A 0 A_TakeInventory ("PB_ShellNew",1,TIF_NOTAKEINFINITE);
		TNT1 A 0 A_PlaySound ("weapons/shotgun/load2",CHAN_7);
SPS4 FGHIJ 1;
{
A_WeaponReady (WRF_NOFIRE|WRF_NOSWITCH);
A_WeaponOffset (CallACS ("Script_GetGunOffsetX"), CallACS("Script_GetGunOffsetY"),WOF_INTERPOLATE);
}
TNT1 A 0 A_JumpIf(GetPlayerInput(INPUT_BUTTONS) & (BT_ATTACK), "ReloadEnd");
TNT1 A 0 A_JumpIf(GetPlayerInput(INPUT_BUTTONS) & (BT_ALTATTACK), "ReloadEnd");
TNT1 A 0 A_JumpIf(GetPlayerInput(INPUT_BUTTONS) & (BT_RELOAD), "ReloadEnd");
		TNT1 A 0 A_JumpIfInventory("PB_ShellNew",1,"ReloadLoop");
		Goto ReloadEnd;
		ReloadEnd:
		SPS3 EDCBA 1;
		{
A_WeaponReady (WRF_NOFIRE|WRF_NOSWITCH);
A_WeaponOffset (CallACS ("Script_GetGunOffsetX"), CallACS("Script_GetGunOffsetY"),WOF_INTERPOLATE);
}
		Goto Ready;
		AltFire:
  TNT1 A 0 A_JumpIfInventory ("PB_SPAS_SA_Mode",1,"AltFire2");
  TNT1 A 0 A_PlaySound ("Weapons/Generic/ChangeFire",CHAN_WEAPON);
  TNT1 A 0 A_GiveInventory ("PB_SPAS_SA_Mode",1);
  TNT1 A 0 A_Print ("Semi Auto",3);
  Goto Ready;
  AltFire2:
  TNT1 A 0 A_PlaySound ("Weapons/Generic/ChangeFire",CHAN_WEAPON);
  TNT1 A 0 A_TakeInventory ("PB_SPAS_SA_Mode",999,0);
  TNT1 A 0 A_Print ("Pump",3);
  Goto Ready;
}
}

Class PB_SPAS_SA_Mode : Inventory
{
Default
{
   Inventory.Amount 1;
   Inventory.MaxAmount 1;
   -INVBAR;
   +IGNORESKILL;
}
}

Class PB_ShotgunDummy : Ammo
{
Default
{
	Inventory.Amount 8;
	Inventory.MaxAmount 8;
	Inventory.Icon "TNT1A0";
	+IgnoreSkill;
}
}
Error message

Code: Select all

Script error, "PB_Projectile_Hell_v2.pk3:zscript/sg.zsc" line 31:
Unexpected ','
Expecting ';'
(The ACS thing is from Nash's weapon sway)

I couldn't see what I was doing wrong, since the error message wasn't very informative.

Thanks in advance
Blue Shadow
Posts: 4949
Joined: Sun Nov 14, 2010 12:59 am

Re: [ZScript] Weapon code error

Post by Blue Shadow »

When doing anonymous functions, you shouldn't terminate the state with that function with a semi-colon:

Code: Select all

SPS1 A 1; // <-- Incorrect. Remove the semi-colon.
{
A_WeaponReady (WRF_ALLOWRELOAD);
A_WeaponOffset (CallACS ("Script_GetGunOffsetX"), CallACS("Script_GetGunOffsetY"),WOF_INTERPOLATE);
}
Check your code for other occurrences like that.
Locked

Return to “Editing (Archive)”