//////////////////////////////////////////////////////////////////////////////// // // Olander's Pack Animals // opa_inc // By Don Anderson // dandersonru@msn.com // //////////////////////////////////////////////////////////////////////////////// //#include "nbde_inc" //:****************************************************************************/ //: ANIMAL MOVEMENT FUNCTIONS void OPAHighLightObject(object oTarget) { effect efx = EffectVisualEffect(VFX_DUR_FREEDOM_OF_MOVEMENT); ApplyEffectToObject(DURATION_TYPE_TEMPORARY,efx,oTarget,2.0); } void OPAHighLightLocation(location lTarget) { effect efx = EffectVisualEffect(VFX_DUR_FREEDOM_OF_MOVEMENT); ApplyEffectAtLocation(DURATION_TYPE_TEMPORARY, efx, lTarget, 2.0f); } void AnimalAssign(object oPC, object oAnimal) { //Give Animal Control Staff object oItem = GetItemPossessedBy(oPC,"AnimalControl"); if(oItem == OBJECT_INVALID) { oItem = CreateItemOnObject("animalcontrol",oPC,1); } //Set Strings on Animal string sPC = GetName(oPC); string sPCU = GetLocalString(oPC,"PCU"); SetLocalString(oAnimal, "OPA_OWNER_NAME", sPC); SetLocalString(oAnimal, "OPA_OWNER_UNIQUE", sPCU); SetLocalString(oAnimal, "OPA_RALLYPOINT", ""); SetLocalInt(oAnimal,"PACKANIMAL",1); //Add this Animal to PC string sResRef = GetResRef(oAnimal); SetLocalInt(oPC,"OPA_ANIMALTOTAL",1); SetLocalInt(oItem,"OPA_ANIMALTOTAL",1); SetLocalString(oItem, "OPA_ANIMALRESREF", sResRef); SetLocalObject(oAnimal,"OPA_OWNER",oPC); SetLocalObject(oPC,"OPA_OWNER",oAnimal); AssignCommand(oAnimal,ClearAllActions()); AssignCommand(oAnimal,ActionForceFollowObject(oPC,3.0)); } void AnimalRecall(object oPC) { //Create Player's Animal object oItem = GetItemPossessedBy(oPC,"AnimalControl"); string sAnimal = GetLocalString(oItem, "OPA_ANIMALRESREF"); location lLoc = GetLocation(oPC); object oAnimal = CreateObject(OBJECT_TYPE_CREATURE,sAnimal,lLoc,FALSE); //Set Strings on Animal string sPC = GetName(oPC); string sPCU = GetLocalString(oPC,"PCU"); SetLocalString(oAnimal, "OPA_OWNER_NAME", sPC); SetLocalString(oAnimal, "OPA_OWNER_UNIQUE", sPCU); SetLocalString(oAnimal, "OPA_RALLYPOINT", ""); SetLocalInt(oAnimal,"PACKANIMAL",1); SetLocalInt(oPC,"OPA_ANIMALTOTAL",1); SetLocalInt(oItem,"OPA_ANIMALTOTAL",1); //Add this Animal to PC SetLocalObject(oAnimal,"OPA_OWNER",oPC); SetLocalObject(oPC,"OPA_OWNER",oAnimal); AssignCommand(oAnimal,ClearAllActions()); AssignCommand(oAnimal,ActionForceFollowObject(oPC,3.0)); } void AnimalToPlayer(object oPC, object oAnimal) { //Retrieve the New Rally Point Info (Will be "" here) string sMoveTo = GetLocalString(oPC,"OPA_RALLYPOINT"); //Get the Lead Distance float fDist = GetLocalFloat(oAnimal,"OPA_DISTANCE"); //Send the Animal to the Player AssignCommand(oAnimal,ClearAllActions()); if(GetArea(oAnimal) != GetArea(oPC)) { AssignCommand(oAnimal,ClearAllActions()); AssignCommand(oAnimal,ActionJumpToLocation(GetLocation(oPC))); SetLocalString(oAnimal, "OPA_RALLYPOINT", sMoveTo); } //In the same area but Animal is Stuck if(GetArea(oAnimal) == GetArea(oPC)) { float fBetween = GetDistanceBetween(oPC, oAnimal); if(fBetween > 30.0) { AssignCommand(oAnimal,ClearAllActions()); AssignCommand(oAnimal,ActionJumpToLocation(GetLocation(oPC))); SetLocalString(oAnimal, "OPA_RALLYPOINT", sMoveTo); AssignCommand(oAnimal,ActionForceFollowObject(oPC,fDist)); } else { AssignCommand(oAnimal,ClearAllActions()); SetLocalString(oAnimal, "OPA_RALLYPOINT", sMoveTo); AssignCommand(oAnimal,ActionForceFollowObject(oPC,fDist)); } } } void AnimalToRally(object oAnimal) { //Retrieve the New Rally Point Info string sMoveTo = GetLocalString(oAnimal,"OPA_RALLYPOINT"); if(sMoveTo != "") { object oMoveTo = GetNearestObjectByTag(sMoveTo,oAnimal,1); AssignCommand(oAnimal,ClearAllActions()); AssignCommand(oAnimal,ActionMoveToObject(oMoveTo,TRUE,1.0)); } } void DismissAnimal(object oPC, object oAnimal) { string sPC = GetLocalString(oAnimal, "OPA_OWNER_NAME"); string sPCU = GetLocalString(oPC, "PCU"); string sSPCU = GetLocalString(oAnimal, "OPA_OWNER_UNIQUE"); //Check the Owner if(GetName(oPC) == sPC) { if(sPCU == sSPCU) { //Remove this Animal from PC SetLocalInt(oPC,"OPA_ANIMALTOTAL",0); //Remove Animal Control Staff object oItem = GetItemPossessedBy(oPC,"AnimalControl"); if(oItem != OBJECT_INVALID) { DestroyObject(oItem,0.1); } //Send the Animal Away AssignCommand(oAnimal,ClearAllActions()); DestroyObject(oAnimal,0.1); DeleteLocalObject(oPC,"OPA_OWNER"); return; } } } //: ANIMAL MOVEMENT FUNCTIONS //:****************************************************************************/ //:****************************************************************************/ //: PACK BOX FUNCTIONS int BoxWeight(object oBox) { int nNth = 0; int nWeight = 0; object oItem = GetFirstItemInInventory(oBox); while(GetIsObjectValid(oItem)) { nWeight = nWeight + GetWeight(oItem); oItem = GetNextItemInInventory(oBox); } return nWeight; } void SetAnimalWeight(object oAnimal, int nStones) { int i; for (i = 0; i < nStones; i++) { CreateItemOnObject("packstone",oAnimal,1); } } void SetGroundingFacing(object oAnimal,object oPC, object oBox) { location lLoc = GetLocation(oAnimal); float fFace = GetFacing(oPC); AssignCommand(oAnimal,ActionMoveAwayFromLocation(lLoc,TRUE,2.0)); AssignCommand(oBox,DelayCommand(3.5,SetFacing(fFace - 180.0))); } void AccessBox(object oPC, object oAnimal) { AssignCommand(oAnimal,ClearAllActions()); location lAnimal = GetLocation(oAnimal); object oBox = CreateObject(OBJECT_TYPE_PLACEABLE,"packbox",lAnimal,FALSE,""); SetLocalObject(oAnimal,"PackBox",oBox); SetLocalObject(oPC,"PackBox",oBox); SetGroundingFacing(oAnimal,oPC, oBox); } void DestroyBox(object oAnimal) { object oBox = GetLocalObject(oAnimal,"PackBox"); DestroyObject(oBox,0.1); DeleteLocalObject(oAnimal,"PackBox"); } void ReassignBox(object oPC, object oAnimal) { object oBox = GetLocalObject(oPC,"PackBox"); SetLocalObject(oAnimal,"PackBox",oBox); //Now Reset Animal Weight int nBoxWeight = BoxWeight(oBox)/10; int nStones = nBoxWeight/5; SetAnimalWeight(oAnimal, nStones); //Now Destroy the Pack Box DestroyBox(oAnimal); } //: PACK BOX FUNCTIONS //:****************************************************************************/ //void main(){}