include ai.ai_aggro; include library.ai_lib; include library.attrib; include library.factions; include library.utils; const string ACTION_ALERT = "alert"; const string ACTION_THREATEN = "threaten"; trigger OnAttach() { setAttributeAttained( self, attrib.THUG ); setAttributeInterested( self, attrib.VICTIM ); return SCRIPT_CONTINUE; } trigger OnInitialize() { setAttributeAttained( self, attrib.THUG ); setAttributeInterested( self, attrib.VICTIM ); return SCRIPT_CONTINUE; } trigger OnTriggerVolumeEntered( string volumeName, obj_id breacher ) { if ( hasObjVar( breacher, "gm") ) return SCRIPT_CONTINUE; if ( ai_lib.isInCombat( self )) return SCRIPT_CONTINUE; if ( breacher == self ) return SCRIPT_CONTINUE; if ( isIncapacitated(self) ) return SCRIPT_CONTINUE; if ( !isMob( breacher) ) return SCRIPT_CONTINUE; if ( ai_lib.isMonster( breacher )) return SCRIPT_CONTINUE; if (isPlayer(breacher)) return SCRIPT_CONTINUE; if ( volumeName == ai_lib.AGGRO_VOLUME_NAME ) { int reaction = factions.getFactionReaction( self, breacher ); if ( hasAttributeAttained( breacher, attrib.VICTIM )) { reaction = factions.REACTION_NEGATIVE; } else if (reaction != factions.REACTION_NEGATIVE ) { reaction = factions.REACTION_LIKE; } switch ( reaction ) { case factions.REACTION_NEGATIVE : { ai_lib.barkString(self, "hi_mean"); ai_aggro.requestAggroCheck(breacher); return SCRIPT_OVERRIDE; } case factions.REACTION_POSITIVE: case factions.REACTION_LIKE: { ai_lib.barkString( self, "hi_nice" ); } break; default: { //if (isPlayer(breacher)) //{ // ai_lib.barkString( self, "hi_mean" ); // // if (rand(1, 5) == 1) // { // ai_combat.requestLosAggroCheck(breacher); // // return SCRIPT_OVERRIDE; // } //} } break; } } return SCRIPT_CONTINUE; } trigger OnTriggerVolumeExited( string volumeName, obj_id breacher ) { if (ai_lib.isInCombat(self)) return SCRIPT_CONTINUE; if (isPlayer(breacher)) return SCRIPT_CONTINUE; if (volumeName == ai_lib.AGGRO_VOLUME_NAME) { if ( isMob(breacher) && !ai_lib.isMonster(breacher)) { int reaction = factions.getFactionReaction( self, breacher ); if (hasAttributeAttained(breacher, attrib.VICTIM)) { reaction = factions.REACTION_NEGATIVE; } else if (reaction != factions.REACTION_NEGATIVE) { reaction = factions.REACTION_LIKE; } switch (reaction) { case factions.REACTION_NEGATIVE: { ai_lib.barkString( self, "bye_mean" ); if ( rand(1,2)==1 ) { //debugSpeakMsg( self, "attack 12" ); ai_aggro.requestAggroCheck(breacher); return SCRIPT_OVERRIDE; } } case factions.REACTION_POSITIVE: case factions.REACTION_LIKE: { ai_lib.barkString(self, "bye_nice"); } break; default: { ai_lib.barkString(self, "bye_mean"); //if ( isPlayer( breacher ) ) //{ // if ( rand(1,4)==1 ) // { // ai_lib.requestLosAggroCheck(breacher); // } //} } break; } } } return SCRIPT_CONTINUE; } trigger OnBehaviorChange( int newBehavior, int oldBehavior, int[] changeFlags ) { if ( isIncapacitated(self) ) return SCRIPT_CONTINUE; if ( ai_lib.isInCombat( self )) return SCRIPT_OVERRIDE; if ( newBehavior > oldBehavior ) { if ( newBehavior >= BEHAVIOR_THREATEN && newBehavior < BEHAVIOR_ATTACK ) { doAgitateBehavior( self, newBehavior ); return SCRIPT_OVERRIDE;//don't do the default AI thing } return SCRIPT_CONTINUE; } else if ( newBehavior == BEHAVIOR_CALM ) { //debugSpeakMsg( self, "I AM CALM AGAIN" ); ai_lib.barkString( self, "calm" ); return SCRIPT_CONTINUE; } //do default behavior stuff: return SCRIPT_CONTINUE; } void doAgitateBehavior( obj_id npc, int behavior ) { if ( isInvulnerable( npc ) ) return; //debugSpeakMsg( npc, "doing custom thing" ); //obj_id threat = ai_lib.getBehaviorTarget( npc, behavior ); //if ( threat == null ) // return; //else // setObjVar( npc, "ai.threat", threat ); // //switch ( behavior ) //{ // case BEHAVIOR_ALERT: // stop( npc ); // ai_lib.setMood( npc, ai_lib.MOOD_NERVOUS ); // break; // case BEHAVIOR_THREATEN: // //debugSpeakMsg( npc, "Grrr!"); // faceTo( npc, threat ); // ai_lib.doThreatenAnimation( npc ); // ai_lib.setMood( npc, ai_lib.MOOD_THREATEN ); // break; // case BEHAVIOR_FLEE: // case BEHAVIOR_PANIC: // //debugSpeakMsg( npc, "attack 14" ); // startCombat( npc, threat ); // break; // default : // //debugSpeakMsg( npc, "default: " + behavior ); // break; //} }