ZScript Discussion

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!)
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 48040
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: ZScript Discussion

Post by Graf Zahl »

Indirectly, yes. You fetch the state with 'let spawnstate = FindState('Spawn');' then the sprite with 'let sprid = spawnstate.sprite;'
The current sprite can be fetched, too, every actor got a 'sprite' property holding that value.
User avatar
Ed the Bat
Posts: 3060
Joined: Thu May 03, 2012 1:18 pm
Graphics Processor: nVidia with Vulkan support
Location: Maryland, US

Re: ZScript Discussion

Post by Ed the Bat »

Ah, this will get me exactly where I wanted to be! Thank you so much. :D
User avatar
ZZYZX
 
 
Posts: 1381
Joined: Sun Oct 14, 2012 1:43 am
Discord: ZZYZX#1394
Github ID: jewalky
Location: Ukraine

Re: ZScript Discussion

Post by ZZYZX »

Graf Zahl wrote:Indirectly, yes. You fetch the state with 'let spawnstate = FindState('Spawn');' then the sprite with 'let sprid = spawnstate.sprite;'
The current sprite can be fetched, too, every actor got a 'sprite' property holding that value.
Is sprid a name or a string? Can you cast it to a string? (string(sprite) would work?)
If so, then probably my vararg implementation should be updated, as it's supposed to convert all ambiguous string-integer stuff into string, unless int(value) specified directly, so that the modder can be sure that his %s won't randomly break.
User avatar
Major Cooke
Posts: 8070
Joined: Sun Jan 28, 2007 3:55 pm

Re: ZScript Discussion

Post by Major Cooke »

sprite is a SpriteID struct.
User avatar
ZZYZX
 
 
Posts: 1381
Joined: Sun Oct 14, 2012 1:43 am
Discord: ZZYZX#1394
Github ID: jewalky
Location: Ukraine

Re: ZScript Discussion

Post by ZZYZX »

Oh. For whatever reason I thought it's an integer.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 48040
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: ZScript Discussion

Post by Graf Zahl »

SpriteID is an integer with special savegame semantics. Those were the only reason it got invented.
User avatar
ZZYZX
 
 
Posts: 1381
Joined: Sun Oct 14, 2012 1:43 am
Discord: ZZYZX#1394
Github ID: jewalky
Location: Ukraine

Re: ZScript Discussion

Post by ZZYZX »

For whatever reason my current code makes GZDoom silently exit to desktop (and sit in the process list) when I try to do this code:

Code: Select all

class MyHandler : StaticRenderEventHandler
{
    String myS;

    override void WorldLoadedUnsafe()
    {
        myS = "";
        Console.Printf("map loaded [unsafe]\n");
    }
}
If I don't try to set myS, it doesn't crash. If myS is an integer, it doesn't crash either.
Is that something I broke or something you broke? (I know there was some internal change about how strings work).
Otherwise, I'm creating my event handlers using PClass::CreateNew() based on type provided to EventHandler.Create(). Does this function not perform scripted field construction?
Putting a string field in an actor class and outputting it in it's Tick() works.

Also, this is safe vs unsafe world events: http://i.imgur.com/AyYkpKf.png
Safe events call exactly like ACS OPEN and UNLOADING (i.e. throughout one game session, and they are savegame-friendly).
Unsafe events call at real map loading and unloading and are not savegame-friendly nor playsim-transparent. This is planned for the future.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 48040
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: ZScript Discussion

Post by Graf Zahl »

What does the function's disassembly look like? You get that with -dumpdisasm on the command line.
User avatar
ZZYZX
 
 
Posts: 1381
Joined: Sun Oct 14, 2012 1:43 am
Discord: ZZYZX#1394
Github ID: jewalky
Location: Ukraine

Re: ZScript Discussion

Post by ZZYZX »

Code: Select all

========================= MyHandler.WorldLoadedUnsafe =========================
Integer regs: 0    Float regs: 0    Address regs: 2    String regs: 1  
Stack size: 1

Constant integers:
  0. 104              1. 0              

Constant addresses:
  0. 0425FB28:1       

Constant strings:
  0. 
  1. map loaded [unsafe]


Disassembly @ 04AB83C0:
00000000: cf010000 add     a1,a0,104                    ;1,0,0
00000004: 04000000 lk      s0,""                        ;0,0,0
00000008: 2f010001 ss      a1,s0,0                      ;1,0,1
0000000c: 48000601 param   "map loaded [unsafe]
"       ;0,6,1
00000010: 4b000100 call    [0425FB28],1,0               ;0,1,0  [Console.Printf [Native]]
00000014: 50808000 ret                                  ;128,128,0
User avatar
Major Cooke
Posts: 8070
Joined: Sun Jan 28, 2007 3:55 pm

Re: ZScript Discussion

Post by Major Cooke »

Will there eventually be support for multi-dimensional constant arrays?

I ask because instead of being able to do this:

Code: Select all

			static const Class<Inventory> weap[][] =
			{
				{"D4Pistol",		"PistolUpgradeAutomatic", 	"PistolUpgradeAltDamage", 	"PistolUpgradeAltCharge", 	"PistolUpgradeDamage", 		"PistolUpgradeLance" },
				{"D4Shotgun", 			"ShotgunMod1", 				"ShotgunMod2",				null, 						null, 						null },
				{"D4SuperShotgun", 	"SSGUpgrade1", 				"SSGUpgrade2", 				"SSGUpgrade3", 				"SSGUpgrade4", 				null },
				{"D4Repeater", 		"RepeaterUpgradePiercing", "RepeaterUpgradeDamage", 	"RepeaterUpgradeAltDamage", "RepeaterUpgradeAltAmmo", 	null },
				{"D4AssaultRifle", 	"AssaultRifleMod1", 		"AssaultRifleMod2", 		null,						null,						null },
				{"D4Chaingun", 		"ChaingunMod1",				"ChaingunMod2",				null, 						null,						null },
				{"D4RocketLauncher", 	"RocketLauncherMod1",		"RocketLauncherMod2",		null,						null,						null },
				//{"D4GrenadeLauncher", },
				{"D4PlasmaRifle", 		"PlasmaRifleMod1",			"PlasmaRifleMod2",			null,						null,						null },
				{"D4LightningGun", 		"LGUpgradeAmmo",			"LGUpgradeRange",			"LGUpgradeDamage",			"LGUpgradeAltFire",			null },
				{"D4StaticRifle", 		"StaticUpgrade1",			"StaticUpgrade2",			"StaticUpgrade3",			"StaticUpgrade4",			null },
				{"D4VortexRifle", 		"VortexUpgradeDamage",		"VortexUpgradeAmmo",		"VortexUpgradeAltSpeed",	"VortexUpgradeAltPierce", 	null },
				{"D4GaussCannon", 		"GaussCannonMod1",			"GaussCannonMod2",			null,						null,						null },
				{"D4BFG",				"BFGUpgrade1",				"BFGUpgrade2",				"BFGUpgrade3",				"BFGUpgrade4",				null },
				{"D4CarrionCannon", 	"CarrionUpgradePickup",		"CarrionUpgradeAmmo",		"CarrionUpgradeStun",		"CarrionUpgradeTime", 		null }
			};
I have to do this:

Code: Select all

    for (int i = 0; i < weap.Size(); i++)
            {
                if (weap[i] && plr.CountInv(weap[i]))
                {
                    OwnedWeaps[i] = weap[i];
                    plr.A_SetInventory("EmptyToken",1); //Use in place of null.
                    if (weap[i] == "D4Pistol")
                    {
                        OwnedWeaps[i][1] = plr.FindInventory("PistolUpgradeAutomatic",false);
                        OwnedWeaps[i][2] = plr.FindInventory("PistolUpgradeAutomatic",false);
                        OwnedWeaps[i][3] = plr.FindInventory("PistolUpgradeAutomatic",false);
                        OwnedWeaps[i][4] = plr.FindInventory("PistolUpgradeAutomatic",false);
                        OwnedWeaps[i][5] = plr.FindInventory("PistolUpgradeAutomatic",false);
                    }
                    else if (weap[i] == "D4Shotgun")
                    {
                        OwnedWeaps[i][1] = plr.FindInventory("",false);
                        OwnedWeaps[i][2] = plr.FindInventory("",false);
                        OwnedWeaps[i][3] = plr.FindInventory("",false);
                        OwnedWeaps[i][4] = plr.FindInventory("",false);
                        OwnedWeaps[i][5] = plr.FindInventory("",false);
                    }
                    else if (weap[i] == "D4SuperShotgun")
                    {
                        OwnedWeaps[i][1] = plr.FindInventory("",false);
                        OwnedWeaps[i][2] = plr.FindInventory("",false);
                        OwnedWeaps[i][3] = plr.FindInventory("",false);
                        OwnedWeaps[i][4] = plr.FindInventory("",false);
                        OwnedWeaps[i][5] = plr.FindInventory("",false);
                    }
                    else if (weap[i] == "D4Repeater")
                    {
                        OwnedWeaps[i][1] = plr.FindInventory("",false);
                        OwnedWeaps[i][2] = plr.FindInventory("",false);
                        OwnedWeaps[i][3] = plr.FindInventory("",false);
                        OwnedWeaps[i][4] = plr.FindInventory("",false);
                        OwnedWeaps[i][5] = plr.FindInventory("",false);
                    }
                    else if (weap[i] == "D4AssaultRifle")
                    {
                        OwnedWeaps[i][1] = plr.FindInventory("",false);
                        OwnedWeaps[i][2] = plr.FindInventory("",false);
                        OwnedWeaps[i][3] = plr.FindInventory("",false);
                        OwnedWeaps[i][4] = plr.FindInventory("",false);
                        OwnedWeaps[i][5] = plr.FindInventory("",false);
                    }
                    else if (weap[i] == "D4Chaingun")
                    {
                        OwnedWeaps[i][1] = plr.FindInventory("",false);
                        OwnedWeaps[i][2] = plr.FindInventory("",false);
                        OwnedWeaps[i][3] = plr.FindInventory("",false);
                        OwnedWeaps[i][4] = plr.FindInventory("",false);
                        OwnedWeaps[i][5] = plr.FindInventory("",false);
                    }
                    else if (weap[i] == "D4RocketLauncher")
                    {
                        OwnedWeaps[i][1] = plr.FindInventory("",false);
                        OwnedWeaps[i][2] = plr.FindInventory("",false);
                        OwnedWeaps[i][3] = plr.FindInventory("",false);
                        OwnedWeaps[i][4] = plr.FindInventory("",false);
                        OwnedWeaps[i][5] = plr.FindInventory("",false);
                    }
                    else if (weap[i] == "D4LightningGun")
                    {
                        OwnedWeaps[i][1] = plr.FindInventory("",false);
                        OwnedWeaps[i][2] = plr.FindInventory("",false);
                        OwnedWeaps[i][3] = plr.FindInventory("",false);
                        OwnedWeaps[i][4] = plr.FindInventory("",false);
                        OwnedWeaps[i][5] = plr.FindInventory("",false);
                    }
                    else if (weap[i] == "D4PlasmaRifle")
                    {
                        OwnedWeaps[i][1] = plr.FindInventory("",false);
                        OwnedWeaps[i][2] = plr.FindInventory("",false);
                        OwnedWeaps[i][3] = plr.FindInventory("",false);
                        OwnedWeaps[i][4] = plr.FindInventory("",false);
                        OwnedWeaps[i][5] = plr.FindInventory("",false);
                    }
                    else if (weap[i] == "D4StaticRifle")
                    {
                        OwnedWeaps[i][1] = plr.FindInventory("",false);
                        OwnedWeaps[i][2] = plr.FindInventory("",false);
                        OwnedWeaps[i][3] = plr.FindInventory("",false);
                        OwnedWeaps[i][4] = plr.FindInventory("",false);
                        OwnedWeaps[i][5] = plr.FindInventory("",false);
                    }
                    else if (weap[i] == "D4VortexRifle")
                    {
                        OwnedWeaps[i][1] = plr.FindInventory("",false);
                        OwnedWeaps[i][2] = plr.FindInventory("",false);
                        OwnedWeaps[i][3] = plr.FindInventory("",false);
                        OwnedWeaps[i][4] = plr.FindInventory("",false);
                        OwnedWeaps[i][5] = plr.FindInventory("",false);
                    }
                    else if (weap[i] == "D4GaussCannon")
                    {
                        OwnedWeaps[i][1] = plr.FindInventory("",false);
                        OwnedWeaps[i][2] = plr.FindInventory("",false);
                        OwnedWeaps[i][3] = plr.FindInventory("",false);
                        OwnedWeaps[i][4] = plr.FindInventory("",false);
                        OwnedWeaps[i][5] = plr.FindInventory("",false);
                    }
                    else if (weap[i] == "D4")
                    {
                        OwnedWeaps[i][1] = plr.FindInventory("",false);
                        OwnedWeaps[i][2] = plr.FindInventory("",false);
                        OwnedWeaps[i][3] = plr.FindInventory("",false);
                        OwnedWeaps[i][4] = plr.FindInventory("",false);
                        OwnedWeaps[i][5] = plr.FindInventory("",false);
                    }
                    else if (weap[i] == "D4")
                    {
                        OwnedWeaps[i][1] = plr.FindInventory("",false);
                        OwnedWeaps[i][2] = plr.FindInventory("",false);
                        OwnedWeaps[i][3] = plr.FindInventory("",false);
                        OwnedWeaps[i][4] = plr.FindInventory("",false);
                        OwnedWeaps[i][5] = plr.FindInventory("",false);
                    } 
Theoretical example, mind you, I'm not done with setting it up yet...
User avatar
Ed the Bat
Posts: 3060
Joined: Thu May 03, 2012 1:18 pm
Graphics Processor: nVidia with Vulkan support
Location: Maryland, US

Re: ZScript Discussion

Post by Ed the Bat »

I, too, would be in favor of the above. Splitting my items into several arrays certainly works, but I feel it would be a little easier for me to manage if I could keep using multi-dimensional arrays like I did in ACS.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 48040
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: ZScript Discussion

Post by Graf Zahl »

Major Cooke wrote:Will there eventually be support for multi-dimensional constant arrays?

I ask because instead of being able to do this:

Code: Select all

			static const Class<Inventory> weap[][] =
			{
				{"D4Pistol",		"PistolUpgradeAutomatic", 	"PistolUpgradeAltDamage", 	"PistolUpgradeAltCharge", 	"PistolUpgradeDamage", 		"PistolUpgradeLance" },
				{"D4Shotgun", 			"ShotgunMod1", 				"ShotgunMod2",				null, 						null, 						null },
				{"D4SuperShotgun", 	"SSGUpgrade1", 				"SSGUpgrade2", 				"SSGUpgrade3", 				"SSGUpgrade4", 				null },
				{"D4Repeater", 		"RepeaterUpgradePiercing", "RepeaterUpgradeDamage", 	"RepeaterUpgradeAltDamage", "RepeaterUpgradeAltAmmo", 	null },
				{"D4AssaultRifle", 	"AssaultRifleMod1", 		"AssaultRifleMod2", 		null,						null,						null },
				{"D4Chaingun", 		"ChaingunMod1",				"ChaingunMod2",				null, 						null,						null },
				{"D4RocketLauncher", 	"RocketLauncherMod1",		"RocketLauncherMod2",		null,						null,						null },
				//{"D4GrenadeLauncher", },
				{"D4PlasmaRifle", 		"PlasmaRifleMod1",			"PlasmaRifleMod2",			null,						null,						null },
				{"D4LightningGun", 		"LGUpgradeAmmo",			"LGUpgradeRange",			"LGUpgradeDamage",			"LGUpgradeAltFire",			null },
				{"D4StaticRifle", 		"StaticUpgrade1",			"StaticUpgrade2",			"StaticUpgrade3",			"StaticUpgrade4",			null },
				{"D4VortexRifle", 		"VortexUpgradeDamage",		"VortexUpgradeAmmo",		"VortexUpgradeAltSpeed",	"VortexUpgradeAltPierce", 	null },
				{"D4GaussCannon", 		"GaussCannonMod1",			"GaussCannonMod2",			null,						null,						null },
				{"D4BFG",				"BFGUpgrade1",				"BFGUpgrade2",				"BFGUpgrade3",				"BFGUpgrade4",				null },
				{"D4CarrionCannon", 	"CarrionUpgradePickup",		"CarrionUpgradeAmmo",		"CarrionUpgradeStun",		"CarrionUpgradeTime", 		null }
			};
I have to do this:

Code: Select all

    for (int i = 0; i < weap.Size(); i++)
            {
                if (weap[i] && plr.CountInv(weap[i]))
                {
                    OwnedWeaps[i] = weap[i];
                    plr.A_SetInventory("EmptyToken",1); //Use in place of null.
                    if (weap[i] == "D4Pistol")
                    {
                        OwnedWeaps[i][1] = plr.FindInventory("PistolUpgradeAutomatic",false);
                        OwnedWeaps[i][2] = plr.FindInventory("PistolUpgradeAutomatic",false);
                        OwnedWeaps[i][3] = plr.FindInventory("PistolUpgradeAutomatic",false);
                        OwnedWeaps[i][4] = plr.FindInventory("PistolUpgradeAutomatic",false);
                        OwnedWeaps[i][5] = plr.FindInventory("PistolUpgradeAutomatic",false);
                    }
                    else if (weap[i] == "D4Shotgun")
                    {
                        OwnedWeaps[i][1] = plr.FindInventory("",false);
                        OwnedWeaps[i][2] = plr.FindInventory("",false);
                        OwnedWeaps[i][3] = plr.FindInventory("",false);
                        OwnedWeaps[i][4] = plr.FindInventory("",false);
                        OwnedWeaps[i][5] = plr.FindInventory("",false);
                    }
                    else if (weap[i] == "D4SuperShotgun")
                    {
                        OwnedWeaps[i][1] = plr.FindInventory("",false);
                        OwnedWeaps[i][2] = plr.FindInventory("",false);
                        OwnedWeaps[i][3] = plr.FindInventory("",false);
                        OwnedWeaps[i][4] = plr.FindInventory("",false);
                        OwnedWeaps[i][5] = plr.FindInventory("",false);
                    }
                    else if (weap[i] == "D4Repeater")
                    {
                        OwnedWeaps[i][1] = plr.FindInventory("",false);
                        OwnedWeaps[i][2] = plr.FindInventory("",false);
                        OwnedWeaps[i][3] = plr.FindInventory("",false);
                        OwnedWeaps[i][4] = plr.FindInventory("",false);
                        OwnedWeaps[i][5] = plr.FindInventory("",false);
                    }
                    else if (weap[i] == "D4AssaultRifle")
                    {
                        OwnedWeaps[i][1] = plr.FindInventory("",false);
                        OwnedWeaps[i][2] = plr.FindInventory("",false);
                        OwnedWeaps[i][3] = plr.FindInventory("",false);
                        OwnedWeaps[i][4] = plr.FindInventory("",false);
                        OwnedWeaps[i][5] = plr.FindInventory("",false);
                    }
                    else if (weap[i] == "D4Chaingun")
                    {
                        OwnedWeaps[i][1] = plr.FindInventory("",false);
                        OwnedWeaps[i][2] = plr.FindInventory("",false);
                        OwnedWeaps[i][3] = plr.FindInventory("",false);
                        OwnedWeaps[i][4] = plr.FindInventory("",false);
                        OwnedWeaps[i][5] = plr.FindInventory("",false);
                    }
                    else if (weap[i] == "D4RocketLauncher")
                    {
                        OwnedWeaps[i][1] = plr.FindInventory("",false);
                        OwnedWeaps[i][2] = plr.FindInventory("",false);
                        OwnedWeaps[i][3] = plr.FindInventory("",false);
                        OwnedWeaps[i][4] = plr.FindInventory("",false);
                        OwnedWeaps[i][5] = plr.FindInventory("",false);
                    }
                    else if (weap[i] == "D4LightningGun")
                    {
                        OwnedWeaps[i][1] = plr.FindInventory("",false);
                        OwnedWeaps[i][2] = plr.FindInventory("",false);
                        OwnedWeaps[i][3] = plr.FindInventory("",false);
                        OwnedWeaps[i][4] = plr.FindInventory("",false);
                        OwnedWeaps[i][5] = plr.FindInventory("",false);
                    }
                    else if (weap[i] == "D4PlasmaRifle")
                    {
                        OwnedWeaps[i][1] = plr.FindInventory("",false);
                        OwnedWeaps[i][2] = plr.FindInventory("",false);
                        OwnedWeaps[i][3] = plr.FindInventory("",false);
                        OwnedWeaps[i][4] = plr.FindInventory("",false);
                        OwnedWeaps[i][5] = plr.FindInventory("",false);
                    }
                    else if (weap[i] == "D4StaticRifle")
                    {
                        OwnedWeaps[i][1] = plr.FindInventory("",false);
                        OwnedWeaps[i][2] = plr.FindInventory("",false);
                        OwnedWeaps[i][3] = plr.FindInventory("",false);
                        OwnedWeaps[i][4] = plr.FindInventory("",false);
                        OwnedWeaps[i][5] = plr.FindInventory("",false);
                    }
                    else if (weap[i] == "D4VortexRifle")
                    {
                        OwnedWeaps[i][1] = plr.FindInventory("",false);
                        OwnedWeaps[i][2] = plr.FindInventory("",false);
                        OwnedWeaps[i][3] = plr.FindInventory("",false);
                        OwnedWeaps[i][4] = plr.FindInventory("",false);
                        OwnedWeaps[i][5] = plr.FindInventory("",false);
                    }
                    else if (weap[i] == "D4GaussCannon")
                    {
                        OwnedWeaps[i][1] = plr.FindInventory("",false);
                        OwnedWeaps[i][2] = plr.FindInventory("",false);
                        OwnedWeaps[i][3] = plr.FindInventory("",false);
                        OwnedWeaps[i][4] = plr.FindInventory("",false);
                        OwnedWeaps[i][5] = plr.FindInventory("",false);
                    }
                    else if (weap[i] == "D4")
                    {
                        OwnedWeaps[i][1] = plr.FindInventory("",false);
                        OwnedWeaps[i][2] = plr.FindInventory("",false);
                        OwnedWeaps[i][3] = plr.FindInventory("",false);
                        OwnedWeaps[i][4] = plr.FindInventory("",false);
                        OwnedWeaps[i][5] = plr.FindInventory("",false);
                    }
                    else if (weap[i] == "D4")
                    {
                        OwnedWeaps[i][1] = plr.FindInventory("",false);
                        OwnedWeaps[i][2] = plr.FindInventory("",false);
                        OwnedWeaps[i][3] = plr.FindInventory("",false);
                        OwnedWeaps[i][4] = plr.FindInventory("",false);
                        OwnedWeaps[i][5] = plr.FindInventory("",false);
                    }
Theoretical example, mind you, I'm not done with setting it up yet...
Not a high priority. You can fake that with a one-dimensional array and doing the multiplication for the second index yourself. So all that bunch of code is not really needed, even with the available features it's a bad way to do stuff.
User avatar
Major Cooke
Posts: 8070
Joined: Sun Jan 28, 2007 3:55 pm

Re: ZScript Discussion

Post by Major Cooke »

...huh. Didn't occur to me to do it that way. All changed. Thanks!

Code: Select all

// Weapons must be on the leftmost side. All upgrades must follow.
int ToAdd = 6;
static const Class<Inventory> weap[] =
{
    "D4Pistol",            "PistolUpgradeAutomatic",    "PistolUpgradeAltDamage",    "PistolUpgradeAltCharge",    "PistolUpgradeDamage",        "PistolUpgradeLance",
    "D4Shotgun",         "ShotgunMod1",                "ShotgunMod2",                null,                        null,                        null,
    "D4SuperShotgun",     "SSGUpgrade1",                "SSGUpgrade2",                "SSGUpgrade3",                "SSGUpgrade4",                null,
    "D4Repeater",         "RepeaterUpgradePiercing",    "RepeaterUpgradeDamage",    "RepeaterUpgradeAltDamage",    "RepeaterUpgradeAltAmmo",    null,
    "D4AssaultRifle",     "AssaultRifleMod1",            "AssaultRifleMod2",            null,                        null,                        null,
    "D4Chaingun",         "ChaingunMod1",                "ChaingunMod2",                null,                        null,                        null,
    "D4RocketLauncher",    "RocketLauncherMod1",        "RocketLauncherMod2",        null,                        null,                        null,
    //"D4GrenadeLauncher",null,                        null,                        null,                        null,                        null, 
    "D4PlasmaRifle",     "PlasmaRifleMod1",            "PlasmaRifleMod2",            null,                        null,                        null,
    "D4LightningGun",     "LGUpgradeAmmo",            "LGUpgradeRange",            "LGUpgradeDamage",            "LGUpgradeAltFire",            null,
    "D4StaticRifle",     "StaticUpgrade1",            "StaticUpgrade2",            "StaticUpgrade3",            "StaticUpgrade4",            null,
    "D4VortexRifle",     "VortexUpgradeDamage",        "VortexUpgradeAmmo",        "VortexUpgradeAltSpeed",    "VortexUpgradeAltPierce",    null,
    "D4GaussCannon",     "GaussCannonMod1",            "GaussCannonMod2",            null,                        null,                        null,
    "D4BFG",            "BFGUpgrade1",                "BFGUpgrade2",                "BFGUpgrade3",                "BFGUpgrade4",                null,
    "D4CarrionCannon",    "CarrionUpgradePickup",        "CarrionUpgradeAmmo",        "CarrionUpgradeStun",        "CarrionUpgradeTime",        null
};

static const bool chainset[] =
{
    true,    //pistol
    true,    //shotgun
    true,    //ssg
    false,    //repeater
    true,    //har
    true,    //chaingun
    true,    //rl
    true,    //plasma
    false,    //lightning
    false,    //static
    false,    //vortex
    true,    //gauss
    true,    //bfg
    false    //carrion
};

Class<Inventory> OwnedWeaps[20];
uint owned = 0, l = 0;
int filled = 0;
for (uint i = 0; i < weap.Size(); i += ToAdd)
{
    int maxfill = 0, cnt = 0;
    
    // If they have the weapon, check to see if they have all the
    // upgrades. Increment maxfill by all applicable upgrades that
    // exist, and increment cnt only by what the player has.
    
    // If the player still has more to go, add that weapon to the
    // pool chance of random droppers.
    if (weap[i] && plr.CountInv(weap[i]))
    {
        bool chaincount = chainset[l];    l++;    // UAC Russia represents.
        
        for (int j = 1; j < ToAdd; j++)
        {
            if (weap[i + j] != null)
            {
                maxfill++;
                cnt += CountInv(weap[i + j],Player1) ? 1 : 0;
            }
        }
        
        //Increment only whenever there is more to be gained.
        if (cnt < maxfill)
        {
            OwnedWeaps[owned] = weap[i];
            owned++;
        }
        else if (chaincount)
        {
            filled++;
        }
    }
}
 
User avatar
ibm5155
Posts: 1268
Joined: Wed Jul 20, 2011 4:24 pm

Re: ZScript Discussion

Post by ibm5155 »

so, Zscript will replace sbarinfo, decorate and acs at the same time?
Ehm, can we interate btw those type of codes? like using acs calls in zscript or spawing a decorate projectile from decorate?

EDIT:
Hmm it looks alot like c++ O_o

Also, can zscript do something that you really cannot do in decorate/acs?
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 48040
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: ZScript Discussion

Post by Graf Zahl »

ibm5155 wrote:so, Zscript will replace sbarinfo, decorate and acs at the same time?
Ehm, can we interate btw those type of codes? like using acs calls in zscript or spawing a decorate projectile from decorate?

EDIT:
Hmm it looks alot like c++ O_o

Also, can zscript do something that you really cannot do in decorate/acs?
Why do you think it got made? Have you looked at the amount of actual game code that already got ported? There is not one single line of actor specific code in C++ anymore.

Return to “Scripting”