Page 1 of 1

NPC's guard tradeskill tools

Posted: Sat Sep 20, 2003 12:48 pm
by Neve
Put this in OnDamaged of a placable to have any NPC attack the attacker of the placable after two warnings. Maybe this is useful ?

Code: Select all

void ShoutWarning(object oNPC, int iNumber, object oTerrorist){
    string Warning = "";

    switch(iNumber){
        case 1 :
            switch(d6()){
                case 1 : Warning = "Hey, what the hell are you doing ? Quit that immediately.";
                break;
                case 2 : Warning = "Please refrain from doing that.";
                break;
                case 3 : Warning = "Hey. Stop that !";
                break;
                case 4 : Warning = "Quit that you lunatic !";
                break;
                case 5 : Warning = "Hey. What do you think you're doing ?";
                break;
                case 6 : Warning = "What the... Stop immediately !";
                break;
            }
            AssignCommand(oNPC, ActionSpeakString(Warning));
            break;
        case 2 :
            switch(d3()){
                case 1 : Warning = "Last warning. Quit NOW.";
                break;
                case 2 : Warning = "I won't warn you again. Stop that.";
                break;
                case 3 : Warning = "Keep it up and I'll smack you in the face. Quit that !";
                break;
            }
            AssignCommand(oNPC, ActionSpeakString(Warning));
            break;
        case 3 :
            AssignCommand(oNPC, ActionSpeakString("Now you're in for it !"));
            AssignCommand(oNPC, PlayVoiceChat(d3()));
            SetLocalInt(oNPC, GetName(oTerrorist), 2);
            SetIsTemporaryEnemy(oTerrorist, oNPC, TRUE, 90.0);
            AssignCommand(oNPC, ActionAttack(oTerrorist));
        break;
    }
}

void Warn(object oNPC, object oTerrorist){
    ShoutWarning(oNPC, GetLocalInt(oNPC, GetName(oTerrorist)), oTerrorist);
    SetLocalInt(oNPC, GetName(oTerrorist), GetLocalInt(oNPC, GetName(oTerrorist)) + 1);
}

int GetIsHumanoid(object oObject){
    if(GetIsPC(oObject) || GetObjectType(oObject) != OBJECT_TYPE_CREATURE) return 0;
    if( GetRacialType(oObject) == RACIAL_TYPE_DWARF     ||
        GetRacialType(oObject) == RACIAL_TYPE_ELF       ||
        GetRacialType(oObject) == RACIAL_TYPE_GNOME     ||
        GetRacialType(oObject) == RACIAL_TYPE_HALFELF   ||
        GetRacialType(oObject) == RACIAL_TYPE_HALFLING  ||
        GetRacialType(oObject) == RACIAL_TYPE_HALFORC   ||
        GetRacialType(oObject) == RACIAL_TYPE_HUMAN)
        return 1;
    return 0;
}

void main(){
    object oTerrorist = GetLastDamager();
    object oNPC = GetFirstObjectInArea();

    while(GetIsObjectValid(oNPC)){
        if(GetIsHumanoid(oNPC) && GetDistanceBetween(oNPC, oTerrorist) <= 25.0){
            if(GetLocalInt(oNPC, GetName(oTerrorist)) < 1)
                AssignCommand(oNPC, ActionMoveToObject(oTerrorist, FALSE, 3.0));
            Warn(oNPC, oTerrorist);
        }
        oNPC = GetNextObjectInArea();
    }
}

Posted: Sat Sep 20, 2003 1:05 pm
by Gaelyn Faerstryd
Nice! Can this script be implemented? If so, can the cost be negotiated IC during the hiring of said guards?

Gaelyn.

Posted: Sat Sep 20, 2003 5:52 pm
by Garand
I know nothing about scripting, but if this sort of thing works I think this would be a great thing to impliment. If this sort of thing were added I think it would do alot to quell some of the problems people are having with the whole "anvil killer" plotline.

ie. NPCs would react to the situation and therefore make it more "realistic"

Posted: Sat Sep 20, 2003 6:06 pm
by LuditeOfAvlis
Knowing nothing of scripting, this looks cool. I assume the NPC in question has to actually see/hear the PC in question though for this to work?

Now I'm going to have to watch that lovely "auto-attack feature" that Bioware has blessed us with when the hostile NPCs come running up. :roll:

Posted: Sat Sep 20, 2003 9:42 pm
by Titanium Dragon
Bravo!

Posted: Sat Sep 20, 2003 11:20 pm
by Neve
LuditeOfAvlis wrote:Knowing nothing of scripting, this looks cool. I assume the NPC in question has to actually see/hear the PC in question though for this to work?
Well... "See"... I'm sure someone who's around will hear people smash their swords on an anvil. The NPC's walk towards the attacker first yelling a warning. Next they'll give a clear "last" warning. After, they'll attack. Basically, all NPC's within a range of 25 metres will respond (That's about the range of a screen, zoomed out if I'm not mistaken, so evil chars still get a fair chance to destroy stuff if their evil friends lure away the NPC's ;) )

[edit] The NPC's are mercyful, they'll change from hostile to neutral 90 seconds after they attack, unless they get attacked of course