Guard attack script
DeviC3
Member Posts: 25
Hi. I got problem with guard attacking script. When my character attack guards, only one of them kicking attacker, then rest of guards comming to attacker...and they are standing in one place.
I want to do this, when PC attack one of city guards, they all come to him and kick his ass.
#include "nw_i0_generic"
void main()
{
// This script will make every ally within the current area attack
location oHere = GetLocation(OBJECT_SELF);
// Lower my faction's relationship with the PC by 100 (to hostile)
AdjustReputation(GetPCSpeaker(), OBJECT_SELF, -100);
// Now cycle through all objects in my area
object oFriend = GetFirstObjectInArea(GetArea(OBJECT_SELF));
while (GetIsObjectValid(oFriend))
{
// If the object is a creature that is a member of my faction
if (GetFactionEqual(oFriend) && (GetObjectType(oFriend) == OBJECT_TYPE_CREATURE))
{
// ...and it can see the PC
if (GetObjectSeen(GetPCSpeaker(), oFriend))
{
// Tell him to start combat
AssignCommand(oFriend, DetermineCombatRound());
}
else // Otherwise, if he can't see the PC
{
// Tell him to stop what he's doing
AssignCommand(oFriend, ClearAllActions());
// ...and come to my location
AssignCommand(oFriend, DetermineCombatRound());
SpeakString("NW_ATTACK_MY_TARGET", TALKVOLUME_SILENT_TALK);
}
}
oFriend = GetNextObjectInArea(GetArea(OBJECT_SELF));
}
// Now start fighting, myself
DetermineCombatRound();
}
I want to do this, when PC attack one of city guards, they all come to him and kick his ass.
#include "nw_i0_generic"
void main()
{
// This script will make every ally within the current area attack
location oHere = GetLocation(OBJECT_SELF);
// Lower my faction's relationship with the PC by 100 (to hostile)
AdjustReputation(GetPCSpeaker(), OBJECT_SELF, -100);
// Now cycle through all objects in my area
object oFriend = GetFirstObjectInArea(GetArea(OBJECT_SELF));
while (GetIsObjectValid(oFriend))
{
// If the object is a creature that is a member of my faction
if (GetFactionEqual(oFriend) && (GetObjectType(oFriend) == OBJECT_TYPE_CREATURE))
{
// ...and it can see the PC
if (GetObjectSeen(GetPCSpeaker(), oFriend))
{
// Tell him to start combat
AssignCommand(oFriend, DetermineCombatRound());
}
else // Otherwise, if he can't see the PC
{
// Tell him to stop what he's doing
AssignCommand(oFriend, ClearAllActions());
// ...and come to my location
AssignCommand(oFriend, DetermineCombatRound());
SpeakString("NW_ATTACK_MY_TARGET", TALKVOLUME_SILENT_TALK);
}
}
oFriend = GetNextObjectInArea(GetArea(OBJECT_SELF));
}
// Now start fighting, myself
DetermineCombatRound();
}
0
Comments
void main()
{
//--------------------------------------------------------------------------
// GZ: 2003-10-16
// Make Plot Creatures Ignore Attacks
//--------------------------------------------------------------------------
if (GetPlotFlag(OBJECT_SELF))
{
return;
}
//--------------------------------------------------------------------------
// Execute old NWN default AI code
//--------------------------------------------------------------------------
ExecuteScript("nw_c2_default5", OBJECT_SELF);
ExecuteScript("straznikatak", OBJECT_SELF);
}
"straznikatak" is script from first post
AdjustReputation(GetPCSpeaker(), OBJECT_SELF, -100);
if (GetObjectSeen(GetPCSpeaker(), oFriend))
{
// Tell him to start combat
AssignCommand(oFriend, DetermineCombatRound());
}
So not much is going to happen.