//:://///////////////////////////////////////////// //:: Name mod_rest //:: mod_rest.nss //:: Copyright (c) 2001 Bioware Corp. //::////////////////////////////////////////////// /* Only allows PC's to use the rest command once ever 8 hours. (thats 16 minutes normal time with a 2 min per day timer) This prevents casters from spam casting rest 30 seconds spam casting. */ //::////////////////////////////////////////////// //:: Created By: Pad O'Lion //:: Created On: 06/29/2002 //::////////////////////////////////////////////// #include "NW_I0_GENERIC" #include "rpo_inc" #include "jw_privates_inc" void CheckRest (object oPC, int nCurrentHour); void GetMobs (object oPC); void main() { object oPC = GetLastPCRested(); //object oComp=GetAssociate(ASSOCIATE_TYPE_ANIMALCOMPANION,oPC); //if (GetIsObjectValid(oPC)) // { // ApplyEffectToObject(DURATION_TYPE_PERMANENT,EffectAttackIncrease(1),oComp); // ApplyEffectToObject(DURATION_TYPE_PERMANENT,EffectACIncrease(2),oComp); // } if (GetTag(GetArea(oPC))=="Startingarea") { return; } object oPet=GetAssociate(ASSOCIATE_TYPE_FAMILIAR,oPC); if (!GetIsObjectValid(oPet)) { oPet=GetAssociate(ASSOCIATE_TYPE_ANIMALCOMPANION,oPC); } if (GetLastRestEventType() == REST_EVENTTYPE_REST_STARTED ) { int nCurrentHour = (GetCalendarYear()-1)*12*28*24 + (GetCalendarMonth()-1)*28*24 + (GetCalendarDay()-1)*24 + GetTimeHour(); int nLastSpawnHour = GetLocalInt( oPC, "LastRestHour"); int nSpawnDelay = 0; if ((GetTag(GetArea(oPC))=="ah_tavern_interior")|| (GetTag(GetArea(oPC))=="Frost_area04")|| (GetTag(GetArea(oPC))=="jw_rog_area") || (GetTag(GetArea(oPC))=="iwd_i_aussir_ghall") || (GetTag(GetArea(oPC))=="iwd_i_dwarf00") || (GetTag(GetArea(oPC))=="fr_corm_barb03") ) { SetLocalInt( oPC, "LastRestHour",nCurrentHour); effect eSnore = EffectVisualEffect(VFX_IMP_SLEEP); ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eSnore, oPC, 7.0); ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eSnore, oPC, 7.0); ApplyEffectToObject(DURATION_TYPE_TEMPORARY, EffectBlindness(), oPC, 17.0); DelayCommand(7.0, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eSnore, oPC, 7.0)); return; } if (nCurrentHour > (nLastSpawnHour + nSpawnDelay)) { if (GetHitDice(oPC)==1) { SetLocalInt( oPC, "LastRestHour",nCurrentHour); SendMessageToPC(oPC,"Once you grow slightly stronger, you will need a bedroll and food to rest."); return; } else { CheckRest(oPC, nCurrentHour); return; } } else { string sSpeakString = "You cannot rest again for a while."; SendMessageToPC(oPC, sSpeakString); AssignCommand( oPC, ClearAllActions()); AssignCommand( oPet, ClearAllActions()); } } } void CheckRest (object oPC, int nCurrentHour) { object oPet=GetAssociate(ASSOCIATE_TYPE_FAMILIAR,oPC); if (!GetIsObjectValid(oPet)) { oPet=GetAssociate(ASSOCIATE_TYPE_ANIMALCOMPANION,oPC); } int nHasbed=0; int nHasfood=0; object oBed; object oFood; string sSpeakString; oBed=GetItemPossessedBy(oPC,"jw_bedroll1"); if (GetIsObjectValid(oBed)) { nHasbed=1; } if (nHasbed==0) { oBed=GetItemPossessedBy(oPC,"jw_bedroll2"); } if (GetIsObjectValid(oBed)) { nHasbed=1; } if (nHasbed==0) { oBed=GetItemPossessedBy(oPC,"jw_bedroll3"); } if (GetIsObjectValid(oBed)) { nHasbed=1; } if (nHasbed==0) { sSpeakString = "You do not have a bed roll and need one in order to rest."; SendMessageToPC(oPC, sSpeakString); AssignCommand( oPC, ClearAllActions()); AssignCommand( oPet, ClearAllActions()); return; } oFood=GetItemPossessedBy(oPC,"jw_food1"); if (GetIsObjectValid(oFood)) { nHasfood=1; } if (nHasfood==0) { oFood=GetItemPossessedBy(oPC,"jw_food2"); } if (GetIsObjectValid(oFood)) { nHasfood=1; } if (nHasfood==0) { oFood=GetItemPossessedBy(oPC,"jw_food3"); } if (GetIsObjectValid(oFood)) { nHasfood=1; } if (nHasfood==0) { sSpeakString = "You do not have food and need some in order to rest."; SendMessageToPC(oPC, sSpeakString); AssignCommand( oPC, ClearAllActions()); AssignCommand( oPet, ClearAllActions()); return; } //check if you have a campfire close enough when camping outside in IWD areas. if (GetStringLeft(GetTag(GetArea(oPC)),5)=="iwd_e") { object oCamp = GetNearestObjectByTag("nk_gn_campfire", oPC); float fDistance = GetDistanceBetween(oPC, oCamp); if((fDistance <= 5.0) && (fDistance > 0.0) ) { } else { sSpeakString = "You do not have a campfire nearby in order to rest in the cold."; SendMessageToPC(oPC, sSpeakString); AssignCommand( oPC, ClearAllActions()); AssignCommand( oPet, ClearAllActions()); return; } } // If we have made it this far then the PCs are resting ok SetLocalInt( oPC, "LastRestHour",nCurrentHour); if (GetHitDice(oPC)>6) { GetMobs (oPC); } object oNewBedroll=CreateObject(OBJECT_TYPE_PLACEABLE,"jw_bedroll",GetLocation(oPC)); effect eSnore = EffectVisualEffect(VFX_IMP_SLEEP); FadeToBlack(oPC,FADE_SPEED_FAST); FadeFromBlack(oPC,FADE_SPEED_FAST); ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eSnore, oPC, 7.0); ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eSnore, oPC, 7.0); ApplyEffectToObject(DURATION_TYPE_TEMPORARY, EffectBlindness(), oPC, 17.0); DelayCommand(7.0, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eSnore, oPC, 7.0)); DelayCommand(17.0,DestroyObject(oNewBedroll)); if (GetTag(oBed)=="jw_bedroll3") { if (Random(3)==1) { DestroyObject(oBed); CreateItemOnObject("jw_bedroll2",oPC); SendMessageToPC(oPC,"That bedroll seems a little worn after use."); } } if (GetTag(oBed)=="jw_bedroll2") { if (Random(3)==1) { DestroyObject(oBed); CreateItemOnObject("jw_bedroll1",oPC); SendMessageToPC(oPC,"That bedroll now seems very worn."); } } if (GetTag(oBed)=="jw_bedroll1") { if (Random(3)==1) { DestroyObject(oBed); SendMessageToPC(oPC,"That bedroll is so worn out, it is no longer useable."); } } if (GetTag(oFood)=="jw_food3") { DestroyObject(oFood); CreateItemOnObject("jw_food2",oPC); } if (GetTag(oFood)=="jw_food2") { DestroyObject(oFood); CreateItemOnObject("jw_food1",oPC); } if (GetTag(oFood)=="jw_food1") { DestroyObject(oFood); SendMessageToPC(oPC,"That item of food has been finished."); } return; } void GetMobs (object oPC) { location lLoc=GetLocation(oPC); object oTarget = GetFirstObjectInShape(SHAPE_SPHERE, 85.0, lLoc); while(GetIsObjectValid(oTarget)) { if(GetIsReactionTypeHostile(oTarget,oPC)&&!GetIsObjectValid(GetTarget(oTarget))) { if(d3()!=1) { SetTarget(oPC,oTarget); } } //Get next target in area oTarget = GetNextObjectInShape(SHAPE_SPHERE, 85.0, lLoc); } }