XML:ONLV: Difference between revisions

2,311 bytes added ,  26 February 2013
examining the recognition of broken glass (env) objects in level 1 TCTF training
m (flags)
(examining the recognition of broken glass (env) objects in level 1 TCTF training)
Line 562: Line 562:


It's used in the training level and determines if glass got shot through or not. How do we set such things up?
It's used in the training level and determines if glass got shot through or not. How do we set such things up?
Let's examine the original setup.
        <TRGV Id="11495">
            <Header>
                <Flags>Locked</Flags>
                <Position>-714.6615 -298 -555.2073</Position>
                <Rotation>0 0 0</Rotation>
            </Header>
            <OSD>
                <Name>tv75</Name>
                <Scripts>
                    <Entry></Entry>
                    <Inside>targets_gone</Inside>
                    <Exit></Exit>
                </Scripts>
                <Teams>255</Teams>
                <Size>400 31 270</Size>
                <TriggerVolumeId>75</TriggerVolumeId>
                <ParentId>0</ParentId>
                <Notes></Notes>
                <Flags>PlayerOnly</Flags>
            </OSD>
        </TRGV>
Player enters the TV, "targets_gone" gets triggered. The variable "inside_target_function" should be 0 be default, so we are entering now the first if statement. Next, we can assume that the player didn't destroy all glass objects, so "num_broken" will be less than 18: "targets_are_not_gone" gets triggered.
The TV function "targets_gone" would be triggered every frame but "targets_are_not_gone" decrease the check interval: The TV gets deactivated for 60 frames. Then the TV becomes enabled again and will start anew until all glass objects got destroyed or Player left the TV.
Unnecessary "targets_gone" functions will do nothing because "inside_target_function" was set to 1 by the first one.
func void enter_target_function(void)
{
    dprint enter_target_function
    inside_target_function = 1;
}
func void exit_target_function(void)
{
    dprint exit_target_function
    inside_target_function = 0;
}
func void targets_are_not_gone(void)
{
# CB: turn off the trigger volume and sleep for a second
# so as not to cause hideous performance loss
trigvolume_enable tv75 0
sleep 60
trigvolume_enable tv75 1
}
func void targets_gone(string ai_name)
{
if(inside_target_function eq 0)
{
enter_target_function() # catch other "targets_gone" functions to let them do nothing
var int num_broken = env_broken(3001, 3018);
if (num_broken eq 18)
{
targets_are_gone();
}
if (num_broken < 18)
{
targets_are_not_gone(); # to set check interval to one second
}
exit_target_function
}
}




8,452

edits