Complete disaster-recovery snapshot: engine/game source, game data assets, VC6 toolchain + DX SDKs, build outputs, deployed game, and _UNUSED archive. Large binaries in Git LFS; text preserved byte-for-byte (core.autocrlf=false, no eol attributes). See RECOVERY.md for the one-clone rebuild procedure.
245 lines
7.1 KiB
Plaintext
245 lines
7.1 KiB
Plaintext
|
|
//------------------------------------------------------------------
|
|
// NOTE: The fsm name below MUST be changed in order for the
|
|
// script to be considered a unique entity!
|
|
|
|
fsm Sample_FriendlyFireWarn : integer;
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
// Sample_FriendlyFireWarn:
|
|
// This script encapsulates the code you need to copy into a
|
|
// script to get it to do a friendly fire warning -- and
|
|
// eventually attack -- when the player shoots it.
|
|
|
|
// INSTRUCTIONS FOR USE:
|
|
|
|
// 1. Copy the static integers in the "var" section of this script
|
|
// into your existing script.
|
|
|
|
// 2. Copy the variable initialization stuff from the Init function
|
|
// of this script into your existing script. You will need to
|
|
// specify the correct sound IDs, and you may need to set custom
|
|
// timer IDs as well to avoid timer ID conflicts (see below).
|
|
|
|
// 3. Copy the CheckIfPlayerShotMe function to your existing script.
|
|
|
|
// 4. Add a call to CheckIfPlayerShotMe to the beginning of each
|
|
// state in your existing script.
|
|
|
|
// 5. Copy the KillPlayerState into your existing script.
|
|
|
|
// Be sure to also ...
|
|
|
|
// -Add the sound files to Content\Audio, and check them in!
|
|
// -Add the sound file names to the mission's .table & .audio files!
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
// Constants
|
|
//------------------------------------------------------------------
|
|
|
|
const
|
|
#include_ <content\ABLScripts\mwconst.abi>
|
|
|
|
//------------------------------------------------------------------
|
|
// Types
|
|
//------------------------------------------------------------------
|
|
|
|
type
|
|
#include_ <content\ABLScripts\mwtype.abi>
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
// Variables
|
|
//------------------------------------------------------------------
|
|
|
|
var
|
|
static integer friendlyFireFrustrationLevel; // An integer indicating how frustrated I am with the player
|
|
static integer frustration_timer; // A timer I use to wait after I'm hit by friendly fire before calling IsShot() again
|
|
static integer attack_player_timer; // A timer I use when I'm really pissed off to give the "OK, you die now" sound enough time to play before I attack
|
|
|
|
static integer warn_sound_1; // Sound ID: "Hey, watch the friendly fire."
|
|
static integer warn_sound_2; // Sound ID: "I warned you, now knock it off."
|
|
static integer warn_sound_3; // Sound ID: "One more friendly fire incident and you're toast."
|
|
static integer warn_sound_4; // Sound ID: "OK, that's it, I'm taking you out, traitor."
|
|
|
|
//------------------------------------------------------------------
|
|
// Init: my initialization function
|
|
//------------------------------------------------------------------
|
|
|
|
function Init;
|
|
code
|
|
friendlyFireFrustrationLevel = 0;
|
|
|
|
// NOTE: replace the following with the warning sound IDs ...
|
|
// such as "eso_FFWarn1" or "eso_FFWarn2".
|
|
|
|
warn_sound_1 = -1;
|
|
warn_sound_2 = -1;
|
|
warn_sound_3 = -1;
|
|
warn_sound_4 = -1;
|
|
|
|
// NOTE: try to give each friendly unit its own timer IDs; if you can't,
|
|
// it's no problem, but then try to make sure each friendly unit script
|
|
// is using a unique pair of timers.
|
|
|
|
// These timers MUST be different from any timers you are using
|
|
// elsewhere in your scripts for a given mission!!
|
|
|
|
frustration_timer = gti_Timer_25;
|
|
attack_player_timer = gti_Timer_26;
|
|
|
|
StartTimer(frustration_timer);
|
|
SetTimer(frustration_timer,100);
|
|
|
|
endfunction;
|
|
|
|
//------------------------------------------------------------------
|
|
// CheckIfPlayerShotMe: this function checks to see if I took
|
|
// friendly fire from the player and responds appropriately.
|
|
|
|
// You should call this function at the beginning of every state in
|
|
// your script.
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
function CheckIfPlayerShotMe : integer;
|
|
var
|
|
ObjectID who_shot;
|
|
|
|
code
|
|
// cool down for at least 8 seconds after I'm shot to give IsShot() a chance to reset
|
|
if (Not TimeGreater(frustration_timer,8)) then
|
|
return (0);
|
|
endif;
|
|
|
|
// Have I been shot?
|
|
if (Not IsShot(ME)) then
|
|
return (0);
|
|
endif;
|
|
|
|
who_shot = WhoShot(me);
|
|
|
|
// OK, I was shot -- was it the player that did it?
|
|
if (who_shot <> getplayervehicle(epl_player0)) then
|
|
return (0);
|
|
endif;
|
|
|
|
ResetTimer(frustration_timer);
|
|
|
|
// Level 1: "Knock off the friendly fire."
|
|
if (friendlyFireFrustrationLevel == 0) then
|
|
if (warn_sound_1 <> -1) then
|
|
PlaySound(warn_sound_1);
|
|
endif;
|
|
|
|
friendlyFireFrustrationLevel = 1;
|
|
return (1);
|
|
endif;
|
|
|
|
// Level 2: "Hey! I warned you, knock it off."
|
|
if (friendlyFireFrustrationLevel == 1) then
|
|
if (warn_sound_2 <> -1) then
|
|
PlaySound(warn_sound_2);
|
|
endif;
|
|
|
|
friendlyFireFrustrationLevel = 2;
|
|
return (1);
|
|
endif;
|
|
|
|
// Level 3: "What we've got here is a failure to communicate."
|
|
if (friendlyFireFrustrationLevel == 2) then
|
|
if (warn_sound_3 <> -1) then
|
|
PlaySound(warn_sound_3);
|
|
endif;
|
|
|
|
friendlyFireFrustrationLevel = 3;
|
|
return (1);
|
|
endif;
|
|
|
|
// Level 4: "OK, you're gonna die now."
|
|
if (warn_sound_4 <> -1) then
|
|
PlaySound(warn_sound_4);
|
|
endif;
|
|
|
|
StartTimer(attack_player_timer);
|
|
ResetTimer(attack_player_timer);
|
|
trans KillPlayerState;
|
|
|
|
return (1);
|
|
|
|
endfunction;
|
|
|
|
//------------------------------------------------------------------
|
|
// StartState: my initial state
|
|
//------------------------------------------------------------------
|
|
|
|
state StartState;
|
|
|
|
code
|
|
// IMPORTANT!!! -- You must turn off friendly-fire-ignoring
|
|
// for this to work!
|
|
SetIgnoreFriendlyFire(me,FALSE);
|
|
|
|
CheckIfPlayerShotMe;
|
|
|
|
endstate;
|
|
|
|
//------------------------------------------------------------------
|
|
// StartState: my initial state
|
|
//------------------------------------------------------------------
|
|
|
|
state SitState;
|
|
code
|
|
CheckIfPlayerShotMe;
|
|
// other state stuff here ...
|
|
endstate;
|
|
|
|
state AttackState;
|
|
code
|
|
CheckIfPlayerShotMe;
|
|
// other state stuff here ...
|
|
endstate;
|
|
|
|
state EveryOtherStateInTheWholeGoddamnScript;
|
|
code
|
|
CheckIfPlayerShotMe;
|
|
// other state stuff here ...
|
|
endstate;
|
|
|
|
//------------------------------------------------------------------
|
|
// KillPlayerState: too much friendly fire -- get pissed, turn into
|
|
// an UberBot, and attack the player
|
|
//------------------------------------------------------------------
|
|
|
|
state KillPlayerState;
|
|
code
|
|
if (TimeGreater(attack_player_timer,6)) then
|
|
SetFiringDelay (ME,0.0,0.0);
|
|
SetSkillLevel (ME,100,999,100);
|
|
|
|
SetAutoTargeting(ME,FALSE);
|
|
SetTarget(ME,getplayervehicle(epl_player0));
|
|
OrderAttack(TRUE);
|
|
endif;
|
|
endstate;
|
|
|
|
//------------------------------------------------------------------
|
|
// DeadState: OK, I kicked the bucket.
|
|
//------------------------------------------------------------------
|
|
|
|
state DeadState;
|
|
code
|
|
orderDie;
|
|
|
|
endstate;
|
|
|
|
|
|
endfsm.
|
|
|