Skip to content

Guard attack script

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();
}

Comments

  • Sylvus_MoonbowSylvus_Moonbow Member Posts: 1,085
    That script is running from a conversation line?
  • DeviC3DeviC3 Member Posts: 25
    edited February 2018
    no, its from Attack


    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
  • Sylvus_MoonbowSylvus_Moonbow Member Posts: 1,085
    But you are using GetPCSpeaker() as the target to make adjustments to reputation and if they have been seen by the guards.

    AdjustReputation(GetPCSpeaker(), OBJECT_SELF, -100);

    if (GetObjectSeen(GetPCSpeaker(), oFriend))
    {
    // Tell him to start combat
    AssignCommand(oFriend, DetermineCombatRound());
    }

    So not much is going to happen.
  • DeviC3DeviC3 Member Posts: 25
    so i done this with GetLastAttacker()...and they are attacking...but while i go few steps they are stands and think what to do :/
Sign In or Register to comment.