XML:BINA/OBJC/TRGV: Difference between revisions

chr_poison TV bug workaround
(string comparison bug in TVs)
(chr_poison TV bug workaround)
Line 224: Line 224:


If you need to detect few characters and if all of these are from different teams you can clone the trigger volume one time for each character and call different functions one for each team. This way you make sure you know which character triggered the trigger volume since each character has a unique team and a unique trigger volume function.
If you need to detect few characters and if all of these are from different teams you can clone the trigger volume one time for each character and call different functions one for each team. This way you make sure you know which character triggered the trigger volume since each character has a unique team and a unique trigger volume function.
====chr_poison bug====
chr_poison is a bsl function which is used in the original game to damage the characters within a specific interval, it is used in fire (example level4) and in gas (level5). It uses trigger volumes to call a function (every frame) which contains chr_poison (using TV "Inside" call). It works as expected except if the trigger volume is trigger many times which in case will trigger the "FATAL SCRIPTING ERROR: exceeded maximum scripting parameter base size of 32768" message in developer console and stop working.
=====Possible workarounds=====
Instead of using <b>Inside</b> to call the damage function use <b>Entry</b> to call an intermediate function let's call it "trigger_damage", "trigger_damage" will call another function called "damage_character", this function will be now be responsible for damaging the character every frame. We also need to know when the player leave the TV so we can stop damaging him, for this in the trigger volume xml file we will also use <b>Exit</b> to trigger the function "trigger_stop_damage".
To know which character leaved the damaging trigger volume, we will first give the LSI item to him and then remove it when he leaves the trigger volume, so will damage him only when he has the LSI. You can use another techniques here if you don't want to use the LSI, for instance you can use the multiple TV one explained above to fix the string comparison bug.
The final bsl code will look like this:
    # this function now does the work of damage the character each frame
    # once the character looses lsi it stops damage 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>


===Mod Tool addon===
===Mod Tool addon===
489

edits