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
Major Cooke
Posts: 8208
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: GZBoomer Town

Re: ZScript Discussion

Post by Major Cooke »

That's not what he meant, ZZYZX, he was asking how to set it up.

Now this is just an example.

Code: Select all

		BlockThingsIterator it = BlockThingsIterator.Create(self);
		while (it.Next())
		{
			Actor mo = it.thing;
			if (!mo || mo == self || mo is "PlayerPawn") // Ignore player actors.
				continue;
			
			double blockdist = radius + mo.radius;
			if (abs(mo.pos.x - it.Position.X) >= blockdist || abs(mo.pos.y - it.Position.Y) >= blockdist)
				continue;

			// Q: Make this z-aware for everything? It never was before.
			if (mo.pos.z + mo.height < pos.z || mo.pos.z > pos.z + height)
			{
				if (CurSector.PortalGroup != mo.CurSector.PortalGroup)
					continue;
			}
			
			if (mo.bSHOOTABLE || mo.bVULNERABLE)
			{	mo.DamageMobj(self, self, "Crush", 2000);	}
			
		}
You are right, Ed, it takes a pointer. That pointer is the 'center' of the search.

it.thing is the actor that is checked (though for convenience I just used 'Actor mo = it.thing;') and did all those checks up there, but bear in mind those are distance checks included. You can ex-nay those if you need to.
Last edited by Major Cooke on Wed Dec 28, 2016 12:42 pm, edited 1 time in total.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49225
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: ZScript Discussion

Post by Graf Zahl »

The BlockThingsIterator is clearly not suitable for counting items. For that you have to get your countable items into some sort of optimized list that doesn't contain anything else, and I'M afraid, right now tids are the only workable solution.
User avatar
Major Cooke
Posts: 8208
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: GZBoomer Town

Re: ZScript Discussion

Post by Major Cooke »

Well it's at least a step up from using thinkeriterator in case if tids aren't an option. That's all I'm saying. At least this way, the snowflakes aren't included.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49225
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: ZScript Discussion

Post by Graf Zahl »

No, it's definitely not! The internal overhead for a BlockThingsIterator is a lot higher than for a ThinkerIterator, because a lot more work has to be done on the script side (which is slower.)
If you want to make this fast, the only real option is to have the stuff you want to count in a list that doesn't contain too much noise, even if that means putting in a bit more work to set up the item to optimize counting.
User avatar
Major Cooke
Posts: 8208
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: GZBoomer Town

Re: ZScript Discussion

Post by Major Cooke »

Now that I didn't know...
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 »

Thanks for all the food for thought, both of you. I may revisit my setup later, but as my only issue seems to be in this one map, I'll deem it to be not worth overhauling it all right now for this one map. As a stopgap, I altered the snow actors to be a lot friendlier to my project (and look better, in my opinion), so I have what I need for now.

Again, thanks!
User avatar
Major Cooke
Posts: 8208
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: GZBoomer Town

Re: ZScript Discussion

Post by Major Cooke »

Curious... What can this be used for?

Code: Select all

struct Wads
{
	enum WadNamespace
	{
		ns_hidden = -1,

		ns_global = 0,
		ns_sprites,
		ns_flats,
		ns_colormaps,
		ns_acslibrary,
		ns_newtextures,
		ns_bloodraw,
		ns_bloodsfx,
		ns_bloodmisc,
		ns_strifevoices,
		ns_hires,
		ns_voxels,

		ns_specialzipdirectory,
		ns_sounds,
		ns_patches,
		ns_graphics,
		ns_music,

		ns_firstskin,
	}

	native static int CheckNumForName(string name, int ns, int wadnum = -1, bool exact = false);
}
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49225
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: ZScript Discussion

Post by Graf Zahl »

Searching for lumps in WADs.
User avatar
Major Cooke
Posts: 8208
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: GZBoomer Town

Re: ZScript Discussion

Post by Major Cooke »

Can it get the name of the wad by chance?
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49225
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: ZScript Discussion

Post by Graf Zahl »

Not yet. What's there is only because some game code needed this.
User avatar
Nash
 
 
Posts: 17487
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia

Re: ZScript Discussion

Post by Nash »

Graf Zahl wrote:Searching for lumps in WADs.
How about reading lump content?

Use context: Modders have abused the LANGUAGE lump for years to create custom "scripted languages" that they'd manually parse and process as they see fit.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49225
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: ZScript Discussion

Post by Graf Zahl »

Like I said: Right now it's just so that I could implement the Minotaur's resource checks. I can't do everything at once. ZScript stage one was just making the code from the g_game directories compile, nothing more.
User avatar
kodi
 
 
Posts: 1355
Joined: Mon May 06, 2013 8:02 am

Re: ZScript Discussion

Post by kodi »

Feeling a little stupid here: I get a "no player classes defined" error while trying to launch d4dzscript or my own project with any of the recent gzdoom dev builds.
nevermind I figured it out. :3:
User avatar
Beed28
Posts: 598
Joined: Sun Feb 24, 2013 4:07 pm
Location: United Kingdom

Re: ZScript Discussion

Post by Beed28 »

Question; will this allow the player actor to freely respawn after death instead of restarting the level, without requiring MAPINFO hacks?
User avatar
Rachael
Posts: 13923
Joined: Tue Jan 13, 2004 1:31 pm
Preferred Pronouns: She/Her

Re: ZScript Discussion

Post by Rachael »

Beed28 wrote:Question; will this allow the player actor to freely respawn after death instead of restarting the level, without requiring MAPINFO hacks?
What exactly do you mean? A player can already do this now, but it's a CVAR that has to be set (I locked it behind one because I considered it a cheat).

Otherwise, MAPINFO is the perfect spot to put that. Unless you're wanting certain types of death to allow a respawn and certain others to force a reload?

Return to “Scripting”