Creative Scripting

From BiaSDK
Jump to: navigation, search

This last section demonstrates how TriggeredScripts can be used creatively, adding to the overall experience. Since we have a P47 flying overhead, why not have one of our squad members yell out "P47!" or "Air Corps!"? (all characters have lines for things like this)

Below is a completed TS_P47_Scene which checks to see who is alive in your squad and plays an appropriate sound:

var int RandomNumber;
State Triggered { Begin:
If ( Unit( GetFirstActor( 'US_AssaultTeam' ) ).GetNumLivingMembers() + \\Unit( GetFirstActor( 'US_BoFTeam' ) ).GetNumLivingMembers() >= 1 ) { WasDead: sleep(0.1); RandomNumber = Rand( 4 );
Switch ( RandomNumber ) { Case 0: If ( getPawn( 'Corrion' ).health > 0 ) { ACTION_PlayLipSyncSound( 'Corrion', "BD_CORRION.M_SEEALLIEDPLANE_A", 1.0, 1.0, 1.0 ); } Else { Goto('WasDead'); } break; Case 1: If ( getPawn( 'Doyle' ).health > 0 ) { ACTION_PlayLipSyncSound( 'Doyle', "BD_DOYLE.M_SEEALLIEDPLANE_B", 1.0, 1.0, 1.0 ); } Else { Goto('WasDead'); } break; Case 2: If ( getPawn( 'Paddock' ).health > 0 ) { ACTION_PlayLipSyncSound( 'Paddock', "BD_PADDOCK.M_SEEALLIEDPLANE_A", 1.0, 1.0, 1.0 ); } Else { Goto('WasDead'); } break; Case 3: If ( getPawn( 'Friar' ).health > 0 ) { ACTION_PlayLipSyncSound( 'Friar', "BD_FRIAR.M_SEEALLIEDPLANE_B", 1.0, 1.0, 1.0 ); } Else { Goto('WasDead'); } break; Default: Break; } } ACTION_TriggerEvent('SCENE_P47_A'); sleep(1.5);
ACTION_PlayLocalSound( "V_PLANE.C47_PASSBY" ); sleep(3.5);
ACTION_SetAnimSet( 'AP_Birds', "k_animal.crow_b_anim" ); ACTION_PlayAnim( 'AP_Birds', 'a_takeoff_long', 0.2, 1.0, False );
ACTION_TriggerEvent('PFX_SMOKE_01');
ACTION_TriggerEvent('EXP_Bomb_01'); Sleep(0.15); ACTION_TriggerEvent('EXP_Bomb_02'); Sleep(0.12); ACTION_TriggerEvent('EXP_Bomb_03'); Sleep(0.25); ACTION_TriggerEvent('EXP_Bomb_04');
sleep( 3.0 );\\
ACTION_DestroyActor( 'SM_P47_A' ); Sleep( 16.0 ); ACTION_DestroyActor( 'AP_Birds' ); }

Here’s an overview of how it's working: We have an If statement which contains all the scripting for having our squad members talk, the first thing it does is check to see if the number of living squad members in US_AssaultTeaM + US_BofTeam are greater or equal to 1.. meaning at least 1 guy has to be alive in order for the code in our If statement to work. You can do the same thing to check German Units for living members also!

So if we have living members, it does the next set of code, a random number gets picked out of 4 (actually 0 to 3), then we have a Switch ( RandomNumber ).. this is similar to an If statement, its basically saying we have multiple choices, or Cases, depending on what our variable called RandomNumber is.

We have 4 Squad members, so there are 4 possible Cases, in each one I do another If statement, which sees if the member is actually alive, using getPawn( PawnTag ).Health If the Pawn is alive, a PlayLipSyncSound is called, with the proper dialog for that character.. if the Pawn is not alive, a Goto('WasDead') is called in the Else segment, and that resets the script right back up to WasDead: where it will pick another random number and go through the Switch statement again. Once the script has played the dialog for one of our squad members, it will break out of the Case and continue on with our scene as it was before.


Back to Main Page