include library.ai_lib; include library.beast_lib; include library.colors; include library.factions; void clearAssist() { const obj_id self = getSelf(); deltadictionary dict = self.getScriptVars(); dict.remove("ai.combat.assist"); } void clearNoAssistCall() { const obj_id self = getSelf(); deltadictionary dict = self.getScriptVars(); dict.remove("ai.combat.assist.noAssistCall"); } boolean isWaiting() { const obj_id self = getSelf(); deltadictionary dict = self.getScriptVars(); return dict.getBoolean("ai.combat.assist"); } int getWaitTime() { const obj_id self = getSelf(); deltadictionary dict = self.getScriptVars(); return dict.getInt("ai.combat.assist.waitTime"); } // This code would fire based on the observer and seemed to ignore line of sight checks. It is disabled // in favor of the defender calling for help explicitly (below in callForAssist). void assist(obj_id defender, obj_id target) { /** const obj_id self = getSelf(); deltadictionary dict = self.getScriptVars(); if (!ai_lib.isInCombat(self)) { //showFlyText(self, new string_id("npc_reaction/flytext", "alert"), 2.0f, colors.ORANGERED); faceTo(self, target); dict.put("ai.combat.assist.waitTime", isPlayer(defender) ? rand(1.0f, 2.0f) : rand(3.0f, 4.0f)); dict.put("ai.combat.assist", true); dict.put("ai.combat.assist.noAssistCall", true); } startCombat(self, target); **/ } boolean canCallForAssist() { const obj_id self = getSelf(); deltadictionary dict = self.getScriptVars(); return !dict.getBoolean("ai.combat.assist.noAssistCall"); } boolean callForAssist() { obj_id self = getSelf(); //we dont want beasts asking for help if(beast_lib.isBeast(self)) return false; //we dont want decoys or holograms asking for help if(hasObjVar(self, "hologram_performer")) return false; obj_id target = getTarget(self); if (!isIdValid(target) || !exists(target)) return false; string type = getStringObjVar(self, "creature_type"); dictionary aiData = dataTableGetRow("datatables/mob/creatures.iff", type); float assistRange = aiData.getFloat("assist"); string socialGroup = aiData.getString("socialGroup"); string pvpFaction = aiData.getString("pvpFaction"); if (assistRange == 0.0f) return false; obj_id[] creatures = getNPCsInRange(self, assistRange); if (creatures == null || creatures.length == 0) return false; resizeable obj_id[] callToList = new obj_id[0]; for (int i=0;i 6.0f) continue; callToList.add(creatures[i]); } if (callToList == null || callToList.length == 0) return false; for (int q=0;q