XML:BINA/OBJC/TRGV: Difference between revisions
m (let's not link to something that's a redirect, since it breaks the chain of links in the nav header) |
m (copy-edit) |
||
Line 1: | Line 1: | ||
{{XML_OBJC_Header | prev=PWRU | type=TRGV | next=TRIG | name=Trigger Volume}} | {{XML_OBJC_Header | prev=PWRU | type=TRGV | next=TRIG | name=Trigger Volume}} | ||
{{TOClimit|3}} | |||
==General information== | |||
* "BINACJBOTrigger Volume" is level specific (level''x''_Final.dat). | |||
* The XML on this page is based on OniSplit '''v0.9.61.0'''. | |||
==BSL support== | |||
''' | '''Show trigger activity''' | ||
: | :<tt>debug_triggers = 1</tt> shows trigger volume (TV) events and which character enters, stays inside or leaves. | ||
'''Resetting the trigger volume''' | '''Resetting the trigger volume''' | ||
: | :<tt>trigvolume_reset (string tv_name)</tt> resets the TV to its original state. The primary use of this is to re-enable "entry", "inside" or "exit" BSL calls after the TV has been triggered (only necessary if the respective trigger-only-once flags are set, of course). Note that some or all the TV functions are disabled at level load, so you'll have to enable them manually after resetting the TV. | ||
'''Removing corpses''' | '''Removing corpses''' | ||
: | :<tt>trigvolume_corpse (integer tv_id)</tt> removes all corpses inside the specified trigger volume. | ||
==File structure== | |||
== | |||
{|width=200px border=0 cellspacing=20 cellpadding=0 style="float:right" | {|width=200px border=0 cellspacing=20 cellpadding=0 style="float:right" | ||
|[[File:Trigger_volume.jpg|200px]] | |[[File:Trigger_volume.jpg|200px]] | ||
The red and blue lines were added to the screenshot in a graphics program, not by debug_triggers. | The red and blue lines were added to the screenshot in a graphics program, not by debug_triggers. But you can now display them with Ctrl-Shift-X if you are using the [[Daodan DLL]] or the Intel Mac build of Oni. | ||
|} | |} | ||
Line 39: | Line 31: | ||
</Oni> | </Oni> | ||
'''''[...]''''' means at least one trigger volume. Paste all | '''''[...]''''' means at least one trigger volume. Paste all your TV data in there (this includes the '''<font color="#0A0"><TRGV Id="..."></font>'''/'''<font color="#0A0"></TRGV></font>''' tag). | ||
'''example''' | '''example''' | ||
Line 69: | Line 61: | ||
- 633.4166 + 46 = -587.4166 = z_blue_line_end | - 633.4166 + 46 = -587.4166 = z_blue_line_end | ||
==Tags== | |||
=== | |||
{| class="wikitable" width="100%" | {| class="wikitable" width="100%" | ||
!width=280px| | !width=280px| Tag | ||
!width=60px| | !width=60px| Type | ||
! | ! Description | ||
|- | |- | ||
| <TRGV Id="..."> | | <TRGV Id="..."> | ||
| integer | | integer | ||
| You can | | You can use <TRGV>s without the ID parameter. | ||
|- | |- | ||
| <Header> | | <Header> | ||
Line 95: | Line 77: | ||
| <Flags> | | <Flags> | ||
| flag | | flag | ||
| | | Development relic, unused. | ||
|- | |- | ||
| <Position> | | <Position> | ||
| float x3 | | float x3 | ||
| TV is spawned at this | | TV is spawned at this XYZ position. | ||
|- | |- | ||
| <Rotation> | | <Rotation> | ||
| float x3 | | float x3 | ||
| TV has this | | TV has this XYZ rotation (in degrees). | ||
|- | |- | ||
| <OSD> | | <OSD> | ||
Line 111: | Line 93: | ||
| <Name> | | <Name> | ||
| string | | string | ||
| | | Can have up to 63 characters. | ||
|- | |- | ||
| <Scripts> | | <Scripts> | ||
| - | | - | ||
| BSL functions; each can have up to 32 characters | | BSL functions to call for each event (below); each function name can have up to 32 characters. | ||
|- | |- | ||
| <Entry> | | <Entry> | ||
| string | | string | ||
| | | Called when character enters the TV. | ||
|- | |- | ||
|valign="top"| <Inside> | |valign="top"| <Inside> | ||
|valign="top"| string | |valign="top"| string | ||
| | | Called while character is inside the TV. | ||
This one is triggered | This one is triggered every frame (60 times per second) unless the trigger-only-once flag is set. Continuous triggering is typically needed for damage by fire or poison gas. | ||
|- | |- | ||
| <Exit> | | <Exit> | ||
| string | | string | ||
| | | Called when character leaves the TV. | ||
|- | |- | ||
|valign="top"| <Teams> | |valign="top"| <Teams> | ||
Line 148: | Line 130: | ||
| <Size> | | <Size> | ||
| float x3 | | float x3 | ||
| | | Volume of TV | ||
|- | |- | ||
| <TriggerVolumeId> | | <TriggerVolumeId> | ||
| integer | | integer | ||
| | | Used by BSL command <tt>trigvolume_corpse ''ID''</tt> | ||
|- | |- | ||
| <ParentId> | | <ParentId> | ||
| integer | | integer | ||
| | | Not used? | ||
|- | |- | ||
| <Notes> | | <Notes> | ||
| string | | string | ||
| | | Space for a note up to 128 characters long. | ||
|- | |- | ||
|valign="top"| <Flags> | |valign="top"| <Flags> | ||
Line 166: | Line 148: | ||
| | | | ||
: OneTimeEnter - entry function called only once (otherwise called every time character enters the TV) | : OneTimeEnter - entry function called only once (otherwise called every time character enters the TV) | ||
: OneTimeInside - inside function called only once (otherwise called | : OneTimeInside - inside function called only once (otherwise called every frame while character is in the TV) | ||
: OneTimeExit - exit function called only once (otherwise called every time character leaves the TV) | : OneTimeExit - exit function called only once (otherwise called every time character leaves the TV) | ||
: EnterDisabled - entry function disabled (can be enabled with "trigvolume_enable ''tv_name'' entry 1") | : EnterDisabled - entry function disabled (can be enabled with "trigvolume_enable ''tv_name'' entry 1") | ||
Line 175: | Line 157: | ||
|} | |} | ||
==BSL bugs and workarounds== | |||
===String comparison bug=== | |||
As you've seen, trigger volumes can call BSL functions. Such a function can receive a string variable which contains the name of the character that triggered the trigger volume. | |||
Unfortunately it seems there's a bug in BSL when comparing this string parameter with another string variable. Even if the trigger volume string and the other string are identical, the comparison always returns false. | |||
To reproduce the bug, open "warehouse_level_scripts.bsl" in IGMD/EnvWarehouse/ and replace the '''t65''' function with this version (make a backup of the file first): | |||
To reproduce the bug | |||
func void t65(string ai_name) | func void t65(string ai_name) | ||
Line 195: | Line 175: | ||
sleep(100); | sleep(100); | ||
if(testVar eq "char_0"){ | if (testVar eq "char_0") | ||
dmsg(" | { | ||
dmsg("Regular string comparison works!"); | |||
} | } | ||
else{ | else | ||
dmsg(" | { | ||
dmsg("Regular string comparison failed!"); | |||
} | } | ||
if(ai_name eq "char_0"){ | if (ai_name eq "char_0") | ||
dmsg(" | { | ||
dmsg("Trigger volume string comparison worked!"); | |||
} | } | ||
else{ | else | ||
dmsg(" | { | ||
dmsg("Trigger volume string comparison failed!"); | |||
} | } | ||
dprint t65 | dprint t65 | ||
if(d6 eq 0) | if (d6 eq 0) | ||
{ | { | ||
message xdoorislocked | message xdoorislocked | ||
Line 217: | Line 201: | ||
} | } | ||
Load savepoint 1 in | Load savepoint 1 in Chapter 1 and move the character up to the first closed door. This function will be triggered. What is the output that you expect? "Trigger volume string comparison worked!", since Konoko is char_0? Wrong! It will print "Trigger volume string comparison failed!" even though both string variables have the same value. | ||
[[Image:Trigger_volume_string_comparison_bug.jpg|300px]] | [[Image:Trigger_volume_string_comparison_bug.jpg|300px]] | ||
( | (Update: Apparently, as detailed by [[User:Loser|Loser]] [[BSL:String_comparison|HERE]], strings are compared by pointer and not by content.) | ||
If you need to detect a few characters and | ====Possible workarounds==== | ||
If you need to detect a few characters and all of them are on different teams, you can clone the trigger volume one time for each character and call different functions, one for each team. This way you'll know which character triggered the trigger volume, since each team can have a unique trigger volume function thanks to the <Teams> flag. | |||
On Windows, you can take advantage of the [[Daodan DLL]]'s custom function <tt>d_getindex(string ai_name)</tt> and compare by ID. | On Windows, you can take advantage of the [[Daodan DLL]]'s custom function <tt>d_getindex(string ai_name)</tt> and compare by ID. | ||
Line 235: | Line 218: | ||
var int index1 = d_getindex(LoadingBay_Thug_1); | var int index1 = d_getindex(LoadingBay_Thug_1); | ||
var int index2 = d_getindex(LoadingBay_Thug_2); | var int index2 = d_getindex(LoadingBay_Thug_2); | ||
if(index eq index0) | if (index eq index0) | ||
dmsg "Konoko is burning!" | dmsg "Konoko is burning!" | ||
if(index eq index1) | if (index eq index1) | ||
dmsg "Thug 1 is burning!" | dmsg "Thug 1 is burning!" | ||
if(index eq index2) | if (index eq index2) | ||
dmsg "Thug 2 is burning!" | dmsg "Thug 2 is burning!" | ||
} | } | ||
Line 251: | Line 234: | ||
{{divhide|end}} | {{divhide|end}} | ||
===chr_poison bug=== | |||
chr_poison is a BSL function which is used in the original game to damage characters continuously within a specific interval. For example it is used for fires (e.g. in Chapter 4) and for poison gas (Chapter 5). A trigger volume's <Inside> tag is used to call a function every frame which contains chr_poison. It works as expected, except if the trigger volume is triggered too many times, in which case you'll see the message "FATAL SCRIPTING ERROR: exceeded maximum scripting parameter base size of 32768" in the developer console and the function will stop working. | |||
====Possible workarounds==== | |||
Instead of using <Inside> to call the damage function, use <Entry> to call an intermediate function — let's call it "trigger_damage". "trigger_damage" will call another function called "damage_character", which will be responsible for damaging the character every frame. We also need to know when the player leaves the TV so we can stop damaging him, so in the trigger volume XML file we'll also use <Exit> to call the function "trigger_stop_damage". | |||
To know which character left the damaging TV, we will give an LSI to him upon entry and then remove it when he leaves the trigger volume, and we'll only damage him when he has the LSI. (You can use another technique here if you don't want to use an LSI; for instance you can use the multiple TV approach that was explained above as a string comparison workaround.) | |||
The final BSL code will look like this: | |||
# This function now does the work of damaging the character each frame | |||
# Once the character loses his LSI, it stops damaging him | |||
# | |||
# | |||
func void damage_character(string ai){ | func void damage_character(string ai){ | ||
if(chr_has_lsi(ai)){ | if (chr_has_lsi(ai)) | ||
{ | |||
chr_poison(ai, 5, 10); | chr_poison(ai, 5, 10); | ||
sleep(1); | sleep(1); | ||
Line 273: | Line 255: | ||
} | } | ||
func void trigger_damage(string ai){ | func void trigger_damage(string ai) | ||
chr_givepowerup(ai,"lsi"); | { | ||
chr_givepowerup(ai, "lsi"); | |||
fork damage_character(ai); | fork damage_character(ai); | ||
} | } | ||
func void trigger_stop_damage(string ai){ | func void trigger_stop_damage(string ai) | ||
chr_inv_reset(ai); # clear | { | ||
chr_inv_reset(ai); # clear LSI | |||
} | } | ||
Line 306: | Line 290: | ||
</TRGV> | </TRGV> | ||
If the technique above is not enough and you are still experiencing the "FATAL SCRIPTING ERROR: exceeded maximum scripting parameter base size of 32768" error after a while, you may try using duplicated trigger volumes, where after a while (and before the error appears) you disable the first one and | If the technique above is not enough and you are still experiencing the "FATAL SCRIPTING ERROR: exceeded maximum scripting parameter base size of 32768" error after a while, you may try using duplicated trigger volumes, where after a while (and before the error appears) you disable the first one and activate the second one (which is a copy of the first). | ||
The duplicated one can look like this: | The duplicated one can look like this: | ||
Line 332: | Line 316: | ||
</TRGV> | </TRGV> | ||
The code to switch between them: | |||
trigvolume_enable("BurnCharacter", 0); # disable the first one | |||
trigvolume_enable("BurnCharacterPart2", 1); # activate the second one | |||
Note that you should have only one of the copies active at a time. | |||
==Mod Tool addon== | |||
[[Image:xsi_addon_trigger_volume_manager.jpg|thumb|200px|right|Trigger volume manager.]] | |||
When ready, export the data as BINACJBOTrigger Volume.xml to a folder of your choice. | With [[Mod_Tool#OniTools_addon|OniTools.xsiaddon]] you can drag'n'drop BINACJBOTrigger Volume'''.oni''' into the viewport. Add or remove TVs, and edit their position and rotation as if they were real objects. Change their size by moving the points. When ready, export the data as BINACJBOTrigger Volume.xml to a folder of your choice. | ||
{{XML}} | {{XML}} |
Revision as of 13:26, 3 April 2021
TRGV : Trigger Volume | ||
---|---|---|
XML
AKEV << Other file types >> CONS TMBD << Other BINA >> ONIE PWRU << Other OBJC >> TRIG |
General information
- "BINACJBOTrigger Volume" is level specific (levelx_Final.dat).
- The XML on this page is based on OniSplit v0.9.61.0.
BSL support
Show trigger activity
- debug_triggers = 1 shows trigger volume (TV) events and which character enters, stays inside or leaves.
Resetting the trigger volume
- trigvolume_reset (string tv_name) resets the TV to its original state. The primary use of this is to re-enable "entry", "inside" or "exit" BSL calls after the TV has been triggered (only necessary if the respective trigger-only-once flags are set, of course). Note that some or all the TV functions are disabled at level load, so you'll have to enable them manually after resetting the TV.
Removing corpses
- trigvolume_corpse (integer tv_id) removes all corpses inside the specified trigger volume.
File structure
The red and blue lines were added to the screenshot in a graphics program, not by debug_triggers. But you can now display them with Ctrl-Shift-X if you are using the Daodan DLL or the Intel Mac build of Oni. |
<?xml version="1.0" encoding="utf-8"?> <Oni> <Objects> [...] </Objects> </Oni>
[...] means at least one trigger volume. Paste all your TV data in there (this includes the <TRGV Id="...">/</TRGV> tag).
example
<TRGV Id="7383"> <Header> <Flags>Locked</Flags> <Position>-651.5666 -298 -633.4166</Position> <Rotation>0 0 0</Rotation> </Header> <OSD> <Name>trigger_volume_46</Name> <Scripts> <Entry>train_block2</Entry> <Inside></Inside> <Exit>block_path</Exit> </Scripts> <Teams>255</Teams> <Size>46 31 46</Size> <TriggerVolumeId>46</TriggerVolumeId> <ParentId>0</ParentId> <Notes></Notes> <Flags>PlayerOnly</Flags> </OSD> </TRGV>
start + size = end - 651.5666 + 46 = -605.5666 = x_blue_line_end - 298 + 31 = -267 = y_blue_line_end - 633.4166 + 46 = -587.4166 = z_blue_line_end
Tags
Tag | Type | Description |
---|---|---|
<TRGV Id="..."> | integer | You can use <TRGV>s without the ID parameter. |
<Header> | - | |
<Flags> | flag | Development relic, unused. |
<Position> | float x3 | TV is spawned at this XYZ position. |
<Rotation> | float x3 | TV has this XYZ rotation (in degrees). |
<OSD> | - | |
<Name> | string | Can have up to 63 characters. |
<Scripts> | - | BSL functions to call for each event (below); each function name can have up to 32 characters. |
<Entry> | string | Called when character enters the TV. |
<Inside> | string | Called while character is inside the TV.
This one is triggered every frame (60 times per second) unless the trigger-only-once flag is set. Continuous triggering is typically needed for damage by fire or poison gas. |
<Exit> | string | Called when character leaves the TV. |
<Teams> | flags |
Every combination is possible. E.g.:
|
<Size> | float x3 | Volume of TV |
<TriggerVolumeId> | integer | Used by BSL command trigvolume_corpse ID |
<ParentId> | integer | Not used? |
<Notes> | string | Space for a note up to 128 characters long. |
<Flags> | flags |
|
BSL bugs and workarounds
String comparison bug
As you've seen, trigger volumes can call BSL functions. Such a function can receive a string variable which contains the name of the character that triggered the trigger volume.
Unfortunately it seems there's a bug in BSL when comparing this string parameter with another string variable. Even if the trigger volume string and the other string are identical, the comparison always returns false.
To reproduce the bug, open "warehouse_level_scripts.bsl" in IGMD/EnvWarehouse/ and replace the t65 function with this version (make a backup of the file first):
func void t65(string ai_name) { var string testVar = "char_0"; dmsg(testVar); dmsg("char_0"); dmsg(ai_name); sleep(100); if (testVar eq "char_0") { dmsg("Regular string comparison works!"); } else { dmsg("Regular string comparison failed!"); } if (ai_name eq "char_0") { dmsg("Trigger volume string comparison worked!"); } else { dmsg("Trigger volume string comparison failed!"); } dprint t65 if (d6 eq 0) { message xdoorislocked dprint door_is_locked } }
Load savepoint 1 in Chapter 1 and move the character up to the first closed door. This function will be triggered. What is the output that you expect? "Trigger volume string comparison worked!", since Konoko is char_0? Wrong! It will print "Trigger volume string comparison failed!" even though both string variables have the same value.
(Update: Apparently, as detailed by Loser HERE, strings are compared by pointer and not by content.)
Possible workarounds
If you need to detect a few characters and all of them are on different teams, you can clone the trigger volume one time for each character and call different functions, one for each team. This way you'll know which character triggered the trigger volume, since each team can have a unique trigger volume function thanks to the <Teams> flag.
On Windows, you can take advantage of the Daodan DLL's custom function d_getindex(string ai_name) and compare by ID.
func void fire_damage(string ai_name) { var int index = d_getindex(ai_name); var int index0 = d_getindex(char_0); var int index1 = d_getindex(LoadingBay_Thug_1); var int index2 = d_getindex(LoadingBay_Thug_2); if (index eq index0) dmsg "Konoko is burning!" if (index eq index1) dmsg "Thug 1 is burning!" if (index eq index2) dmsg "Thug 2 is burning!" } func void main(void) { ai2_spawn LoadingBay_Thug_1 ai2_spawn LoadingBay_Thug_2 chr_location 0 134 -105 1029 }
chr_poison bug
chr_poison is a BSL function which is used in the original game to damage characters continuously within a specific interval. For example it is used for fires (e.g. in Chapter 4) and for poison gas (Chapter 5). A trigger volume's <Inside> tag is used to call a function every frame which contains chr_poison. It works as expected, except if the trigger volume is triggered too many times, in which case you'll see the message "FATAL SCRIPTING ERROR: exceeded maximum scripting parameter base size of 32768" in the developer console and the function will stop working.
Possible workarounds
Instead of using <Inside> to call the damage function, use <Entry> to call an intermediate function — let's call it "trigger_damage". "trigger_damage" will call another function called "damage_character", which will be responsible for damaging the character every frame. We also need to know when the player leaves the TV so we can stop damaging him, so in the trigger volume XML file we'll also use <Exit> to call the function "trigger_stop_damage".
To know which character left the damaging TV, we will give an LSI to him upon entry and then remove it when he leaves the trigger volume, and we'll only damage him when he has the LSI. (You can use another technique here if you don't want to use an LSI; for instance you can use the multiple TV approach that was explained above as a string comparison workaround.)
The final BSL code will look like this:
# This function now does the work of damaging the character each frame # Once the character loses his LSI, it stops damaging him func void damage_character(string ai){ if (chr_has_lsi(ai)) { chr_poison(ai, 5, 10); sleep(1); fork damage_character(ai); } }
func void trigger_damage(string ai) { chr_givepowerup(ai, "lsi"); fork damage_character(ai); }
func void trigger_stop_damage(string ai) { chr_inv_reset(ai); # clear LSI }
And the trigger volume XML will look like this:
<TRGV Id="1"> <Header> <Flags>0</Flags> <Position>2005.23 1239.87 -3628.82</Position> <Rotation>0 0 0</Rotation> </Header> <OSD> <Name>BurnCharacter</Name> <Scripts> <Entry>trigger_damage</Entry> <Inside /> <Exit>trigger_stop_damage</Exit> </Scripts> <Teams>4</Teams> <Size>-287.04 1 -179.85</Size> <TriggerVolumeId>1</TriggerVolumeId> <ParentId>0</ParentId> <Notes></Notes> <Flags /> </OSD> </TRGV>
If the technique above is not enough and you are still experiencing the "FATAL SCRIPTING ERROR: exceeded maximum scripting parameter base size of 32768" error after a while, you may try using duplicated trigger volumes, where after a while (and before the error appears) you disable the first one and activate the second one (which is a copy of the first).
The duplicated one can look like this:
<TRGV Id="2"> <Header> <Flags>0</Flags> <Position>2005.23 1239.87 -3628.82</Position> <Rotation>0 0 0</Rotation> </Header> <OSD> <Name>BurnCharacterPart2</Name> <Scripts> <Entry>trigger_damage</Entry> <Inside /> <Exit>trigger_stop_damage</Exit> </Scripts> <Teams>4</Teams> <Size>-287.04 1 -179.85</Size> <TriggerVolumeId>2</TriggerVolumeId> <ParentId>0</ParentId> <Notes></Notes> <Flags /> </OSD> </TRGV>
The code to switch between them:
trigvolume_enable("BurnCharacter", 0); # disable the first one trigvolume_enable("BurnCharacterPart2", 1); # activate the second one
Note that you should have only one of the copies active at a time.
Mod Tool addon
With OniTools.xsiaddon you can drag'n'drop BINACJBOTrigger Volume.oni into the viewport. Add or remove TVs, and edit their position and rotation as if they were real objects. Change their size by moving the points. When ready, export the data as BINACJBOTrigger Volume.xml to a folder of your choice.