include library.groundquests; include library.badge; include library.factions; include library.chat; const string MASTER_PATROL_ARRAY = "master_patrol_point_array"; const string PATROL_POINTS = "patrolPoints"; const string PATROL_TYPE = "patrolType"; const string STAGE_TWO_DATA = "datatables/spawning/restuss_event/invasion_data.iff"; const string IS_STATIC = "isStaticPosition"; //Triggers const string TRIGGER_NAME = "trigger.name"; const string TRIGGER_OCCURANCE = "trigger.occurance"; const string TRIGGER_DELAY = "trigger.delay"; const string TRIGGER_INTEREST = "trigger.interest"; const string TRIGGER_TYPE = "trigger.type"; //Effect Types const string EFFECT_NAME = "effect.name"; const string EFFECT_DELTA = "effect.duration"; const string EFFECT_VISABILITY = "effect.visability"; //Patrol Types const int PATROL_NONE = 0; const int PATROL = 1; const int PATROL_ONCE = 2; const int PATROL_FLIP = 3; const int PATROL_FLIP_ONCE = 4; const int PATROL_RANDOM = 5; const int PATROL_RANDOM_ONCE = 6; //Music Files const string MUS_BATTLE_IMPERIAL_INTRO = ""; //Quest Resource Table const string QUEST_TABLE = "datatables/quest/restuss_event/quest_count.iff"; const string PREFIX = "restuss_event_quest."; // Restuss PvP Region const string PVP_REGION_NAME = "restuss_event_pvp_region"; const string_id SID_PVP_ENTER_WARNING = new string_id("restuss_event/object", "pvp_area_approach"); const string_id SID_PVP_EXIT_MESSAGE = new string_id("restuss_event/object", "pvp_area_depart"); // Event winner check const int WINNER_REBEL = 0; const int WINNER_IMPERIAL = 1; const int WINNER_NONE = -1; const string WINNING_FACTION = "winningFaction"; // AI Trigger constants const string TRIG_ONDEATH = "trigger_marks.OnDeath"; const string TRIG_ENTERCOMBAT = "trigger_marks.EnterCombat"; const string TRIG_EXITCOMBAT = "trigger_marks.ExitCombat"; const string TRIG_ARRIVELOCATION = "trigger_marks.OnArrivedAtLocation"; const string TRIG_CUSTOMSIGNAL = "trigger_marks.CustomSignal"; void playMusicInArea(obj_id controller, string music) { playMusicInArea(controller, music, 50.0f); } void playMusicInArea(obj_id controller, string music, float range) { } void sendAreaSystemMessage(obj_id controller, string_id message){} boolean getIsStatic(obj_id subject) { if (utils.hasScriptVar(subject, IS_STATIC)) return utils.getBooleanScriptVar(subject, IS_STATIC); utils.setScriptVar(subject, IS_STATIC, false); return false; } void setIsStatic(obj_id subject, boolean state) { utils.setScriptVar(subject, IS_STATIC, state); } int getPhase(obj_id object) { if (hasObjVar(object, "base_builder.current_phase")) return getIntObjVar(object, "base_builder.current_phase"); obj_id parent = trial.getParent(object); if (!isIdValid(parent)) return -1; return getPhase(parent); } void incrimentPhase (obj_id object) { if (hasObjVar(object, "base_builder.current_phase")) { messageTo(object, "incrimentPhase", null, 0, false); return; } obj_id parent = trial.getParent(object); if (!isIdValid(parent)) { return; } messageTo (parent, "incrimentPhase", null, 0, false); } void decrimentPhase (obj_id object) { if (hasObjVar(object, "base_builder.current_phase")) { messageTo(object, "decrimentPhase", null, 0, false); return; } obj_id parent = trial.getParent(object); if (!isIdValid(parent)) return; messageTo (parent, "decrimentPhase", null, 0, false); } int getRequiredQuestNumber(obj_id subject, string questName) { return dataTableGetInt(QUEST_TABLE, questName, "completion_number"); } int getCompletedQuestCount(obj_id subject, string questName) { int cQuest = 0; obj_id parent = trial.getParent(subject); if (hasObjVar(parent, PREFIX+questName)) cQuest = getIntObjVar(parent, PREFIX+questName); return cQuest; } float getCompletedQuestRatio(obj_id subject, string questName) { return (float)getCompletedQuestCount(subject, questName) / getRequiredQuestNumber(subject, questName); } void setCompletedQuestCount(obj_id subject, string questName, int number) { int max = getRequiredQuestNumber(subject, questName); if (number > max) number = max; setObjVar(subject, PREFIX+questName, number); } void incrimentCompletedQuestCount(obj_id subject, string questName) { int current = getCompletedQuestCount(subject, questName); current +=1; setCompletedQuestCount(trial.getParent(subject),questName, current); } void decrimentCompletedQuestCount(obj_id subject, string questName) { int current = getCompletedQuestCount(subject, questName); current = current -1; if (current < 0) current = 0; setCompletedQuestCount(trial.getParent(subject), questName, current); } boolean isRequiredCountMet(obj_id subject, string questName) { return (getCompletedQuestRatio(subject, questName) == 1); } int getWinningFaction(obj_id self) { obj_id restuss_controller = getFirstObjectWithScript(getLocation(self), 1000.0f, "theme_park.restuss_event.stage_one_watcher"); if (!isIdValid(restuss_controller)) return WINNER_NONE; if (!hasObjVar(restuss_controller, WINNING_FACTION)) return WINNER_NONE; return getIntObjVar(restuss_controller, WINNING_FACTION); } boolean grantEventBadge(obj_id player) { if (!factions.isRebel(player) && !factions.isImperial(player)) return false; int winner = getWinningFaction(player); if (winner == WINNER_NONE) return false; string[] badgeList = { "restuss_rebel_first", "restuss_rebel_second", "restuss_imperial_first", "restuss_imperial_second" }; for (int k=0;k -1) { if (factions.isRebel(player)) { if (groundquests.hasCompletedQuest(player, quests[i])) eligable = true; } } if (quests[i].indexOf("imperial") > -1) { if (factions.isImperial(player)) { if (groundquests.hasCompletedQuest(player, quests[i])) eligable = true; } } } if (!eligable) return false; if (winner == WINNER_REBEL) { if (factions.isRebel(player)) badge.grantBadge(player, "restuss_rebel_first"); if (factions.isImperial(player)) badge.grantBadge(player, "restuss_imperial_second"); return true; } if (winner == WINNER_IMPERIAL) { if (factions.isRebel(player)) badge.grantBadge(player, "restuss_rebel_second"); if (factions.isImperial(player)) badge.grantBadge(player, "restuss_imperial_first"); return true; } return false; } boolean isRestussInStageThree(obj_id npc) { obj_id top = trial.getTop(npc); obj_id[] controller_id = getAllObjectsWithObjVar(getLocation(top), 1500.0f, "element"); obj_id restuss_controller = null; if (controller_id == null || controller_id.length == 0) return false; for (int i=0;i