Files
dsrc/sku.0/sys.server/compiled/game/script/working/jfreeman/combattest.script
T
2013-09-10 23:17:15 -07:00

120 lines
2.7 KiB
Plaintext

inherits systems.combat.combat_base;
trigger OnAttach()
{
debugSpeakMsg( self, "attached. Detaching AI scripts in 5" );
messageTo( self, "detachAI", null, 5, false );
return SCRIPT_CONTINUE;
}
messageHandler detachAI()
{
detachScript( self, "ai.ai" );
detachScript( self, "ai.creature_combat" );
stop( self );
debugSpeakMsg( self, "ai detached!" );
return SCRIPT_CONTINUE;
}
trigger OnHearSpeech(obj_id objSpeaker, string strText)
{
if(strText=="setTarget")
{
debugSpeakMsg(self, "target is set to "+objSpeaker);
setTarget(self, objSpeaker);
}
if(strText=="getTarget")
{
obj_id objTarget = getTarget(self);
debugSpeakMsg(self, "target is "+objTarget);
}
return SCRIPT_CONTINUE;
}
trigger OnDefenderCombatAction( obj_id attacker, obj_id weapon, int combatResult )
{
debugSpeakMsg(self, "defender_action, locomotion is "+getLocomotion(self)+" and posture is "+getPosture(self));
if ( hasCombatAction( self ) )
{
debugSpeakMsg(self, "I've got combat actions already, returning");
return SCRIPT_CONTINUE;
}
obj_id objTarget = getTarget(self);
if((objTarget==null)||(objTarget==obj_id.NULL_ID))
{
debugSpeakMsg(self, "setting target to "+attacker);
setTarget(self, attacker);
}
//debugServerConsoleMsg(self, "ONDEFENDERCOMBATMESSAGE, my attacker is "+attacker);
//debugSpeakMsg( self, "enqueueing attack vs " + getName( attacker ));
debugSpeakMsg(self, "queueing attack against "+attacker);
queueCommand( self, ##"defaultAttack", attacker, "Test params", COMMAND_PRIORITY_DEFAULT);
return SCRIPT_CONTINUE;
}
/*
trigger OnCombatLoop()
{
debugSpeakMsg(self, "combat_loop, locomotion is "+getLocomotion(self)+" and posture is "+getPosture(self));
debugSpeakMsg(self, "ONCOMBATLOOP, target is "+getTarget(self));
if ( hasCombatAction( self ) )
{
debugSpeakMsg(self, "actions queueued up already, returning from oncombatloop");
return SCRIPT_CONTINUE;
}
obj_id target = getTarget(self);
if(target==null)
{
debugSpeakMsg( self, "my target is null" );
return SCRIPT_CONTINUE;
}
debugSpeakMsg( self, "enqueueing attack vs " + getName(target) );
queueCommand( self, ##"defaultAttack", target, "Test params", COMMAND_PRIORITY_DEFAULT);
return SCRIPT_CONTINUE;
}
*/
boolean hasCombatAction( obj_id npc )
{
return checkForCombatActions(npc);
/*
if( queueHasCommandFromGroup(npc, ##"combat") )
return true;
if( queueHasCommandFromGroup(npc, ##"combat_general") )
return true;
if( queueHasCommandFromGroup(npc, ##"combat_melee") )
return true;
if( queueHasCommandFromGroup(npc, ##"combat_ranged") )
return true;
return false;
* */
}
trigger OnIncapacitated( obj_id attacker )
{
kill( self );
debugSpeakMsg( self, "I am dead" );
detachScript( self, "jfreeman.combattest" );
return SCRIPT_CONTINUE;
}