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

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;
            iBashteam++;
            AssignCommand(oThis, ClearAllActions());
            switch(d4()){
                case 1 :    PlayVoiceChat(VOICE_CHAT_ATTACK, oThis);
                            AssignCommand(oThis, ActionSpeakString("Someone's breaking into that house, Attack !"));
                            break;
                case 2 :    PlayVoiceChat(VOICE_CHAT_MOVEOVER, oThis);
                            AssignCommand(oThis, ActionSpeakString("Move over here, I spotted a burglar !"));
                            break;
                case 3 :    PlayVoiceChat(VOICE_CHAT_STOP, oThis);
                            AssignCommand(oThis, ActionSpeakString("Stop, in the name of the law !"));
                            break;
                case 4 :    PlayVoiceChat(VOICE_CHAT_BATTLECRY1, oThis);
                            AssignCommand(oThis, ActionSpeakString("I kick ass for the lord !"));
                            break;
            }
            SetIsTemporaryEnemy(oBurglar, oThis, TRUE, 600.0);
            AssignCommand(oThis, ActionAttack(oBurglar, FALSE));
        }
        oThis = GetNextObjectInArea(GetArea(oBurglar));
    }

    if(iSpotted == 1){
        ActionCloseDoor(OBJECT_SELF);
        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
Neve
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: Bing [Bot], Google [Bot], refminion