--- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/death02.lua Sat Dec 21 01:14:59 2013 +0400
+++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/death02.lua Sat Dec 21 02:18:40 2013 +0200
@@ -120,9 +120,9 @@
elseif deadHog.weapon == amGrenade then
hero.grenadeAmmo = 0
end
- local randomHog = math.random(1,table.getn(enemies))
+ local randomHog = GetRandom(table.getn(enemies))+1
while not GetHealth(enemies[randomHog].gear) do
- randomHog = math.random(1,table.getn(enemies))
+ randomHog = GetRandom(table.getn(enemies))+1
end
table.insert(enemies[randomHog].additionalWeapons, deadHog.weapon)
for i=1,table.getn(deadHog.additionalWeapons) do
@@ -229,7 +229,7 @@
function shuffleHogs(hogs)
local hogsNumber = table.getn(hogs)
for i=1,hogsNumber do
- local randomHog = math.random(hogsNumber)
+ local randomHog = GetRandom(hogsNumber) + 1
hogs[i], hogs[randomHog] = hogs[randomHog], hogs[i]
end
end
--- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/desert01.lua Sat Dec 21 01:14:59 2013 +0400
+++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/desert01.lua Sat Dec 21 02:18:40 2013 +0200
@@ -10,6 +10,7 @@
HedgewarsScriptLoad("/Scripts/Locale.lua")
HedgewarsScriptLoad("/Scripts/Animate.lua")
+HedgewarsScriptLoad("/Scripts/Utils.lua")
HedgewarsScriptLoad("/Missions/Campaign/A_Space_Adventure/global_functions.lua")
----------------- VARIABLES --------------------
@@ -191,22 +192,22 @@
local x = 800
while x < 1630 do
AddGear(x, 900, gtMine, 0, 0, 0, 0)
- x = x + math.random(8,20)
+ x = x + GetRandom(13)+8
end
x = 1890
while x < 2988 do
AddGear(x, 760, gtMine, 0, 0, 0, 0)
- x = x + math.random(8,20)
+ x = x + GetRandom(13)+8
end
x = 2500
while x < 3300 do
AddGear(x, 1450, gtMine, 0, 0, 0, 0)
- x = x + math.random(8,20)
+ x = x + GetRandom(13)+8
end
x = 1570
while x < 2900 do
AddGear(x, 470, gtMine, 0, 0, 0, 0)
- x = x + math.random(8,20)
+ x = x + GetRandom(13)+8
end
if checkPointReached == 1 then
@@ -334,7 +335,8 @@
function onHeroFleeFirstBattle(gear)
if GetHealth(hero.gear) and GetHealth(smuggler1.gear) and heroIsInBattle
- and distance(hero.gear, smuggler1.gear) > 1400 and StoppedGear(hero.gear) then
+ and not gearIsInCircle(smuggler1.gear, GetX(hero.gear), GetY(hero.gear), 1400, false)
+ and StoppedGear(hero.gear) then
return true
end
return false
--- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/final.lua Sat Dec 21 01:14:59 2013 +0400
+++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/final.lua Sat Dec 21 02:18:40 2013 +0200
@@ -63,14 +63,14 @@
x = 400
while x < 815 do
local gear = AddGear(x, 500, gtExplosives, 0, 0, 0, 0)
- x = x + math.random(15,40)
+ x = x + GetRandom(26) + 15
table.insert(explosives, gear)
end
-- mines
local x = 360
while x < 815 do
AddGear(x, 480, gtMine, 0, 0, 0, 0)
- x = x + math.random(5,20)
+ x = x + GetRandom(16) + 5
end
-- health crate
SpawnHealthCrate(910, 5)
--- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/fruit01.lua Sat Dec 21 01:14:59 2013 +0400
+++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/fruit01.lua Sat Dec 21 02:18:40 2013 +0200
@@ -142,7 +142,7 @@
-- the rest of the Yellow Watermelons
local yellowHats = { "fr_apple", "fr_banana", "fr_lemon", "fr_orange" }
for i=1,7 do
- yellowArmy[i].gear = AddHog(yellowArmy[i].name, 1, yellowArmy[i].health, yellowHats[math.random(1,4)])
+ yellowArmy[i].gear = AddHog(yellowArmy[i].name, 1, yellowArmy[i].health, yellowHats[GetRandom(4)+1])
AnimSetGearPosition(yellowArmy[i].gear, yellowArmy[i].x, yellowArmy[i].y)
end
--- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/fruit02.lua Sat Dec 21 01:14:59 2013 +0400
+++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/fruit02.lua Sat Dec 21 02:18:40 2013 +0200
@@ -112,7 +112,7 @@
local assasinsHats = { "NinjaFull", "NinjaStraight", "NinjaTriangle" }
AddTeam(teamC.name, teamC.color, "Bone", "Island", "HillBilly", "cm_birdy")
for i=1,table.getn(redHedgehogs) do
- redHedgehogs[i].gear = AddHog(redHedgehogs[i].name, 1, 100, assasinsHats[math.random(1,3)])
+ redHedgehogs[i].gear = AddHog(redHedgehogs[i].name, 1, 100, assasinsHats[GetRandom(3)+1])
AnimSetGearPosition(redHedgehogs[i].gear, 2010 + 50*i, 630)
end
@@ -549,7 +549,7 @@
end
function wind()
- SetWind(math.random(-100,100))
+ SetWind(GetRandom(201)-100)
end
function saveHogsPositions()
--- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/fruit03.lua Sat Dec 21 01:14:59 2013 +0400
+++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/fruit03.lua Sat Dec 21 02:18:40 2013 +0200
@@ -89,12 +89,12 @@
"fr_pumpkin", "Gasmask", "NinjaFull", "NinjaStraight", "NinjaTriangle" }
AddTeam(teamC.name, teamC.color, "Bone", "Island", "HillBilly", "cm_birdy")
for i=1,table.getn(enemiesEven) do
- enemiesEven[i].gear = AddHog(enemiesEven[i].name, 1, 100, hats[math.random(1,table.getn(hats))])
+ enemiesEven[i].gear = AddHog(enemiesEven[i].name, 1, 100, hats[GetRandom(table.getn(hats))+1])
AnimSetGearPosition(enemiesEven[i].gear, enemiesEven[i].x, enemiesEven[i].y)
end
AddTeam(teamB.name, teamB.color, "Bone", "Island", "HillBilly", "cm_birdy")
for i=1,table.getn(enemiesOdd) do
- enemiesOdd[i].gear = AddHog(enemiesOdd[i].name, 1, 100, hats[math.random(1,table.getn(hats))])
+ enemiesOdd[i].gear = AddHog(enemiesOdd[i].name, 1, 100, hats[GetRandom(table.getn(hats))+1])
AnimSetGearPosition(enemiesOdd[i].gear, enemiesOdd[i].x, enemiesOdd[i].y)
end
--- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/global_functions.lua Sat Dec 21 01:14:59 2013 +0400
+++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/global_functions.lua Sat Dec 21 02:18:40 2013 +0200
@@ -118,9 +118,3 @@
end
return res
end
-
--- returns the distance of 2 gears
-function distance(gear1, gear2)
- local dist = math.sqrt(math.pow((GetX(gear1) - GetX(gear2)),2) + math.pow((GetY(gear1) - GetY(gear2)),2))
- return dist
-end
--- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/ice01.lua Sat Dec 21 01:14:59 2013 +0400
+++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/ice01.lua Sat Dec 21 02:18:40 2013 +0200
@@ -184,9 +184,9 @@
step = step + 1
if step == 5 then
step = 0
- x = x + math.random(100,300)
+ x = x + GetRandom(201)+100
else
- x = x + math.random(10,30)
+ x = x + GetRandom(21)+10
end
end
--- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/ice02.lua Sat Dec 21 01:14:59 2013 +0400
+++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/ice02.lua Sat Dec 21 02:18:40 2013 +0200
@@ -5,6 +5,7 @@
HedgewarsScriptLoad("/Scripts/Locale.lua")
HedgewarsScriptLoad("/Scripts/Animate.lua")
+HedgewarsScriptLoad("/Scripts/Utils.lua")
HedgewarsScriptLoad("/Missions/Campaign/A_Space_Adventure/global_functions.lua")
----------------- VARIABLES --------------------
@@ -249,9 +250,8 @@
function checkIfHeroInWaypoint()
if not hero.dead then
local wp = waypoints[currentWaypoint-1]
- local distance = math.sqrt((GetX(hero.gear)-wp.x)^2 + (GetY(hero.gear)-wp.y)^2)
- if distance <= radius+4 then
- SetWind(math.random(-100,100))
+ if gearIsInCircle(hero.gear, wp.x, wp.y, radius+4, false) then
+ SetWind(GetRandom(201)-100)
return true
end
end