Globalname: Difference between revisions
No edit summary |
No edit summary |
||
(6 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
{{TabsBar|main=gs|base=Globalname}} | |||
{{draft}} | {{draft}} | ||
{{todo|somebody fact check and remove draft}} | {{todo|somebody fact check and remove draft}} | ||
{{toc-right}} | |||
{{This is a|[[keyvalue]]|name=globalname}} It's a name to designate two entities in different maps as being logically the same entity. When player transitions from map A to B the entity in map B with matching globalname will get most of its properties from entity that was in map A like origin, angles, color etc. (model for example is not transferred). If the entity was killed in map A it will not spawn in map B. | {{This is a|[[keyvalue]]|name=globalname}} It's a name to designate two entities in different maps as being logically the same entity. When player transitions from map A to B the entity in map B with matching globalname will get most of its properties from entity that was in map A like origin, angles, color etc. (model for example is not transferred). If the entity was killed in map A it will not spawn in map B. | ||
Line 7: | Line 9: | ||
{{PlacementTip|This is important when wanting to transition brush entities as [[bmodel|brush models]] are saved within a map file and is the reason model is one of the properties that isn't transferred.}} | {{PlacementTip|This is important when wanting to transition brush entities as [[bmodel|brush models]] are saved within a map file and is the reason model is one of the properties that isn't transferred.}} | ||
Other ways to ensure no duplicate (logically same) entities between transition is properly utilizing {{ent|logic_auto}} outputs like <kbd>OnNewGame</kbd>, <kbd>OnMapTransition</kbd>. | Other ways to ensure no duplicate (logically same) entities between maps transition is properly utilizing {{ent|logic_auto}} outputs like <kbd>OnNewGame</kbd>, <kbd>OnMapTransition</kbd>. | ||
== Example == | == Example == | ||
Line 45: | Line 47: | ||
After transition we can see states were preserved and model name being different (*112 and *113 in d5 changed to *162 and *161 in d6). | After transition we can see states were preserved and model name being different (*112 and *113 in d5 changed to *162 and *161 in d6). | ||
[[File:D1 canals 05-d1 canals 06-transition-example-4.jpg|600px|center]] | [[File:D1 canals 05-d1 canals 06-transition-example-4.jpg|600px|center]] | ||
== Rough entity transition logic == | |||
{{cleanup|finish up, make this make sense}} | |||
gGlobalState - object containing list of global states that persists between transitions, each element consists of "name, map_name, state (ON/OFF/DEAD), counter" | |||
# Changelevel begins | |||
# Remember all entities that are supposed to transition which means | |||
## They are in info_landmark's PVS unless trigger_transition exists which is then used instead | |||
## They are capable of transitioning which means they have proper [[ObjectCaps]] or globalname | |||
# Next map loads, all entities spawn and following applies: | |||
## Entities with globalname where global state doesn't exist yet normally spawn and are tracked by adding state <code>"name: <globalname>, map_name: <current_map>, state: ON"</code> to gGlobalState | |||
## Entities with globalname where global state is ON and map_name is not current map are made dormant and invisible waiting to get their non-global properties overwritten by global entity that transitions | |||
## Entities with globalname where global state is DEAD are not spawned | |||
# Remembered transitioning entities spawn, following happens for each that had globalname: | |||
## Search for already spawned entity (the dormant one) (if it doesn't exist print warning and leave the entity that were to transition in previous map) | |||
## Mark self for removal | |||
## Set the associated global state's map_name to current_map | |||
## Transfer all '''non'''-global properties to the corresponding dormant entity (see datamap dump to see which are non global for example [[Half-Life 2 datamap dump]]) | |||
== See also == | == See also == | ||
* {{cmd|dump_globals}} | |||
* [[targetname]] | * [[targetname]] | ||
* [[classname]] | * [[classname]] |
Latest revision as of 11:19, 1 June 2025

Remember to check for any notes left by the tagger at this article's talk page.
globalname
is a keyvalue available in all Source games. It's a name to designate two entities in different maps as being logically the same entity. When player transitions from map A to B the entity in map B with matching globalname will get most of its properties from entity that was in map A like origin, angles, color etc. (model for example is not transferred). If the entity was killed in map A it will not spawn in map B.





Other ways to ensure no duplicate (logically same) entities between maps transition is properly utilizing logic_auto outputs like OnNewGame, OnMapTransition.
Example


d1_canals_05 / d1_canals_06
To properly preserve states of the following entities
- func_breakables (on the left with globalnames 05.breakable02_1 to 05.breakable02_6)
- func_physboxes (on the right with globalnames 05.breakable01_1 and 05.breakable01_2)
After destroying the func_breakables then using dump_globals command we can see global states 05.breakable02_1 to 05.breakable02_6 marked as Dead
which will ensure they will not spawn in next map.
] dump_globals is_pc: d1_canals_05 (On) = 217026304 -- Globals -- 05.breakable01_2: d1_canals_05 (On) = 12110476 skill.cfg: d1_canals_05 (On) = 0 05.breakable01_1: d1_canals_05 (On) = 12110476 is_console: d1_canals_05 (Off) = 1560839504 05.breakable02_4: d1_canals_05 (Dead) = 12110476 05.breakable02_1: d1_canals_05 (Dead) = 12110476 05.breakable02_5: d1_canals_05 (Dead) = 12110476 05.breakable02_6: d1_canals_05 (Dead) = 12110476 05.breakable02_2: d1_canals_05 (Dead) = 12110476 05.breakable02_3: d1_canals_05 (Dead) = 12110476
Changing one of the func_physboxes color to red using ent_fire !picker color "255 0 0"
for the sake of demonstration.
After transition we can see states were preserved and model name being different (*112 and *113 in d5 changed to *162 and *161 in d6).
Rough entity transition logic

gGlobalState - object containing list of global states that persists between transitions, each element consists of "name, map_name, state (ON/OFF/DEAD), counter"
- Changelevel begins
- Remember all entities that are supposed to transition which means
- They are in info_landmark's PVS unless trigger_transition exists which is then used instead
- They are capable of transitioning which means they have proper ObjectCaps or globalname
- Next map loads, all entities spawn and following applies:
- Entities with globalname where global state doesn't exist yet normally spawn and are tracked by adding state
"name: <globalname>, map_name: <current_map>, state: ON"
to gGlobalState - Entities with globalname where global state is ON and map_name is not current map are made dormant and invisible waiting to get their non-global properties overwritten by global entity that transitions
- Entities with globalname where global state is DEAD are not spawned
- Entities with globalname where global state doesn't exist yet normally spawn and are tracked by adding state
- Remembered transitioning entities spawn, following happens for each that had globalname:
- Search for already spawned entity (the dormant one) (if it doesn't exist print warning and leave the entity that were to transition in previous map)
- Mark self for removal
- Set the associated global state's map_name to current_map
- Transfer all non-global properties to the corresponding dormant entity (see datamap dump to see which are non global for example Half-Life 2 datamap dump)