how to connect items between maps?

Ask about mapping, UDMF, using DoomBuilder/editor of choice, etc, 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.
Post Reply
User avatar
Sir Robin
Posts: 537
Joined: Wed Dec 22, 2021 7:02 pm
Graphics Processor: Intel (Modern GZDoom)
Location: Medellin, Colombia

how to connect items between maps?

Post by Sir Robin »

How can one map track what happened on another map?

For example I flip a switch on map 1 then go to map 2 and a door is opened?

My first thought was to give the player a marker item in map 1 then check for it in map 2. But what if the player carrying it dies or disconnects, then the object is lost and the link is broken.

So what's the best way to do that?
Jarewill
 
 
Posts: 1853
Joined: Sun Jul 21, 2019 8:54 am

Re: how to connect items between maps?

Post by Jarewill »

I think using world or global scope variables in ACS would do the trick here.
Here's a small example using world-scope variables to lower a floor on another level.
If you go to the next map without pressing the switch behind you, nothing will happen, but if you press that misaligned texture switch then the second map's floor will lower.
Attachments
GLOBALVARS.wad
(4.68 KiB) Downloaded 116 times
User avatar
Sir Robin
Posts: 537
Joined: Wed Dec 22, 2021 7:02 pm
Graphics Processor: Intel (Modern GZDoom)
Location: Medellin, Colombia

Re: how to connect items between maps?

Post by Sir Robin »

Awesome! Thanks for throwing together that example for me!

So my next question is can I access those variables from ZScript, or does ZScript have it's own equivelent?

It is a little trickier, but yes: wiki: ZScript global variables
Jarewill
 
 
Posts: 1853
Joined: Sun Jul 21, 2019 8:54 am

Re: how to connect items between maps?

Post by Jarewill »

While I don't know of a method to access ACS variables in ZScript, you could potentially use ScriptCall to call a ZScript function that sets the ZScript variable to the ACS one.
Untested example:

Code: Select all

//ZScript
	int globalvar;
	static void SetVariable(int value){
		globalvar = value;
	}
	
	//ACS
	ScriptCall("MyEventHandler","SetVariable",globalvar);
boris
Posts: 775
Joined: Tue Jul 15, 2003 3:37 pm

Re: how to connect items between maps?

Post by boris »

You can simply run a script in another map. Actions like ACS_Execute take a map as one of the parameters. Only works for maps in the same hub, though. Hexen makes extensive use of that.
User avatar
Sir Robin
Posts: 537
Joined: Wed Dec 22, 2021 7:02 pm
Graphics Processor: Intel (Modern GZDoom)
Location: Medellin, Colombia

Re: how to connect items between maps?

Post by Sir Robin »

Awesome guys, thanks for the help. I've been digging through the wiki to understand this stuff.
So, yes ACS can call a script on another level. I understand that it's not realtime (because the map is not actually loaded) but it queues the function call and executes it next time the player(s) are on that level.
Ah yes I remember that about Hexen, you'd flip a switch and it would say something like "a puzzle has been solved on another map" or something like that.

Ok, so real simple, is there a way to run a special (or specifically, activate and deactivate thing) from ZScript? Or do I need to write ACS functions and call them from ZS?

An overview of what I'm doing:
I've got a map with some of the passages between areas blocked off by an actor, let's call it BunchOfRocks. this actor is at both end of the passage. It has a specific TID, let's say 1001, and also a user_passageId=1001. When a player uses this object, it says the passage is blocked by rocks. If the player has a pickaxe in inventory, one is taken and the actor deactivates all ohter TID=user_passageId actors, thereby clearing the rocks at both ends of the passage. This works great with the passage on one map, I'm trying to get it to work across 2 maps with passage ends on either map.
So I'm got all that functionality working I just need to know a way to transmit that activate/deactivate to other maps.
ZScript if possible, but I'll use whatever works.

I think if I go the mixed route, I can create a set of scripts on each level called activateTID and deactivateTID, that takes a TID as parameter, and then I can call that from that ACS_Execute thing. And if I understand correctly, I can put those functions in an ACS library so I don't have to copy paste them to all the levels.

Is that the way to go?
User avatar
22alpha22
Posts: 308
Joined: Fri Feb 21, 2014 5:04 pm
Graphics Processor: nVidia with Vulkan support
Location: Montana, USA

Re: how to connect items between maps?

Post by 22alpha22 »

Sir Robin wrote: Mon Oct 16, 2023 3:08 pm Ok, so real simple, is there a way to run a special (or specifically, activate and deactivate thing) from ZScript? Or do I need to write ACS functions and call them from ZS?
You can use A_CallSpecial to call an action special from ZScript. NOTE: It will only accept numbered action specials, ACS specific functions cannot be called from ZScript.

https://zdoom.org/wiki/A_CallSpecial
Post Reply

Return to “Mapping”