Jump to content

Home

Howto run script when entering combat


Xiskio

Recommended Posts

As far as I can tell, In K2 there is an "OnAttacked" that is used in the scripts section of a UTC file. The script looks like the right one. You will probably need to redefine "k_def_attacked1".

 

#include "k_inc_switch"
#include "k_inc_debug"

void main()
{
   ExecuteScript("k_ai_master", OBJECT_SELF, KOTOR_DEFAULT_EVENT_ON_ATTACKED);
   /*
   //Shout that I was attacked
   SpeakString("GEN_I_WAS_ATTACKED", TALKVOLUME_SILENT_TALK);
   //SpeakString("GEN_COMBAT_ACTIVE", TALKVOLUME_SILENT_TALK);
   if(GetCommandable() && !GN_GetSpawnInCondition(SW_FLAG_AI_OFF))
   {
       if(!GN_GetIsFighting(OBJECT_SELF))
       {
           GN_MyPrintString("GENERIC DEBUG *************** Determine Combat Round from On Attacked");
           GN_DetermineCombatRound();
           //Shout that I was attacked
           SpeakString("GEN_I_WAS_ATTACKED", TALKVOLUME_SILENT_TALK);
           //SpeakString("GEN_COMBAT_ACTIVE", TALKVOLUME_SILENT_TALK);
       }
       else if(GetCurrentAction() == ACTION_QUEUEEMPTY)
       {
           GN_MyPrintString("GENERIC DEBUG *************** Determine Combat Round from On Attacked");
           GN_DetermineCombatRound();
           //Shout that I was attacked
           SpeakString("GEN_I_WAS_ATTACKED", TALKVOLUME_SILENT_TALK);
       }
   }
   if(GN_GetSpawnInCondition(SW_FLAG_EVENT_ON_ATTACKED))
   {
       SignalEvent(OBJECT_SELF, EventUserDefined(1005));
   }
   */
}

Link to comment
Share on other sites

Thanks for the hint.

 

It seems to work but not exactly as I would have wished. The event seems to be fired whenever someone is hit and not as soon as the party enters combat.

 

I am currently looking deeper into the event handling.

Any ideas where I can get some more infos about it?

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...