home *** CD-ROM | disk | FTP | other *** search
-
- //------------------------------------------------------------------
- // NOTE: The fsm name below MUST be changed in order for the
- // script to be considered a unique entity!
-
- fsm Generic_AttackList : integer;
-
-
- //------------------------------------------------------------------
-
- // Generic_AttackList:
- // This script can be used to attack (or defend) a series of targets
- // contained in a group. The unit will use a specified tactic
- // on the first living target in the group, and if that unit is
- // destroyed, it will switch to the next one. When there are no
- // units left in the group, it will go on a rampage, attacking
- // any enemies it can find.
-
- //------------------------------------------------------------------
-
-
- //------------------------------------------------------------------
- // Constants
- //------------------------------------------------------------------
-
- const
- #include_ <content\ABLScripts\mwconst.abi>
-
- //------------------------------------------------------------------
- // Types
- //------------------------------------------------------------------
-
- type
- #include_ <content\ABLScripts\mwtype.abi>
-
-
- //------------------------------------------------------------------
- // Variables
- //------------------------------------------------------------------
-
- var
- static integer rampageAttackRange; // When all my targets are destroyed, at what range do I start shooting?
-
- static integer myGroupID; // The ID of my group ... i.e. this script will
- // call GroupObjectID(groupID)
- static integer tactic; // The tactic to use to attack (or defend) my targets
-
- static integer piloting; // Piloting skill
- static integer gunnery; // Gunnery skill/chance to hit
- static real minDelay; // Minimum amount of time I will wait between shots once a weapon is reloaded
- static real maxDelay; // Maximum amount of time I will wait between shots once a weapon is reloaded
- static integer eliteLevel; // Elite level. This helps determine tactics, defensive manuevers, opportunity fire
- // and other things. It indicates a general level of combat experience.
- static integer attackThrottle; // My attack throttle
-
- static integer isShotRadius; // How far away from me will I detect an enemy shot?
-
- static integer attackSound; // The attack sound I play when I first attack
- static integer deathSound; // The sound I play when I die
-
- static integer mood; // My default mood.
-
- static integer takeOffDistance; // My take-off distance if I'm an airplane (ignored if not an airplane)
-
- //------------------------------------------------------------------
- // Init: my initialization function
- //------------------------------------------------------------------
-
- function Init;
- code
- // script-specific variables
- rampageAttackRange = 1200;
-
- myGroupID = 0;
- tactic = TACTIC_PICK_BEST;
-
- takeOffDistance = 150;
-
- // driver settings
- piloting = 50;
- gunnery = 30;
- minDelay = 1.5;
- maxDelay = 3.0;
- eliteLevel = 30;
- attackThrottle = 80;
- isShotRadius = 120;
- attackSound = -1; // no sound
- deathSound = -1; // no sound
- mood = NEUTRAL_START;
-
- endfunction;
-
- //------------------------------------------------------------------
- // StartState: my initial state
- //------------------------------------------------------------------
-
- state StartState;
-
- code
- SetFiringDelay (ME,minDelay,maxDelay);
- SetIgnoreFriendlyFire (ME,true);
- SetIsShotRadius (ME,isShotRadius);
- SetEntropyMood (ME,mood);
- SetCurMood (ME,mood);
- SetSkillLevel (ME,piloting,gunnery,eliteLevel);
- SetAttackThrottle (ME,attackThrottle);
-
- if (orderTakeOff(takeOffDistance) == true) then
- trans AttackFirstLivingTargetState;
- endif;
-
- endstate;
-
- //------------------------------------------------------------------
- // AttackFirstLivingTargetState: get the first object in my group, set
- // it as my target, and issue the attack order with my tactic
- //------------------------------------------------------------------
-
- state AttackFirstLivingTargetState;
-
- var
- ObjectID next_target;
-
- code
- if (GetTarget(ME) == NO_UNIT) then
- next_target = GroupGetFirstObject(GroupObjectID(myGroupID));
-
- if (next_target == NO_UNIT) then
- trans RampageState;
- endif;
-
- SetTarget(ME,next_target);
- endif;
-
- if (attackSound <> -1) then
- PlaySoundOnce(attackSound);
- endif;
-
- OrderAttackTactic(tactic,TRUE);
-
- endstate;
-
- //------------------------------------------------------------------
- // RampageState: no targets remain -- let's kick some ass!
- //------------------------------------------------------------------
-
- state RampageState;
- code
- if (GetTarget(ME) == NO_UNIT) then
- FindEnemy(rampageAttackRange,FT_DEFAULT);
- endif;
-
- if (GetTarget(ME) <> NO_UNIT) then
- if (attackSound <> -1) then
- PlaySoundOnce(attackSound);
- endif;
-
- OrderAttack(TRUE);
- endif;
-
- endstate;
-
- //------------------------------------------------------------------
- // DeadState: OK, I kicked the bucket.
- //------------------------------------------------------------------
-
- state DeadState;
- code
- if (deathSound <> -1) then
- PlaySoundOnce(deathSound);
- endif;
-
- orderDie;
-
- endstate;
-
-
- endfsm.
-
-