

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...");
}
}