/* This function handles making undead friends with vampires, and vice versa. */ // Makes undeads friendly to entering vampire. void vamp_vampirefriend(object oPC) { //Get area. object oArea = GetArea(oPC); //Get first object in area. object oNPC = GetFirstObjectInArea(oArea); //As long as objects are valid. Do following. PrintString("vamp_friends: vamp_vampirefriend() called by " + GetName(oPC) + " in "+GetName(oArea)+" ... makes undeads friendly to the aforementioned Vampire in this area."); while(oNPC != OBJECT_INVALID) { // if the thing is a creature, continue wasting CPU time if (GetObjectType(oNPC)==OBJECT_TYPE_CREATURE) { // PrintString("vamp_friends: vamp_vampirefriend() called by " + GetName(oPC) + " - "+GetName(oNPC)+" is a creature, but is it undead?"); // If object is undead and hostile towards vampire. if (GetRacialType(oNPC) == RACIAL_TYPE_UNDEAD && GetIsEnemy(oPC,oNPC) == TRUE) { PrintString("vamp_friends: vamp_vampirefriend() called by " + GetName(oPC) + " - "+GetName(oNPC)+" is an undead and is an enemy of the PC, so will now be made a friend."); // Make object friendly towards vampire. SetIsTemporaryFriend(oPC, oNPC); } } //Take next object. oNPC = GetNextObjectInArea(oArea); } } //Makes entering npc friendly towards every vampire on module. void vamp_npcfriend(object oNPC) { PrintString("vamp_friends: vamp_npcfriend() called by " + GetName(oNPC) + "... makes all PC's with 'Vampire' subrace friendly to this NPC."); //Take first player from player list. object oPC = GetFirstPC(); //Do following until whole player list is studied. while(oPC != OBJECT_INVALID) { //If player is vampire. if (GetSubRace(oPC)=="Vampire") { //Make npc(Undead) friendly towards pc. SetIsTemporaryFriend(oPC, oNPC); PrintString("vamp_friends: vamp_vampirefriend() called by " + GetName(oNPC) + " - "+GetName(oPC)+" is Vampire PC, so will now be made a friend of the NPC."); } //Take next pc from list. oPC = GetNextPC(); } } //Checks who is entering. void vamp_friends(object oCreature) { object oMod = GetModule(); string sArea = GetName(GetArea(oCreature)); // PrintString("vamp_friends: called by " + GetName(oCreature) + " GetRacialType["+IntToString(GetRacialType(oCreature))+"] in area '"+sArea+"'."); // If entering object is pc and subrace is vampire. // Make every undead on area friendly towards entering vampire. if (GetSubRace(oCreature)=="Vampire"&&GetIsPC(oCreature)==TRUE) { vamp_vampirefriend(oCreature); } // If entering object is undead and it is not pc or dm. // Make undead friendly towards every vampire on module. if (GetRacialType(oCreature) == RACIAL_TYPE_UNDEAD && GetIsPC(oCreature)==FALSE && GetIsDM(oCreature) == FALSE) { // We should do this BEFORE we destroy vampire spawns triggered by vampires // because otherwise existing undead in the area are not made friends. // Better to waste time making friends with things that are about to be // destroyed than have undead randomly attack a vampire because he stepped // on a vampire spawn the moment he came in. vamp_npcfriend(oCreature); } }