Note: LucasForums Archive Project
The content here was reconstructed by scraping the Wayback Machine in an effort to restore some of what was lost when LF went down. The LucasForums Archive Project claims no ownership over the content or assets that were archived on archive.org.

This project is meant for research purposes only.

Howto run script when entering combat

Page: 1 of 1
 Xiskio
09-21-2008, 1:39 PM
#1
Hi all,

If I want to make sure that a certain script runs whenever the party enters combat, how would I achieve that?

Is there an event I can use?
If so, how do I attach the script to it?

See ya
Xiskio
 Kovвnб Ẑeleznэ
09-21-2008, 2:17 PM
#2
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_ATTACKE D))
{
SignalEvent(OBJECT_SELF, EventUserDefined(1005));
}
*/
}
 Xiskio
09-22-2008, 5:40 AM
#3
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?
Page: 1 of 1