diff --git a/scripts/vscripts/tf2ware_ultimate/minigames/pirate.nut b/scripts/vscripts/tf2ware_ultimate/minigames/pirate.nut index 92ab2157..d3c5a207 100644 --- a/scripts/vscripts/tf2ware_ultimate/minigames/pirate.nut +++ b/scripts/vscripts/tf2ware_ultimate/minigames/pirate.nut @@ -16,6 +16,7 @@ minigame <- Ware_MinigameData "pirate_red" "pirate_blue" ] + modes = 2 }) ship_model <- "models/marioragdoll/super mario galaxy/bj ship/bjship.mdl" @@ -23,6 +24,8 @@ ship_model <- "models/marioragdoll/super mario galaxy/bj ship/bjship.mdl" red_ship <- null blue_ship <- null +ships <- [] + function OnPrecache() { PrecacheModel(ship_model) @@ -32,32 +35,102 @@ function OnStart() { Ware_SetGlobalLoadout(TF_CLASS_DEMOMAN, "Stickybomb Jumper") - foreach (player in Ware_MinigamePlayers) + if (Ware_MinigameMode == 0) { - local team = player.GetTeam() - if (team == TF_TEAM_RED) - Ware_SetPlayerMission(player, 0) - else if (team == TF_TEAM_BLUE) - Ware_SetPlayerMission(player, 1) - } + foreach (player in Ware_MinigamePlayers) + { + local team = player.GetTeam() + if (team == TF_TEAM_RED) + Ware_SetPlayerMission(player, 0) + else if (team == TF_TEAM_BLUE) + Ware_SetPlayerMission(player, 1) + } - local swap = RandomBool() - red_ship = Ware_SpawnEntity("prop_dynamic_override", - { - origin = Ware_MinigameLocation.center + Vector(2200, swap ? -500 : 300, -136), - model = ship_model - rendercolor = "255 0 0", - }) - blue_ship = Ware_SpawnEntity("prop_dynamic_override", + local swap = RandomBool() + + red_ship = Ware_SpawnEntity("prop_dynamic_override", + { + origin = Ware_MinigameLocation.center + Vector(2200, swap ? -500 : 300, -136), + model = ship_model + rendercolor = "255 0 0", + }) + blue_ship = Ware_SpawnEntity("prop_dynamic_override", + { + origin = Ware_MinigameLocation.center + Vector(2200, swap ? 300 : -500, -136), + model = ship_model + rendercolor = "0 255 255", + }) + } + else { - origin = Ware_MinigameLocation.center + Vector(2200, swap ? 300 : -500, -136), - model = ship_model - rendercolor = "0 255 255", - }) + local mission = RandomInt(0,1) + foreach (player in Ware_MinigamePlayers) + { + Ware_SetPlayerMission(player, mission) + } + + local x_off = 100 + red_ship = Ware_SpawnEntity("prop_dynamic_override", + { + origin = Ware_MinigameLocation.center + Vector(2200 + (mission == 0 ? x_off : 0), RandomFloat(-300,300), -136), + model = ship_model + rendercolor = "255 0 0", + }) + blue_ship = Ware_SpawnEntity("prop_dynamic_override", + { + origin = Ware_MinigameLocation.center + Vector(2200 + (mission == 1 ? x_off : 0), RandomFloat(-300,300), -136), + model = ship_model + rendercolor = "0 255 255", + }) + + ships <- [red_ship, blue_ship] + foreach (ship in ships) + { + ship.ValidateScriptScope() + local scope = ship.GetScriptScope() + + scope.start_origin <- ship.GetOrigin() + scope.start_angles <- ship.GetAngles() + + scope.bob_speed <- RandomFloat(1.5, 2.5) + scope.bob_amplitude <- RandomFloat(4.0, 9.0) + scope.bob_phase <- RandomFloat(0, 2 * PI) + + scope.roll_speed <- RandomFloat(0.8, 1.2) + scope.roll_amplitude <- RandomFloat(2.5, 8.0) + scope.roll_phase <- RandomFloat(0, 2 * PI) + + //Horizontal movement + scope.sway_speed <- RandomFloat(1, 1.5) + scope.sway_amplitude <- RandomFloat(0.0, 600.0) + scope.sway_phase <- RandomFloat(0, 2 * PI) + } + } } function OnUpdate() { + if (Ware_MinigameMode == 1) + { + local minigame_time = Ware_GetMinigameTime() + foreach (ship in ships) + { + local scope = ship.GetScriptScope() + + local bob_offset = sin(minigame_time * scope.bob_speed + scope.bob_phase) * scope.bob_amplitude + local sway_offset = sin(minigame_time * scope.sway_speed + scope.sway_phase) * scope.sway_amplitude + local roll_angle_offset = sin(minigame_time * scope.roll_speed + scope.roll_phase) * scope.roll_amplitude + + local new_origin = scope.start_origin + Vector(0, sway_offset, bob_offset) + + local base_angles = scope.start_angles + local new_angles = QAngle(base_angles.x, base_angles.y, base_angles.z + roll_angle_offset) + + ship.KeyValueFromVector("origin", new_origin) + ship.SetAbsAngles(new_angles) + } + } + local offset = Vector(0, 0, 300) local red_point = red_ship.GetOrigin() + offset local blue_point = blue_ship.GetOrigin() + offset @@ -75,8 +148,8 @@ function OnUpdate() local target = player // squirrel needs this to be happy local origin = player.GetOrigin() - local team = player.GetTeam() - if (team == TF_TEAM_RED) + local mission = Ware_GetPlayerMission(player) + if (mission == 0) { if (origin.z > red_point.z && VectorDistance2D(origin, red_point) < 150.0) { @@ -95,7 +168,7 @@ function OnUpdate() Ware_ChatPrint(player, "You pirated the wrong ship!") } } - else if (team == TF_TEAM_BLUE) + else if (mission == 1) { if (origin.z > blue_point.z && VectorDistance2D(origin, blue_point) < 150.0) {