diff -r d72fb761aa59 -r 7bb7e5e54f70 share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/fruit02.lua --- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/fruit02.lua Fri Dec 21 02:07:11 2018 +0100 +++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/fruit02.lua Fri Dec 21 06:33:33 2018 +0100 @@ -22,12 +22,7 @@ local dialog05 = {} -- mission objectives local minesTimeText = loc("Mines time: 0 seconds") -local goals = { - [dialog01] = {missionName, loc("Exploring the tunnel"), loc("Search for the device with the help of the other hedgehogs ").."|"..loc("Hog Solo has to reach the last crates") .. "|" .. minesTimeText, 1, 4000}, - [dialog02] = {missionName, loc("Exploring the tunnel"), loc("Explore the tunnel with the other hedgehogs and search for the device").."|"..loc("Hog Solo has to reach the last crates") .. "|" .. minesTimeText, 1, 4000}, - [dialog03] = {missionName, loc("Return to the Surface"), loc("Go to the surface!").."|"..loc("Attack Captain Lime before he attacks back").."|"..minesTimeText, 1, 4000}, - [dialog04] = {missionName, loc("Return to the Surface"), loc("Go to the surface!").."|"..loc("Attack the assassins before they attack back").."|"..minesTimeText, 1, 4000}, -} +local goals -- crates local girderCrate = {name = amGirder, x = 1680, y = 1160} @@ -51,13 +46,16 @@ hero.y = 820 hero.dead = false green1.name = loc("Captain Lime") +green1.hat = "war_desertofficer" green1.x = 1050 green1.y = 820 green1.dead = false green2.name = loc("Mister Pear") +green2.hat = "war_britmedic" green2.x = 1350 green2.y = 820 green3.name = loc("Lady Mango") +green3.hat = "hair_red" green3.x = 1450 green3.y = 820 local redHedgehogs = { @@ -101,22 +99,37 @@ AddTeam(teamC.name, teamC.color, "bp2", "Island", "Default", "cm_scout") for i=1,table.getn(redHedgehogs) do redHedgehogs[i].gear = AddHog(redHedgehogs[i].name, 1, 100, assasinsHats[GetRandom(3)+1]) - AnimSetGearPosition(redHedgehogs[i].gear, 2010 + 50*i, 630) + SetGearPosition(redHedgehogs[i].gear, 2010 + 50*i, 630) end local assassinsColor = div(GetClanColor(GetHogClan(redHedgehogs[1].gear)), 0x100) - -- Hog Solo and Green Bananas - AddTeam(teamA.name, teamA.color, "Simple", "Island", "Default", "hedgehog") - hero.gear = AddHog(hero.name, 0, health, "war_desertgrenadier1") - AnimSetGearPosition(hero.gear, hero.x, hero.y) + -- Hero and Green Bananas + teamA.name = AddMissionTeam(teamA.color) + hero.gear = AddMissionHog(health) + hero.name = GetHogName(hero.gear) + SetHogTeamName(hero.gear, string.format(loc("%s and GB"), teamA.name)) + teamA.name = GetHogTeamName(hero.gear) + SetGearPosition(hero.gear, hero.x, hero.y) HogTurnLeft(hero.gear, true) - green2.gear = AddHog(green2.name, 0, 100, "war_britmedic") - AnimSetGearPosition(green2.gear, green2.x, green2.y) + local heroColor = div(GetClanColor(GetHogClan(hero.gear)), 0x100) + + -- companions + -- Change companion identity if they have same name as hero + -- to avoid confusion. + if green2.name == hero.name then + green2.name = loc("Green Hog Grape") + green2.hat = "war_desertsapper1" + elseif green3.name == hero.name then + green3.name = loc("Green Hog Grape") + green3.hat = "war_desertsapper1" + end + green2.gear = AddHog(green2.name, 0, 100, green2.hat) + SetGearPosition(green2.gear, green2.x, green2.y) HogTurnLeft(green2.gear, true) - green3.gear = AddHog(green3.name, 0, 100, "hair_red") - AnimSetGearPosition(green3.gear, green3.x, green3.y) + + green3.gear = AddHog(green3.name, 0, 100, green3.hat) + SetGearPosition(green3.gear, green3.x, green3.y) HogTurnLeft(green3.gear, true) - local heroColor = div(GetClanColor(GetHogClan(hero.gear)), 0x100) -- Captain Lime -- Returns a color that is as close as possible to the color argument @@ -140,8 +153,16 @@ -- This is a hack, but it works. See explanation at top of file local cptnColor = getSimilarColor(heroColor, assassinsColor) AddTeam(teamB.name, cptnColor, "Cherry", "Island", "Default", "congo-brazzaville") - green1.gear= AddHog(green1.name, 0, 100, "war_desertofficer") - AnimSetGearPosition(green1.gear, green1.x, green1.y) + green1.gear= AddHog(green1.name, 0, 100, green1.hat) + SetGearPosition(green1.gear, green1.x, green1.y) + + -- Populate goals table + goals = { + [dialog01] = {missionName, loc("Exploring the tunnel"), loc("Search for the device with the help of the other hedgehogs.").."|"..string.format(loc("%s must collect the final crates."), hero.name) .. "|" .. minesTimeText, 1, 4000}, + [dialog02] = {missionName, loc("Exploring the tunnel"), loc("Explore the tunnel with the other hedgehogs and search for the device.").."|"..string.format(loc("%s must collect the final crates."), hero.name) .. "|" .. minesTimeText, 1, 4000}, + [dialog03] = {missionName, loc("Return to the Surface"), loc("Go to the surface!").."|"..loc("Attack Captain Lime before he attacks back.").."|"..minesTimeText, 1, 4000}, + [dialog04] = {missionName, loc("Return to the Surface"), loc("Go to the surface!").."|"..loc("Attack the assassins before they attack back.").."|"..minesTimeText, 1, 4000}, + } AnimInit(true) AnimationSetup() @@ -158,7 +179,7 @@ AddEvent(onHeroDeath, {hero.gear}, heroDeath, {hero.gear}, 0) AddEvent(onDeviceCrates, {hero.gear}, deviceCrateEvent, {hero.gear}, 0) - -- Hog Solo and GB weapons + -- Hero and Green Bananas weapons AddAmmo(hero.gear, amSwitch, 100) -- Assassins weapons AddAmmo(redHedgehogs[1].gear, amBazooka, 6) @@ -363,13 +384,13 @@ function heroDeath(gear) if not ended then - SendStat(siGameResult, loc("Hog Solo lost, try again!")) - SendStat(siCustomAchievement, loc("To win the game, Hog Solo has to get the bottom crates and come back to the surface.")) + SendStat(siGameResult, string.format(loc("%s lost, try again!"), hero.name)) + SendStat(siCustomAchievement, string.format(loc("To win the game, %s has to get the bottom crates and come back to the surface."), hero.name)) SendStat(siCustomAchievement, loc("You can use the other 2 hogs to assist you.")) SendStat(siCustomAchievement, loc("Do not destroy the crates!")) if tookPartInBattle then if permitCaptainLimeDeath then - SendStat(siCustomAchievement, loc("You'll have to eliminate the Fruit Assassins at the end.")) + SendStat(siCustomAchievement, string.format(loc("You'll have to eliminate %s at the end."), teamC.name)) sendSimpleTeamRankings({teamC.name, teamA.name}) else sendSimpleTeamRankings({teamA.name}) @@ -393,7 +414,7 @@ -- Stop hedgehog SetGearMessage(deviceCrate.collector, 0) if deviceCrate.collector == hero.gear then - -- Hog Solo collected the device crate + -- Hero collected the device crate if not tookPartInBattle then -- Captain Lime turns evil @@ -473,10 +494,10 @@ end function AnimationSetup() - -- DIALOG 01 - Start, Captain Lime helps Hog Solo because he took part in the battle + -- DIALOG 01 - Start, Captain Lime helps the hero because he took part in the battle AddSkipFunction(dialog01, Skipanim, {dialog01}) table.insert(dialog01, {func = AnimWait, args = {hero.gear, 3000}}) - table.insert(dialog01, {func = AnimCaption, args = {hero.gear, loc("Somewhere else on the planet of fruits, Captain Lime helps Hog Solo"), 5000}}) + table.insert(dialog01, {func = AnimCaption, args = {hero.gear, string.format(loc("Somewhere else on the planet of fruits, Captain Lime helps %s"), hero.name), 5000}}) table.insert(dialog01, {func = AnimSay, args = {green1.gear, loc("You fought bravely and you helped us win this battle!"), SAY_SAY, 5000}}) table.insert(dialog01, {func = AnimSay, args = {green1.gear, loc("So, as promised I have brought you where I think that the device you are looking for is hidden."), SAY_SAY, 7000}}) table.insert(dialog01, {func = AnimSay, args = {green1.gear, loc("I know that your resources are low due to the battle but I'll send two of my best hogs to assist you."), SAY_SAY, 7000}}) @@ -484,10 +505,10 @@ table.insert(dialog01, {func = AnimWait, args = {hero.gear, 500}}) table.insert(dialog01, {func = AnimSwitchHog, args = {hero.gear}}) table.insert(dialog01, {func = ShowMission, args = goals[dialog01]}) - -- DIALOG02 - Start, Hog Solo escaped from the previous battle + -- DIALOG02 - Start, hero escaped from the previous battle AddSkipFunction(dialog02, Skipanim, {dialog02}) table.insert(dialog02, {func = AnimWait, args = {hero.gear, 3000}}) - table.insert(dialog02, {func = AnimCaption, args = {hero.gear, loc("Somewhere else on the planet of fruits Hog Solo gets closer to the device"), 5000}}) + table.insert(dialog02, {func = AnimCaption, args = {hero.gear, string.format(loc("Somewhere else on the planet of fruits, %s gets closer to the device"), hero.name), 5000}}) table.insert(dialog02, {func = AnimSay, args = {green1.gear, loc("You are the one who fled! So, you are alive."), SAY_SAY, 4000}}) table.insert(dialog02, {func = AnimSay, args = {green1.gear, loc("I'm still low on hogs. If you are not afraid I could use a set of extra hands."), SAY_SAY, 4000}}) table.insert(dialog02, {func = AnimWait, args = {hero.gear, 8000}}) @@ -506,7 +527,7 @@ table.insert(dialog03, {func = FollowGear, args = {hero.gear}}) table.insert(dialog03, {func = AnimSay, args = {hero.gear, loc("Hooray! I've found it, now I have to get back to Captain Lime!"), SAY_SAY, 4000}}) table.insert(dialog03, {func = AnimWait, args = {green1.gear, 4000}}) - table.insert(dialog03, {func = AnimSay, args = {green1.gear, loc("This Hog Solo is so naive! When he returns I'll shoot him and keep that device for myself!"), SAY_THINK, 4000}}) + table.insert(dialog03, {func = AnimSay, args = {green1.gear, string.format(loc("This %s is so naive! I'm going to shoot this fool so I can keep that device for myself!"), hero.name), SAY_THINK, 4000}}) table.insert(dialog03, {func = ShowMission, args = goals[dialog03]}) table.insert(dialog03, {func = makeCptLimeEvil, args = {hero.gear}}) -- DIALOG04 - At crates, hero learns about the Assassins ambush @@ -564,9 +585,9 @@ escapeHog(deviceCrate.collector) AddCaption(loc("The device part has been stolen!")) sendSimpleTeamRankings({teamA.name}) - SendStat(siGameResult, loc("Hog Solo lost, try again!")) - SendStat(siCustomAchievement, loc("Oh no, the Green Bananas have betrayed Hog Solo and stole the anti-gravity device part!")) - SendStat(siCustomAchievement, loc("Only Hog Solo can be trusted with the crate.")) + SendStat(siGameResult, string.format(loc("%s lost, try again!"), hero.name)) + SendStat(siCustomAchievement, string.format(loc("Oh no, the companions have betrayed %s and stole the anti-gravity device part!"), hero.name)) + SendStat(siCustomAchievement, string.format(loc("Only %s can be trusted with the crate."), hero.name)) EndGame() ended = true end