Server Totals
Underdark - (1)
M'Chek - (1)
Visimontium - (0)
Ferrell - (0)
Elysia - (0)
Le'Or - (0)
Deglos - (0)
Wilderness - (0)
Mikona - (0)
Total players: 2

Links Menu

Guards beating thieves up

Moderators: Nighthawk4, Dungeon Masters

Guards beating thieves up

PostAuthor: Neve » Tue Aug 05, 2003 2:51 pm

Paste this code in the OnOpen of a door you wish to guard. It's fun for when you have an area where guards guard via waypoints. Thieves will have to look out, everytime they open that door, there will be a check wether the nearby guards 'know' if the door opened. I don't think NWN has a GetIsViewable function to check for line of sight of an object, so they will see you within a circle of 30 feet, no matter if there's a house in between :? They will only hate you for 10 minutes though. Change variable iMaxBash to set the maximum number of guards attacking you simultaneous. Note : If you go fighting with them, all guards will attack on charge of armed assault :)

In the following line I used a set variable 30, which is the spot skill of my cityguards.

(d20() + 30) >= (d20() + GetSkillRank(SKILL_HIDE, oBurglar))

It can be replaced with GetSkillRank(SKILL_SPOT, oThis) aswell.

Code: Select all
#include "nw_i0_generic"

void main()
    object oBurglar     = GetLastOpenedBy();
    object oThis        = GetFirstObjectInArea(GetArea(oBurglar));
    int    iSpotted     = 0;
    int    iBashteam    = 0;
    int    iMaxBash     = 2;

    DelayCommand(20.0, ActionCloseDoor(OBJECT_SELF));

    while(GetIsObjectValid(oThis) == TRUE){
        if((GetTag(oThis) == "CityGuard") && (GetDistanceBetween(oBurglar, oThis) <= 30.0) && GetIsPC(oBurglar) && (d20() + 30) >= (d20() + GetSkillRank(SKILL_HIDE, oBurglar)) && iBashteam < iMaxBash){
            iSpotted = 1;
            AssignCommand(oThis, ClearAllActions());
                case 1 :    PlayVoiceChat(VOICE_CHAT_ATTACK, oThis);
                            AssignCommand(oThis, ActionSpeakString("Someone's breaking into that house, Attack !"));
                case 2 :    PlayVoiceChat(VOICE_CHAT_MOVEOVER, oThis);
                            AssignCommand(oThis, ActionSpeakString("Move over here, I spotted a burglar !"));
                case 3 :    PlayVoiceChat(VOICE_CHAT_STOP, oThis);
                            AssignCommand(oThis, ActionSpeakString("Stop, in the name of the law !"));
                case 4 :    PlayVoiceChat(VOICE_CHAT_BATTLECRY1, oThis);
                            AssignCommand(oThis, ActionSpeakString("I kick ass for the lord !"));
            SetIsTemporaryEnemy(oBurglar, oThis, TRUE, 600.0);
            AssignCommand(oThis, ActionAttack(oBurglar, FALSE));
        oThis = GetNextObjectInArea(GetArea(oBurglar));

    if(iSpotted == 1){
        SendMessageToPC(oBurglar, "You were spotted by the city guards while breaking into a house...");
- As you gaze unknowingly into the seemingly infinite depths of the optics of this altogether passionate embodiment of insatiability, you experience a gradual realisation that the heavily-embellished vocabulary scattered lavishly throughout the sentence you are currently reading is indisputably nothing greater than a generous ration of masculine bovine faeces.
User avatar
Prince of Bloated Discourse
Posts: 192
Joined: Mon Apr 14, 2003 4:09 pm
Location: The Netherlands

Return to NWN Scripting

Who is online

Registered users: jwhite5730, rk57957