Thanks the both codes for you..
Code: Select all
use npc;
use os;
use uo;
use cfgfile;
use vitals;
use storage;
include "include/eventID";
include "include/attributes";
include "include/sysEvent";
include "include/NPCBackpacks";
include "include/NPCCast";
include "include/randName";
include "include/dist";
include "include/snooping";
set_priority(5);
const HALT_THRESHOLD := 15;
const SYSEVENT_ALL_GUARD_CMD := 0x13;
Const me := Self();
var npccfgfile := ReadConfigFile("npcdesc");
var dmgsound := npccfgfile[me.npctemplate].damagedsound;
var hit := npccfgfile[me.npctemplate].attackhitsound;
var idlesnd1 := npccfgfile[me.npctemplate].idlesound1;
var idlesnd2 := npccfgfile[me.npctemplate].idlesound2;
var FLAME_STRENGTH := npccfgfile[me.npctemplate].flamestrength;
var caster := 0;
var spells;
var firebreather;
var mypack := FindPack(me.serial);
var orneriness := npccfgfile[me.npctemplate].orneriness;
var masterserial := GetObjProperty(me, "master");
var saywords := 0;
var master;
var chaseloop := 0;
var guarding :=0;
var following := 0;
var nextwatch := ReadGameClock();
var happiness := CInt(GetObjProperty(me,"happiness"));
var waittime := 120;
var LAST_BREATH := ReadGameClock();
if((!happiness)||(happiness == error))
happiness := 100;
SetObjProperty(me,"happiness", 100);
endif
program TamedAI()
Detach();
var time := ReadGameClock();
SetObjProperty(me,"countercheck", time);
var parms := {};
parms[1] := me;
parms[2] := time;
start_script(":taming:happyCounter", parms);
master := SystemFindObjectBySerial(masterserial, SYSFIND_SEARCH_OFFLINE_MOBILES);
if(!master)
ApplyRawDamage(me, GetHP(me)+ 1);
return;
endif
me.setmaster(master);
if(me.name["<random>"])
SetName(me, RandomName(me));
endif
if(!happiness)
happiness := 10;
endif
if(!orneriness)
orneriness := 0;
endif
if(!me.backpack)
var newbackpack := CreateItemAtLocation(5288, 1176, 0, 0xe75,1);
EquipItem(me, newbackpack);
endif
SetAnchor(me.x, me.y, 20, 0);
var npccfg := ReadConfigFile("npcdesc");
if(npccfg[me.npctemplate].spell)
caster := 1;
spells := GetConfigStringArray(npccfg[me.npctemplate], "spell");
endif
if(FLAME_STRENGTH)
firebreather := 1;
endif
SetWarMode(0);
SetObjProperty(me, "serial", me.serial);
MainAILoop();
endprogram
function FindPack(myserial)
var mybank := OpenTamedStorageAreas();
var bank_obj_name := "Bankbox " + Hex(myserial);
var bankbox := FindRootItemInStorageArea(mybank, bank_obj_name);
if(!bankbox)
if((me.graphic == 0x123)||(me.graphic == 0x124))
bankbox := CreateRootItemInStorageArea(mybank, bank_obj_name, 0x966b);
else
bankbox := CreateRootItemInStorageArea(mybank, bank_obj_name, UOBJ_BANKBOX);
endif
else
if(((me.graphic == 0x123)||(me.graphic == 0x124))&&((me.backpack).objtype == UOBJ_BANKBOX))
DestroyItem(bankbox);
bankbox := CreateRootItemInStorageArea(mybank, bank_obj_name, 0x966b);
endif
endif
return bankbox;
endfunction
function MainAILoop()
var ev;
var evtext;
nextwatch := ReadGameClock();
var happytimer := 0;
var sleeper := 0;
var mhp;
EnableMainEvents();
while(GetHp(me)> 0)
happiness := GetObjProperty(me,"happiness");
mhp := GetHp(me);
if(GetObjProperty(me, "onhold"))
HoldLoop("onhold");
elseif(GetObjProperty(me, "stabled"))
HoldLoop("stabled");
elseif(GetObjProperty(me, "mounted"))
HoldLoop("mounted");
else
if(happiness < 10)
release();
endif
ev := os::wait_for_event(waittime);
case(ev.type)
SYSEVENT_SPEECH: ProcessSpeech(ev);
SYSEVENT_ENGAGED: Fight(ev.source);
SYSEVENT_DAMAGED: if(GetHp(me)< mhp)
if(ev.source)
Fight(ev.source);
endif
PlaySoundEffect(me,dmgsound);
endif
SYSEVENT_DOUBLECLICKED: if((ev.source == master) or (ev.source.cmdlevel > 2))
OpenMyPack();
else
snoop(ev.source, me);
endif
SYSEVENT_ITEM_GIVEN: if(ev.source == master)
TakeItem(ev);
endif
EVID_ALL_ATTACK_CMD: Fight(ev.target);
EVID_ALL_FOLLOW_CMD: following := ev.target;
SYSEVENT_ALL_GUARD_CMD: guarding := ev.target;
PrintTextAbove(me,"*guarding " + guarding.name + "*");
endcase
if(master.dead)
dismountme(master);
endif
if(following)
waittime := 0;
Follow();
elseif(guarding)
waittime := 7;
Guard();
else
waittime := 120;
EraseObjProperty(me,"#flees");
endif
endif
endwhile
endfunction
function HoldLoop(type)
disablemainevents();
EnableTameEvents();
var ev, happiness;
while(GetObjProperty(me, type))
if(type == "mounted")
happiness := GetObjProperty(me, "happiness");
ev := os::wait_for_event(60);
if(happiness < 10)
release();
endif
else
ev := os::wait_for_event(300);
endif
case(ev.type)
EVID_WAKEUP: EraseObjProperty(me, type);
endcase
endwhile
EnableMainEvents();
endfunction
function Fight(opponent)
var oldfollowing := following;
var flees := 0;
SetDexterityMod(me, 0);
following := 0;
if(opponent == me)
return;
endif
TurnToward(opponent);
SetOpponent(opponent);
var nextbreath := ReadGameClock();
var ev;
var loops := 0;
var waittime := 0;
while((opponent) && (!opponent.dead || !opponent.hidden || !opponent.concealed)&&(dist(me,opponent)< 15))
if(!CloseDistance(opponent))
loops := loops + 1;
waittime := 0;
else
if(!CheckLineOfSight(me, opponent))
loops := loops + 1;
endif
waittime := 1;
endif
ev := wait_for_event(waittime);
case(ev.type)
EVID_ALL_ATTACK_CMD: opponent := ev.target;
SetOpponent(opponent);
EVID_ALL_FOLLOW_CMD: following := ev.target;
SYSEVENT_ALL_GUARD_CMD: guarding := ev.target;
PrintTextAbove(me,"*guarding " + guarding.name + "*");
SYSEVENT_SPEECH: ProcessSpeech(ev);
SYSEVENT_ENGAGED:
SYSEVENT_DAMAGED: if(ev.source == opponent)
PlaySoundEffect(me,dmgsound);
endif
if(ev.source)
if(ev.source != opponent)
if((!CheckLineOfSight(me, opponent))||(RandomInt(8)==1))
opponent := ev.source;
SetOpponent(opponent);
endif
endif
TurnToward(opponent);
endif
EVID_PEACEMADE: SetWarMode(0);
opponent := 0;
following := oldfollowing;
return;
SYSEVENT_DOUBLECLICKED: if((ev.source == master) or (ev.source.cmdlevel > 2))
OpenMyPack();
else
snoop(ev.source, me);
endif
endcase
if(master.dead)
dismountme(master);
endif
if(following)
SetWarMode(0);
opponent := 0;
return;
endif
if(firebreather and caster)
if(LAST_BREATH <= ReadGameClock())
if((CheckLineOfSight(me, opponent)) and (dist(me, opponent) <= 15))
if(RandomInt(4) == 1)
cast_meteor(opponent);
else
cast_offensive_spell(me,opponent);
endif
LAST_BREATH := Cint(ReadGameClock() + (RandomInt(4) + 4));
endif
endif
elseif(caster)
if(LAST_BREATH <= ReadGameClock())
if((CheckLineOfSight(me, opponent)) and (dist(me, opponent) <= 15))
cast_offensive_spell(me, opponent);
LAST_BREATH := Cint(ReadGameClock() + (RandomInt(4) + 4));
endif
endif
elseif(firebreather)
if(LAST_BREATH <= ReadGameClock())
if(RandomInt(4)== 1)
cast_meteor(opponent);
endif
LAST_BREATH := Cint(ReadGameClock() + (RandomInt(4) + 4));
endif
endif
if(loops > 30)
flees := flees + 1;
if(flees > 4)
flee(opponent);
endif
return;
endif
endwhile
SetWarMode(0);
opponent := 0;
following := oldfollowing;
endfunction
function CloseDistance(opponent)
case ( Distance(me, opponent))
1:
0: return 1;
default: if(!RunToward(opponent))
return 1;
else
return 0;
endif
endcase
endfunction
function Transfer()
if(GetObjProperty(me, "summoned"))
return;
endif
SendSysMessage(master, "Transfer " + me.name + " to whom?");
var whom := Target(master, TGTOPT_NOCHECK_LOS);
if(!whom)
SendSysMessage(master, "Canceled");
return;
endif
if(!whom.acctname)
printtextabove(me, "your pet refuses to accept that as a master.");
return;
endif
if(whom == master)
printtextabove(me, "you are already my master.");
return;
endif
var npccfgfile := ReadConfigFile("npcdesc");
var tameskill := CInt(npccfgfile[me.npctemplate].tameskill);
var mastaming := GetEffectiveSkill(master, SKILLID_TAMING);
var maslore := GetEffectiveSkill(master, SKILLID_ANIMALLORE)/5;
var tgttaming := CInt(GetEffectiveSkill(whom, SKILLID_TAMING));
var tgtlore := CInt(GetEffectiveSkill(whom, SKILLID_ANIMALLORE)/5);
happiness := GetObjProperty(me, "happiness");
if(tgttaming <(tameskill - 50))
PlaySoundEffect(me, dmgsound);
if(!orneriness)
orneriness := 1;
endif
happiness := happiness - orneriness;
if(happiness < 10)
release();
else
SetObjProperty(me, "happiness", happiness);
SendSysMessage(master, "That person has no chance of controlling this beast!");
return;
endif
endif
var dif := CInt(tameskill -((mastaming/10)+ maslore));
var diff := CInt((tameskill-20)-((tgttaming/10)+ tgtlore));
if(dif < 1)
dif := 1;
endif
if(diff < 1)
diff := 1;
endif
var tsm := CInt(RandomInt(40)+(mastaming + 40));
var tst := CInt(RandomInt(40)+(tgttaming + 40));
if(tsm > dif)
if(tst < diff)
PlaySoundEffect(me, dmgsound);
happiness := happiness - orneriness;
if(happiness < 10)
release();
else
SetObjProperty(me, "happiness", happiness);
SendSysMessage(master,"your pet refuses to accept " + whom.name + " as a master");
return;
endif
else
PlaySoundEffect(me, hit);
SetObjProperty(me, "master", whom.serial);
PrintTextAbove(me, me.name + " accepts " + whom.name+ " as its new master");
RestartScript(me);
endif
else
PlaySoundEffect(me, dmgsound);
happiness := happiness - orneriness;
SetObjProperty(me, "happiness", happiness);
if(happiness < 10)
release();
else
SendSysMessage(master,"your pet refuses to listen to you");
return;
endif
endif
endfunction
function release()
if((GetObjProperty(me,"onhold")) or (GetObjProperty(me,"stabled")))
return;
endif
var char;
var mounted_char;
var onchars := EnumerateOnlineCharacters();
if(GetObjProperty(me,"summoned") == 1)
if(GetObjProperty(me,"mounted") == 1)
char := GetObjProperty(me,"mounted_on");
foreach person in onchars
if(person.serial == CInt(char))
mounted_char := person;
break;
endif
endforeach
dismountme(mounted_char);
endif
PlayStationaryEffect(me.x, me.y, me.z, FX_SMOKE, 0xa, 0xa);
MoveObjectToLocation(me,5288, 1176, 0,MOVEOBJECT_FORCELOCATION);
ApplyRawDamage(me, GetHp(me)+ 3);
else
if(GetObjProperty(me,"mounted"))
char := GetObjProperty(me,"mounted_on");
foreach person in onchars
if(person.serial == CInt(char))
mounted_char := person;
break;
endif
endforeach
dismountme(mounted_char);
endif
me.script := npccfgfile[me.npctemplate].script;
PrintTextAbove(me, me.name + " has decided it is better off without a master.");
me.setmaster(0);
EraseObjProperty(me, "master");
EraseObjProperty(me, "serial");
EraseObjProperty(me, "script");
EraseObjProperty(me, "happiness");
EraseObjProperty(me, "mounted");
EraseObjProperty(me, "mounted_on");
SetAnchor(me.x,me.y,10,1);
SetHpRegenRate(me ,(100)* 12);
RestartScript(me);
endif
endfunction
function dismountme(who)
var mount := GetEquipmentByLayer(who, 25);
me.facing := who.facing;
MoveObjectToLocation(me, master.x, who.y, who.z, MOVEOBJECT_FORCELOCATION);
EraseObjProperty(me, "mounted");
EraseObjProperty(me, "mounted_on");
DestroyItem(mount);
endfunction
function Fetch()
var tobj := Target(master);
if(tobj.container)
PlaySoundEffect(me, dmgsound);
return;
endif
var times := 0;
while((Distance(me, tobj)> 1)&&(times <= 5)&& CheckLineOfSight(me,tobj))
if(!walktoward(tobj))
sleepms(100);
times := times + 1;
else
times := 0;
endif
endwhile
if(Accessible(me,tobj))
PlaySoundEffect(me, hit);
MoveItemToContainer(tobj, mypack);
while((Distance(me, master)> 1)&&(times <= 5)&& CheckLineOfSight(me,master))
if(!walktoward(master))
sleepms(100);
times := times + 1;
else
times := 0;
endif
endwhile
MoveObjectToLocation(tobj, me.x, me.y, me.z, MOVEOBJECT_FORCELOCATION);
else
PlaySoundEffect(me, dmgsound);
endif
endfunction
function Get()
var tobj := Target(master);
if(tobj.container)
PlaySoundEffect(me, dmgsound);
return;
endif
var times := 0;
while((Distance(me, tobj)> 1)&&(times <= 5)&& CheckLineOfSight(me,tobj))
if(!walktoward(tobj))
sleepms(100);
times := times + 1;
else
times := 0;
endif
endwhile
if(Accessible(me,tobj))
PlaySoundEffect(me, hit);
MoveItemToContainer(tobj, mypack);
else
PlaySoundEffect(me, dmgsound);
endif
endfunction
function drop()
var myitems;
foreach myitems in EnumerateItemsInContainer(mypack)
if(myitems.container.serial == mypack.serial)
MoveObjectToLocation(myitems, me.x, me.y, me.z,0);
sleepms(100);
endif
endforeach
endfunction
function speak()
if(RandomInt(1)+1 == 1)
PlaySoundEffect(me, idlesnd1);
else
PlaySoundEffect(me, idlesnd1);
endif
endfunction
function OpenMyPack();
if((me.graphic == 0x123)||(me.graphic == 0x124))
if(Distance(me, master)> 2)
return;
endif
foreach item in EnumerateItemsInContainer(mypack)
if(item.container == me.backpack)
MoveItemToContainer(item, me.backpack);
endif
endforeach
SendOpenSpecialContainer(master, mypack);
return;
else
if(Distance(me, master)> 1)
return;
endif
var alreadymounted := GetEquipmentByLayer(master, 25);
if(alreadymounted)
return;
endif
var mounttype := 0;
case(me.graphic)
0xcc: mounttype := 0x3ea2;
0xc8: mounttype := 0x3e9f;
0xe2: mounttype := 0x3ea0;
0xe4: mounttype := 0x3ea1;
0xdc: mounttype := 0x3ea6;
0xd2: mounttype := 0x3ea3;
0xda: mounttype := 0x3ea4;
0xdb: mounttype := 0x3ea5;
endcase
if(mounttype)
if(MoveObjectToLocation(master,me.x,me.y,me.z,0))
master.facing := me.facing;
var mount := CreateItemAtLocation(5228, 1182, 0, 0xf021,1);
if(Cint(GetObjProperty(me, "summoned")) == 1)
SetObjProperty(mount, "summoned", 1);
endif
mount.color := me.color;
MoveObjectToLocation(me, 5228, 1182, 0, MOVEOBJECT_FORCELOCATION);
mount.graphic := mounttype;
EquipItem(master,mount);
SetObjProperty(mount,"serial", me.serial);
SetObjProperty(me,"mounted", 1);
SetObjProperty(me,"mounted_on", master.serial);
guarding := 0;
following := 0;
endif
endif
endif
endfunction
function TakeItem(ev)
var npccfg := ReadConfigFile("npcdesc");
var foodtype := npccfg[me.npctemplate].food;
if(!foodtype)
foodtype := "all";
endif
var cfg := ReadConfigFile("::food");
var elem := FindConfigElem(cfg,foodtype);
var foodarray := GetConfigStringArray(elem,"food");
if(CStr(ev.item.objtype)in foodarray)
PlaySoundEffect(me, CInt(0x3b)+ RandomInt(3));
DestroyItem(ev.item);
PrintTextAbovePrivate(me,"your pet looks happier.", master);
SetObjProperty(me,"happiness", 100);
return;
endif
if((me.graphic == 0x123)||(me.graphic == 0x124))
if(!MoveItemToContainer(ev.item, mypack))
say("*your pet cannot hold that item*");
return;
else
PlaySoundEffect(me,0x49);
endif
else
var yourpack := ev.source.backpack;
MoveItemToContainer(ev.item,yourpack);
endif
endfunction
function Guard()
if(nextwatch <= ReadGameClock())
nextwatch := ReadGameClock()+ 7;
if(RandomInt(8)==1)
PrintTextAbove(me,"*guarding " + guarding.name + "*");
endif
foreach mob in ListHostiles(guarding, 9, 0);
Fight(mob);
return;
endforeach
endif
if((!GetStrength(guarding))||(guarding.dead)||(dist(me,guarding)> 15))
guarding := 0;
endif
endfunction
function Follow()
var d := Distance(me, following);
if(d <= 2)
waittime := 1;
elseif(d > 15)
following := 0;
waittime := 120;
elseif(d > 6)
if(GetObjProperty(me, "Pause"))
waittime := 2;
else
var ma := 200 - CInt(GetDexterity(me));
SetDexterityMod(me, CInt(GetDexterityMod(me))+ ma);
RunToward(following);
SetDexterityMod(me, CInt(GetDexterityMod(me))- ma);
waittime := 0;
endif
else
if(GetObjProperty(me, "Pause"))
waittime := 2;
else
var ma := 200 - CInt(GetDexterity(me));
SetDexterityMod(me, CInt(GetDexterityMod(me))+ ma);
walktoward(following);
SetDexterityMod(me, CInt(GetDexterityMod(me))- ma);
waittime := 0;
endif
endif
if(guarding)
Guard();
endif
endfunction
function ProcessSpeech(ev)
if(ev.source.serial != masterserial)
return;
endif
if(!master)
RestartScript(me);
endif
var evtext := lower(ev.text);
var mename := lower(me.name);
if(evtext[mename + " kill"] || evtext[mename + " attack"] || evtext["all kill"] || evtext["all attack"])
var what := Target(master, TGTOPT_HARMFUL + TGTOPT_CHECK_LOS);
if(what)
if(what == ev.source)
return;
elseif(evtext["all kill"] || evtext["all attack"])
if(obediencecheck()== 0)
return;
endif
AllCommand(EVID_ALL_ATTACK_CMD, what);
else
if(obediencecheck()== 0)
return;
endif
Fight(what);
endif
endif
elseif(evtext[mename + " stop"] || evtext["all stop"])
if(obediencecheck()== 0)
return;
endif
guarding := 0;
following := 0;
elseif((evtext[mename + " come"])||(evtext["all come"]))
if(obediencecheck()== 0)
return;
endif
var done := 0;
chaseloop := 0;
while(done == 0)
chaseloop := chaseloop +1;
done := CloseDistance(ev.source);
if(chaseloop > 25)
done :=1;
endif
endwhile
elseif(evtext[mename + " follow"])
if(obediencecheck()== 0)
return;
endif
if(evtext["follow me"])
following := ev.source;
else
var what := Target(master, TGTOPT_CHECK_LOS);
if(what)
following := what;
endif
endif
elseif(evtext["all follow"])
if(obediencecheck()== 0)
return;
endif
if(evtext["follow me"])
following := ev.source;
else
var what := Target(master, TGTOPT_CHECK_LOS);
if(what)
AllCommand(EVID_ALL_FOLLOW_CMD, what);
endif
endif
elseif(evtext[mename + " transfer"] ||(evtext["all transfer"]))
Transfer();
elseif(evtext[mename + " release"] ||(evtext["all release"]))
release();
elseif(evtext[mename + " guard me"])
guarding := ev.source;
PrintTextAbove(me,"Im guarding you.");
elseif(evtext[mename + " guard"])
say("Who should I guard?");
var what := Target(master, TGTOPT_HELPFUL + TGTOPT_CHECK_LOS);
if(what.isA(POLCLASS_UOBJECT))
guarding := what;
PrintTextAbove(me,"Im guarding " + guarding.name);
endif
elseif(evtext["all guard me"])
guarding := ev.source;
PrintTextAbove(me,"Im guarding you");
elseif(evtext["all guard"])
say("Who should I guard?");
var what := Target(master, TGTOPT_HELPFUL + TGTOPT_CHECK_LOS);
if(GetHp(what))
AllCommand(SYSEVENT_ALL_GUARD_CMD, what);
endif
elseif(evtext[mename + " fetch"])
if(obediencecheck()== 0)
return;
endif
Fetch();
elseif(evtext[mename + " get"])
if(obediencecheck()== 0)
return;
endif
Get();
elseif(evtext[mename + " drop"])
if(obediencecheck()== 0)
return;
endif
drop();
elseif(evtext[mename + " speak"] ||(evtext["all speak"]))
if(obediencecheck()== 0)
return;
endif
speak();
endif
endfunction
function AllCommand(evtype,what)
var mobs := ListMobilesNearLocation(master.x, master.y, master.z, 9);
var eve array;
eve.+type := evtype;
eve.+source := me;
eve.+target := what;
SendEvent(me, eve);
foreach mob in mobs
if(GetObjProperty(mob, "master")== me.master.serial)
SendEvent(mob, eve);
endif
endforeach
endfunction
function cast_meteor(opponent)
var base := Cint(((FLAME_STRENGTH * GetHp(me)) / GetMaxHp(me)) / 2);
var dmg := RandomInt(base) + base;
PerformAction(me,0x0c);
PlaysoundEffect(me, 0x16b);
sleep(3);
PlayMovingEffect(me, opponent, 0x36d4, 10, 1, 1);
ApplyRawDamage(opponent, dmg);
endfunction
function flee(opponent)
var numflees := GetObjProperty(me,"#flees");
if(numflees)
if(numflees > 5)
MoveObjectToLocation(me,5288,1176,0,MOVEOBJECT_FORCELOCATION);
SetObjProperty(me,"guardkill",1);
ApplyRawDamage(me, GetMaxHp(me)+ 3);
else
numflees := numflees + 1;
endif
else
numflees := 1;
endif
SetObjProperty(me,"#flees",numflees);
var runs := 0;
while((Distance(me, opponent)< 20)&&(runs < 50))
RunAwayFrom(opponent);
runs := runs +1;
wait_for_event(0);
endwhile
RestartScript(me);
endfunction
function obediencecheck()
var arry := { 0xcc, 0xc8, 0xe2, 0xe4, 0x123, 0x124, 0xd2, 0xdb };
if(me.objtype in arry)
return 1;
endif
var maslore := GetEffectiveSkill(master, SKILLID_ANIMALLORE)/5;
var mastaming := CInt(GetEffectiveSkill(master, SKILLID_TAMING)+ maslore);
var checkvalue := CInt(mastaming - 20);
happiness := GetObjProperty(me, "happiness");
var happybonus := happiness/10;
checkvalue := checkvalue + happybonus;
var defiance :=(orneriness * 20)-30;
if(defiance < 1)
defiance := 1;
endif
defiance := defiance + petcount();
var finaldefiance := CInt(defiance + RandomInt(40));
if(GetObjProperty(me, "summoned")== 1)
return 1;
elseif(finaldefiance > checkvalue)
PlaySoundEffect(me, dmgsound);
happiness := happiness - orneriness;
SetObjProperty(me, "happiness",(happiness-1));
if(happiness < 10)
release();
endif
return 0;
else
PlaySoundEffect(me,hit);
if(happiness < 10)
release();
return 0;
endif
return 1;
endif
endfunction
function petcount()
var npccfg := ReadConfigFile("npcdesc");
var pets := 0;
var mobs := ListMobilesNearLocation(me.x,me.y,me.z,8);
foreach mob in mobs
if((mob.script == "tamed")&&(GetObjProperty(mob,"master")==masterserial))
if(GetObjProperty(mob, "summoned"))
pets := pets + 0;
else
pets := pets+5;
endif
endif
endforeach
return pets;
endfunction
function EnableTameEvents()
EnableEvents(EVID_WAKEUP);
endfunction
function EnableMainEvents()
EnableEvents(SYSEVENT_SPEECH, 8);
EnableEvents(SYSEVENT_ENGAGED);
EnableEvents(SYSEVENT_DAMAGED);
EnableEvents(SYSEVENT_DOUBLECLICKED);
EnableEvents(SYSEVENT_ITEM_GIVEN);
EnableEvents(EVID_PEACEMADE);
endfunction
function disablemainevents()
DisableEvents(SYSEVENT_SPEECH);
DisableEvents(SYSEVENT_ENGAGED);
DisableEvents(SYSEVENT_DAMAGED);
DisableEvents(SYSEVENT_ITEM_GIVEN);
DisableEvents(EVID_PEACEMADE);
endfunction