# HG changeset patch # User Wuzzy # Date 1520463165 -3600 # Node ID d3e9f3423ef3f3d295cd99201c442fef28f89eed # Parent 03d065fc60dc488e8296be070a2a6dce67c632f3 Target Practice: Re-center camera to hog after projectiles get destroyed or drown diff -r 03d065fc60dc -r d3e9f3423ef3 ChangeLog.txt --- a/ChangeLog.txt Wed Mar 07 23:06:19 2018 +0100 +++ b/ChangeLog.txt Wed Mar 07 23:52:45 2018 +0100 @@ -65,6 +65,9 @@ * Mission 1: Fix error message spam when Leaks a Lot drowns * Mission 6: Fix cyborgs sometimes doing nothing for a full turn +Missions: + + Target Practice: Re-center camera to hog when projectile is destroyed or drowns + Theme customization: + Add fallback music with fallback-music and fallback-sd-music * Fix green color channel on themes with sd-tint diff -r 03d065fc60dc -r d3e9f3423ef3 share/hedgewars/Data/Missions/Challenge/Target_Practice_-_Cluster_Bomb.lua --- a/share/hedgewars/Data/Missions/Challenge/Target_Practice_-_Cluster_Bomb.lua Wed Mar 07 23:06:19 2018 +0100 +++ b/share/hedgewars/Data/Missions/Challenge/Target_Practice_-_Cluster_Bomb.lua Wed Mar 07 23:52:45 2018 +0100 @@ -3,6 +3,7 @@ local params = { ammoType = amClusterBomb, gearType = gtClusterBomb, + secGearType = gtCluster, missionTitle = loc("Cluster Bomb Training"), solidLand = false, map = "Trash", diff -r 03d065fc60dc -r d3e9f3423ef3 share/hedgewars/Data/Scripts/TargetPractice.lua --- a/share/hedgewars/Data/Scripts/TargetPractice.lua Wed Mar 07 23:06:19 2018 +0100 +++ b/share/hedgewars/Data/Scripts/TargetPractice.lua Wed Mar 07 23:52:45 2018 +0100 @@ -33,6 +33,7 @@ time = , ammoType = , gearType = , + secondaryGearType = , targets = { { x = , y = }, { x = , y = }, @@ -64,6 +65,8 @@ local time_goal = 0 local total_targets local targets +local gearsInGameCount = 0 +local gearsInGame = {} --[[ TrainingMission(params) @@ -76,7 +79,7 @@ - theme: the name of the theme (does not need to be a standalone theme) - time: the time limit in milliseconds - ammoType: the ammo type of the weapon to be used - - gearType: the gear type of the gear which is fired (used to count shots) + - gearType: the gear type of the gear which is fired (used to count shots and re-center camera) - targets: The coordinates of where the targets will be spawned. It is a table containing tables containing coordinates of format { x=value, y=value }. The targets will be spawned in the same @@ -97,6 +100,7 @@ - teamName: name of the hedgehog’s team (default: "Training Team") - teamGrave: name of the hedgehog’s grave - teamFlag: name of the team’s flag (default: "cm_crosshair") + - secGearType: cluster of projectile gear (if present) (used to re-center camera) - clanColor: color of the (only) clan (default: 0xFF0204, which is a red tone) - goalText: A short string explaining the goal of the mission (default: "Destroy all targets within the time!") @@ -199,13 +203,26 @@ else TurnTimeLeft = time_goal end - end_timer = end_timer - 20 + end_timer = end_timer - 20 + end + + for gear, _ in pairs(gearsInGame) do + if band(GetState(gear), gstDrowning) ~= 0 then + -- Re-center camera on hog if projectile gears drown + gearsInGame[gear] = nil + gearsInGameCount = gearsInGameCount - 1 + if gearsInGameCount == 0 and GetHealth(CurrentHedgehog) then + FollowGear(CurrentHedgehog) + end + end end end _G.onGearAdd = function(gear) - if GetGearType(gear) == params.gearType then + if GetGearType(gear) == params.gearType or (params.secGearType and GetGearType(gear) == params.secGearType) then shots = shots + 1 + gearsInGameCount = gearsInGameCount + 1 + gearsInGame[gear] = true end end @@ -252,6 +269,13 @@ if not success then WriteLnToConsole("ERROR: Failed to spawn girder under respawned target!") end + elseif gearsInGame[gear] then + gearsInGame[gear] = nil + gearsInGameCount = gearsInGameCount - 1 + if gearsInGameCount == 0 and GetHealth(CurrentHedgehog) then + -- Re-center camera to hog after all projectile gears were destroyed + FollowGear(CurrentHedgehog) + end end end