//------------------------------------------------ // // A system to allow players to board specific ships once disabled and aquire a 'treasure chest' static item. // 1. Eliminate the target ship's bodyguard. // 2. Disable the target ship. // 3. Dock with the ship //------------------------------------------------ //------------------------------------------------ // Includes //------------------------------------------------ include library.space_create; include library.space_quest; include library.space_utils; include library.space_crafting; include library.space_transition; include library.utils; include library.ship_ai; include library.prose; //------------------------------------------------ //------------------------------------------------ messageHandler startBeacon() { if(!isSpaceScene()) { return SCRIPT_CONTINUE; } // Just to be safe.. one hour from now everything is erased. messageTo(self, "cleanupPiracyEvent", null, 3600.f, false); if(!hasObjVar(self, "warmUpTimer")) { int warmUpTimer = rand(6, 8); setObjVar(self, "warmUpTimer", warmUpTimer); } int timer = getIntObjVar(self, "warmUpTimer"); playClientEffectLoc(self, "appearance/pt_space_interdiction_burst.prt", getLocation(self), 0f); if(timer > 0) { timer--; messageTo(self, "startBeacon", null, 2.f, false); setObjVar(self, "warmUpTimer", timer); return SCRIPT_CONTINUE; } messageTo(self, "startPiracyEvent", null, 2.f, false); return SCRIPT_CONTINUE; } messageHandler startPiracyEvent() { // Set up quest specific objvars. obj_id player = getObjIdObjVar(self, "player"); if(!isIdValid(player) || !exists(player)) { return SCRIPT_CONTINUE; } CustomerServiceLog("space_piracy","Player "+player+" is starting a piracy event at location: "+getLocation(self)+" in zone: "+getCurrentSceneName()); clearMissionCriticalObjects(player); generateShipList(self); return SCRIPT_CONTINUE; } void generateShipList(obj_id self) { int difficulty = getIntObjVar(self, "difficulty"); string faction = getStringObjVar(self, "faction"); string targetShipString = "targetship"; string bigEscortString = "bigescort"; string mediumEscortString = "mediumescort"; string smallEscortString = "smallescort"; if(faction != null) { targetShipString = faction+targetShipString; bigEscortString = faction+bigEscortString; mediumEscortString = faction+mediumEscortString; smallEscortString = faction+smallEscortString; } string table = "/datatables/spacequest/piracy/piracy_spawn_table.iff"; // Find the target ship string[] targetShipArray = dataTableGetStringColumnNoDefaults(table, targetShipString); if(targetShipArray == null || targetShipArray.length <= 0) { return; } //int i = rand(0, targetShipArray.length -1); int i = rand(0, difficulty -1); string targetShipType = targetShipArray[i]; if(difficulty == 5) { difficulty++; } //Find the escort ships int numBigShips = 1 + (difficulty / 2); int numMediumShips = rand(0, (difficulty / 2)); int numSmallShips = rand(1, 2) + (difficulty); int escortSize = numBigShips+numMediumShips+numSmallShips; string[] escortsArray = new string[escortSize]; string[] bigShipArray = dataTableGetStringColumnNoDefaults(table, bigEscortString); string[] mediumShipArray = dataTableGetStringColumnNoDefaults(table, mediumEscortString); string[] smallShipArray = dataTableGetStringColumnNoDefaults(table, smallEscortString); //int i = 0; int a = 0; int b = 0; int c = 0; for(a=0; a 5) { difficulty = 1; } setObjVar(targetShip, "difficulty", difficulty); if(!exists(targetShip) || !isIdValid(targetShip)) { return; } CustomerServiceLog("space_piracy"," Warping in the TargetShip for player "+player+"'s Piracy Event. TargetShip OID: "+targetShip+" TargetShip type: "+targetShipType); ship_ai.unitSetLeashDistance(targetShip, 16000); ship_ai.unitSetSquadId(targetShip, targetSquad); setLookAtTarget(player, targetShip); attachScript(targetShip, "space.quest_logic.piracy_ship"); ship_ai.unitSetAttackOrders(targetShip, ship_ai.ATTACK_ORDERS_RETURN_FIRE); ship_ai.unitAddExclusiveAggro(targetShip, player); addMissionCriticalObject(player, targetShip); setObjVar(targetShip, "objMissionOwner", player); setObjVar(targetShip, "piracyEventOwner", player); // Set the ship's speed limits. float maxspeed = getShipEngineSpeedMaximum(targetShip); if (maxspeed < 15.f) setShipEngineSpeedMaximum(targetShip, 15.f + rand()*10.f); else if (maxspeed > 25.f) setShipEngineSpeedMaximum(targetShip, 23.f + rand()*5.f); // Play the music. //play2dNonLoopingMusic( player, "clienteffect/ui_quest_spawn_wave.cef"); messageTo(self, "updateTargetWaypoint", null, 1.f, false); messageTo(self, "startMovement", null, 3.f, false); messageTo(self, "eventTimer", null, 1.f, false); return; } void warpInEscortShips(obj_id self, string[] escortShips) { // Warp in support ships. //string[] escortShips = getStringArrayObjVar(self, "escortArray"); obj_id player = getObjIdObjVar(self, "player"); if(!isIdValid(player) || !exists(player)) { return; } obj_id playerShip = space_transition.getContainingShip(player); if(!isIdValid(playerShip) || !exists(playerShip)) { return; } if(!hasObjVar(self, "targetSquad")) { return; } obj_id targetShip = getObjIdObjVar(self, "targetShip"); if(!isIdValid(targetShip) || !exists(targetShip)) { return; } int targetSquad = getIntObjVar(self, "targetSquad"); int escortSquad = ship_ai.squadCreateSquadId(); if(escortShips != null) { obj_id[] escortIdArray = new obj_id[escortShips.length]; for ( int i=0; i= 7500 ) { // out of bounds, lets try again messageTo(self, "startMovement", null, 0.f, false); return SCRIPT_CONTINUE; } ship_ai.unitMoveTo(targetShip, randomTransform); return SCRIPT_CONTINUE; } messageHandler updateTargetWaypoint() { obj_id player = getObjIdObjVar(self, "player"); obj_id targetShip = getObjIdObjVar(self, "targetShip"); obj_id waypoint = getObjIdObjVar(self, "spacepiracy.waypoint"); location loc = getLocation(targetShip); if(!exists(player) || !isIdValid(player)) { messageTo(self, "cleanupPiracyEvent", null, 0.f, false); return SCRIPT_CONTINUE; } if(!exists(targetShip) || !isIdValid(targetShip)) { if(waypoint != null) { destroyWaypointInDatapad(waypoint, player); } return SCRIPT_CONTINUE; } if(!isIdValid(waypoint)) waypoint = createWaypointInDatapad(player, loc); if(isIdValid(waypoint)) { setWaypointVisible(waypoint, true); setWaypointActive(waypoint, true); setWaypointLocation(waypoint, loc); setWaypointName(waypoint, "Convoy"); setWaypointColor(waypoint, "space"); setObjVar(self, "spacepiracy.waypoint", waypoint); } sendSystemMessage(player, "updating waypoint", null); messageTo(self, "updateTargetWaypoint", null, 30.f, false); return SCRIPT_CONTINUE; } messageHandler cleanupPiracyEvent() { obj_id targetShip = getObjIdObjVar(self, "targetShip"); obj_id waypoint = getObjIdObjVar(self, "spacepiracy.waypoint"); obj_id player = getObjIdObjVar(self, "player"); clearMissionCriticalObjects(player); if(exists(targetShip) && isIdValid(targetShip)) { messageTo(targetShip, "hyperLeave", null, 0.f, false); } obj_id[] escortIdArray = utils.getObjIdArrayObjVar(self, "escortIdArray"); if(escortIdArray != null) { for ( int i=0; i= 100 && !hasObjVar(targetShip, "isDisabled")) { string_id hyperfinished = new string_id(dialog, "hyperfinished"); prose_package pp = prose.getPackage(hyperfinished, 0); space_quest.groupTaunt(targetShip, player, pp); CustomerServiceLog("space_piracy","Time expired for piracy event started by "+player+" Starting cleanup."); sendSystemMessage(player, "You failed to disable your target in time. Your target is making the jump to hyperspace", null); messageTo(self, "cleanupPiracyEvent", null, 1.f, false); } hyperTimer = hyperTimer + 10; utils.setScriptVar(self, "hyperTimer", hyperTimer); messageTo(self, "eventTimer", null, 60.f, false); return SCRIPT_CONTINUE; }