#include "NW_I0_GENERIC" #include "prc_inc_spells" ///// void jw_woken(); void jw_sleep(); void jw_wake(); void jw_general(); void jw_cook(); void jw_endcook(); void jw_leavehouse(); void jw_gohome(); void jw_forcewake(); void jw_lumberjack(); void jw_destroy_logs(); void jw_hunt(); void jw_destroy_loot(); void Asheebalife(); void Asheebalife() { if (!GetPlotFlag(OBJECT_SELF)) {SetPlotFlag(OBJECT_SELF,TRUE);} int nTime=GetLocalInt(OBJECT_SELF,"jw_time"); /// force the NPC to wake up if asleep if ((nTime>7)&&(nTime<23)) { jw_forcewake(); } /// the default action is 3, general at home actions. But they will only happen if the /// NPC is at home if (GetArea(OBJECT_SELF)==GetArea(GetObjectByTag("jw_"+GetTag(OBJECT_SELF)+"_indoor"))||GetArea(OBJECT_SELF)==GetArea(GetObjectByTag("jw_"+GetTag(OBJECT_SELF)+"_door"))) { if ((nTime>7)&&(nTime<23)) { SetLocalInt(OBJECT_SELF,"njw_current",3); } /// go to bed if (((nTime>=23)||(nTime<=6))&&(GetLocalInt(OBJECT_SELF,"njw_completed")!=1)) { // SetLocalInt(OBJECT_SELF,"njw_current",1); } if (((nTime>=7)&&(nTime<=12))&&(GetLocalInt(OBJECT_SELF,"njw_completed")==1)) { // get up // SetLocalInt(OBJECT_SELF,"njw_current",2); } if (((nTime>=13)&&(nTime<14))&&(GetLocalInt(OBJECT_SELF,"njw_completed")!=4)) { // make dinner SetLocalInt(OBJECT_SELF,"njw_current",4); } if (((nTime>=14)&&(nTime<15))&&(GetLocalInt(OBJECT_SELF,"njw_completed")!=5)) { // get dinner out of oven SetLocalInt(OBJECT_SELF,"njw_current",5); } /// end of general moves } /// COMMONER's special moves if (GetLocalString(OBJECT_SELF,"behaviour")=="commoner") { } /// end of COMMONER's special moves /// LUMBERJACK's special moves if (GetLocalString(OBJECT_SELF,"behaviour")=="lumberjack") { /// 6 is leave the home if ((nTime>9)&&(nTime<18)&&(GetLocalInt(OBJECT_SELF,"njw_completed")!=6)) { // SetLocalInt(OBJECT_SELF,"njw_current",6); } /// 14 is lumberjack if ((nTime>9)&&(nTime<18)&&(GetTag(GetArea(OBJECT_SELF))=="jw_asheeba_area")) { SetLocalInt(OBJECT_SELF,"njw_current",14); } /// if for some reason the lumberjack is still at home when we want him out, get him out if ((nTime>9)&&(nTime<18)&&(GetTag(GetArea(OBJECT_SELF))!="jw_asheeba_area")) { SetLocalInt(OBJECT_SELF,"njw_current",6); } /// 8 is go home if ((nTime>18)&&(GetTag(GetArea(OBJECT_SELF))=="jw_asheeba_area")) { SetLocalInt(OBJECT_SELF,"njw_current",8); } } /// end of LUMBERJACK'S special moves /// HUNTER's special moves if (GetLocalString(OBJECT_SELF,"behaviour")=="hunter") { /// 6 is leave the home if ((nTime>9)&&(nTime<18)&&(GetLocalInt(OBJECT_SELF,"njw_completed")!=6)) { // SetLocalInt(OBJECT_SELF,"njw_current",6); } /// 15 is hunt if ((nTime>9)&&(nTime<18)&&(GetTag(GetArea(OBJECT_SELF))=="jw_asheeba_area")) { SetLocalInt(OBJECT_SELF,"njw_current",15); } /// if for some reason the lumberjack is still at home when we want him out, get him out if ((nTime>9)&&(nTime<18)&&(GetTag(GetArea(OBJECT_SELF))!="jw_asheeba_area")) { SetLocalInt(OBJECT_SELF,"njw_current",6); } /// 8 is go home if ((nTime>18)&&(GetTag(GetArea(OBJECT_SELF))=="jw_asheeba_area")) { SetLocalInt(OBJECT_SELF,"njw_current",8); } } /// end of HUNTER'S special moves if (GetLocalInt(OBJECT_SELF,"njw_current")==1) {jw_sleep();} if ((GetLocalInt(OBJECT_SELF,"njw_completed")==1)&&(GetLocalInt(OBJECT_SELF,"njw_current")==0)) {jw_woken();} if (GetLocalInt(OBJECT_SELF,"njw_current")==2) { jw_wake(); } if (GetLocalInt(OBJECT_SELF,"njw_current")==3) { jw_general();} if (GetLocalInt(OBJECT_SELF,"njw_current")==4) { jw_cook();} if (GetLocalInt(OBJECT_SELF,"njw_current")==5) { jw_endcook();} if (GetLocalInt(OBJECT_SELF,"njw_current")==6) { jw_leavehouse();} if (GetLocalInt(OBJECT_SELF,"njw_current")==8) { jw_gohome();} if (GetLocalInt(OBJECT_SELF,"njw_current")==14) { jw_lumberjack();} if (GetLocalInt(OBJECT_SELF,"njw_current")==15) { jw_hunt();} } void jw_sleep() { int nCounter; object oObject; if ((!IsInConversation(OBJECT_SELF))&&(!GetIsInCombat(OBJECT_SELF))) { if (GetLocalInt(OBJECT_SELF,"njw_steps")==0) { ClearAllActions(); ActionSpeakString("Time for bed."); ActionDoCommand(SetLocalInt(OBJECT_SELF,"njw_steps",1)); } if (GetLocalInt(OBJECT_SELF,"njw_steps")==1) { // nCounter=0; // oObject=GetObjectByTag("jw_"+GetTag(OBJECT_SELF)+"_candle1",nCounter); // while ((GetIsObjectValid(oObject))&&(GetLocalInt(oObject,"NW_L_AMION")!=2)) // { // ActionForceMoveToObject(oObject); // if (GetLocalInt(oObject,"NW_L_AMION")!=2) // { // ActionInteractObject(oObject); // ActionPlayAnimation(ANIMATION_LOOPING_GET_MID,1.0,0.5); // } // nCounter++; // oObject=GetObjectByTag("jw_"+GetTag(OBJECT_SELF)+"_candle1",nCounter); // } ActionDoCommand(SetLocalInt(OBJECT_SELF,"njw_steps",2)); } if (GetLocalInt(OBJECT_SELF,"njw_steps")==2) { ClearAllActions(); ActionForceMoveToObject(GetObjectByTag("WP_jw_"+GetTag(OBJECT_SELF)+"up_at"),0,3.0); ActionForceMoveToObject(GetObjectByTag("WP_jw_"+GetTag(OBJECT_SELF)+"down_at"),0,3.0); ActionDoCommand(SetLocalInt(OBJECT_SELF,"njw_steps",3)); } if (GetLocalInt(OBJECT_SELF,"njw_steps")==3) { // oObject=GetObjectByTag("jw_"+GetTag(OBJECT_SELF)+"_candle2"); // if ((GetIsObjectValid(oObject))&&(GetLocalInt(oObject,"NW_L_AMION")!=2)) // { // ActionForceMoveToObject(oObject); // if (GetLocalInt(oObject,"NW_L_AMION")!=2) // { // ActionInteractObject(oObject); // ActionPlayAnimation(ANIMATION_LOOPING_GET_MID,1.0,0.5); // } // } ActionDoCommand(SetLocalInt(OBJECT_SELF,"njw_steps",4)); } if (GetLocalInt(OBJECT_SELF,"njw_steps")==4) { ActionForceMoveToObject(GetObjectByTag("jw_"+GetTag(OBJECT_SELF)+"_door"),0,0.1); ActionOpenDoor(GetObjectByTag("jw_"+GetTag(OBJECT_SELF)+"_door")); ActionDoCommand(SetLocalInt(OBJECT_SELF,"njw_steps",5)); } if (GetLocalInt(OBJECT_SELF,"njw_steps")==5) { ActionForceMoveToLocation(GetLocation(GetObjectByTag("jw_"+GetTag(OBJECT_SELF)+"sleep2_wp")),FALSE,5.0); ActionDoCommand(SetLocalInt(OBJECT_SELF,"njw_steps",6)); } if (GetLocalInt(OBJECT_SELF,"njw_steps")==6) { // for (nCounter=0;nCounter<=1;nCounter++) // { // oObject=GetObjectByTag("jw_"+GetTag(OBJECT_SELF)+"_candle3",nCounter); // if (GetIsObjectValid(oObject)&&(GetLocalInt(oObject,"NW_L_AMION")!=2)) // { // ActionForceMoveToObject(oObject); // if (GetLocalInt(oObject,"NW_L_AMION")!=2) // { // ActionInteractObject(oObject); // ActionPlayAnimation(ANIMATION_LOOPING_GET_MID,1.0,0.5); // } // } // } ActionForceMoveToLocation(GetLocation(GetObjectByTag("jw_"+GetTag(OBJECT_SELF)+"sleep2_wp")),FALSE,2.0); ActionDoCommand(SetFacing(DIRECTION_NORTH)); ActionPlayAnimation(ANIMATION_LOOPING_MEDITATE,1.0,3.0); ActionPlayAnimation(ANIMATION_LOOPING_PAUSE_TIRED,1.0,2.0); //ActionRest(); effect eLieDown = EffectSleep(); effect eSnore = EffectVisualEffect (VFX_IMP_SLEEP); effect eSleep = EffectLinkEffects (eLieDown, eSnore); ActionDoCommand(SetLocalInt(OBJECT_SELF,"njw_steps",0)); ActionDoCommand(SetLocalInt(OBJECT_SELF,"njw_completed",1)); ActionDoCommand(SetLocalInt(OBJECT_SELF,"njw_current",0)); ActionDoCommand(SetPlotFlag(OBJECT_SELF,0)); ActionDoCommand(ApplyEffectToObject (DURATION_TYPE_PERMANENT, eSleep, OBJECT_SELF)); DelayCommand(2.0,ActionDoCommand(ClearAllActions())); } } } void jw_woken() { int nWoken=0; object oTarget; // if ((!IsInConversation(OBJECT_SELF))&&(!GetIsInCombat(OBJECT_SELF))) { // if I am asleep if (PRCGetHasEffect(EFFECT_TYPE_SLEEP)) { // get the nearest enemy creature to me oTarget = GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR,PLAYER_CHAR_IS_PC); // and if there is one and it is less than 5 meters away if ((GetDistanceToObject(oTarget) < 3.0) && (GetIsObjectValid(oTarget))) { effect eSleep = GetFirstEffect(OBJECT_SELF); // scroll through my current effects while (GetIsEffectValid(eSleep)) { // and if one of them if the effect sleep but but didn't come from a sleep spell if ((GetEffectType(eSleep) == EFFECT_TYPE_SLEEP) && (GetEffectSpellId(eSleep) != SPELL_SLEEP)) { // remove it RemoveEffect(OBJECT_SELF, eSleep); nWoken=1; } eSleep = GetNextEffect(OBJECT_SELF); } } } if (nWoken==1) { SpeakString("You woke me up - please leave"); DelayCommand(2.0,ActionDoCommand(SetLocalInt(OBJECT_SELF,"njw_steps",4))); DelayCommand(2.1,ActionDoCommand(SetLocalInt(OBJECT_SELF,"njw_completed",0))); } } } void jw_wake() { object oTarget; object oObject; object oChair; int nCounter=1; int nFoundchair=0; if ((!IsInConversation(OBJECT_SELF))&&(!GetIsInCombat(OBJECT_SELF))) { if (PRCGetHasEffect(EFFECT_TYPE_SLEEP)) { effect eSleep = GetFirstEffect(OBJECT_SELF); // scroll through my current effects while (GetIsEffectValid(eSleep)) { // and if one of them if the effect sleep but but didn't come from a sleep spell if ((GetEffectType(eSleep) == EFFECT_TYPE_SLEEP) && (GetEffectSpellId(eSleep) != SPELL_SLEEP)) { // remove it RemoveEffect(OBJECT_SELF, eSleep); } eSleep = GetNextEffect(OBJECT_SELF); } } // is now awake // open door //ActionForceMoveToObject(GetObjectByTag("jw_"+GetTag(OBJECT_SELF)+"_door"),0,0.1); //ActionOpenDoor(GetObjectByTag("jw_"+GetTag(OBJECT_SELF)+"_door")); // go to upstairs waypoint ActionForceMoveToObject(GetObjectByTag("WP_jw_"+GetTag(OBJECT_SELF)+"down_at"),0,1.0); // move to downstairs waypoint ActionForceMoveToObject(GetObjectByTag("WP_jw_"+GetTag(OBJECT_SELF)+"up_at"),0,2.0); // move to living room centre ActionForceMoveToObject(GetObjectByTag("jw_"+GetTag(OBJECT_SELF)+"living_wp"),0,3.0); ActionSpeakString("What a beautiful morning"); ActionDoCommand(SetLocalInt(OBJECT_SELF,"njw_completed",2)); ActionDoCommand(SetLocalInt(OBJECT_SELF,"njw_current",3)); ActionDoCommand(SetLocalInt(OBJECT_SELF,"njw_steps",0)); ActionDoCommand(ClearAllActions()); } } void jw_general() { ////one in 10 chance of changing behaviour int nRandom=Random(10); object oChair; int nCounter=1; int nFoundchair=0; ActionDoCommand(SetLocalInt(OBJECT_SELF,"njw_steps",0)); if ((!IsInConversation(OBJECT_SELF))&&(!GetIsInCombat(OBJECT_SELF))) { if (nRandom==1) { nRandom=Random(5); ClearAllActions(); switch (nRandom) { case 0: ActionForceMoveToObject(GetNearestObjectByTag("jw_"+GetTag(OBJECT_SELF)+"_bookshelf"),0,0.1); ActionPlayAnimation(ANIMATION_LOOPING_GET_LOW,1.0,1.0); oChair =GetNearestObjectByTag ("jw_"+GetTag(OBJECT_SELF)+"_couch", OBJECT_SELF); if (GetIsObjectValid(GetSittingCreature(oChair))) { nFoundchair=0; oChair =GetNearestObjectByTag ("jw_"+GetTag(OBJECT_SELF)+"_chair", OBJECT_SELF,nCounter); while (GetIsObjectValid(oChair)&&(nFoundchair==0)) { if (!GetIsObjectValid(GetSittingCreature(oChair))) { nFoundchair=1; ActionForceMoveToObject(oChair,0); ActionSit(oChair); break; } else { nCounter++; oChair=GetNearestObjectByTag ("jw_"+GetTag(OBJECT_SELF)+"_chair", OBJECT_SELF,nCounter); } } if (nFoundchair==0) { ActionSpeakString("Hmm . . . it's busy in here today"); break; } else { ActionForceMoveToObject(oChair,0); ActionSit(oChair); break; } } case 1: ActionRandomWalk(); break; case 2: ActionForceMoveToObject(GetNearestObjectByTag("jw_"+GetTag(OBJECT_SELF)+"_bookshelf"),0,0.1); ActionPlayAnimation(ANIMATION_LOOPING_GET_LOW,1.0,1.0); oChair =GetNearestObjectByTag ("jw_"+GetTag(OBJECT_SELF)+"_chair", OBJECT_SELF,nCounter); nFoundchair=0; while (GetIsObjectValid(oChair)&&(nFoundchair==0)) { if (!GetIsObjectValid(GetSittingCreature(oChair))) { nFoundchair=1; ActionForceMoveToObject(oChair,0); ActionSit(oChair); break; } else { nCounter++; oChair=GetNearestObjectByTag ("jw_"+GetTag(OBJECT_SELF)+"_chair", OBJECT_SELF,nCounter); } } if (nFoundchair==0) { ActionSpeakString("Hmm . . . it's busy in here today"); break; } case 3: ActionPlayAnimation(ANIMATION_FIREFORGET_HEAD_TURN_LEFT); ActionPlayAnimation(ANIMATION_FIREFORGET_HEAD_TURN_RIGHT); ActionPlayAnimation(ANIMATION_FIREFORGET_PAUSE_SCRATCH_HEAD); ActionForceMoveToObject(GetObjectByTag("jw_"+GetTag(OBJECT_SELF)+"_cabinet"),0,0.1); ActionPlayAnimation(ANIMATION_LOOPING_GET_LOW,1.0,1.0); ActionWait(1.0); ActionPlayAnimation(ANIMATION_FIREFORGET_DRINK); ActionWait(1.0); ActionRandomWalk(); case 4: ActionForceMoveToObject(GetNearestObjectByTag("jw_"+GetTag(OBJECT_SELF)+"_bookshelf"),0,0.1); ActionPlayAnimation(ANIMATION_LOOPING_GET_LOW,1.0,1.0); oChair =GetNearestObjectByTag ("jw_"+GetTag(OBJECT_SELF)+"_couch", OBJECT_SELF); if (GetIsObjectValid(GetSittingCreature(oChair))) { break;} else { ActionForceMoveToObject(oChair,0); ActionSit(oChair); break; } SetLocalInt(OBJECT_SELF,"njw_steps",0); } ///ended switch } } } void jw_cook() { if ((!IsInConversation(OBJECT_SELF))&&(!GetIsInCombat(OBJECT_SELF))) { if (GetLocalInt(OBJECT_SELF,"njw_steps")==0) { ClearAllActions(); ActionSpeakString("Time to make some food"); ActionDoCommand( SetLocalInt(OBJECT_SELF,"njw_steps",1)); } if (GetLocalInt(OBJECT_SELF,"njw_steps")==1) { ActionForceMoveToObject(GetObjectByTag("jw_"+GetTag(OBJECT_SELF)+"_oven"),0,0.1); ActionDoCommand(SetFacing(DIRECTION_SOUTH)); ActionDoCommand( SetLocalInt(OBJECT_SELF,"njw_steps",2)); } if (GetLocalInt(OBJECT_SELF,"njw_steps")==2) { if (GetLocalInt(GetObjectByTag("jw_"+GetTag(OBJECT_SELF)+"_oven"),"NW_L_AMION") != 1) { ActionInteractObject(GetObjectByTag("jw_"+GetTag(OBJECT_SELF)+"_oven")); } ActionDoCommand(SetLocalInt(OBJECT_SELF,"njw_steps",3)); } if (GetLocalInt(OBJECT_SELF,"njw_steps")==3) { ActionPlayAnimation(ANIMATION_LOOPING_GET_LOW,1.0,2.0); ActionPlayAnimation(ANIMATION_FIREFORGET_PAUSE_BORED); ActionForceMoveToObject(GetObjectByTag("jw_"+GetTag(OBJECT_SELF)+"living_wp")); ActionDoCommand(SetLocalInt(OBJECT_SELF,"njw_completed",4)); ActionDoCommand( SetLocalInt(OBJECT_SELF,"njw_current",3)); ActionDoCommand(SetLocalInt(OBJECT_SELF,"njw_steps",0)); ActionDoCommand(ClearAllActions()); } } } void jw_endcook() { object oChair; int nCounter=1; int nFoundchair; if ((!IsInConversation(OBJECT_SELF))&&(!GetIsInCombat(OBJECT_SELF))) { if (GetLocalInt(OBJECT_SELF,"njw_steps")==0) { ClearAllActions(); ActionSpeakString("Time to get the food out of the oven"); ActionDoCommand(SetLocalInt(OBJECT_SELF,"njw_steps",1)); } if (GetLocalInt(OBJECT_SELF,"njw_steps")==1) { ActionForceMoveToObject(GetObjectByTag("jw_"+GetTag(OBJECT_SELF)+"_oven"),0,0.1); ActionDoCommand(SetFacing(DIRECTION_SOUTH)); ActionDoCommand(SetLocalInt(OBJECT_SELF,"njw_steps",2)); } if (GetLocalInt(OBJECT_SELF,"njw_steps")==2) { if (GetLocalInt(GetObjectByTag("jw_"+GetTag(OBJECT_SELF)+"_oven"),"NW_L_AMION") != 2) { ActionInteractObject(GetObjectByTag("jw_"+GetTag(OBJECT_SELF)+"_oven")); } ActionDoCommand(SetLocalInt(OBJECT_SELF,"njw_steps",3)); } if (GetLocalInt(OBJECT_SELF,"njw_steps")==3) { ActionPlayAnimation(ANIMATION_LOOPING_GET_LOW,1.0,2.0); ActionPlayAnimation(ANIMATION_FIREFORGET_HEAD_TURN_RIGHT); ActionForceMoveToObject(GetObjectByTag("jw_"+GetTag(OBJECT_SELF)+"living_wp")); oChair =GetNearestObjectByTag ("jw_"+GetTag(OBJECT_SELF)+"_chair", OBJECT_SELF,nCounter); while (GetIsObjectValid(oChair)&&(nFoundchair==0)) { if (!GetIsObjectValid(GetSittingCreature(oChair))) { nFoundchair=1; ActionForceMoveToObject(oChair,0); ActionDoCommand(SetLocalInt(OBJECT_SELF,"njw_completed",5)); ActionDoCommand(SetLocalInt(OBJECT_SELF,"njw_current",3)); ActionDoCommand(SetLocalInt(OBJECT_SELF,"njw_steps",0)); ActionSit(oChair); } else { nCounter++; oChair=GetNearestObjectByTag ("jw_"+GetTag(OBJECT_SELF)+"_chair", OBJECT_SELF,nCounter); } } if (nFoundchair==0) { ActionSpeakString("Well, there's nowhere to sit"); } ActionDoCommand(SetLocalInt(OBJECT_SELF,"njw_completed",5)); ActionDoCommand( SetLocalInt(OBJECT_SELF,"njw_current",3)); ActionDoCommand(SetLocalInt(OBJECT_SELF,"njw_steps",0)); ActionDoCommand(ClearAllActions()); } } } void jw_leavehouse() { if ((!IsInConversation(OBJECT_SELF))&&(!GetIsInCombat(OBJECT_SELF))) { if (GetLocalInt(OBJECT_SELF,"njw_steps")!=1) { ClearAllActions(); ActionDoCommand(SetLocalInt(OBJECT_SELF,"njw_steps",1)); //ActionForceMoveToLocation(GetLocation(GetObjectByTag("jw_"+GetTag(OBJECT_SELF)+"living_wp")),FALSE,3.0); ActionForceMoveToLocation(GetLocation(GetObjectByTag("jw_"+GetTag(OBJECT_SELF)+"_outside_wp")),FALSE,30.0); } if (GetLocalInt(OBJECT_SELF,"njw_steps")==1) { DelayCommand(33.0,(SetLocalInt(OBJECT_SELF,"njw_steps",0))); //DelayCommand(13.3,ActionForceMoveToLocation(GetLocation(GetObjectByTag("jw_"+GetTag(OBJECT_SELF)+"_outside_wp")))); if (GetSittingCreature(GetNearestObjectByTag ("jw_"+GetTag(OBJECT_SELF)+"_chair", OBJECT_SELF))==OBJECT_SELF||GetSittingCreature(GetNearestObjectByTag ("jw_"+GetTag(OBJECT_SELF)+"_couch", OBJECT_SELF))== OBJECT_SELF) { SetLocalInt(OBJECT_SELF,"njw_steps",0); } } } } void jw_gohome() { if ((!IsInConversation(OBJECT_SELF))&&(!GetIsInCombat(OBJECT_SELF))) { if (GetLocalInt(OBJECT_SELF,"njw_steps")==0) { ClearAllActions(); ActionDoCommand(SetLocalInt(OBJECT_SELF,"njw_steps",1)); ActionForceMoveToLocation(GetLocation(GetObjectByTag("jw_"+GetTag(OBJECT_SELF)+"_outside_wp")),FALSE,120.0); ActionForceMoveToObject(GetObjectByTag("jw_"+GetTag(OBJECT_SELF)+"_inside_wp")); ActionForceMoveToObject(GetObjectByTag("jw_"+GetTag(OBJECT_SELF)+"_living_wp")); ActionDoCommand(SetLocalInt(OBJECT_SELF,"njw_completed",8)); ActionDoCommand(SetLocalInt(OBJECT_SELF,"njw_steps",0)); ActionDoCommand(SetLocalInt(OBJECT_SELF,"njw_steps",0)); ActionDoCommand(ClearAllActions()); } if (GetLocalInt(OBJECT_SELF,"njw_steps")==1) { DelayCommand(80.0,(SetLocalInt(OBJECT_SELF,"njw_steps",0))); } } } void jw_forcewake() { object oTarget; // if I am asleep if (PRCGetHasEffect(EFFECT_TYPE_SLEEP)) { effect eSleep = GetFirstEffect(OBJECT_SELF); // scroll through my current effects while (GetIsEffectValid(eSleep)) { // and if one of them if the effect sleep but but didn't come from a sleep spell if ((GetEffectType(eSleep) == EFFECT_TYPE_SLEEP) && (GetEffectSpellId(eSleep) != SPELL_SLEEP)) { // remove it RemoveEffect(OBJECT_SELF, eSleep); } eSleep = GetNextEffect(OBJECT_SELF); } } } void jw_lumberjack() { object oTree; object oTimber; object oLogs; int nLogs=0; int nTimber=0; int nTree=0; int nCounter=1; object oObject; object oSearch; if ((!IsInConversation(OBJECT_SELF))&&(!GetIsInCombat(OBJECT_SELF))) { SetLocalInt(OBJECT_SELF,"njw_steps",0); /// if he is at home check to see if he has a log in his backpack and if so destroy it, else leave the house if (GetArea(OBJECT_SELF)==GetArea(GetObjectByTag("jw_"+GetTag(OBJECT_SELF)+"_indoor"))||GetArea(OBJECT_SELF)==GetArea(GetObjectByTag("jw_"+GetTag(OBJECT_SELF)+"_door"))) { /// this begins the at home commands oObject=GetFirstItemInInventory(); while (GetIsObjectValid(oObject)) { if (GetTag(oObject)=="jw_logs") { DestroyObject(oObject); nLogs=1; } oObject=GetNextItemInInventory(); } if (nLogs=1) { ActionPlayAnimation(ANIMATION_FIREFORGET_PAUSE_SCRATCH_HEAD); } else { jw_leavehouse(); } ///This next one ends the at home commands } if (GetTag(GetArea(OBJECT_SELF))=="jw_asheeba_area") /// this begins what he does in Brighthaven { /// first of all, if he is already on his way to a tree then keep going and smash it if (GetIsObjectValid(GetLocalObject(OBJECT_SELF,"tree"))) { oTree=GetLocalObject(OBJECT_SELF,"tree"); ActionForceMoveToObject(oTree); ActionEquipMostDamagingMelee(); ActionDoCommand(DoPlaceableObjectAction(oTree,PLACEABLE_ACTION_BASH)); //okay, he has done things to a tree so that's it ActionDoCommand(ClearAllActions()); return; } /// if he is already on his way to timber, go to the timber. if (GetIsObjectValid(GetLocalObject(OBJECT_SELF,"timber"))&&GetIsObjectValid(GetLocalObject(OBJECT_SELF,"logs"))) { ActionForceMoveToObject(GetLocalObject(OBJECT_SELF,"timber")); ActionPlayAnimation(ANIMATION_LOOPING_GET_LOW,1.0,3.0); ActionTakeItem(GetLocalObject(OBJECT_SELF,"logs"),GetLocalObject(OBJECT_SELF,"timber")); ActionDoCommand(jw_destroy_logs()); ActionDoCommand(DeleteLocalObject(OBJECT_SELF,"timber")); ActionDoCommand(DeleteLocalObject(OBJECT_SELF,"logs")); ActionDoCommand(ClearAllActions()); // okay, he has got his logs so that's it. return; } else /// if no timber found, find some. Must have logs in. { oObject=GetNearestObjectByTag("jw_timber",OBJECT_SELF,nCounter); while (GetIsObjectValid(oObject)&&nTimber!=1) { oSearch=GetFirstItemInInventory(oObject); if (GetTag(oSearch)=="jw_logs") { SetLocalObject(OBJECT_SELF,"timber",oObject); SetLocalObject(OBJECT_SELF,"logs",oSearch); nTimber=1; ActionDoCommand(ClearAllActions()); // okay, he has chosen some timber an he'll go there next time, so that's it. return; } nCounter++; oObject=GetNearestObjectByTag("jw_timber",OBJECT_SELF,nCounter); } } //// okay, he has no logs and cannot find any timber either, so he must find a tree. { oTree=GetNearestObjectByTag("jw_tree"); if (GetIsObjectValid(oTree)) { SetLocalObject(OBJECT_SELF,"tree",oTree); // okay, he has found a tree, that's it ActionDoCommand(ClearAllActions()); return; } } /// the next one ends what he does in Brighthaven } /// if he is still here, he's screwed ///DEBUG /// the next one ends if is con etc } } void jw_destroy_logs() { object oObject; oObject=GetFirstItemInInventory(OBJECT_SELF); while (GetIsObjectValid(oObject)) { if (GetTag(oObject)=="jw_logs") { DestroyObject(oObject); } oObject=GetNextItemInInventory(OBJECT_SELF); } } void jw_hunt() { object oDeer; object oCorpse; object oLoot; int nLoot=0; int nCorpse=0; int nDeer=0; int nCounter=1; object oObject; object oSearch; if ((!IsInConversation(OBJECT_SELF))&&(!GetIsInCombat(OBJECT_SELF))) { SetLocalInt(OBJECT_SELF,"njw_steps",0); /// if he is at home check to see if he has a log in his backpack and if so destroy it, else leave the house if (GetTag(GetArea(OBJECT_SELF))=="jw_asheeba_area") /// this begins what he does in Brighthaven { /// first of all, if he is already on his way to a deer then keep going and smash it if (GetIsObjectValid(GetLocalObject(OBJECT_SELF,"deer"))) if (GetIsDead(GetLocalObject(OBJECT_SELF,"deer"))) { DeleteLocalObject(OBJECT_SELF,"deer"); return; } else { oDeer=GetLocalObject(OBJECT_SELF,"deer"); SetIsTemporaryEnemy(oDeer,OBJECT_SELF,FALSE); SetIsTemporaryEnemy(OBJECT_SELF,oDeer,FALSE); if (GetObjectSeen(oDeer)) { ActionEquipMostDamagingRanged(); ActionAttack(oDeer); return; } else { ActionMoveToObject(oDeer,TRUE); ActionEquipMostDamagingRanged(); ActionAttack(oDeer); /// okay, he is after his deer and should be killing it. return; } } /// if he is already on his way to corpse, go to the corpse. if (GetIsObjectValid(GetLocalObject(OBJECT_SELF,"corpse"))&&GetIsObjectValid(GetLocalObject(OBJECT_SELF,"loot"))) { ActionForceMoveToObject(GetLocalObject(OBJECT_SELF,"corpse")); ActionPlayAnimation(ANIMATION_LOOPING_GET_LOW,1.0,3.0); ActionTakeItem(GetLocalObject(OBJECT_SELF,"loot"),GetLocalObject(OBJECT_SELF,"corpse")); ActionDoCommand(jw_destroy_loot()); ActionDoCommand(DeleteLocalObject(OBJECT_SELF,"corpse")); ActionDoCommand(DeleteLocalObject(OBJECT_SELF,"loot")); ActionDoCommand(ClearAllActions()); // okay, he has got his loot so that's it. return; } else /// if no corpse found, find some. Must have loot in. { oObject=GetNearestObjectByTag("BodyBag",OBJECT_SELF,nCounter); while (GetIsObjectValid(oObject)&&nCorpse!=1&&GetArea(oObject)==GetArea(OBJECT_SELF)) { oSearch=GetFirstItemInInventory(oObject); if (GetTag(oSearch)=="jw_meat"||GetTag(oSearch)=="jw_hide") { SetLocalObject(OBJECT_SELF,"corpse",oObject); SetLocalObject(OBJECT_SELF,"loot",oSearch); nCorpse=1; ActionDoCommand(ClearAllActions()); // okay, he has chosen some corpse an he'll go there next time, so that's it. return; } nCounter++; oObject=GetNearestObjectByTag("BodyBag",OBJECT_SELF,nCounter); } } //// okay, he has no loot and cannot find any timber either, so he must find a tree. { oDeer=GetNearestObjectByTag("jw_deer"); if (GetIsObjectValid(oDeer)&&GetObjectType(oDeer)==OBJECT_TYPE_CREATURE) { SetLocalObject(OBJECT_SELF,"deer",oDeer); // okay, he has found a deer, that's it ActionDoCommand(ClearAllActions()); return; } else { oDeer=GetNearestObjectByTag("jw_deer",OBJECT_SELF,2); if (GetIsObjectValid(oDeer)&&GetObjectType(oDeer)==OBJECT_TYPE_CREATURE) { SetLocalObject(OBJECT_SELF,"deer",oDeer); // okay, he has found a deer, that's it ActionDoCommand(ClearAllActions()); return; } } } /// the next one ends what he does in Brighthaven } /// if he is still here, he's screwed ///DEBUG /// the next one ends if is con etc } // DEBUG } void jw_destroy_loot() { object oObject; oObject=GetFirstItemInInventory(OBJECT_SELF); while (GetIsObjectValid(oObject)) { if (GetTag(oObject)=="jw_meat"||GetTag(oObject)=="jw_hide") { DestroyObject(oObject); } oObject=GetNextItemInInventory(OBJECT_SELF); } }