//------------------------------------------------------------------ // NOTE: The fsm name below MUST be changed in order for the // script to be considered a unique entity! fsm dropship_Turret : integer; //------------------------------------------------------------------ // Generic_Turret: // This shoots anything that comes near, but never moves. // It can be used for turrets. //------------------------------------------------------------------ //------------------------------------------------------------------ // Constants //------------------------------------------------------------------ const #include_ //------------------------------------------------------------------ // Types //------------------------------------------------------------------ type #include_ //------------------------------------------------------------------ // Variables //------------------------------------------------------------------ var static integer attackRange; // At what range do I start shooting? static integer withdrawRange; // At what range do I stop attacking? 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 isShotRadius; // How far away from me will I detect an enemy shot? static integer findTypes; // What kind of enemies to look for static integer mood; // My default mood. //------------------------------------------------------------------ // Init: my initialization function //------------------------------------------------------------------ function Init; code // script-specific variables attackRange = 900; withdrawRange = 901; // driver settings piloting = 100; gunnery = 999; minDelay = 1.5; maxDelay = 3.0; eliteLevel = 30; isShotRadius = 120; mood = NEUTRAL_START; findTypes = FT_DEFAULT; // EnablePerWeaponRayCasting (ME,TRUE); 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); trans WaitState; endstate; //------------------------------------------------------------------ // WaitState: wait for someone to come near //------------------------------------------------------------------ state WaitState; code if (IsShot(ME) == TRUE) then SetTarget(ME,WhoShot(ME)); trans AttackState; endif; if (Bot_FindEnemy(attackrange)) then trans AttackState; endif; SetSensorVisibility(ME,TRUE); OrderMoveLookOut; endstate; //------------------------------------------------------------------ // AttackState: let's see what's around, and destroy it //------------------------------------------------------------------ state AttackState; code if (LeaveAttackState(withdrawRange)) then OrderStopAttacking; SetTarget(ME,NO_UNIT); trans WaitState; endif; if (IsShot(ME) == TRUE) then SetTarget(ME,WhoShot(ME)); endif; SetSensorVisibility(ME,TRUE); OrderAttackTactic(TACTIC_SHOOT_ONLY,true); endstate; //------------------------------------------------------------------ // DeadState: OK, I kicked the bucket. //------------------------------------------------------------------ state DeadState; code orderDie; endstate; endfsm.