//------------------------------------------------------------------ // NOTE: The fsm name below MUST be changed in order for the // script to be considered a unique entity! fsm 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 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 objectid mytower; //------------------------------------------------------------------ // Init: my initialization function //------------------------------------------------------------------ function Init; code // script-specific variables attackRange = 500; withdrawRange = attackRange * 3 / 2; // driver settings piloting = 50; gunnery = 30; minDelay = 1.5; maxDelay = 3.0; eliteLevel = 30; isShotRadius = 120; attackSound = -1; // no sound deathSound = -1; // no sound mood = 5; mytower = -1; //no tower switch (getmemoryinteger(me,9)) case 1: attackrange = 600; mytower = eve_southturretcontrol; endcase; case 2: attackrange = 600; mytower = ebu_midturrettower; endcase; endswitch; 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); setalignment (ME,enemy); setsensorvisibility(me,false); trans WaitState; endstate; //------------------------------------------------------------------ // WaitState: wait for someone to come near //------------------------------------------------------------------ state WaitState; code if (SetMyTarget(attackRange)) then setsensorvisibility(me,true); trans AttackState; endif; if (mytower <> -1) then if (isdead(mytower)) then trans towergone; endif; endif; OrderMoveLookOut; endstate; //------------------------------------------------------------------ // AttackState: let's see what's around, and destroy it //------------------------------------------------------------------ state AttackState; code if (LeaveAttackState(withdrawRange)) then OrderStopAttacking; SetTarget(ME,NO_UNIT); setsensorvisibility(me,false); trans WaitState; endif; if (attackSound <> -1) then PlaySoundOnce(attackSound); endif; if (mytower <> -1) then if (isdead(mytower)) then trans towergone; endif; endif; OrderAttackTactic(TACTIC_SHOOT_ONLY,true); endstate; //--------------------------------------- //Towergone state: My plugs been pulled. Stop shooting and shutdown //--------------------------------------- state towergone; code switch (getmemoryinteger(me,9)) case 1: southtowerdown = true; endcase; case 2: midtowerdown=true; endcase; endswitch; SetTarget(ME,NO_UNIT); OrderStopAttacking; SetTargetDesirability(ME,-1); setsensorvisibility(me,false); clearmoveorder(me); trans hangout; endstate; state hangout; code endstate; //------------------------------------------------------------------ // DeadState: OK, I kicked the bucket. //------------------------------------------------------------------ state DeadState; code if (deathSound <> -1) then PlaySoundOnce(deathSound); endif; orderDie; endstate; endfsm.