Files
dsrc/sku.0/sys.server/compiled/game/script/poi/gangwar/mediator.script
T

179 lines
4.5 KiB
Plaintext

/**
*
* Title: mediator.script
* Description: mediator object script: POI = prisonbreak
*/
//------------------------------------------------
// Includes
//------------------------------------------------
include library.npc;
include library.combat;
include library.poi;
include library.scenario;
include library.ai_lib;
include library.pclib;
include ai.ai_combat;
//-----------------------------------------------
// Inherits
//-----------------------------------------------
inherits poi.base.scenario_actor;
//------------------------------------------------
// Constants
//------------------------------------------------
const string SCRIPT_CONVERSE = "npc.converse.npc_converse_menu";
const string LOG_NAME = "poiGangWar Mediator";
//------------------------------------------------
// Methods
//------------------------------------------------
//------------------------------------------------
// OnAttach
//------------------------------------------------
trigger OnAttach()
{
// TEST: Arm weapon.
messageTo( self, "armWeapon", null, 2, false );
detachScript( self, SCRIPT_CONVERSE );
return SCRIPT_CONTINUE;
}
//------------------------------------------------
// armWeapon
//------------------------------------------------
messageHandler armWeapon()
{
aiEquipPrimaryWeapon( self );
return SCRIPT_CONTINUE;
}
//------------------------------------------------
// OnIncapacitated
//------------------------------------------------
trigger OnIncapacitated( obj_id killer )
{
// Get reference to base.
obj_id poiMaster = poi.getBaseObject( self );
if ( (poiMaster == null) || (poiMaster == obj_id.NULL_ID) )
return SCRIPT_CONTINUE;
messageTo( poiMaster, scenario.HANDLER_ACTOR_DEATH, null, 0, false );
return SCRIPT_CONTINUE;
}
//------------------------------------------------
// OnTriggerVolumeEntered
//------------------------------------------------
trigger OnTriggerVolumeEntered( string volumeName, obj_id breacher )
{
return SCRIPT_OVERRIDE;
}
//------------------------------------------------
// vocalizeEndCombat
//
// Find a new target once ours is dead.
//------------------------------------------------
messageHandler vocalizeEndCombat()
{
// Don't do this if dead or in combat.
if ( ai_lib.isDead( self ) || ai_lib.isInCombat( self ))
return SCRIPT_OVERRIDE;
// Kill players that are down.
obj_id[] players = getPlayerCreaturesInRange(self, 80f);
for ( int i = 0; i < players.length; i++ )
{
if ( isIncapacitated( players[i] ) && getPosture( players[i] ) != POSTURE_DEAD )
{
pclib.coupDeGrace( players[i], self );
return SCRIPT_OVERRIDE;
}
}
// Get base object reference.
obj_id poiMaster = poi.getBaseObject(self);
if ( (poiMaster == null) || (poiMaster == obj_id.NULL_ID) )
return SCRIPT_CONTINUE;
// Find a new target.
obj_id[] antagonists = scenario.getTeamMembers( poiMaster, "antagonist" );
for ( int i=0; i<antagonists.length; i++ )
{
if ( isIncapacitated( antagonists[i] ) || ai_lib.isDead( antagonists[i] ) )
continue;
startCombat( self, antagonists[i] );
return SCRIPT_CONTINUE;
}
// Celebrate.
if ( getPosture( self ) == POSTURE_UPRIGHT )
{
string skeleton = dataTableGetString("datatables/ai/species.iff", ai_lib.aiGetSpecies( self ), "Skeleton");
if ( skeleton == "human" )
doAnimationAction( self, "celebrate" );
else
doAnimationAction( self, "vocalize" );
}
messageTo( self, "postCombatPathHome", null, rand(10,20), false );
// Allow us to loiter.
ai_lib.setDefaultCalmBehavior( self, ai_lib.BEHAVIOR_LOITER );
return SCRIPT_OVERRIDE;
}
//------------------------------------------------
// OnTargeted
//------------------------------------------------
trigger OnTargeted( obj_id attacker )
{
// Only do this once ever.
if ( hasObjVar( self, "attackedByElse" ) )
return SCRIPT_CONTINUE;
setObjVar( self, "attackedByElse", 1 );
// Get base object reference.
obj_id poiMaster = poi.getBaseObject(self);
if ( (poiMaster == null) || (poiMaster == obj_id.NULL_ID) )
return SCRIPT_CONTINUE;
// Check to see if we were targetted by a non-antagonist.
obj_id[] antagonists = scenario.getTeamMembers( poiMaster, "antagonist" );
for ( int i=0; i<antagonists.length; i++ )
{
if ( antagonists[i] == attacker )
return SCRIPT_CONTINUE;
}
// Say something!
poi.quickSay( self, "m_whatthehell" );
// We were targeted by a non mediator. Start the attack!
obj_id a = poi.findObject( "antagonist_0" );
if ( (a == null) || (a == obj_id.NULL_ID) )
return SCRIPT_CONTINUE;
messageTo( a, "startAttack", null, 0, false );
return SCRIPT_CONTINUE;
}