--- a/share/hedgewars/Data/Locale/missions_en.txt Wed Jul 15 00:27:12 2015 +0200
+++ b/share/hedgewars/Data/Locale/missions_en.txt Thu Jul 16 08:39:35 2015 -0400
@@ -1,74 +1,74 @@
-Basic_Training_-_Bazooka.name=Basic Bazooka Training
-Basic_Training_-_Bazooka.desc="Using the wind to your advantage is key!"
-
-Basic_Training_-_Grenade.name=Basic Grenade Training
-Basic_Training_-_Grenade.desc="Remember, you pull the pin out AND throw!"
-
-Basic_Training_-_Cluster_Bomb.name=Basic Cluster Bomb Training
-Basic_Training_-_Cluster_Bomb.desc="Someone needs hot shower!"
-
-Basic_Training_-_Shotgun.name=Basic Shotgun Training
-Basic_Training_-_Shotgun.desc="Shoot first, ask questions later!"
-
-Basic_Training_-_Sniper_Rifle.name=Basic Sniper Rifle Training
-Basic_Training_-_Sniper_Rifle.desc="Boom, headshot!"
-
-Basic_Training_-_Rope.name=Basic Rope Training
-Basic_Training_-_Rope.desc="Get out there and swing!"
-
-User_Mission_-_Dangerous_Ducklings.name=Mission: Dangerous Ducklings
-User_Mission_-_Dangerous_Ducklings.desc="Alright, rookie! Time to put what we learned in Basic Training into practice!"
-
-User_Mission_-_Diver.name=Mission: Diver
-User_Mission_-_Diver.desc="This 'amphibious assault' thing is harder than it looks..."
-
-User_Mission_-_Teamwork.name=Mission: Teamwork
-User_Mission_-_Teamwork.desc="Sometimes, love hurts."
-
-User_Mission_-_Spooky_Tree.name=Mission: Spooky Tree
-User_Mission_-_Spooky_Tree.desc="Lots of crates out here. I sure hope that bird ain't feeling hungry."
-
-User_Mission_-_Bamboo_Thicket.name=Mission: Bamboo Thicket
-User_Mission_-_Bamboo_Thicket.desc="Death comes from above."
-
-User_Mission_-_That_Sinking_Feeling.name=Mission: That Sinking Feeling
-User_Mission_-_That_Sinking_Feeling.desc="The water is rising rapidly and time is limited. Many have tried and failed. Can you save them all?"
-
-User_Mission_-_Newton_and_the_Hammock.name=Mission: Newton and the Hammock
-User_Mission_-_Newton_and_the_Hammock.desc="Remember hoglets: The velocity of a body remains constant unless the body is acted upon by an external force!"
-
-User_Mission_-_The_Great_Escape.name=Mission: The Great Escape
-User_Mission_-_The_Great_Escape.desc="You think you can cage me!?"
-
-User_Mission_-_Rope_Knock_Challenge.name=Challenge: Rope Knocking
-User_Mission_-_Rope_Knock_Challenge.desc="Look behind you!"
-
-User_Mission_-_Nobody_Laugh.name=Mission: Nobody Laugh
-User_Mission_-_Nobody_Laugh.desc="This ain't no joke."
-
-User_Mission_-_RCPlane_Challenge.name=Challenge: RC Plane
-User_Mission_-_RCPlane_Challenge.desc="Feeling pretty confident, eh, flyboy?"
-
-portal.name=Mission: Portal Mind Challenge
-portal.desc="Use the portal to move fast and far, use it to kill, use it with caution!"
-
-Target_Practice_-_Bazooka_easy.name=Target Practice: Bazooka (easy)
-Target_Practice_-_Bazooka_easy.desc="Alright, soldier, blow those targets up as fast as you can!"
-
-Target_Practice_-_Bazooka_hard.name=Target Practice: Bazooka (hard)
-Target_Practice_-_Bazooka_hard.desc="Can you hit the targets even when they are very far away?"
-
-Target_Practice_-_Cluster_Bomb.name=Target Practice: Cluster Bomb
-Target_Practice_-_Cluster_Bomb.desc="Someone needs hot shower!"
-
-Target_Practice_-_Shotgun.name=Target Practice: Shotgun
-Target_Practice_-_Shotgun.desc="Shoot first, ask questions later!"
-
-Target_Practice_-_Homing_Bee.name=Target Practice: Homing Bee
-Target_Practice_-_Homing_Bee.desc="Using the homing bee is trickier than it seems."
-
-Target_Practice_-_Grenade_easy.name=Target Practice: Grenade (easy)
-Target_Practice_-_Grenade_easy.desc="A warm-up training for the aspiring grenadier."
-
-Target_Practice_-_Grenade_hard.name=Target Practice: Grenade (hard)
+Basic_Training_-_Bazooka.name=Basic Bazooka Training
+Basic_Training_-_Bazooka.desc="Using the wind to your advantage is key!"
+
+Basic_Training_-_Grenade.name=Basic Grenade Training
+Basic_Training_-_Grenade.desc="Remember, you pull the pin out AND throw!"
+
+Basic_Training_-_Cluster_Bomb.name=Basic Cluster Bomb Training
+Basic_Training_-_Cluster_Bomb.desc="Someone needs hot shower!"
+
+Basic_Training_-_Shotgun.name=Basic Shotgun Training
+Basic_Training_-_Shotgun.desc="Shoot first, ask questions later!"
+
+Basic_Training_-_Sniper_Rifle.name=Basic Sniper Rifle Training
+Basic_Training_-_Sniper_Rifle.desc="Boom, headshot!"
+
+Basic_Training_-_Rope.name=Basic Rope Training
+Basic_Training_-_Rope.desc="Get out there and swing!"
+
+User_Mission_-_Dangerous_Ducklings.name=Mission: Dangerous Ducklings
+User_Mission_-_Dangerous_Ducklings.desc="Alright, rookie! Time to put what we learned in Basic Training into practice!"
+
+User_Mission_-_Diver.name=Mission: Diver
+User_Mission_-_Diver.desc="This 'amphibious assault' thing is harder than it looks..."
+
+User_Mission_-_Teamwork.name=Mission: Teamwork
+User_Mission_-_Teamwork.desc="Sometimes, love hurts."
+
+User_Mission_-_Spooky_Tree.name=Mission: Spooky Tree
+User_Mission_-_Spooky_Tree.desc="Lots of crates out here. I sure hope that bird ain't feeling hungry."
+
+User_Mission_-_Bamboo_Thicket.name=Mission: Bamboo Thicket
+User_Mission_-_Bamboo_Thicket.desc="Death comes from above."
+
+User_Mission_-_That_Sinking_Feeling.name=Mission: That Sinking Feeling
+User_Mission_-_That_Sinking_Feeling.desc="The water is rising rapidly and time is limited. Many have tried and failed. Can you save them all?"
+
+User_Mission_-_Newton_and_the_Hammock.name=Mission: Newton and the Hammock
+User_Mission_-_Newton_and_the_Hammock.desc="Remember hoglets: The velocity of a body remains constant unless the body is acted upon by an external force!"
+
+User_Mission_-_The_Great_Escape.name=Mission: The Great Escape
+User_Mission_-_The_Great_Escape.desc="You think you can cage me!?"
+
+User_Mission_-_Rope_Knock_Challenge.name=Challenge: Rope Knocking
+User_Mission_-_Rope_Knock_Challenge.desc="Look behind you!"
+
+User_Mission_-_Nobody_Laugh.name=Mission: Nobody Laugh
+User_Mission_-_Nobody_Laugh.desc="This ain't no joke."
+
+User_Mission_-_RCPlane_Challenge.name=Challenge: RC Plane
+User_Mission_-_RCPlane_Challenge.desc="Feeling pretty confident, eh, flyboy?"
+
+portal.name=Mission: Portal Mind Challenge
+portal.desc="Use the portal to move fast and far, use it to kill, use it with caution!"
+
+Target_Practice_-_Bazooka_easy.name=Target Practice: Bazooka (easy)
+Target_Practice_-_Bazooka_easy.desc="Alright, soldier, blow those targets up as fast as you can!"
+
+Target_Practice_-_Bazooka_hard.name=Target Practice: Bazooka (hard)
+Target_Practice_-_Bazooka_hard.desc="Can you hit the targets even when they are very far away?"
+
+Target_Practice_-_Cluster_Bomb.name=Target Practice: Cluster Bomb
+Target_Practice_-_Cluster_Bomb.desc="Someone needs hot shower!"
+
+Target_Practice_-_Shotgun.name=Target Practice: Shotgun
+Target_Practice_-_Shotgun.desc="Shoot first, ask questions later!"
+
+Target_Practice_-_Homing_Bee.name=Target Practice: Homing Bee
+Target_Practice_-_Homing_Bee.desc="Using the homing bee is trickier than it seems."
+
+Target_Practice_-_Grenade_easy.name=Target Practice: Grenade (easy)
+Target_Practice_-_Grenade_easy.desc="A warm-up training for the aspiring grenadier."
+
+Target_Practice_-_Grenade_hard.name=Target Practice: Grenade (hard)
Target_Practice_-_Grenade_hard.desc="This is nothing for greenhorns! We will place the targets at some really tricky positions."
\ No newline at end of file
--- a/share/hedgewars/Data/Missions/Training/Basic_Training_-_Bazooka.lua Wed Jul 15 00:27:12 2015 +0200
+++ b/share/hedgewars/Data/Missions/Training/Basic_Training_-_Bazooka.lua Thu Jul 16 08:39:35 2015 -0400
@@ -1,242 +1,242 @@
--- Hedgewars Bazooka Training
--- Scripting Example
-
--- Lines such as this one are comments - they are ignored
--- by the game, no matter what kind of text is in there.
--- It's also possible to place a comment after some real
--- instruction as you see below. In short, everything
--- following "--" is ignored.
-
----------------------------------------------------------------
--- At first we implement the localization library using loadfile.
--- This allows us to localize strings without needing to think
--- about translations.
--- We can use the function loc(text) to localize a string.
-
-HedgewarsScriptLoad("/Scripts/Locale.lua")
-
--- This variable will hold the number of destroyed targets.
-local score = 0
--- This variable represents the number of targets to destroy.
-local score_goal = 5
--- This variable controls how many milliseconds/ticks we'd
--- like to wait before we end the round once all targets
--- have been destroyed.
-local end_timer = 1000 -- 1000 ms = 1 s
--- This variable is set to true if the game is lost (i.e.
--- time runs out).
-local game_lost = false
--- This variable will point to the hog's gear
-local player = nil
--- This variable will grab the time left at the end of the round
-local time_goal = 0
--- This variable stores the number of bazooka shots
-local shots = 0
-
--- This is a custom function to make it easier to
--- spawn more targets with just one line of code
--- You may define as many custom functions as you
--- like.
-function spawnTarget()
- -- add a new target gear
- gear = AddGear(0, 0, gtTarget, 0, 0, 0, 0)
-
- -- move it to a random position within 0 and
- -- LAND_WIDTH - the width of the map
- FindPlace(gear, true, 0, LAND_WIDTH)
-
- -- move the target to a higher vertical position
- -- to ensure it's not somewhere down below
- x, y = GetGearPosition(gear)
- SetGearPosition(gear, x, 0)
-end
-
--- This function is called before the game loads its
--- resources.
--- It's one of the predefined function names that will
--- be called by the game. They give you entry points
--- where you're able to call your own code using either
--- provided instructions or custom functions.
-function onGameInit()
- -- At first we have to overwrite/set some global variables
- -- that define the map, the game has to load, as well as
- -- other things such as the game rules to use, etc.
- -- Things we don't modify here will use their default values.
-
- -- The base number for the random number generator
- Seed = 1
- -- Game settings and rules
- EnableGameFlags(gfMultiWeapon, gfOneClanMode, gfSolidLand)
- -- Uncommenting this wouldn't do anything
- --EnableGameFlags(gfMultiWeapon, gfOneClanMode, gfSolidLand)
- -- Neither this
- --DisableGameFlags(gfArtillery)
- -- Uncommenting this would make the terrain damageable
- --DisableGameFlags(gfSolidLand)
- -- Uncommenting this would remove all flags set previously
- --ClearGameFlags()
- -- The time the player has to move each round (in ms)
- TurnTime = 60000
- -- The frequency of crate drops
- CaseFreq = 0
- -- The number of mines being placed
- MinesNum = 0
- -- The number of explosives being placed
- Explosives = 0
- -- The delay between each round
- Delay = 0
- -- The map to be played
- Map = "Bamboo"
- -- The theme to be used
- Theme = "Bamboo"
-
- -- Create the player team
- AddTeam(loc("'Zooka Team"), 14483456, "Simple", "Island", "Default")
- -- And add a hog to it
- player = AddHog(loc("Hunter"), 0, 1, "NoHat")
- SetGearPosition(player, 936, 136)
-end
-
--- This function is called when the round starts
--- it spawns the first target that has to be destroyed.
--- In addition it shows the scenario goal(s).
-function onGameStart()
- -- Disable the graph in the stats screen, we don't need it
- SendHealthStatsOff()
- -- Spawn the first target.
- spawnTarget()
-
- -- Show some nice mission goals.
- -- Parameters are: caption, sub caption, description,
- -- extra text, icon and time to show.
- -- A negative icon parameter (-n) represents the n-th weapon icon
- -- A positive icon paramter (n) represents the (n+1)-th mission icon
- -- A timeframe of 0 is replaced with the default time to show.
- ShowMission(loc("Bazooka Training"), loc("Aiming Practice"), loc("Eliminate all targets before your time runs out.|You have unlimited ammo for this mission."), -amBazooka, 0)
-end
-
-function onNewTurn()
- SetWeapon(amBazooka)
-end
-
--- This function is called every game tick.
--- Note that there are 1000 ticks within one second.
--- You shouldn't try to calculate too complicated
--- code here as this might slow down your game.
-function onGameTick20()
- -- If time's up, set the game to be lost.
- -- We actually check the time to be "1 ms" as it
- -- will be at "0 ms" right at the start of the game.
- if TurnTimeLeft < 40 and TurnTimeLeft > 0 and score < score_goal and not game_lost then
- game_lost = true
- -- ... and show a short message.
- ShowMission(loc("Bazooka Training"), loc("Aiming Practice"), loc("Oh no! Time's up! Just try again."), -amSkip, 0)
- -- How about killing our poor hog due to his poor performance?
- SetHealth(player, 0)
- -- Just to be sure set the goal time to 1 ms
- time_goal = 1
- end
-
- if band(GetState(player), gstDrowning) == gstDrowning and game_lost == false and score < score_goal then
- game_lost = true
- time_goal = 1
- AddCaption(loc("You lose!"), 0xFFFFFFFF, capgrpGameState)
- ShowMission(loc("Bazooka Training"), loc("Aiming practice"), loc("Oh no! You failed! Just try again."), -amSkip, 0)
- end
-
- -- If the goal is reached or we've lost ...
- if score == score_goal or game_lost then
- -- ... check to see if the time we'd like to
- -- wait has passed and then ...
- if end_timer == 0 then
- -- Let’s create some stats for the stats screen!
- -- We will expose the number of hit targets hit, launched bazooka and the accuracy
-
- SendStat(siPointType, loc("hits"))
- SendStat(siPlayerKills, tostring(score), loc("'Zooka Team"))
- SendStat(siCustomAchievement, string.format(loc("You have destroyed %d of %d targets."), score, score_goal))
- SendStat(siCustomAchievement, string.format(loc("You have launched %d bazookas."), shots))
-
- -- We must avoid a division by zero
- if(shots > 0) then
- SendStat(siCustomAchievement, string.format(loc("Your accuracy was %.1f%%."), (score/shots)*100))
- end
- if score == score_goal then
- SendStat(siGameResult, "You have finished the bazooka training!")
- SendStat(siCustomAchievement, string.format(loc("%.1f seconds were remaining."), (time_goal/1000), math.ceil(time_goal/12)))
- end
- if game_lost then
- SendStat(siGameResult, "You lose!")
- end
-
- -- Finally we end the game ...
- EndGame()
- else
- -- ... or just lower the timer by 20ms.
- -- Reset the time left to stop the timer
- TurnTimeLeft = time_goal
- end
- end_timer = end_timer - 20
- end
-end
-
--- This function is called when the game is initialized
--- to request the available ammo and probabilities
-function onAmmoStoreInit()
- -- add an unlimited supply of bazooka ammo
- SetAmmo(amBazooka, 9, 0, 0, 0)
-end
-
--- This function is called when a new gear is added.
--- We don't need it for this training, so we can
--- keep it empty.
--- function onGearAdd(gear)
--- end
-
--- This function is called before a gear is destroyed.
--- We use it to count the number of targets destroyed.
-function onGearDelete(gear)
- -- We're only interested in target gears.
- if GetGearType(gear) == gtTarget then
- -- Add one point to our score/counter
- score = score + 1
- -- If we haven't reached the goal ...
- if score < score_goal then
- -- ... spawn another target.
- spawnTarget()
- else
- if not game_lost then
- -- Otherwise show that the goal was accomplished
- ShowMission(loc("Bazooka Training"), loc("Aiming Practice"), loc("Congratulations! You've eliminated all targets|within the allowed time frame."), 0, 0)
- -- Also let the hogs shout "victory!"
- PlaySound(sndVictory)
- -- Save the time left so we may keep it.
- time_goal = TurnTimeLeft
- end
- end
- end
-end
-
--- This function is called when a gear has been damaged.
--- We only use it to determine wheather our hog took damage in order to abort the mission.
-function onGearDamage(gear, damage)
- if GetGearType(gear) == gtHedgehog then
- if not game_lost then
- game_lost = true
- AddCaption(loc("You lose!", 0xFFFFFFFF, capgrpGameState))
- ShowMission(loc("Bazooka Training") , loc("Aiming practice"), loc("Oh no! You failed! Just try again."), -amSkip, 0)
-
- time_goal = 1
- end
- end
-end
-
-
--- This function is called after a gear is added.
--- We use it to count the number of bazooka shots.
-function onGearAdd(gear)
- -- Count the number of bazooka shots for our stats
- if GetGearType(gear) == gtShell then
- shots = shots + 1
- end
-end
+-- Hedgewars Bazooka Training
+-- Scripting Example
+
+-- Lines such as this one are comments - they are ignored
+-- by the game, no matter what kind of text is in there.
+-- It's also possible to place a comment after some real
+-- instruction as you see below. In short, everything
+-- following "--" is ignored.
+
+---------------------------------------------------------------
+-- At first we implement the localization library using loadfile.
+-- This allows us to localize strings without needing to think
+-- about translations.
+-- We can use the function loc(text) to localize a string.
+
+HedgewarsScriptLoad("/Scripts/Locale.lua")
+
+-- This variable will hold the number of destroyed targets.
+local score = 0
+-- This variable represents the number of targets to destroy.
+local score_goal = 5
+-- This variable controls how many milliseconds/ticks we'd
+-- like to wait before we end the round once all targets
+-- have been destroyed.
+local end_timer = 1000 -- 1000 ms = 1 s
+-- This variable is set to true if the game is lost (i.e.
+-- time runs out).
+local game_lost = false
+-- This variable will point to the hog's gear
+local player = nil
+-- This variable will grab the time left at the end of the round
+local time_goal = 0
+-- This variable stores the number of bazooka shots
+local shots = 0
+
+-- This is a custom function to make it easier to
+-- spawn more targets with just one line of code
+-- You may define as many custom functions as you
+-- like.
+function spawnTarget()
+ -- add a new target gear
+ gear = AddGear(0, 0, gtTarget, 0, 0, 0, 0)
+
+ -- move it to a random position within 0 and
+ -- LAND_WIDTH - the width of the map
+ FindPlace(gear, true, 0, LAND_WIDTH)
+
+ -- move the target to a higher vertical position
+ -- to ensure it's not somewhere down below
+ x, y = GetGearPosition(gear)
+ SetGearPosition(gear, x, 0)
+end
+
+-- This function is called before the game loads its
+-- resources.
+-- It's one of the predefined function names that will
+-- be called by the game. They give you entry points
+-- where you're able to call your own code using either
+-- provided instructions or custom functions.
+function onGameInit()
+ -- At first we have to overwrite/set some global variables
+ -- that define the map, the game has to load, as well as
+ -- other things such as the game rules to use, etc.
+ -- Things we don't modify here will use their default values.
+
+ -- The base number for the random number generator
+ Seed = 1
+ -- Game settings and rules
+ EnableGameFlags(gfMultiWeapon, gfOneClanMode, gfSolidLand)
+ -- Uncommenting this wouldn't do anything
+ --EnableGameFlags(gfMultiWeapon, gfOneClanMode, gfSolidLand)
+ -- Neither this
+ --DisableGameFlags(gfArtillery)
+ -- Uncommenting this would make the terrain damageable
+ --DisableGameFlags(gfSolidLand)
+ -- Uncommenting this would remove all flags set previously
+ --ClearGameFlags()
+ -- The time the player has to move each round (in ms)
+ TurnTime = 60000
+ -- The frequency of crate drops
+ CaseFreq = 0
+ -- The number of mines being placed
+ MinesNum = 0
+ -- The number of explosives being placed
+ Explosives = 0
+ -- The delay between each round
+ Delay = 0
+ -- The map to be played
+ Map = "Bamboo"
+ -- The theme to be used
+ Theme = "Bamboo"
+
+ -- Create the player team
+ AddTeam(loc("'Zooka Team"), 14483456, "Simple", "Island", "Default")
+ -- And add a hog to it
+ player = AddHog(loc("Hunter"), 0, 1, "NoHat")
+ SetGearPosition(player, 936, 136)
+end
+
+-- This function is called when the round starts
+-- it spawns the first target that has to be destroyed.
+-- In addition it shows the scenario goal(s).
+function onGameStart()
+ -- Disable the graph in the stats screen, we don't need it
+ SendHealthStatsOff()
+ -- Spawn the first target.
+ spawnTarget()
+
+ -- Show some nice mission goals.
+ -- Parameters are: caption, sub caption, description,
+ -- extra text, icon and time to show.
+ -- A negative icon parameter (-n) represents the n-th weapon icon
+ -- A positive icon paramter (n) represents the (n+1)-th mission icon
+ -- A timeframe of 0 is replaced with the default time to show.
+ ShowMission(loc("Bazooka Training"), loc("Aiming Practice"), loc("Eliminate all targets before your time runs out.|You have unlimited ammo for this mission."), -amBazooka, 0)
+end
+
+function onNewTurn()
+ SetWeapon(amBazooka)
+end
+
+-- This function is called every game tick.
+-- Note that there are 1000 ticks within one second.
+-- You shouldn't try to calculate too complicated
+-- code here as this might slow down your game.
+function onGameTick20()
+ -- If time's up, set the game to be lost.
+ -- We actually check the time to be "1 ms" as it
+ -- will be at "0 ms" right at the start of the game.
+ if TurnTimeLeft < 40 and TurnTimeLeft > 0 and score < score_goal and not game_lost then
+ game_lost = true
+ -- ... and show a short message.
+ ShowMission(loc("Bazooka Training"), loc("Aiming Practice"), loc("Oh no! Time's up! Just try again."), -amSkip, 0)
+ -- How about killing our poor hog due to his poor performance?
+ SetHealth(player, 0)
+ -- Just to be sure set the goal time to 1 ms
+ time_goal = 1
+ end
+
+ if band(GetState(player), gstDrowning) == gstDrowning and game_lost == false and score < score_goal then
+ game_lost = true
+ time_goal = 1
+ AddCaption(loc("You lose!"), 0xFFFFFFFF, capgrpGameState)
+ ShowMission(loc("Bazooka Training"), loc("Aiming practice"), loc("Oh no! You failed! Just try again."), -amSkip, 0)
+ end
+
+ -- If the goal is reached or we've lost ...
+ if score == score_goal or game_lost then
+ -- ... check to see if the time we'd like to
+ -- wait has passed and then ...
+ if end_timer == 0 then
+ -- Let’s create some stats for the stats screen!
+ -- We will expose the number of hit targets hit, launched bazooka and the accuracy
+
+ SendStat(siPointType, loc("hits"))
+ SendStat(siPlayerKills, tostring(score), loc("'Zooka Team"))
+ SendStat(siCustomAchievement, string.format(loc("You have destroyed %d of %d targets."), score, score_goal))
+ SendStat(siCustomAchievement, string.format(loc("You have launched %d bazookas."), shots))
+
+ -- We must avoid a division by zero
+ if(shots > 0) then
+ SendStat(siCustomAchievement, string.format(loc("Your accuracy was %.1f%%."), (score/shots)*100))
+ end
+ if score == score_goal then
+ SendStat(siGameResult, "You have finished the bazooka training!")
+ SendStat(siCustomAchievement, string.format(loc("%.1f seconds were remaining."), (time_goal/1000), math.ceil(time_goal/12)))
+ end
+ if game_lost then
+ SendStat(siGameResult, "You lose!")
+ end
+
+ -- Finally we end the game ...
+ EndGame()
+ else
+ -- ... or just lower the timer by 20ms.
+ -- Reset the time left to stop the timer
+ TurnTimeLeft = time_goal
+ end
+ end_timer = end_timer - 20
+ end
+end
+
+-- This function is called when the game is initialized
+-- to request the available ammo and probabilities
+function onAmmoStoreInit()
+ -- add an unlimited supply of bazooka ammo
+ SetAmmo(amBazooka, 9, 0, 0, 0)
+end
+
+-- This function is called when a new gear is added.
+-- We don't need it for this training, so we can
+-- keep it empty.
+-- function onGearAdd(gear)
+-- end
+
+-- This function is called before a gear is destroyed.
+-- We use it to count the number of targets destroyed.
+function onGearDelete(gear)
+ -- We're only interested in target gears.
+ if GetGearType(gear) == gtTarget then
+ -- Add one point to our score/counter
+ score = score + 1
+ -- If we haven't reached the goal ...
+ if score < score_goal then
+ -- ... spawn another target.
+ spawnTarget()
+ else
+ if not game_lost then
+ -- Otherwise show that the goal was accomplished
+ ShowMission(loc("Bazooka Training"), loc("Aiming Practice"), loc("Congratulations! You've eliminated all targets|within the allowed time frame."), 0, 0)
+ -- Also let the hogs shout "victory!"
+ PlaySound(sndVictory)
+ -- Save the time left so we may keep it.
+ time_goal = TurnTimeLeft
+ end
+ end
+ end
+end
+
+-- This function is called when a gear has been damaged.
+-- We only use it to determine wheather our hog took damage in order to abort the mission.
+function onGearDamage(gear, damage)
+ if GetGearType(gear) == gtHedgehog then
+ if not game_lost then
+ game_lost = true
+ AddCaption(loc("You lose!", 0xFFFFFFFF, capgrpGameState))
+ ShowMission(loc("Bazooka Training") , loc("Aiming practice"), loc("Oh no! You failed! Just try again."), -amSkip, 0)
+
+ time_goal = 1
+ end
+ end
+end
+
+
+-- This function is called after a gear is added.
+-- We use it to count the number of bazooka shots.
+function onGearAdd(gear)
+ -- Count the number of bazooka shots for our stats
+ if GetGearType(gear) == gtShell then
+ shots = shots + 1
+ end
+end
--- a/share/hedgewars/Data/Missions/Training/Basic_Training_-_Sniper_Rifle.lua Wed Jul 15 00:27:12 2015 +0200
+++ b/share/hedgewars/Data/Missions/Training/Basic_Training_-_Sniper_Rifle.lua Thu Jul 16 08:39:35 2015 -0400
@@ -1,349 +1,349 @@
--- Hedgewars SniperRifle Training
--- Scripting Example
-
--- Lines such as this one are comments - they are ignored
--- by the game, no matter what kind of text is in there.
--- It's also possible to place a comment after some real
--- instruction as you see below. In short, everything
--- following "--" is ignored.
-
----------------------------------------------------------------
--- At first we implement the localization library using loadfile.
--- This allows us to localize strings without needing to think
--- about translations.
--- We can use the function loc(text) to localize a string.
-
-HedgewarsScriptLoad("/Scripts/Locale.lua")
-
--- This variable will hold the number of destroyed targets.
-local score = 0
--- This variable will hold the number of shots from the sniper rifle
-local shots = 0
--- This variable represents the number of targets to destroy.
-local score_goal = 31
--- This variable controls how many milliseconds/ticks we'd
--- like to wait before we end the round once all targets
--- have been destroyed.
-local end_timer = 1000 -- 1000 ms = 1 s
--- This variable is set to true if the game is lost (i.e.
--- time runs out).
-local game_lost = false
--- This variable will point to the hog's gear
-local player = nil
--- This variable will grab the time left at the end of the round
-local time_goal = 0
-
-local target = nil
-
-local last_hit_time = 0
--- This is a custom function to make it easier to
--- spawn more targets with just one line of code
--- You may define as many custom functions as you
--- like.
-function spawnTarget(x, y)
- -- add a new target gear
- target = AddGear(x, y, gtTarget, 0, 0, 0, 0)
- -- have the camera move to the target so the player knows where it is
- FollowGear(target)
-end
-
-function blowUp(x, y)
- -- adds some TNT
- gear = AddGear(x, y, gtDynamite, 0, 0, 0, 0)
-end
-
-function onNewTurn()
- SetWeapon(amSniperRifle)
-end
-
--- This function is called before the game loads its
--- resources.
--- It's one of the predefined function names that will
--- be called by the game. They give you entry points
--- where you're able to call your own code using either
--- provided instructions or custom functions.
-function onGameInit()
- -- At first we have to overwrite/set some global variables
- -- that define the map, the game has to load, as well as
- -- other things such as the game rules to use, etc.
- -- Things we don't modify here will use their default values.
-
- -- The base number for the random number generator
- Seed = 0
- -- Game settings and rules
- GameFlags = gfMultiWeapon + gfOneClanMode + gfArtillery
- -- The time the player has to move each round (in ms)
- TurnTime = 150000
- -- The frequency of crate drops
- CaseFreq = 0
- -- The number of mines being placed
- MinesNum = 0
- -- The number of explosives being placed
- Explosives = 0
- -- The delay between each round
- Delay = 0
- -- The map to be played
- Map = "Ropes"
- -- The theme to be used
- Theme = "City"
-
- -- Create the player team
- AddTeam(loc("Sniperz"), 14483456, "Simple", "Island", "Default")
- -- And add a hog to it
- player = AddHog(loc("Hunter"), 0, 1, "Sniper")
- SetGearPosition(player, 602, 1465)
-end
-
--- This function is called when the round starts
--- it spawns the first target that has to be destroyed.
--- In addition it shows the scenario goal(s).
-function onGameStart()
- -- Disable graph in stats screen
- SendHealthStatsOff()
- -- Spawn the first target.
- spawnTarget(860,1020)
-
- -- Show some nice mission goals.
- -- Parameters are: caption, sub caption, description,
- -- extra text, icon and time to show.
- -- A negative icon parameter (-n) represents the n-th weapon icon
- -- A positive icon paramter (n) represents the (n+1)-th mission icon
- -- A timeframe of 0 is replaced with the default time to show.
- ShowMission(loc("Sniper Training"), loc("Aiming Practice"), loc("Eliminate all targets before your time runs out.|You have unlimited ammo for this mission."), -amSniperRifle, 0)
-end
-
--- This function is called every game tick.
--- Note that there are 1000 ticks within one second.
--- You shouldn't try to calculate too complicated
--- code here as this might slow down your game.
-function onGameTick20()
- if game_lost then
- return
- end
- -- after a target is destroyed, show hog, then target
- if (target ~= nil) and (TurnTimeLeft + 1300 < last_hit_time) then
- -- move camera to the target
- FollowGear(target)
- elseif TurnTimeLeft + 300 < last_hit_time then
- -- move camera to the hog
- FollowGear(player)
- end
- -- If time's up, set the game to be lost.
- -- We actually check the time to be "1 ms" as it
- -- will be at "0 ms" right at the start of the game.
- if TurnTimeLeft < 40 and TurnTimeLeft > 0 and score < score_goal and game_lost == false then
- game_lost = true
- -- ... and show a short message.
- AddCaption(loc("Time's up!"))
- ShowMission(loc("Sniper Training"), loc("Aiming Practice"), loc("Oh no! Time's up! Just try again."), -amSkip, 0)
- -- and generate the stats and go to the stats screen
- generateStats()
- EndGame()
- -- Just to be sure set the goal time to 1 ms
- time_goal = 1
- end
- -- If the goal is reached or we've lost ...
- if score == score_goal or game_lost then
- -- ... check to see if the time we'd like to
- -- wait has passed and then ...
- if end_timer == 0 then
- -- ... end the game ...
- generateStats()
- EndGame()
- else
- -- ... or just lower the timer by 1.
- -- Reset the time left to stop the timer
- TurnTimeLeft = time_goal
- end
- end_timer = end_timer - 20
- end
-end
-
--- This function is called when the game is initialized
--- to request the available ammo and probabilities
-function onAmmoStoreInit()
- -- add an unlimited supply of shotgun ammo
- SetAmmo(amSniperRifle, 9, 0, 0, 0)
-end
-
--- This function is called when a new gear is added.
--- We use it to count the number of shots, which we
--- in turn use to calculate the final score and stats
-function onGearAdd(gear)
- if GetGearType(gear) == gtSniperRifleShot then
- shots = shots + 1
- end
-end
-
--- This function is called before a gear is destroyed.
--- We use it to count the number of targets destroyed.
-function onGearDelete(gear)
-
- if GetGearType(gear) == gtCase then
- game_lost = true
- return
- end
-
- if (GetGearType(gear) == gtTarget) then
- -- remember when the target was hit for adjusting the camera
- last_hit_time = TurnTimeLeft
- -- Add one point to our score/counter
- score = score + 1
- -- If we haven't reached the goal ...
- if score < score_goal then
- -- ... spawn another target.
- if score == 1 then
- spawnTarget(1520,1350)
- elseif score == 2 then
- spawnTarget(1730,1040)
- elseif score == 3 then
- spawnTarget(2080,780)
- elseif score == 4 then
- AddCaption(loc("Good so far!") .. " " .. loc("Keep it up!"));
- blowUp(1730,1226)
- blowUp(1440,1595)
- blowUp(1527,1575)
- blowUp(1614,1595)
- blowUp(1420,1675)
- blowUp(1527,1675)
- blowUp(1634,1675)
- blowUp(1440,1755)
- blowUp(1527,1775)
- blowUp(1614,1755)
- spawnTarget(1527,1667)
- elseif score == 5 then
- spawnTarget(1527,1667)
- elseif score == 6 then
- spawnTarget(2175,1300)
- elseif score == 7 then
- spawnTarget(2250,940)
- elseif score == 8 then
- spawnTarget(2665,1540)
- elseif score == 9 then
- spawnTarget(3040,1160)
- elseif score == 10 then
- spawnTarget(2930,1500)
- elseif score == 11 then
- AddCaption(loc("This one's tricky."));
- spawnTarget(700,720)
- elseif score == 12 then
- AddCaption(loc("Well done."));
- blowUp(914,1222)
- blowUp(1050,1222)
- blowUp(1160,1008)
- blowUp(1160,1093)
- blowUp(1160,1188)
- blowUp(375,911)
- blowUp(510,911)
- blowUp(640,911)
- blowUp(780,911)
- blowUp(920,911)
- blowUp(1060,913)
- blowUp(1198,913)
- spawnTarget(1200,730)
- elseif score == 13 then
- spawnTarget(1200,830)
- elseif score == 14 then
- spawnTarget(1430,450)
- elseif score == 15 then
- spawnTarget(796,240)
- elseif score == 16 then
- spawnTarget(300,10)
- elseif score == 17 then
- spawnTarget(2080,820)
- elseif score == 18 then
- AddCaption(loc("Demolition is fun!"));
- blowUp(2110,920)
- blowUp(2210,920)
- blowUp(2200,305)
- blowUp(2300,305)
- blowUp(2300,400)
- blowUp(2300,500)
- blowUp(2300,600)
- blowUp(2300,700)
- blowUp(2300,800)
- blowUp(2300,900)
- blowUp(2401,305)
- blowUp(2532,305)
- blowUp(2663,305)
- spawnTarget(2300,760)
- elseif score == 19 then
- spawnTarget(2300,760)
- elseif score == 20 then
- spawnTarget(2738,190)
- elseif score == 21 then
- spawnTarget(2590,-100)
- elseif score == 22 then
- AddCaption(loc("Will this ever end?"));
- blowUp(2790,305)
- blowUp(2930,305)
- blowUp(3060,305)
- blowUp(3190,305)
- blowUp(3310,305)
- blowUp(3393,613)
- blowUp(2805,370)
- blowUp(2805,500)
- blowUp(2805,630)
- blowUp(2805,760)
- blowUp(2805,890)
- blowUp(3258,370)
- blowUp(3258,475)
- blowUp(3264,575)
- spawnTarget(3230,240)
- elseif score == 23 then
- spawnTarget(3230,290)
- elseif score == 24 then
- spawnTarget(3670,250)
- elseif score == 25 then
- spawnTarget(2620,-100)
- elseif score == 26 then
- spawnTarget(2870,300)
- elseif score == 27 then
- spawnTarget(3850,900)
- elseif score == 28 then
- spawnTarget(3780,300)
- elseif score == 29 then
- spawnTarget(3670,0)
- elseif score == 30 then
- AddCaption(loc("Last Target!"));
- spawnTarget(3480,1200)
- end
- else
- if not game_lost then
- -- Otherwise show that the goal was accomplished
- ShowMission(loc("Sniper Training"), loc("Aiming Practice"), loc("Congratulations! You've eliminated all targets|within the allowed time frame."), 0, 0)
- -- Also let the hogs shout "victory!"
- PlaySound(sndVictory)
- -- Save the time left so we may keep it.
- time_goal = TurnTimeLeft
- end
- end
- end
-end
-
--- This function calculates the final score of the player and provides some texts and
--- data for the final stats screen
-function generateStats()
- local accuracy = (score/shots)*100
- local end_score_targets = (score * 200)
- local end_score_overall
- if not game_lost then
- local end_score_time = math.ceil(time_goal/5)
- local end_score_accuracy = math.ceil(accuracy * 100)
- end_score_overall = end_score_time + end_score_targets + end_score_accuracy
-
- SendStat(siGameResult, loc("You have successfully finished the sniper rifle training!"))
- SendStat(siCustomAchievement, string.format(loc("You have destroyed %d of %d targets (+%d points)."), score, score_goal, end_score_targets))
- SendStat(siCustomAchievement, string.format(loc("You have made %d shots."), shots))
- SendStat(siCustomAchievement, string.format(loc("Accuracy bonus: +%d points"), end_score_accuracy))
- SendStat(siCustomAchievement, string.format(loc("You had %.2fs remaining on the clock (+%d points)."), (time_goal/1000), end_score_time))
- else
- SendStat(siGameResult, loc("You lose!"))
-
- SendStat(siCustomAchievement, string.format(loc("You have destroyed %d of %d targets (+%d points)."), score, score_goal, end_score_targets))
- SendStat(siCustomAchievement, string.format(loc("You have made %d shots."), shots))
- end_score_overall = end_score_targets
- end
- SendStat(siPlayerKills, tostring(end_score_overall), loc("Sniperz"))
- SendStat(siPointType, loc("points"))
-end
+-- Hedgewars SniperRifle Training
+-- Scripting Example
+
+-- Lines such as this one are comments - they are ignored
+-- by the game, no matter what kind of text is in there.
+-- It's also possible to place a comment after some real
+-- instruction as you see below. In short, everything
+-- following "--" is ignored.
+
+---------------------------------------------------------------
+-- At first we implement the localization library using loadfile.
+-- This allows us to localize strings without needing to think
+-- about translations.
+-- We can use the function loc(text) to localize a string.
+
+HedgewarsScriptLoad("/Scripts/Locale.lua")
+
+-- This variable will hold the number of destroyed targets.
+local score = 0
+-- This variable will hold the number of shots from the sniper rifle
+local shots = 0
+-- This variable represents the number of targets to destroy.
+local score_goal = 31
+-- This variable controls how many milliseconds/ticks we'd
+-- like to wait before we end the round once all targets
+-- have been destroyed.
+local end_timer = 1000 -- 1000 ms = 1 s
+-- This variable is set to true if the game is lost (i.e.
+-- time runs out).
+local game_lost = false
+-- This variable will point to the hog's gear
+local player = nil
+-- This variable will grab the time left at the end of the round
+local time_goal = 0
+
+local target = nil
+
+local last_hit_time = 0
+-- This is a custom function to make it easier to
+-- spawn more targets with just one line of code
+-- You may define as many custom functions as you
+-- like.
+function spawnTarget(x, y)
+ -- add a new target gear
+ target = AddGear(x, y, gtTarget, 0, 0, 0, 0)
+ -- have the camera move to the target so the player knows where it is
+ FollowGear(target)
+end
+
+function blowUp(x, y)
+ -- adds some TNT
+ gear = AddGear(x, y, gtDynamite, 0, 0, 0, 0)
+end
+
+function onNewTurn()
+ SetWeapon(amSniperRifle)
+end
+
+-- This function is called before the game loads its
+-- resources.
+-- It's one of the predefined function names that will
+-- be called by the game. They give you entry points
+-- where you're able to call your own code using either
+-- provided instructions or custom functions.
+function onGameInit()
+ -- At first we have to overwrite/set some global variables
+ -- that define the map, the game has to load, as well as
+ -- other things such as the game rules to use, etc.
+ -- Things we don't modify here will use their default values.
+
+ -- The base number for the random number generator
+ Seed = 0
+ -- Game settings and rules
+ GameFlags = gfMultiWeapon + gfOneClanMode + gfArtillery
+ -- The time the player has to move each round (in ms)
+ TurnTime = 150000
+ -- The frequency of crate drops
+ CaseFreq = 0
+ -- The number of mines being placed
+ MinesNum = 0
+ -- The number of explosives being placed
+ Explosives = 0
+ -- The delay between each round
+ Delay = 0
+ -- The map to be played
+ Map = "Ropes"
+ -- The theme to be used
+ Theme = "City"
+
+ -- Create the player team
+ AddTeam(loc("Sniperz"), 14483456, "Simple", "Island", "Default")
+ -- And add a hog to it
+ player = AddHog(loc("Hunter"), 0, 1, "Sniper")
+ SetGearPosition(player, 602, 1465)
+end
+
+-- This function is called when the round starts
+-- it spawns the first target that has to be destroyed.
+-- In addition it shows the scenario goal(s).
+function onGameStart()
+ -- Disable graph in stats screen
+ SendHealthStatsOff()
+ -- Spawn the first target.
+ spawnTarget(860,1020)
+
+ -- Show some nice mission goals.
+ -- Parameters are: caption, sub caption, description,
+ -- extra text, icon and time to show.
+ -- A negative icon parameter (-n) represents the n-th weapon icon
+ -- A positive icon paramter (n) represents the (n+1)-th mission icon
+ -- A timeframe of 0 is replaced with the default time to show.
+ ShowMission(loc("Sniper Training"), loc("Aiming Practice"), loc("Eliminate all targets before your time runs out.|You have unlimited ammo for this mission."), -amSniperRifle, 0)
+end
+
+-- This function is called every game tick.
+-- Note that there are 1000 ticks within one second.
+-- You shouldn't try to calculate too complicated
+-- code here as this might slow down your game.
+function onGameTick20()
+ if game_lost then
+ return
+ end
+ -- after a target is destroyed, show hog, then target
+ if (target ~= nil) and (TurnTimeLeft + 1300 < last_hit_time) then
+ -- move camera to the target
+ FollowGear(target)
+ elseif TurnTimeLeft + 300 < last_hit_time then
+ -- move camera to the hog
+ FollowGear(player)
+ end
+ -- If time's up, set the game to be lost.
+ -- We actually check the time to be "1 ms" as it
+ -- will be at "0 ms" right at the start of the game.
+ if TurnTimeLeft < 40 and TurnTimeLeft > 0 and score < score_goal and game_lost == false then
+ game_lost = true
+ -- ... and show a short message.
+ AddCaption(loc("Time's up!"))
+ ShowMission(loc("Sniper Training"), loc("Aiming Practice"), loc("Oh no! Time's up! Just try again."), -amSkip, 0)
+ -- and generate the stats and go to the stats screen
+ generateStats()
+ EndGame()
+ -- Just to be sure set the goal time to 1 ms
+ time_goal = 1
+ end
+ -- If the goal is reached or we've lost ...
+ if score == score_goal or game_lost then
+ -- ... check to see if the time we'd like to
+ -- wait has passed and then ...
+ if end_timer == 0 then
+ -- ... end the game ...
+ generateStats()
+ EndGame()
+ else
+ -- ... or just lower the timer by 1.
+ -- Reset the time left to stop the timer
+ TurnTimeLeft = time_goal
+ end
+ end_timer = end_timer - 20
+ end
+end
+
+-- This function is called when the game is initialized
+-- to request the available ammo and probabilities
+function onAmmoStoreInit()
+ -- add an unlimited supply of shotgun ammo
+ SetAmmo(amSniperRifle, 9, 0, 0, 0)
+end
+
+-- This function is called when a new gear is added.
+-- We use it to count the number of shots, which we
+-- in turn use to calculate the final score and stats
+function onGearAdd(gear)
+ if GetGearType(gear) == gtSniperRifleShot then
+ shots = shots + 1
+ end
+end
+
+-- This function is called before a gear is destroyed.
+-- We use it to count the number of targets destroyed.
+function onGearDelete(gear)
+
+ if GetGearType(gear) == gtCase then
+ game_lost = true
+ return
+ end
+
+ if (GetGearType(gear) == gtTarget) then
+ -- remember when the target was hit for adjusting the camera
+ last_hit_time = TurnTimeLeft
+ -- Add one point to our score/counter
+ score = score + 1
+ -- If we haven't reached the goal ...
+ if score < score_goal then
+ -- ... spawn another target.
+ if score == 1 then
+ spawnTarget(1520,1350)
+ elseif score == 2 then
+ spawnTarget(1730,1040)
+ elseif score == 3 then
+ spawnTarget(2080,780)
+ elseif score == 4 then
+ AddCaption(loc("Good so far!") .. " " .. loc("Keep it up!"));
+ blowUp(1730,1226)
+ blowUp(1440,1595)
+ blowUp(1527,1575)
+ blowUp(1614,1595)
+ blowUp(1420,1675)
+ blowUp(1527,1675)
+ blowUp(1634,1675)
+ blowUp(1440,1755)
+ blowUp(1527,1775)
+ blowUp(1614,1755)
+ spawnTarget(1527,1667)
+ elseif score == 5 then
+ spawnTarget(1527,1667)
+ elseif score == 6 then
+ spawnTarget(2175,1300)
+ elseif score == 7 then
+ spawnTarget(2250,940)
+ elseif score == 8 then
+ spawnTarget(2665,1540)
+ elseif score == 9 then
+ spawnTarget(3040,1160)
+ elseif score == 10 then
+ spawnTarget(2930,1500)
+ elseif score == 11 then
+ AddCaption(loc("This one's tricky."));
+ spawnTarget(700,720)
+ elseif score == 12 then
+ AddCaption(loc("Well done."));
+ blowUp(914,1222)
+ blowUp(1050,1222)
+ blowUp(1160,1008)
+ blowUp(1160,1093)
+ blowUp(1160,1188)
+ blowUp(375,911)
+ blowUp(510,911)
+ blowUp(640,911)
+ blowUp(780,911)
+ blowUp(920,911)
+ blowUp(1060,913)
+ blowUp(1198,913)
+ spawnTarget(1200,730)
+ elseif score == 13 then
+ spawnTarget(1200,830)
+ elseif score == 14 then
+ spawnTarget(1430,450)
+ elseif score == 15 then
+ spawnTarget(796,240)
+ elseif score == 16 then
+ spawnTarget(300,10)
+ elseif score == 17 then
+ spawnTarget(2080,820)
+ elseif score == 18 then
+ AddCaption(loc("Demolition is fun!"));
+ blowUp(2110,920)
+ blowUp(2210,920)
+ blowUp(2200,305)
+ blowUp(2300,305)
+ blowUp(2300,400)
+ blowUp(2300,500)
+ blowUp(2300,600)
+ blowUp(2300,700)
+ blowUp(2300,800)
+ blowUp(2300,900)
+ blowUp(2401,305)
+ blowUp(2532,305)
+ blowUp(2663,305)
+ spawnTarget(2300,760)
+ elseif score == 19 then
+ spawnTarget(2300,760)
+ elseif score == 20 then
+ spawnTarget(2738,190)
+ elseif score == 21 then
+ spawnTarget(2590,-100)
+ elseif score == 22 then
+ AddCaption(loc("Will this ever end?"));
+ blowUp(2790,305)
+ blowUp(2930,305)
+ blowUp(3060,305)
+ blowUp(3190,305)
+ blowUp(3310,305)
+ blowUp(3393,613)
+ blowUp(2805,370)
+ blowUp(2805,500)
+ blowUp(2805,630)
+ blowUp(2805,760)
+ blowUp(2805,890)
+ blowUp(3258,370)
+ blowUp(3258,475)
+ blowUp(3264,575)
+ spawnTarget(3230,240)
+ elseif score == 23 then
+ spawnTarget(3230,290)
+ elseif score == 24 then
+ spawnTarget(3670,250)
+ elseif score == 25 then
+ spawnTarget(2620,-100)
+ elseif score == 26 then
+ spawnTarget(2870,300)
+ elseif score == 27 then
+ spawnTarget(3850,900)
+ elseif score == 28 then
+ spawnTarget(3780,300)
+ elseif score == 29 then
+ spawnTarget(3670,0)
+ elseif score == 30 then
+ AddCaption(loc("Last Target!"));
+ spawnTarget(3480,1200)
+ end
+ else
+ if not game_lost then
+ -- Otherwise show that the goal was accomplished
+ ShowMission(loc("Sniper Training"), loc("Aiming Practice"), loc("Congratulations! You've eliminated all targets|within the allowed time frame."), 0, 0)
+ -- Also let the hogs shout "victory!"
+ PlaySound(sndVictory)
+ -- Save the time left so we may keep it.
+ time_goal = TurnTimeLeft
+ end
+ end
+ end
+end
+
+-- This function calculates the final score of the player and provides some texts and
+-- data for the final stats screen
+function generateStats()
+ local accuracy = (score/shots)*100
+ local end_score_targets = (score * 200)
+ local end_score_overall
+ if not game_lost then
+ local end_score_time = math.ceil(time_goal/5)
+ local end_score_accuracy = math.ceil(accuracy * 100)
+ end_score_overall = end_score_time + end_score_targets + end_score_accuracy
+
+ SendStat(siGameResult, loc("You have successfully finished the sniper rifle training!"))
+ SendStat(siCustomAchievement, string.format(loc("You have destroyed %d of %d targets (+%d points)."), score, score_goal, end_score_targets))
+ SendStat(siCustomAchievement, string.format(loc("You have made %d shots."), shots))
+ SendStat(siCustomAchievement, string.format(loc("Accuracy bonus: +%d points"), end_score_accuracy))
+ SendStat(siCustomAchievement, string.format(loc("You had %.2fs remaining on the clock (+%d points)."), (time_goal/1000), end_score_time))
+ else
+ SendStat(siGameResult, loc("You lose!"))
+
+ SendStat(siCustomAchievement, string.format(loc("You have destroyed %d of %d targets (+%d points)."), score, score_goal, end_score_targets))
+ SendStat(siCustomAchievement, string.format(loc("You have made %d shots."), shots))
+ end_score_overall = end_score_targets
+ end
+ SendStat(siPlayerKills, tostring(end_score_overall), loc("Sniperz"))
+ SendStat(siPointType, loc("points"))
+end
--- a/share/hedgewars/Data/Missions/Training/User_Mission_-_RCPlane_Challenge.lua Wed Jul 15 00:27:12 2015 +0200
+++ b/share/hedgewars/Data/Missions/Training/User_Mission_-_RCPlane_Challenge.lua Thu Jul 16 08:39:35 2015 -0400
@@ -1,490 +1,490 @@
-HedgewarsScriptLoad("/Scripts/Locale.lua")
-
-local player = nil
-local RCGear = nil
-local planesUsed = 0
-local planeTimer = 0
-local planeUhOh = false
-local cratesLeft = 0
-local crateStreak = 0
-local longestCrateStreak = 0
-local commentTimer = 0
-local missiles = 0
-local totalMissiles = 0
-local missileScanTimer = 0
-local nextComment = sndNone
-
-function onGameInit()
-
- Seed = 1
- GameFlags = gfInfAttack + gfInvulnerable + gfOneClanMode + gfSolidLand
-
- TurnTime = 90 * 1000
-
- Map = "Ropes"
- Theme = "Eyes"
-
- CaseFreq = 0
- MinesNum = 0
- Explosives = 0
-
- AddTeam(loc("Wannabe Flyboys"), 14483456, "Simple", "Island", "Default", "Hedgewars")
- player = AddHog(loc("Ace"), 0, 80, "Gasmask")
- SetGearPosition(player, 1380, 1500)
-
-end
-
-
-
-function onGameStart()
-
- SendHealthStatsOff()
-
- ShowMission (
- loc("RC PLANE TRAINING"),
- loc("a Hedgewars challenge"),
-
- loc("Collect or destroy all the health crates.") .. "|" ..
- loc("Compete to use as few planes as possible!") .. "|" ..
- "", -amRCPlane, 4000
- )
-
- PlaceGirder(2192, 508, 6)
- PlaceGirder(2192, 670, 6)
- PlaceGirder(2193, 792, 2)
- PlaceGirder(2100, 825, 4)
- PlaceGirder(2009, 899, 6)
- PlaceGirder(2084, 992, 4)
- PlaceGirder(2145, 1087, 6)
- PlaceGirder(2199, 1235, 5)
- PlaceGirder(2308, 1296, 0)
- PlaceGirder(2424, 1234, 7)
- PlaceGirder(2473, 1129, 2)
- PlaceGirder(2437, 1046, 1)
- PlaceGirder(2409, 927, 6)
- PlaceGirder(2408, 763, 6)
- PlaceGirder(2404, 540, 6)
- PlaceGirder(2426, 423, 3)
- PlaceGirder(2550, 400, 4)
- PlaceGirder(2668, 425, 1)
- PlaceGirder(2707, 541, 6)
- PlaceGirder(2706, 703, 6)
- PlaceGirder(2705, 867, 6)
- PlaceGirder(2779, 962, 4)
- PlaceGirder(2894, 924, 3)
- PlaceGirder(2908, 802, 6)
- PlaceGirder(2907, 639, 6)
- PlaceGirder(3052, 566, 4)
- PlaceGirder(2971, 394, 4)
- PlaceGirder(3103, 448, 7)
- PlaceGirder(3047, 654, 0)
- PlaceGirder(3043, 746, 6)
- PlaceGirder(3265, 1583, 6)
- PlaceGirder(3256, 1491, 4)
- PlaceGirder(3187, 1401, 6)
- PlaceGirder(3326, 1400, 6)
- PlaceGirder(774, 530, 5)
- PlaceGirder(922, 595, 4)
- PlaceGirder(1079, 533, 7)
- PlaceGirder(1139, 386, 6)
- PlaceGirder(1074, 237, 5)
- PlaceGirder(723, 381, 6)
- PlaceGirder(781, 229, 7)
- PlaceGirder(927, 746, 6)
- PlaceGirder(874, 736, 0)
- PlaceGirder(982, 737, 0)
- PlaceGirder(2430, 1730, 4)
-
- PlaceGirder(1613, 1104, 7)
- PlaceGirder(1564, 1256, 6)
- PlaceGirder(1643, 1341, 5)
- PlaceGirder(1780, 1372, 4)
- PlaceGirder(1869, 1296, 7)
- PlaceGirder(1858, 1163, 5)
- PlaceGirder(1739, 1044, 5)
- PlaceGirder(1621, 926, 5)
- PlaceGirder(1597, 985, 5)
- PlaceGirder(1449, 939, 4)
- PlaceGirder(1473, 874, 4)
- PlaceGirder(2092, 1352, 7)
- PlaceGirder(2145, 1444, 7)
- PlaceGirder(2004, 1443, 3)
- PlaceGirder(1978, 1523, 2)
- PlaceGirder(2021, 1596, 1)
- PlaceGirder(2103, 1625, 0)
- PlaceGirder(2208, 1551, 7)
- PlaceGirder(2327, 1431, 7)
- PlaceGirder(2395, 1478, 6)
- PlaceGirder(2396, 1600, 2)
- PlaceGirder(2495, 1285, 6)
- PlaceGirder(2494, 1408, 2)
- PlaceGirder(2547, 530, 0)
-
- PlaceGirder(2451, 1551, 0)
- PlaceGirder(2551, 706, 6)
- PlaceGirder(2551, 869, 6)
- PlaceGirder(2623, 1016, 5)
- PlaceGirder(2773, 1083, 4)
- PlaceGirder(2924, 1019, 7)
- PlaceGirder(2568, 1491, 7)
- PlaceGirder(2618, 1346, 6)
- PlaceGirder(2674, 1195, 7)
- PlaceGirder(2822, 1142, 4)
- PlaceGirder(2963, 1069, 7)
- PlaceGirder(3067, 938, 5)
- PlaceGirder(2803, 1373, 2)
- PlaceGirder(2811, 1559, 2)
-
- tempG = SpawnHealthCrate(930, 557)
- SetHealth(tempG, 25)
- tempG = SpawnHealthCrate(979, 692)
- SetHealth(tempG, 25)
- tempG = SpawnHealthCrate(876, 703)
- SetHealth(tempG, 25)
- tempG = SpawnHealthCrate(2309, 1260)
- SetHealth(tempG, 25)
- tempG = SpawnHealthCrate(1733, 1127)
- SetHealth(tempG, 25)
- tempG = SpawnHealthCrate(1738, 1320)
- SetHealth(tempG, 25)
- tempG = SpawnHealthCrate(3249, 1460)
- SetHealth(tempG, 25)
- tempG = SpawnHealthCrate(3051, 617)
- SetHealth(tempG, 25)
- tempG = SpawnHealthCrate(2972, 353)
- SetHealth(tempG, 25)
- tempG = SpawnHealthCrate(2548, 358)
-
- SetHealth(tempG, 25)
- tempG = SpawnHealthCrate(2090, 1580)
- SetHealth(tempG, 25)
- tempG = SpawnHealthCrate(1752, 1753)
- SetHealth(tempG, 25)
- tempG = SpawnHealthCrate(1865, 1758)
- SetHealth(tempG, 25)
- tempG = SpawnHealthCrate(1985, 1760)
- SetHealth(tempG, 25)
- tempG = SpawnHealthCrate(2429, 1760)
- SetHealth(tempG, 25)
- tempG = SpawnHealthCrate(2810, 1480)
- SetHealth(tempG, 25)
- tempG = SpawnHealthCrate(2800, 1277)
- SetHealth(tempG, 25)
- tempG = SpawnHealthCrate(2806, 1107)
- SetHealth(tempG, 25)
-
- PlaceGirder(1897, 903, 6)
- PlaceGirder(1916, 784, 3)
- PlaceGirder(2010, 732, 4)
- PlaceGirder(2082, 639, 6)
- PlaceGirder(2081, 516, 2)
- PlaceGirder(1985, 487, 4)
- PlaceGirder(1862, 407, 5)
- PlaceGirder(1855, 224, 7)
- PlaceGirder(2006, 163, 4)
- PlaceGirder(2128, 187, 1)
- PlaceGirder(2251, 213, 4)
- PlaceGirder(2413, 213, 4)
- PlaceGirder(1952, 618, 0)
- PlaceGirder(957, 1068, 4)
- PlaceGirder(794, 1069, 4)
- PlaceGirder(728, 1163, 6)
- PlaceGirder(728, 1287, 2)
- PlaceGirder(802, 1342, 4)
- PlaceGirder(966, 1342, 4)
- PlaceGirder(674, 1032, 1)
- PlaceGirder(554, 1011, 4)
- PlaceGirder(445, 1056, 3)
- PlaceGirder(422, 1174, 6)
- PlaceGirder(369, 1341, 5)
- PlaceGirder(495, 1313, 5)
- PlaceGirder(568, 1379, 3)
- PlaceGirder(577, 1202, 2)
- PlaceGirder(744, 1490, 5)
- PlaceGirder(760, 1617, 7)
- PlaceGirder(622, 1693, 4)
- PlaceGirder(476, 1623, 5)
- PlaceGirder(376, 1697, 1)
- PlaceGirder(955, 1746, 2)
- PlaceGirder(1025, 1746, 2)
- PlaceGirder(1090, 1745, 2)
- PlaceGirder(1156, 1746, 2)
- PlaceGirder(3806, 1530, 2)
- PlaceGirder(3880, 1464, 2)
- PlaceGirder(3738, 1458, 2)
- PlaceGirder(3806, 1390, 2)
- PlaceGirder(3805, 1588, 0)
- PlaceGirder(3676, 1609, 3)
- PlaceGirder(3930, 1615, 1)
- PlaceGirder(3719, 1295, 0)
- PlaceGirder(3888, 1294, 0)
- PlaceGirder(3661, 1385, 2)
- PlaceGirder(3955, 1377, 2)
- PlaceGirder(3982, 1518, 0)
- PlaceGirder(3378, 440, 2)
- PlaceGirder(3447, 492, 4)
- PlaceGirder(3564, 529, 1)
- PlaceGirder(3596, 647, 6)
- PlaceGirder(3521, 740, 4)
- PlaceGirder(3524, 838, 4)
- PlaceGirder(3644, 819, 3)
- PlaceGirder(3691, 708, 6)
- PlaceGirder(3690, 545, 6)
- PlaceGirder(3612, 433, 5)
- PlaceGirder(3463, 383, 4)
- PlaceGirder(2815, 122, 7)
- PlaceGirder(2960, 72, 4)
- PlaceGirder(3032, 123, 2)
- PlaceGirder(3063, 174, 0)
- PlaceGirder(3095, 124, 2)
- PlaceGirder(3169, 71, 4)
- PlaceGirder(3320, 124, 5)
- PlaceGirder(3210, 179, 2)
- PlaceGirder(2932, 181, 2)
-
- tempG = SpawnHealthCrate(3804, 1461)
- SetHealth(tempG, 25)
- tempG = SpawnHealthCrate(3269, 1742)
- SetHealth(tempG, 25)
- tempG = SpawnHealthCrate(3066, 121)
- SetHealth(tempG, 25)
- tempG = SpawnHealthCrate(3207, 104)
- SetHealth(tempG, 25)
- tempG = SpawnHealthCrate(2928, 103)
- SetHealth(tempG, 25)
- tempG = SpawnHealthCrate(1997, 202)
- SetHealth(tempG, 25)
- tempG = SpawnHealthCrate(2253, 159)
- SetHealth(tempG, 25)
- tempG = SpawnHealthCrate(2132, 774)
- SetHealth(tempG, 25)
- tempG = SpawnHealthCrate(2549, 490)
- SetHealth(tempG, 25)
- tempG = SpawnHealthCrate(3527, 694)
- SetHealth(tempG, 25)
- tempG = SpawnHealthCrate(3777, 78)
- SetHealth(tempG, 25)
- tempG = SpawnHealthCrate(1124, 1746)
- SetHealth(tempG, 25)
- tempG = SpawnHealthCrate(1056, 1740)
- SetHealth(tempG, 25)
- tempG = SpawnHealthCrate(993, 1742)
- SetHealth(tempG, 25)
- tempG = SpawnHealthCrate(799, 1298)
- SetHealth(tempG, 25)
- tempG = SpawnHealthCrate(577, 1126)
- SetHealth(tempG, 25)
- tempG = SpawnHealthCrate(596, 1463)
- SetHealth(tempG, 25)
- tempG = SpawnHealthCrate(3854, 1043)
- SetHealth(tempG, 25)
- tempG = SpawnHealthCrate(1944, 567)
- SetHealth(tempG, 25)
- tempG = SpawnHealthCrate(338, 1748)
- SetHealth(tempG, 25)
-
-
-end
-
---function onGameTick()
-
- --if RCGear ~= nil then
- -- AddCaption(GetTimer(RCGear))
- --end
-
---end
-
-function onGameTick20()
- if RCGear ~= nil then
- if(GetTimer(RCGear) < 3000 and planeUhOh == false) then
- PlaySound(sndUhOh, player)
- planeUhOh = true
- end
- planeTimer = planeTimer + 20
- end
- if commentTimer > 0 then
- commentTimer = commentTimer - 20
- elseif(nextComment ~= sndNone) then
- PlaySound(nextComment, player)
- nextComment = sndNone
- end
- if missileScanTimer > 0 then
- missileScanTimer = missileScanTimer - 20
- else
- if crateStreak == 0 and missiles == 3 then
- PlaySound(sndMissed, player)
- missiles = 4
- end
- end
-end
-
-function onNewTurn()
- TurnTimeLeft = -1
-end
-
-function onGearAdd(gear)
-
- if GetGearType(gear) == gtRCPlane then
- RCGear = gear
- planesUsed = planesUsed + 1
- planeTimer = 0
- missiles = 0
- end
-
- if GetGearType(gear) == gtCase then
- cratesLeft = cratesLeft + 1
- end
-
- if GetGearType(gear) == gtAirBomb then
- totalMissiles = totalMissiles + 1
- end
-end
-
-function onGearDelete(gear)
-
- if GetGearType(gear) == gtRCPlane then
-
- RCGear = nil
- planeUhOh = false
- missiles = 0
- AddCaption(string.format(loc("Planes used: %d"), planesUsed))
-
- if(planeTimer < 2000 and crateStreak == 0) then
- nextComment = sndStupid
- commentTimer = math.min(2000-planeTimer, 800)
- elseif(planeTimer < 5000 and crateStreak == 0) then
- PlaySound(sndOops, player)
- elseif(planesUsed == 72) then
- PlaySound(sndStupid, player)
- elseif(planesUsed == 50) then
- PlaySound(sndNutter, player)
- elseif(planesUsed == 30) then
- PlaySound(sndOops, player)
- end
-
- crateStreak = 0
-
- elseif GetGearType(gear) == gtAirBomb then
- missiles = missiles + 1
- missileScanTimer = 500
-
- elseif GetGearType(gear) == gtCase then
-
- cratesLeft = cratesLeft - 1
- crateStreak = crateStreak + 1
- if(crateStreak > longestCrateStreak) then
- longestCrateStreak = crateStreak
- end
-
- AddCaption(string.format(loc("Crates left: %d"), cratesLeft))
-
- if cratesLeft == 0 then
-
- local rank = "unknown"
- local color = 0xFFFFFFFF
- local sound = sndVictory
- if planesUsed >= 156 then
- rank = loc("Destroyer of planes")
- color = 0xD06700FF
- sound = sndLaugh
- elseif planesUsed >= 98 then
- rank = loc("Hopeless case")
- color = 0xFF0000FF
- elseif planesUsed >= 72 then
- rank = loc("Drunk greenhorn")
- color = 0xFF0040FF
- elseif planesUsed >= 50 then
- rank = loc("Greenhorn") -- a.k.a. "absolute beginner"
- color = 0xFF0080FF
- elseif planesUsed >= 39 then
- rank = loc("Beginner")
- color = 0xFF00BFFF
- elseif planesUsed >= 30 then
- rank = loc("Experienced beginner")
- color = 0xFF00CCFF
- elseif planesUsed >= 21 then
- rank = loc("Below-average pilot")
- color = 0xFF00FFFF
- elseif planesUsed >= 17 then
- rank = loc("Average pilot")
- color = 0xBF00FFFF
- elseif planesUsed >= 13 then
- rank = loc("Above-average pilot")
- color = 0x8000FFFF
- elseif planesUsed >= 8 then
- rank = loc("Professional pilot")
- color = 0x4000FFFF
- elseif planesUsed >= 5 then
- rank = loc("Professional stunt pilot")
- color = 0x0000FFFF
- elseif planesUsed >= 3 then
- rank = loc("Elite pilot")
- color = 0x0040FFFF
- elseif planesUsed == 2 then
- rank = loc("Upper-class elite pilot")
- color = 0x0080FFFF
- elseif planesUsed == 1 then
- rank = loc("Top-class elite pilot")
- color = 0x00FFFFFF
- sound = sndFlawless
- else
- rank = loc("Cheater")
- color = 0xFF0000FF
- sound = sndCoward
- end
- AddCaption(string.format(loc("Rank: %s"), rank), color, capgrpMessage2)
- SendStat(siCustomAchievement, string.format(loc("Your rank: %s"), rank))
- if planesUsed == 1 then
- AddCaption(loc("Flawless victory!"))
- SendStat(siGameResult, loc("You have perfectly beaten the challenge!"))
- SendStat(siCustomAchievement, loc("You have used only 1 RC plane. Outstanding!"))
- else
- AddCaption(loc("Victory!"))
- SendStat(siGameResult, loc("You have finished the challenge!"))
- SendStat(siCustomAchievement, string.format(loc("You have used %d RC planes."), planesUsed))
- end
-
- if(totalMissiles > 1) then
- SendStat(siCustomAchievement, string.format(loc("You have dropped %d missiles."), totalMissiles))
- end
-
- if(longestCrateStreak > 5) then
- if(planesUsed == 1) then
- SendStat(siCustomAchievement, string.format(loc("In your best (and only) flight you took out %d crates with one RC plane!"), longestCrateStreak))
- else
- SendStat(siCustomAchievement, string.format(loc("In your best flight you took out %d crates with one RC plane."), longestCrateStreak))
- end
- end
-
- if(planesUsed == 2) then
- SendStat(siCustomAchievement, loc("This was an awesome performance! But this challenge can be finished with even just one RC plane. Can you figure out how?"))
- end
- if(planesUsed == 1) then
- SendStat(siCustomAchievement, loc("Congratulations! You have truly mastered this challenge! Don't forget to save the demo."))
- SendStat(siCustomAchievement, string.format(loc("You have gained an achievement: %s"), loc("Prestigious Pilot")))
- end
-
- ShowMission (
- loc("CHALLENGE COMPLETE"),
- loc("Congratulations!"),
- string.format(loc("Planes used: %d"), planesUsed) .. "|" ..
- "", 0, 0
- )
- SetState(player, gstWinner)
- PlaySound(sound, player)
-
-
- DismissTeam(loc("Wannabe Flyboys"))
- EndGame()
- end
-
- if RCGear ~= nil then
- SetTimer(RCGear, GetTimer(RCGear) + 10000)
- end
- end
-
-end
-
-function onAmmoStoreInit()
- SetAmmo(amRCPlane, 9, 0, 0, 0)
+HedgewarsScriptLoad("/Scripts/Locale.lua")
+
+local player = nil
+local RCGear = nil
+local planesUsed = 0
+local planeTimer = 0
+local planeUhOh = false
+local cratesLeft = 0
+local crateStreak = 0
+local longestCrateStreak = 0
+local commentTimer = 0
+local missiles = 0
+local totalMissiles = 0
+local missileScanTimer = 0
+local nextComment = sndNone
+
+function onGameInit()
+
+ Seed = 1
+ GameFlags = gfInfAttack + gfInvulnerable + gfOneClanMode + gfSolidLand
+
+ TurnTime = 90 * 1000
+
+ Map = "Ropes"
+ Theme = "Eyes"
+
+ CaseFreq = 0
+ MinesNum = 0
+ Explosives = 0
+
+ AddTeam(loc("Wannabe Flyboys"), 14483456, "Simple", "Island", "Default", "Hedgewars")
+ player = AddHog(loc("Ace"), 0, 80, "Gasmask")
+ SetGearPosition(player, 1380, 1500)
+
+end
+
+
+
+function onGameStart()
+
+ SendHealthStatsOff()
+
+ ShowMission (
+ loc("RC PLANE TRAINING"),
+ loc("a Hedgewars challenge"),
+
+ loc("Collect or destroy all the health crates.") .. "|" ..
+ loc("Compete to use as few planes as possible!") .. "|" ..
+ "", -amRCPlane, 4000
+ )
+
+ PlaceGirder(2192, 508, 6)
+ PlaceGirder(2192, 670, 6)
+ PlaceGirder(2193, 792, 2)
+ PlaceGirder(2100, 825, 4)
+ PlaceGirder(2009, 899, 6)
+ PlaceGirder(2084, 992, 4)
+ PlaceGirder(2145, 1087, 6)
+ PlaceGirder(2199, 1235, 5)
+ PlaceGirder(2308, 1296, 0)
+ PlaceGirder(2424, 1234, 7)
+ PlaceGirder(2473, 1129, 2)
+ PlaceGirder(2437, 1046, 1)
+ PlaceGirder(2409, 927, 6)
+ PlaceGirder(2408, 763, 6)
+ PlaceGirder(2404, 540, 6)
+ PlaceGirder(2426, 423, 3)
+ PlaceGirder(2550, 400, 4)
+ PlaceGirder(2668, 425, 1)
+ PlaceGirder(2707, 541, 6)
+ PlaceGirder(2706, 703, 6)
+ PlaceGirder(2705, 867, 6)
+ PlaceGirder(2779, 962, 4)
+ PlaceGirder(2894, 924, 3)
+ PlaceGirder(2908, 802, 6)
+ PlaceGirder(2907, 639, 6)
+ PlaceGirder(3052, 566, 4)
+ PlaceGirder(2971, 394, 4)
+ PlaceGirder(3103, 448, 7)
+ PlaceGirder(3047, 654, 0)
+ PlaceGirder(3043, 746, 6)
+ PlaceGirder(3265, 1583, 6)
+ PlaceGirder(3256, 1491, 4)
+ PlaceGirder(3187, 1401, 6)
+ PlaceGirder(3326, 1400, 6)
+ PlaceGirder(774, 530, 5)
+ PlaceGirder(922, 595, 4)
+ PlaceGirder(1079, 533, 7)
+ PlaceGirder(1139, 386, 6)
+ PlaceGirder(1074, 237, 5)
+ PlaceGirder(723, 381, 6)
+ PlaceGirder(781, 229, 7)
+ PlaceGirder(927, 746, 6)
+ PlaceGirder(874, 736, 0)
+ PlaceGirder(982, 737, 0)
+ PlaceGirder(2430, 1730, 4)
+
+ PlaceGirder(1613, 1104, 7)
+ PlaceGirder(1564, 1256, 6)
+ PlaceGirder(1643, 1341, 5)
+ PlaceGirder(1780, 1372, 4)
+ PlaceGirder(1869, 1296, 7)
+ PlaceGirder(1858, 1163, 5)
+ PlaceGirder(1739, 1044, 5)
+ PlaceGirder(1621, 926, 5)
+ PlaceGirder(1597, 985, 5)
+ PlaceGirder(1449, 939, 4)
+ PlaceGirder(1473, 874, 4)
+ PlaceGirder(2092, 1352, 7)
+ PlaceGirder(2145, 1444, 7)
+ PlaceGirder(2004, 1443, 3)
+ PlaceGirder(1978, 1523, 2)
+ PlaceGirder(2021, 1596, 1)
+ PlaceGirder(2103, 1625, 0)
+ PlaceGirder(2208, 1551, 7)
+ PlaceGirder(2327, 1431, 7)
+ PlaceGirder(2395, 1478, 6)
+ PlaceGirder(2396, 1600, 2)
+ PlaceGirder(2495, 1285, 6)
+ PlaceGirder(2494, 1408, 2)
+ PlaceGirder(2547, 530, 0)
+
+ PlaceGirder(2451, 1551, 0)
+ PlaceGirder(2551, 706, 6)
+ PlaceGirder(2551, 869, 6)
+ PlaceGirder(2623, 1016, 5)
+ PlaceGirder(2773, 1083, 4)
+ PlaceGirder(2924, 1019, 7)
+ PlaceGirder(2568, 1491, 7)
+ PlaceGirder(2618, 1346, 6)
+ PlaceGirder(2674, 1195, 7)
+ PlaceGirder(2822, 1142, 4)
+ PlaceGirder(2963, 1069, 7)
+ PlaceGirder(3067, 938, 5)
+ PlaceGirder(2803, 1373, 2)
+ PlaceGirder(2811, 1559, 2)
+
+ tempG = SpawnHealthCrate(930, 557)
+ SetHealth(tempG, 25)
+ tempG = SpawnHealthCrate(979, 692)
+ SetHealth(tempG, 25)
+ tempG = SpawnHealthCrate(876, 703)
+ SetHealth(tempG, 25)
+ tempG = SpawnHealthCrate(2309, 1260)
+ SetHealth(tempG, 25)
+ tempG = SpawnHealthCrate(1733, 1127)
+ SetHealth(tempG, 25)
+ tempG = SpawnHealthCrate(1738, 1320)
+ SetHealth(tempG, 25)
+ tempG = SpawnHealthCrate(3249, 1460)
+ SetHealth(tempG, 25)
+ tempG = SpawnHealthCrate(3051, 617)
+ SetHealth(tempG, 25)
+ tempG = SpawnHealthCrate(2972, 353)
+ SetHealth(tempG, 25)
+ tempG = SpawnHealthCrate(2548, 358)
+
+ SetHealth(tempG, 25)
+ tempG = SpawnHealthCrate(2090, 1580)
+ SetHealth(tempG, 25)
+ tempG = SpawnHealthCrate(1752, 1753)
+ SetHealth(tempG, 25)
+ tempG = SpawnHealthCrate(1865, 1758)
+ SetHealth(tempG, 25)
+ tempG = SpawnHealthCrate(1985, 1760)
+ SetHealth(tempG, 25)
+ tempG = SpawnHealthCrate(2429, 1760)
+ SetHealth(tempG, 25)
+ tempG = SpawnHealthCrate(2810, 1480)
+ SetHealth(tempG, 25)
+ tempG = SpawnHealthCrate(2800, 1277)
+ SetHealth(tempG, 25)
+ tempG = SpawnHealthCrate(2806, 1107)
+ SetHealth(tempG, 25)
+
+ PlaceGirder(1897, 903, 6)
+ PlaceGirder(1916, 784, 3)
+ PlaceGirder(2010, 732, 4)
+ PlaceGirder(2082, 639, 6)
+ PlaceGirder(2081, 516, 2)
+ PlaceGirder(1985, 487, 4)
+ PlaceGirder(1862, 407, 5)
+ PlaceGirder(1855, 224, 7)
+ PlaceGirder(2006, 163, 4)
+ PlaceGirder(2128, 187, 1)
+ PlaceGirder(2251, 213, 4)
+ PlaceGirder(2413, 213, 4)
+ PlaceGirder(1952, 618, 0)
+ PlaceGirder(957, 1068, 4)
+ PlaceGirder(794, 1069, 4)
+ PlaceGirder(728, 1163, 6)
+ PlaceGirder(728, 1287, 2)
+ PlaceGirder(802, 1342, 4)
+ PlaceGirder(966, 1342, 4)
+ PlaceGirder(674, 1032, 1)
+ PlaceGirder(554, 1011, 4)
+ PlaceGirder(445, 1056, 3)
+ PlaceGirder(422, 1174, 6)
+ PlaceGirder(369, 1341, 5)
+ PlaceGirder(495, 1313, 5)
+ PlaceGirder(568, 1379, 3)
+ PlaceGirder(577, 1202, 2)
+ PlaceGirder(744, 1490, 5)
+ PlaceGirder(760, 1617, 7)
+ PlaceGirder(622, 1693, 4)
+ PlaceGirder(476, 1623, 5)
+ PlaceGirder(376, 1697, 1)
+ PlaceGirder(955, 1746, 2)
+ PlaceGirder(1025, 1746, 2)
+ PlaceGirder(1090, 1745, 2)
+ PlaceGirder(1156, 1746, 2)
+ PlaceGirder(3806, 1530, 2)
+ PlaceGirder(3880, 1464, 2)
+ PlaceGirder(3738, 1458, 2)
+ PlaceGirder(3806, 1390, 2)
+ PlaceGirder(3805, 1588, 0)
+ PlaceGirder(3676, 1609, 3)
+ PlaceGirder(3930, 1615, 1)
+ PlaceGirder(3719, 1295, 0)
+ PlaceGirder(3888, 1294, 0)
+ PlaceGirder(3661, 1385, 2)
+ PlaceGirder(3955, 1377, 2)
+ PlaceGirder(3982, 1518, 0)
+ PlaceGirder(3378, 440, 2)
+ PlaceGirder(3447, 492, 4)
+ PlaceGirder(3564, 529, 1)
+ PlaceGirder(3596, 647, 6)
+ PlaceGirder(3521, 740, 4)
+ PlaceGirder(3524, 838, 4)
+ PlaceGirder(3644, 819, 3)
+ PlaceGirder(3691, 708, 6)
+ PlaceGirder(3690, 545, 6)
+ PlaceGirder(3612, 433, 5)
+ PlaceGirder(3463, 383, 4)
+ PlaceGirder(2815, 122, 7)
+ PlaceGirder(2960, 72, 4)
+ PlaceGirder(3032, 123, 2)
+ PlaceGirder(3063, 174, 0)
+ PlaceGirder(3095, 124, 2)
+ PlaceGirder(3169, 71, 4)
+ PlaceGirder(3320, 124, 5)
+ PlaceGirder(3210, 179, 2)
+ PlaceGirder(2932, 181, 2)
+
+ tempG = SpawnHealthCrate(3804, 1461)
+ SetHealth(tempG, 25)
+ tempG = SpawnHealthCrate(3269, 1742)
+ SetHealth(tempG, 25)
+ tempG = SpawnHealthCrate(3066, 121)
+ SetHealth(tempG, 25)
+ tempG = SpawnHealthCrate(3207, 104)
+ SetHealth(tempG, 25)
+ tempG = SpawnHealthCrate(2928, 103)
+ SetHealth(tempG, 25)
+ tempG = SpawnHealthCrate(1997, 202)
+ SetHealth(tempG, 25)
+ tempG = SpawnHealthCrate(2253, 159)
+ SetHealth(tempG, 25)
+ tempG = SpawnHealthCrate(2132, 774)
+ SetHealth(tempG, 25)
+ tempG = SpawnHealthCrate(2549, 490)
+ SetHealth(tempG, 25)
+ tempG = SpawnHealthCrate(3527, 694)
+ SetHealth(tempG, 25)
+ tempG = SpawnHealthCrate(3777, 78)
+ SetHealth(tempG, 25)
+ tempG = SpawnHealthCrate(1124, 1746)
+ SetHealth(tempG, 25)
+ tempG = SpawnHealthCrate(1056, 1740)
+ SetHealth(tempG, 25)
+ tempG = SpawnHealthCrate(993, 1742)
+ SetHealth(tempG, 25)
+ tempG = SpawnHealthCrate(799, 1298)
+ SetHealth(tempG, 25)
+ tempG = SpawnHealthCrate(577, 1126)
+ SetHealth(tempG, 25)
+ tempG = SpawnHealthCrate(596, 1463)
+ SetHealth(tempG, 25)
+ tempG = SpawnHealthCrate(3854, 1043)
+ SetHealth(tempG, 25)
+ tempG = SpawnHealthCrate(1944, 567)
+ SetHealth(tempG, 25)
+ tempG = SpawnHealthCrate(338, 1748)
+ SetHealth(tempG, 25)
+
+
+end
+
+--function onGameTick()
+
+ --if RCGear ~= nil then
+ -- AddCaption(GetTimer(RCGear))
+ --end
+
+--end
+
+function onGameTick20()
+ if RCGear ~= nil then
+ if(GetTimer(RCGear) < 3000 and planeUhOh == false) then
+ PlaySound(sndUhOh, player)
+ planeUhOh = true
+ end
+ planeTimer = planeTimer + 20
+ end
+ if commentTimer > 0 then
+ commentTimer = commentTimer - 20
+ elseif(nextComment ~= sndNone) then
+ PlaySound(nextComment, player)
+ nextComment = sndNone
+ end
+ if missileScanTimer > 0 then
+ missileScanTimer = missileScanTimer - 20
+ else
+ if crateStreak == 0 and missiles == 3 then
+ PlaySound(sndMissed, player)
+ missiles = 4
+ end
+ end
+end
+
+function onNewTurn()
+ TurnTimeLeft = -1
+end
+
+function onGearAdd(gear)
+
+ if GetGearType(gear) == gtRCPlane then
+ RCGear = gear
+ planesUsed = planesUsed + 1
+ planeTimer = 0
+ missiles = 0
+ end
+
+ if GetGearType(gear) == gtCase then
+ cratesLeft = cratesLeft + 1
+ end
+
+ if GetGearType(gear) == gtAirBomb then
+ totalMissiles = totalMissiles + 1
+ end
+end
+
+function onGearDelete(gear)
+
+ if GetGearType(gear) == gtRCPlane then
+
+ RCGear = nil
+ planeUhOh = false
+ missiles = 0
+ AddCaption(string.format(loc("Planes used: %d"), planesUsed))
+
+ if(planeTimer < 2000 and crateStreak == 0) then
+ nextComment = sndStupid
+ commentTimer = math.min(2000-planeTimer, 800)
+ elseif(planeTimer < 5000 and crateStreak == 0) then
+ PlaySound(sndOops, player)
+ elseif(planesUsed == 72) then
+ PlaySound(sndStupid, player)
+ elseif(planesUsed == 50) then
+ PlaySound(sndNutter, player)
+ elseif(planesUsed == 30) then
+ PlaySound(sndOops, player)
+ end
+
+ crateStreak = 0
+
+ elseif GetGearType(gear) == gtAirBomb then
+ missiles = missiles + 1
+ missileScanTimer = 500
+
+ elseif GetGearType(gear) == gtCase then
+
+ cratesLeft = cratesLeft - 1
+ crateStreak = crateStreak + 1
+ if(crateStreak > longestCrateStreak) then
+ longestCrateStreak = crateStreak
+ end
+
+ AddCaption(string.format(loc("Crates left: %d"), cratesLeft))
+
+ if cratesLeft == 0 then
+
+ local rank = "unknown"
+ local color = 0xFFFFFFFF
+ local sound = sndVictory
+ if planesUsed >= 156 then
+ rank = loc("Destroyer of planes")
+ color = 0xD06700FF
+ sound = sndLaugh
+ elseif planesUsed >= 98 then
+ rank = loc("Hopeless case")
+ color = 0xFF0000FF
+ elseif planesUsed >= 72 then
+ rank = loc("Drunk greenhorn")
+ color = 0xFF0040FF
+ elseif planesUsed >= 50 then
+ rank = loc("Greenhorn") -- a.k.a. "absolute beginner"
+ color = 0xFF0080FF
+ elseif planesUsed >= 39 then
+ rank = loc("Beginner")
+ color = 0xFF00BFFF
+ elseif planesUsed >= 30 then
+ rank = loc("Experienced beginner")
+ color = 0xFF00CCFF
+ elseif planesUsed >= 21 then
+ rank = loc("Below-average pilot")
+ color = 0xFF00FFFF
+ elseif planesUsed >= 17 then
+ rank = loc("Average pilot")
+ color = 0xBF00FFFF
+ elseif planesUsed >= 13 then
+ rank = loc("Above-average pilot")
+ color = 0x8000FFFF
+ elseif planesUsed >= 8 then
+ rank = loc("Professional pilot")
+ color = 0x4000FFFF
+ elseif planesUsed >= 5 then
+ rank = loc("Professional stunt pilot")
+ color = 0x0000FFFF
+ elseif planesUsed >= 3 then
+ rank = loc("Elite pilot")
+ color = 0x0040FFFF
+ elseif planesUsed == 2 then
+ rank = loc("Upper-class elite pilot")
+ color = 0x0080FFFF
+ elseif planesUsed == 1 then
+ rank = loc("Top-class elite pilot")
+ color = 0x00FFFFFF
+ sound = sndFlawless
+ else
+ rank = loc("Cheater")
+ color = 0xFF0000FF
+ sound = sndCoward
+ end
+ AddCaption(string.format(loc("Rank: %s"), rank), color, capgrpMessage2)
+ SendStat(siCustomAchievement, string.format(loc("Your rank: %s"), rank))
+ if planesUsed == 1 then
+ AddCaption(loc("Flawless victory!"))
+ SendStat(siGameResult, loc("You have perfectly beaten the challenge!"))
+ SendStat(siCustomAchievement, loc("You have used only 1 RC plane. Outstanding!"))
+ else
+ AddCaption(loc("Victory!"))
+ SendStat(siGameResult, loc("You have finished the challenge!"))
+ SendStat(siCustomAchievement, string.format(loc("You have used %d RC planes."), planesUsed))
+ end
+
+ if(totalMissiles > 1) then
+ SendStat(siCustomAchievement, string.format(loc("You have dropped %d missiles."), totalMissiles))
+ end
+
+ if(longestCrateStreak > 5) then
+ if(planesUsed == 1) then
+ SendStat(siCustomAchievement, string.format(loc("In your best (and only) flight you took out %d crates with one RC plane!"), longestCrateStreak))
+ else
+ SendStat(siCustomAchievement, string.format(loc("In your best flight you took out %d crates with one RC plane."), longestCrateStreak))
+ end
+ end
+
+ if(planesUsed == 2) then
+ SendStat(siCustomAchievement, loc("This was an awesome performance! But this challenge can be finished with even just one RC plane. Can you figure out how?"))
+ end
+ if(planesUsed == 1) then
+ SendStat(siCustomAchievement, loc("Congratulations! You have truly mastered this challenge! Don't forget to save the demo."))
+ SendStat(siCustomAchievement, string.format(loc("You have gained an achievement: %s"), loc("Prestigious Pilot")))
+ end
+
+ ShowMission (
+ loc("CHALLENGE COMPLETE"),
+ loc("Congratulations!"),
+ string.format(loc("Planes used: %d"), planesUsed) .. "|" ..
+ "", 0, 0
+ )
+ SetState(player, gstWinner)
+ PlaySound(sound, player)
+
+
+ DismissTeam(loc("Wannabe Flyboys"))
+ EndGame()
+ end
+
+ if RCGear ~= nil then
+ SetTimer(RCGear, GetTimer(RCGear) + 10000)
+ end
+ end
+
+end
+
+function onAmmoStoreInit()
+ SetAmmo(amRCPlane, 9, 0, 0, 0)
end
\ No newline at end of file
--- a/share/hedgewars/Data/Scripts/Multiplayer/Construction_Mode.lua Wed Jul 15 00:27:12 2015 +0200
+++ b/share/hedgewars/Data/Scripts/Multiplayer/Construction_Mode.lua Thu Jul 16 08:39:35 2015 -0400
@@ -1,1909 +1,1909 @@
----------------------------------------------------------
---- LE CONSTRUCTION MODE 0.7 (badly adapted from Hedge Editor 0.5)
----------------------------------------------------------
--- a hedgewars gameplay mode by mikade
--- special thanks to all who helped test and offered suggestions
--- additional thanks to sheepluva/nemo for adding some extra hooks
-
--- (to do)
--- investigate loc not working on addcaptions
--- check for parsecommands before porting to dev
--- test onUpDown more extensively as it may need revision (check for amRubber etc)
--- test localization of weapons and utils and stuff
-
--- try posistion grenades in Harmer so it blows hogs away from the struc
--- and don't explode too close to the struc
-
--- additional/previous balance ideas
--- based on your money?
--- based on the number of strucs/gens you own?
--- based on your existing arsenal?
--- limit number of crates spawned per round perhaps (done)
--- limit number of generators?
-
-------------------------------------------------------------------------------
---version history
-------------------------------------------------------------------------------
---v0.1
--- concept test
-
---v0.2
--- improved documentation (in script and in game)
--- improved localisation (or is it? at any rate, crate placement should now say e.g. Bazooka and not amBazooka)
--- added variable weapon costs (based on the values from Vatten's Consumerism script)
-
--- added reflector shield (still needs work and balancing)
--- added weapon-filter (probably ok)
-
--- enabled super weapons like ballgun, rcplane, watermelon, hellish to test balance
--- reduce max money to 1000
-
---v0.3
--- some /s removed
-
---v0.4
--- added support for per hog ammo (hopefully)
-
---v0.5 (dev)
--- added somewhat horribly implemented support for different structure sprites
--- added override pictures for ammo menu
--- added override message on wep select to aid understanding
--- split menu into/between weps/parts: struc, crates, gears
--- add a limit on crates per turn
--- add a limit on extra time per turn
--- add a test level
--- restored rubber placement
--- cleaned up some of the code a bit and removed about 280 lines of code I didn't need, lol
-
---v0.6 (dev)
--- added magic dance
-
---v.07 (pushed to repo)
--- added a cfg file
--- removed another 903 lines of code we weren't using (lol)
-
---------------------------------
--- STRUCTURES LIST / IDEAS
---------------------------------
-
---Healing Station: heals hogs to 150 life
---Teleportation Node: allows teleporting to any other teleporter nodes
---Bio-filter: explodes enemy hogs
---Respawner: if you have one of these, any slain hogs are resurrected here :D
---Generator: generates energy (used to buy stuff, and possibly later other strucs might have upkeep costs)
---Support Station: allows purchasing of weapons, utilities, and med-crates
---Construction Station: allows purchasing of girders, rubber, mines, sticky mines, barrels
---Reflector Shield: reflect projectiles
---Weapon Filter: kill all equipement of enemy hogs passing through this area.
-
-
---to make the grill more attractive make it vaporize flying saucers
---and also rope, and maybe incoming gears
-
--- make healing thing also cure poison
--- maybe make poison more virulent and dangerous
-
---(not implemented / abandoned ideas)
--- Core: allows construction of other structures.
--- Automated Turret (think red drones from space invasion)
--- Canon (gives access to 3 fireballs per turn while near)
--- something that allows control of wind/water
--- Gravity Field generator : triggers world gravity change
-
--- structures consume power over time and
--- maybe you can turn structures OFF/ON, manually to save power.
-
--- hacking
--- allow hacking of structures, either being able to use enemy structures,
--- or turning a team's structures against them.
-
--- pylons
--- allow hogs to put down a pylon-like gear which then allows the core
--- to place other structures/objects within the pylon's sphere of influence
--- this would allow aggressive structure advancement
-
--- resouce mining?
--- you could designate something like mines, that you could get close to,
--- "pick up", and then "drop" back at a central location to simulate
--- resource mining. bit complicated/meh, normal power generators probably easier
-
--- it would be cool to have a red mask we could apply over girders
--- that would indicate they were Indestructible
-
-HedgewarsScriptLoad("/Scripts/Locale.lua")
-HedgewarsScriptLoad("/Scripts/Tracker.lua")
-
-----------------------------------------------
--- STRUC CRAP
-----------------------------------------------
-
-strucID = {}
-strucGear = {}
-strucClan = {}
-strucType = {}
-strucCost = {}
-strucHealth = {}
-
-strucCirc = {}
-strucCircCol = {}
-strucCircRadius = {}
-strucCircType = {}
-strucAltDisplay = {}
-
-placedExpense = 0
-
-tempID = nil
-
-sUID = 0
-
-colorRed = 0xff0000ff
-colorGreen = 0x00ff00ff
-
-clanBoundsSX = {}
-clanBoundsSY = {}
-clanBoundsEX = {}
-clanBoundsEY = {}
-
-clanPower = {}
-clanBoon = {}
-clanID = {}
-clanLStrucIndex = {}
-
-clanLWepIndex = {} -- for ease of use let's track this stuff
-clanLUtilIndex = {}
-clanLGearIndex = {}
-clanUsedExtraTime = {}
-clanCratesSpawned = {}
-
-effectTimer = 0
-
-wallsVisible = false
-wX = {}
-wY = {}
-wWidth = {}
-wHeight = {}
-wCol = {}
-margin = 20
-
-tauntString = ""
-
-vTag = {}
-lastWep = nil
-
-function HideTags()
-
- for i = 0, 2 do
- SetVisualGearValues(vTag[i],0,0,0,0,0,1,0, 0, 240000, 0xffffff00)
- end
-
-end
-
-function DrawTag(i)
-
- zoomL = 1.3
-
- xOffset = 40
-
- if i == 0 then
- yOffset = 40
- tCol = 0xffba00ff
- tValue = 30--TimeLeft
- elseif i == 1 then
- zoomL = 1.1
- xOffset = 45
- yOffset = 70
- tCol = 0x00ff00ff
- tValue = clanPower[GetHogClan(CurrentHedgehog)]
- elseif i == 2 then
- zoomL = 1.1
- xOffset = 60 + 35
- yOffset = 70
- tCol = 0xa800ffff
- tValue = 10--shieldHealth - 80
- end
-
- DeleteVisualGear(vTag[i])
- vTag[i] = AddVisualGear(0, 0, vgtHealthTag, 0, false)
- g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(vTag[i])
- SetVisualGearValues (
- vTag[i], --id
- -div(ScreenWidth,2) + xOffset, --xoffset
- ScreenHeight - yOffset, --yoffset
- 0, --dx
- 0, --dy
- zoomL, --zoom
- 1, --~= 0 means align to screen
- g7, --frameticks
- tValue, --value
- 240000, --timer
- tCol --GetClanColor( GetHogClan(CurrentHedgehog) )
- )
-
-end
-
-function onScreenResize()
-
- -- redraw Tags so that their screen locations are updated
- if (CurrentHedgehog ~= nil) then
- DrawTag(0)
- DrawTag(1)
- DrawTag(2)
- end
-
-end
-
-function XYisInRect(px, py, psx, psy, pex, pey)
-
- if (px > psx) and (px < pex) and (py > psy) and (py < pey) then
- return(true)
- else
- return(false)
- end
-
-end
-
-function AddWall(zXMin,zYMin, zWidth, zHeight, zCol)
-
- table.insert(wX, zXMin)
- table.insert(wY, zYMin)
- table.insert(wWidth, zWidth)
- table.insert(wHeight, zHeight)
- table.insert(wCol, zCol)
-
-end
-
-function BorderSpark(zXMin,zYMin, zWidth, zHeight, bCol)
-
- eX = zXMin + GetRandom(zWidth+10)
- eY = zYMin + GetRandom(zHeight+10)
- tempE = AddVisualGear(eX, eY, vgtDust, 0, false)
- if tempE ~= 0 then
- g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(tempE)
- SetVisualGearValues(tempE, eX, eY, g3, g4, g5, g6, g7, 1, g9, bCol )
- end
-
-end
-
-function HandleBorderEffects()
-
- effectTimer = effectTimer + 1
- if effectTimer > 15 then --25
- effectTimer = 1
- for i = 1, #wX do
- BorderSpark(wX[i],wY[i],wWidth[i],wHeight[i], wCol[i])
- end
- end
-
-end
-
-----
--- old reflecting stuff from like 3 years ago lol
----
-
-function gearCanBeDeflected(gear)
-
- if (GetGearType(gear) == gtShell) or
- --(GetGearType(gear) == gtBee) or
- (GetGearType(gear) == gtGrenade) or
- (GetGearType(gear) == gtAirBomb) or
- --(GetGearType(gear) == gtRCPlane) or
- --(GetGearType(gear) == gtRope) or
- (GetGearType(gear) == gtClusterBomb) or
- (GetGearType(gear) == gtCluster) or
- (GetGearType(gear) == gtGasBomb) or
- --(GetGearType(gear) == gtSeduction) or
- (GetGearType(gear) == gtMine) or -------
- (GetGearType(gear) == gtMortar) or
- (GetGearType(gear) == gtHellishBomb) or
- (GetGearType(gear) == gtWatermelon) or
- (GetGearType(gear) == gtMelonPiece) or
- (GetGearType(gear) == gtEgg) or
- (GetGearType(gear) == gtDrill) or
- (GetGearType(gear) == gtBall) or
- (GetGearType(gear) == gtExplosives) or ------
- (GetGearType(gear) == gtFlame) or
- (GetGearType(gear) == gtPortal) or
- (GetGearType(gear) == gtDynamite) or
- (GetGearType(gear) == gtSMine) or
- --(GetGearType(gear) == gtKamikaze) or
- --(GetGearType(gear) == gtRCPlane) or
- --(GetGearType(gear) == gtCake) or
- --(GetGearType(gear) == gtHedgehog) or ------
- (GetGearType(gear) == gtKnife) or
- (GetGearType(gear) == gtJetpack) or -- test this and birdy plz
- (GetGearType(gear) == gtBirdy) or -- test this and birdy plz
- (GetGearType(gear) == gtSnowball) or
- (GetGearType(gear) == gtMolotov)
- then
- return(true)
- else
- return(false)
- end
-
-end
-
-function getThreatDamage(gear)
-
- --- damage amounts for weapons
- if (GetGearType(gear) == gtGrenade) or
- (GetGearType(gear) == gtClusterBomb) or
- (GetGearType(gear) == gtGasBomb) or
- (GetGearType(gear) == gtKnife) or
- (GetGearType(gear) == gtEgg) or
- (GetGearType(gear) == gtMolotov) or
- (GetGearType(gear) == gtHellishBomb) or
- (GetGearType(gear) == gtWatermelon) or
- (GetGearType(gear) == gtSMine)
- then
- dmg = 30
-
- elseif (GetGearType(gear) == gtMelonPiece) then
- dmg = 40
-
- elseif (GetGearType(gear) == gtAirBomb) or
- (GetGearType(gear) == gtDrill) or
- (GetGearType(gear) == gtMine) or
- (GetGearType(gear) == gtCluster) then
- dmg = 20
-
- elseif (GetGearType(gear) == gtFlame) or
- (GetGearType(gear) == gtPortal) or
- (GetGearType(gear) == gtDynamite)
- --(GetGearType(gear) == gtKamikaze) or
- --(GetGearType(gear) == gtRCPlane) or
-
- --(GetGearType(gear) == gtCake)
- then
- dmg = 0
-
- elseif (GetGearType(gear) == gtBall) then
- dmg = 1
-
- else --normal shell, snowball etc
- dmg = 65
- end
-
- return(dmg)
-
-end
-
-function setGearReflectionValues(gear)
-
- dmg = getThreatDamage(gear)
- setGearValue(gear,"damage",dmg)
- setGearValue(gear,"deflects",0)
-
- if (CurrentHedgehog ~= nil) then --and (gameStarted == true) then
- setGearValue(gear,"owner",GetHogClan(CurrentHedgehog)) -- NEW NEEDS CHANGE?
- else
- setGearValue(gear,"owner",10) -- nil
- end
-
-end
-
-function AddStruc(pX,pY, pType, pClan)
-
- sUID = sUID + 1
-
- tempG = AddGear(0, 0, gtTarget, 0, 0, 0, 0)
- SetGearPosition(tempG, pX, pY)
- setGearValue(tempG, "sUID", sUID)
-
- tempCirc = AddVisualGear(0,0,vgtCircle,0,true)
-
- SetVisualGearValues(tempCirc, 0, 0, 100, 255, 1, 100, 0, 500, 1, 0xFFFFFF00)
-
- table.insert(strucID, sUID)
- table.insert(strucType, pType)
- table.insert(strucGear,tempG)
- table.insert(strucClan,pClan)
- table.insert(strucCost,2)
-
- frameID = 0
- visualSprite = sprTarget
- madness = AddVisualGear(GetX(tempG), GetY(tempG), vgtStraightShot, 1, true,1)
- g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(madness) --g9
-
-
- if pType == loc("Reflector Shield") then
- table.insert(strucHealth,255)
-
- --SetVisualGearValues(madness, g1, g2, 0, 0, g5, frameID, g7, visualSprite, g9, g10 )
- --SetState(tempG, bor(GetState(tempG),gstInvisible) )
- --table.insert(strucAltDisplay, madness)
-
- else
- table.insert(strucHealth,1)
- --table.insert(strucAltDisplay, 1)
- end
-
- table.insert(strucCirc,tempCirc)
-
- table.insert(strucCircType, 1)
- if pType == loc("Bio-Filter") then
- table.insert(strucCircCol,colorRed)
- table.insert(strucCircRadius,1000)
- frameID = 7
- elseif pType == loc("Healing Station") then
- table.insert(strucCircCol,0xFF00FF00)
- --table.insert(strucCircCol,colorGreen)
- table.insert(strucCircRadius,500)
- frameID = 3
- elseif pType == loc("Respawner") then
- table.insert(strucCircCol,0xFF00FF00)
- --table.insert(strucCircCol,0xFF00FFFF)
- table.insert(strucCircRadius,75)
- runOnHogs(EnableHogResurrectionForThisClan)
- frameID = 1
- elseif pType == loc("Teleportation Node") then
- table.insert(strucCircCol,0x0000FFFF)
- table.insert(strucCircRadius,350)
- frameID = 6
- elseif pType == loc("Core") then
- table.insert(strucCircCol,0xFFFFFFFF)
- table.insert(strucCircRadius,350)
- elseif pType == loc("Generator") then
- table.insert(strucCircCol,0xFFFF00FF)
- table.insert(strucCircRadius,75)
- setGearValue(tempG, "power", 0)
- frameID = 2
- elseif pType == loc("Support Station") then
- table.insert(strucCircCol,0xFFFF00FF)
- table.insert(strucCircRadius,500)
- frameID = 4
- elseif pType == loc("Construction Station") then
- table.insert(strucCircCol,0xFFFFFFFF)
- table.insert(strucCircRadius,500)
- frameID = 8
- elseif pType == loc("Reflector Shield") then
- table.insert(strucCircCol,0xffae00ff)
- table.insert(strucCircRadius,750)
- frameID = 9
- elseif pType == loc("Weapon Filter") then
- table.insert(strucCircCol,0xa800ffff)
- table.insert(strucCircRadius,750)
- frameID = 5
- end
-
-
- SetVisualGearValues(madness, g1, g2, 0, 0, g5, frameID, g7, visualSprite, g9, g10 )
- SetState(tempG, bor(GetState(tempG),gstInvisible) )
- table.insert(strucAltDisplay, madness)
-
- -- may be needed for non gear-based structures
- --table.insert(strucX, GetX(tempG))
- --table.insert(strucY, GetY(tempG))
-
-end
-
--- this is basically onStructureDelete
--- we may need to expand it for non-gear structures later
-function CheckGearForStructureLink(gear)
-
- respawnerDestroyed = false
-
- for i = 1, #strucID do
- if strucID[i] == getGearValue(gear,"sUID") then
-
- if strucType[i] == loc("Respawner") then
- respawnerDestroyed = true
- end
-
- table.remove(strucID,i)
- table.remove(strucGear,i)
- table.remove(strucClan,i)
- table.remove(strucType,i)
- table.remove(strucCost,i)
- table.remove(strucHealth,i)
-
- DeleteVisualGear(strucCirc[i])
- table.remove(strucCirc,i)
-
- table.remove(strucCircCol,i)
- table.remove(strucCircRadius,i)
- table.remove(strucCircType,i)
-
- if strucAltDisplay[i] ~= 1 then
- DeleteVisualGear(strucAltDisplay[i])
- end
- table.remove(strucAltDisplay,i)
-
- end
- end
-
- if respawnerDestroyed == true then
- runOnHogs(RecalibrateRespawn)
- end
-
-end
-
--- called when we add a new respawner
-function EnableHogResurrectionForThisClan(gear)
- if GetHogClan(gear) == GetHogClan(CurrentHedgehog) then
- SetEffect(gear, heResurrectable, 1)
- end
-end
-
--- this is called when a respawner blows up
-function RecalibrateRespawn(gear)
-
- respawnerList = {}
- for i = 1, #strucID do
- if (strucType[i] == loc("Respawner")) and (strucClan[i] == GetHogClan(gear)) then
- table.insert(respawnerList, i)
- end
- end
-
- if #respawnerList >= 1 then
- SetEffect(gear, heResurrectable, 1)
- else
- SetEffect(gear, heResurrectable, 0)
- end
-
-end
-
---resposition dead hogs at a respawner if they own one
-function FindRespawner(gear)
-
- respawnerList = {}
- for i = 1, #strucID do
- if (strucType[i] == loc("Respawner")) and (strucClan[i] == GetHogClan(gear)) then
- table.insert(respawnerList, i)
- end
- end
-
- if #respawnerList >= 1 then
- i = GetRandom(#respawnerList)+1
- SetGearPosition(gear,GetX(strucGear[respawnerList[i]]),GetY(strucGear[respawnerList[i]])-25)
- AddVisualGear(GetX(gear), GetY(gear), vgtExplosion, 0, false)
- else -- (this should never happen, but just in case)
- SetEffect(gear, heResurrectable, 0)
- DeleteGear(gear)
- end
-
-end
-
-function onGearResurrect(gear)
- AddVisualGear(GetX(gear), GetY(gear), vgtExplosion, 0, false)
- FindRespawner(gear)
-end
-
-
-function CheckTeleport(gear, tX, tY)
-
- teleportOriginSuccessful = false
- teleportDestinationSuccessful = false
-
- for i = 1, #strucID do
-
- if (strucType[i] == loc("Teleportation Node")) and (strucClan[i] == GetHogClan(CurrentHedgehog)) then
-
- dist = GetDistFromGearToXY(CurrentHedgehog,GetX(strucGear[i]), GetY(strucGear[i]))
- if strucCircType[i] == 0 then
- NR = strucCircRadius[i]
- else
- NR = (48/100*strucCircRadius[i])/2
- --NR = div((div(48,100) * strucCircRadius[tempID]),2)
- end
- if dist <= NR*NR then
- teleportOriginSuccessful = true
- end
-
- dist = GetDistFromXYtoXY(tX,tY,GetX(strucGear[i]), GetY(strucGear[i]))
- if strucCircType[i] == 0 then
- NR = strucCircRadius[i]
- else
- NR = (48/100*strucCircRadius[i])/2
- --NR = div((div(48,100) * strucCircRadius[tempID]),2)
- end
- if dist <= NR*NR then
- teleportDestinationSuccessful = true
- end
-
- end
-
-
- end
-
- if ((teleportDestinationSuccessful == false) or (teleportOriginSuccessful == false)) then
- AddCaption(loc("Teleport Unsuccessful. Please teleport within a clan teleporter's sphere of influence."))
- SetGearTarget(gear, GetX(CurrentHedgehog), GetY(CurrentHedgehog))
- end
-
-end
-
---Check for proximity of gears to structures, and make structures behave accordingly
-function CheckProximity(gear)
-
- --if isAStructureEffectingGear(gear) then
-
- dist = GetDistFromGearToXY(gear, GetX(strucGear[tempID]), GetY(strucGear[tempID]))
-
- -- calculate my real radius if I am an aura
- if strucCircType[tempID] == 0 then
- NR = strucCircRadius[tempID]
- else
- NR = (48/100*strucCircRadius[tempID])/2
- --NR = div((div(48,100) * strucCircRadius[tempID]),2) -- doesn't work ffff
- --NR = div((48/100*strucCircRadius[tempID]),2) -- still works
-
- end
-
- -- we're in business
- if dist <= NR*NR then
-
-
- -- heal clan hogs
- if strucType[tempID] == loc("Healing Station") then
-
- if GetGearType(gear) == gtHedgehog then
- if GetHogClan(gear) == strucClan[tempID] then
-
- hogLife = GetHealth(gear) + 1
- if hogLife > 150 then
- hogLife = 150
- end
- SetHealth(gear, hogLife)
-
- -- change this to the med kit sprite health ++++s later
- tempE = AddVisualGear(GetX(strucGear[tempID]), GetY(strucGear[tempID]), vgtSmoke, 0, true)
- g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(tempE)
- SetVisualGearValues(tempE, g1, g2, g3, g4, g5, g6, g7, g8, g9, colorGreen )
-
-
- end
- end
-
- -- explode enemy clan hogs
- elseif strucType[tempID] == loc("Bio-Filter") then
-
- --tempE = AddVisualGear(GetX(strucGear[tempID]), GetY(strucGear[tempID]), vgtSmoke, 0, true)
- --g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(tempE)
- --SetVisualGearValues(tempE, g1, g2, g3, g4, g5, g6, g7, g8, g9, colorRed )
-
- if GetGearType(gear) == gtHedgehog then
- if (GetHogClan(gear) ~= strucClan[tempID]) and (GetHealth(gear) > 0) then
- AddGear(GetX(gear), GetY(gear), gtGrenade, 0, 0, 0, 1)
- end
- end
-
- -- were those weapons in your pocket, or were you just happy to see me?
- elseif strucType[tempID] == loc("Weapon Filter") then
-
- if GetGearType(gear) == gtHedgehog then
- if (GetHogClan(gear) ~= strucClan[tempID]) then
-
- for wpnIndex = 1, #atkArray do
- AddAmmo(gear, atkArray[wpnIndex][1], 0)
- end
-
- for wpnIndex = 1, #utilArray do
- AddAmmo(gear, utilArray[wpnIndex][1], 0)
- end
-
- AddAmmo(gear, amAirAttack, 100)
- AddAmmo(gear, amSwitch, 100)
- AddAmmo(gear, amSkip, 100)
-
- end
- end
-
- -- BOUNCE! POGO! POGO! POGO! POGO!
- elseif strucType[tempID] == loc("Reflector Shield") then
-
- -- add check for whose projectile it is
- if gearCanBeDeflected(gear) == true then
-
- gOwner = getGearValue(gear,"owner")
- gDeflects = getGearValue(gear,"deflects")
- gDmg = getGearValue(gear,"damage")
-
- if gDeflects >= 3 then
- DeleteGear(gear)
- AddVisualGear(GetX(gear), GetY(gear), vgtSmoke, 0, false)
- PlaySound(sndVaporize)
- elseif gOwner ~= strucClan[tempID] then
- --whether to vaporize gears or bounce them
- if gDmg ~= 0 then
- dx, dy = GetGearVelocity(gear)
-
- if (dx == 0) and (dy == 0) then
- -- static mine, explosive, etc encountered
- -- do nothing
- else
-
- --let's bounce something!
-
- --if dx == 0 then
- -- bounce away eggs
- -- dx = 0.5
- --end
-
- dx = dx*(-1)
- dy = dy*(-1)
- SetGearVelocity(gear,dx,dy)
- setGearValue(gear,"deflects",(gDeflects+1))
-
- AddVisualGear(GetX(gear), GetY(gear), vgtExplosion, 0, false)
- PlaySound(sndExplosion)
-
- strucHealth[tempID] = strucHealth[tempID] - gDmg
- strucCircCol[tempID] = strucCircCol[tempID] - gDmg
-
- if strucHealth[tempID] <= 0 then
- AddVisualGear(GetX(strucGear[tempID]), GetY(strucGear[tempID]), vgtExplosion, 0, false)
- DeleteGear(strucGear[tempID])
- PlaySound(sndExplosion)
- end
-
- end
-
- else
- DeleteGear(gear)
- AddVisualGear(GetX(gear), GetY(gear), vgtSmoke, 0, false)
- PlaySound(sndVaporize)
- end
- end
- end
-
- --mark as within range of a teleporter node
- elseif strucType[tempID] == loc("Teleportation Node") then
-
- if GetGearType(gear) == gtHedgehog then
- if GetHogClan(gear) == strucClan[tempID] then
- --tempE = AddVisualGear(GetX(strucGear[tempID]), GetY(strucGear[tempID]), vgtSmoke, 0, true)
-
- for i = 1, #sProx do
- if sProx[i][1] == loc("Teleportation Mode") then
- sProx[i][2] = true
- end
- end
-
- end
- end
-
- -- mark as within range of construction station
- -- and thus allow menu access to placement modes
- -- for girders, mines, sticky mines and barrels
- elseif strucType[tempID] == loc("Construction Station") then
-
- if GetGearType(gear) == gtHedgehog then
- if GetHogClan(gear) == strucClan[tempID] then
- tempE = AddVisualGear(GetX(strucGear[tempID]), GetY(strucGear[tempID]), vgtSmoke, 0, true)
-
- for i = 1, #sProx do
- if ((sProx[i][1] == loc("Girder Placement Mode"))
- or (sProx[i][1] == loc("Rubber Placement Mode"))
- or (sProx[i][1] == loc("Mine Placement Mode"))
- or (sProx[i][1] == loc("Sticky Mine Placement Mode"))
- or (sProx[i][1] == loc("Barrel Placement Mode")))
- then
- sProx[i][2] = true
- end
- end
-
-
- end
- end
-
- -- mark as within stupport station range
- -- and thus allow menu access to placement modes
- -- for weapon, utility, and med crates
- elseif strucType[tempID] == loc("Support Station") then
-
- if GetGearType(gear) == gtHedgehog then
- if GetHogClan(gear) == strucClan[tempID] then
- tempE = AddVisualGear(GetX(strucGear[tempID]), GetY(strucGear[tempID]), vgtSmoke, 0, true)
-
- for i = 1, #sProx do
- if ((sProx[i][1] == loc("Health Crate Placement Mode"))
- or (sProx[i][1] == loc("Weapon Crate Placement Mode"))
- or (sProx[i][1] == loc("Utility Crate Placement Mode")))
- then
- sProx[i][2] = true
- --AddCaption("wahey in a support station")
- end
- end
-
-
- end
- end
-
- -- doesn't do shit
- elseif strucType[tempID] == loc("Core") then
-
- if GetGearType(gear) == gtHedgehog then
- if GetHogClan(gear) == strucClan[tempID] then
-
- tempE = AddVisualGear(GetX(strucGear[tempID]), GetY(strucGear[tempID]), vgtSmoke, 0, true)
- g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(tempE)
- SetVisualGearValues(tempE, g1+20, g2, g3, g4, g5, g6, g7, g8, g9, GetClanColor(strucClan[tempID]) )
-
- tempE = AddVisualGear(GetX(strucGear[tempID]), GetY(strucGear[tempID]), vgtSmoke, 0, true)
- g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(tempE)
- SetVisualGearValues(tempE, g1-20, g2, g3, g4, g5, g6, g7, g8, g9, GetClanColor(strucClan[tempID]) )
-
- end
- end
-
- end
-
- end
-
- --end
-
-end
-
--- used to check if we need to run through all hogs or just currenthedgehog
-function isAStructureThatAppliesToMultipleGears(pID)
- if strucType[pID] == loc("Healing Station") or
- strucType[pID] == loc("Reflector Shield") or
- strucType[pID] == loc("Weapon Filter") or
- strucType[pID] == loc("Bio-Filter")
- then
- return(true)
- else
- return(false)
- end
-end
-
-function HandleStructures()
-
- for i = 1, #sProx do
- sProx[i][2] = false
-
- if sProx[i][1] == loc("Structure Placement Mode") then
- sProx[i][2] = true
- end
-
- end
-
- for i = 1, #strucID do
-
- g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(strucCirc[i])
- SetVisualGearValues(strucCirc[i], GetX(strucGear[i]), GetY(strucGear[i]), g3, g4, g5, g6, g7, strucCircRadius[i], g9, strucCircCol[i])
-
- tempID = i
-
- g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(strucAltDisplay[i]) --8000
- SetVisualGearValues(strucAltDisplay[i], GetX(strucGear[i]), GetY(strucGear[i]), 0, 0, g5, g6, 800000, sprTarget, g9, g10 )
-
-
-
- -- Check For proximity of stuff to our structures
- if isAStructureThatAppliesToMultipleGears(i) then
- runOnGears(CheckProximity)
- else -- only check prox on CurrentHedgehog
- CheckProximity(CurrentHedgehog)
- end
-
- if strucType[i] == loc("Core") then
- tempE = AddVisualGear(GetX(strucGear[i]), GetY(strucGear[i]), vgtSmoke, 0, true)
- g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(tempE)
- SetVisualGearValues(tempE, g1, g2, g3, g4, g5, g6, g7, g8, g9, GetClanColor(strucClan[i]) )
- elseif strucType[i] == loc("Reflector Shield") then
-
-
-
- --frameID = 1
- --visualSprite = sprTarget
- --g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(strucAltDisplay[i]) --frameID / g6
- --SetVisualGearValues(strucAltDisplay[i], GetX(strucGear[i]), GetY(strucGear[i]), 0, 0, g5, g6, 8000, visualSprite, g9, g10 )
-
- elseif strucType[i] == loc("Generator") then
-
- --frameID = 1
- --visualSprite = sprTarget
- --layer
- --tempE = AddVisualGear(GetX(strucGear[i]), GetY(strucGear[i]), vgtStraightShot, 1, true,1)
- --g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(tempE) --g9
- --SetVisualGearValues(tempE, g1, g2, 0, 0, g5, frameID, g7, visualSprite, g9, g10 )
- --SetState(strucGear[i], bor(GetState(strucGear[i]),gstInvisible) )
-
- --currently generate power for all clans.
- -- or should power only be generated for current clan?
- for z = 0, ClansCount-1 do
- if z == strucClan[i] then
- increaseGearValue(strucGear[i],"power")
- if getGearValue(strucGear[i],"power") == 10 then
- setGearValue(strucGear[i],"power",0)
- clanPower[z] = clanPower[z] + 1
- if clanPower[z] > 1000 then
- clanPower[z] = 1000
- end
- end
-
- end
- end
-
- end
-
- end
-
-
-
- -- this is kinda messy and gross (even more than usual), fix it up at some point
- -- it just assumes that if you have access to girders, it works for rubbers
- -- as that is what the struc implemenation means due to construction station
- anyUIProx = false
- for i = 1, #sProx do
-
- if sProx[i][1] == loc("Girder Placement Mode") then
- if sProx[i][2] == true then
- AddAmmo(CurrentHedgehog, amGirder, 100)
- AddAmmo(CurrentHedgehog, amRubber, 100)
- AddAmmo(CurrentHedgehog, amDrillStrike, 100)
- else
- AddAmmo(CurrentHedgehog, amGirder, 0)
- AddAmmo(CurrentHedgehog, amRubber, 0)
- AddAmmo(CurrentHedgehog, amDrillStrike, 0) -- new
- end
- elseif sProx[i][1] == loc("Teleportation Mode") then
- if sProx[i][2] == true then
- AddAmmo(CurrentHedgehog, amTeleport, 100)
- else
- AddAmmo(CurrentHedgehog, amTeleport, 0)
- end
- elseif sProx[i][1] == loc("Weapon Crate Placement Mode") then
- -- this is new stuff
- if sProx[i][2] == true then
- AddAmmo(CurrentHedgehog, amNapalm, 100)
- else
- AddAmmo(CurrentHedgehog, amNapalm, 0)
- end
- end
-
- if (sProx[i][2] == true) then
- anyUIProx = true
- end
-
- end
-
- -- doesn't do shit atm, maybe later when we add cores we can use this
- --if anyUIProx == true then --(and core is placed)
- -- AddAmmo(CurrentHedgehog, amAirAttack, 100)
- --else
- -- AddAmmo(CurrentHedgehog, amAirAttack, 0)
- --end
-
-
-end
-
-
-function checkForSpecialWeapons()
-
-
-
- if (GetCurAmmoType() == amAirAttack) then
- AddCaption(loc("Structure Placement Tool"),GetClanColor(GetHogClan(CurrentHedgehog)),capgrpAmmoinfo)
- elseif (GetCurAmmoType() == amDrillStrike) then
- AddCaption(loc("Object Placement Tool"),GetClanColor(GetHogClan(CurrentHedgehog)),capgrpAmmoinfo)
- elseif (GetCurAmmoType() == amNapalm) then
- AddCaption(loc("Crate Placement Tool"),GetClanColor(GetHogClan(CurrentHedgehog)),capgrpAmmoinfo)
- end
-
- lastWep = GetCurAmmoType()
-
-end
-
-----------------------------------------------------------
--- EXCERPTS OF ADAPTED HEDGE_EDITOR CODE FOLLOWS
-----------------------------------------------------------
--- experimental crap
-
-local landType = 0
------------------------------------------
--- tracking vars for save slash load purposes
------------------------------------------
-
-local hhs = {}
-
----------------------------------
--- crates are made of this stuff
----------------------------------
-placeholder = 20
- atkArray =
- {
- {amBazooka, "amBazooka", 0, loc("Bazooka"), 2*placeholder},
- --{amBee, "amBee", 0, loc("Homing Bee"), 4*placeholder},
- {amMortar, "amMortar", 0, loc("Mortar"), 1*placeholder},
- {amDrill, "amDrill", 0, loc("Drill Rocket"), 3*placeholder},
- {amSnowball, "amSnowball", 0, loc("Mudball"), 3*placeholder},
-
- {amGrenade, "amGrenade", 0, loc("Grenade"), 2*placeholder},
- {amClusterBomb, "amClusterBomb", 0, loc("Cluster Bomb"), 3*placeholder},
- {amMolotov, "amMolotov", 0, loc("Molotov Cocktail"), 3*placeholder},
- {amWatermelon, "amWatermelon", 0, loc("Watermelon Bomb"), 25*placeholder},
- {amHellishBomb, "amHellishBomb", 0, loc("Hellish Handgrenade"), 25*placeholder},
- {amGasBomb, "amGasBomb", 0, loc("Limburger"), 3*placeholder},
-
- {amShotgun, "amShotgun", 0, loc("Shotgun"), 2*placeholder},
- {amDEagle, "amDEagle", 0, loc("Desert Eagle"), 2*placeholder},
- {amFlamethrower,"amFlamethrower", 0, loc("Flamethrower"), 4*placeholder},
- {amSniperRifle, "amSniperRifle", 0, loc("Sniper Rifle"), 3*placeholder},
- --{amSineGun, "amSineGun", 0, loc("SineGun"), 6*placeholder},
- {amIceGun, "amIceGun", 0, loc("Freezer"), 15*placeholder},
- {amLandGun, "amLandGun", 0, loc("Land Sprayer"), 5*placeholder},
-
- {amFirePunch, "amFirePunch", 0, loc("Shoryuken"), 3*placeholder},
- {amWhip, "amWhip", 0, loc("Whip"), 1*placeholder},
- {amBaseballBat, "amBaseballBat", 0, loc("Baseball Bat"), 7*placeholder},
- --{amKamikaze, "amKamikaze", 0, loc("Kamikaze"), 1*placeholder},
- {amSeduction, "amSeduction", 0, loc("Seduction"), 1*placeholder},
- {amHammer, "amHammer", 0, loc("Hammer"), 1*placeholder},
-
- {amMine, "amMine", 0, loc("Mine"), 1*placeholder},
- {amDynamite, "amDynamite", 0, loc("Dynamite"), 9*placeholder},
- {amCake, "amCake", 0, loc("Cake"), 25*placeholder},
- {amBallgun, "amBallgun", 0, loc("Ballgun"), 40*placeholder},
- --{amRCPlane, "amRCPlane", 0, loc("RC Plane"), 25*placeholder},
- {amSMine, "amSMine", 0, loc("Sticky Mine"), 5*placeholder},
-
- --{amAirAttack, "amAirAttack", 0, loc("Air Attack"), 10*placeholder},
- --{amMineStrike, "amMineStrike", 0, loc("Mine Strike"), 15*placeholder},
- --{amDrillStrike, "amDrillStrike", 0, loc("Drill Strike"), 15*placeholder},
- --{amNapalm, "amNapalm", 0, loc("Napalm"), 15*placeholder},
- --{amPiano, "amPiano", 0, loc("Piano Strike"), 40*placeholder},
-
- {amKnife, "amKnife", 0, loc("Cleaver"), 2*placeholder},
-
- {amBirdy, "amBirdy", 0, loc("Birdy"), 7*placeholder}
-
- }
-
- utilArray =
- {
- {amBlowTorch, "amBlowTorch", 0, loc("Blowtorch"), 4*placeholder},
- {amPickHammer, "amPickHammer", 0, loc("Pickhammer"), 2*placeholder},
- --{amGirder, "amGirder", 0, loc("Girder"), 4*placeholder},
- --{amRubber, "amRubber", 0, loc("Rubber Band"), 5*placeholder},
- {amPortalGun, "amPortalGun", 0, loc("Personal Portal Device"), 15*placeholder},
-
- {amRope, "amRope", 0, loc("Rope"), 7*placeholder},
- {amParachute, "amParachute", 0, loc("Parachute"), 2*placeholder},
- --{amTeleport, "amTeleport", 0, loc("Teleport"), 6*placeholder},
- {amJetpack, "amJetpack", 0, loc("Flying Saucer"), 8*placeholder},
-
- {amInvulnerable, "amInvulnerable", 0, loc("Invulnerable"), 5*placeholder},
- {amLaserSight, "amLaserSight", 0, loc("Laser Sight"), 2*placeholder},
- {amVampiric, "amVampiric", 0, loc("Vampirism"), 6*placeholder},
-
- {amLowGravity, "amLowGravity", 0, loc("Low Gravity"), 4*placeholder},
- {amExtraDamage, "amExtraDamage", 0, loc("Extra Damage"), 6*placeholder},
- {amExtraTime, "amExtraTime", 0, loc("Extra Time"), 8*placeholder}
-
- --{amResurrector, "amResurrector", 0, loc("Resurrector"), 8*placeholder},
- --{amTardis, "amTardis", 0, loc("Tardis"), 2*placeholder},
-
- --{amSwitch, "amSwitch", 0, loc("Switch Hog"), 4*placeholder}
- }
-
-----------------------------
--- hog and map editting junk
-----------------------------
-
- local reducedSpriteIDArray = {
- sprBigDigit, sprKowtow, sprBee, sprExplosion50, sprGirder
- }
-
- local reducedSpriteTextArray = {
- "sprBigDigit", "sprKowtow", "sprBee", "sprExplosion50", "sprGirder"
- }
-
-----------------------------
--- placement shite
-----------------------------
-
-local cGear = nil -- detects placement of girders and objects (using airattack)
-local curWep = amNothing
-
--- primary placement categories
-local cIndex = 1 -- category index
-local cat = {
- "Girder Placement Mode",
- "Rubber Placement Mode",
- "Mine Placement Mode",
- "Sticky Mine Placement Mode",
- "Barrel Placement Mode",
- "Health Crate Placement Mode",
- "Weapon Crate Placement Mode",
- "Utility Crate Placement Mode",
- --"Target Placement Mode",
- --"Cleaver Placement Mode",
-
- --"Advanced Repositioning Mode",
- --"Tagging Mode",
- --"Sprite Testing Mode",
- --"Sprite Placement Mode",
- "Structure Placement Mode"
- }
-
-
- sProx = {
- {loc("Girder Placement Mode"),false},
- {loc("Rubber Placement Mode"),false},
- {loc("Mine Placement Mode"),false},
- {loc("Sticky Mine Placement Mode"),false},
- {loc("Barrel Placement Mode"),false},
- {loc("Health Crate Placement Mode"),false},
- {loc("Weapon Crate Placement Mode"),false},
- {loc("Utility Crate Placement Mode"),false},
- --{loc("Target Placement Mode"),false},
- --{loc("Cleaver Placement Mode"),false},
-
- --{loc("Advanced Repositioning Mode"),false},
- --{loc("Tagging Mode"),false},
- --{loc("Sprite Testing Mode"),false},
- --{loc("Sprite Placement Mode"),false},
- {loc("Structure Placement Mode"),false},
- {loc("Teleportation Mode"),false}
- }
-
-
-local pMode = {} -- pMode contains custom subsets of the main categories
-local pIndex = 1
-
-local genTimer = 0
-
-local CGR = 1 -- current girder rotation, we actually need this as HW remembers what rotation you last used
-
-local placedX = {}
-local placedY = {}
-local placedSpec = {}
-local placedSuperSpec = {}
-local placedType = {}
-local placedCount = 0
-
-local sCirc -- circle that appears around selected gears
-local sGear = nil
-local closestDist
-local closestGear = nil
-
-local tCirc = {} -- array of circles that appear around tagged gears
-
-------------------------
--- SOME GENERAL METHODS
-------------------------
-
-function GetDistFromGearToXY(gear, g2X, g2Y)
-
- g1X, g1Y = GetGearPosition(gear)
- q = g1X - g2X
- w = g1Y - g2Y
-
- return ( (q*q) + (w*w) )
-
-end
-
-function GetDistFromXYtoXY(a, b, c, d)
- q = a - c
- w = b - d
- return ( (q*q) + (w*w) )
-end
-
-function SelectGear(gear)
-
- d = GetDistFromGearToXY(gear, placedX[placedCount], placedY[placedCount])
-
- if d < closestDist then
- closestDist = d
- closestGear = gear
- end
-
-end
-
--- essentially called when user clicks the mouse
--- with girders or an airattack
-function PlaceObject(x,y)
-
- placedX[placedCount] = x
- placedY[placedCount] = y
- placedType[placedCount] = cat[cIndex]
- placedSpec[placedCount] = pMode[pIndex]
-
- if (clanUsedExtraTime[GetHogClan(CurrentHedgehog)] == true) and (cat[cIndex] == "Utility Crate Placement Mode") and (utilArray[pIndex][1] == amExtraTime) then
- AddCaption(loc("You may only use 1 Extra Time per turn."),0xffba00ff,capgrpVolume)
- PlaySound(sndDenied)
- elseif (clanCratesSpawned[GetHogClan(CurrentHedgehog)] > 4) and ( (cat[cIndex] == "Health Crate Placement Mode") or (cat[cIndex] == "Utility Crate Placement Mode") or (cat[cIndex] == "Weapon Crate Placement Mode") ) then
- AddCaption(loc("You may only spawn 5 crates per turn."),0xffba00ff,capgrpVolume)
- PlaySound(sndDenied)
- elseif (XYisInRect(x,y, clanBoundsSX[GetHogClan(CurrentHedgehog)],clanBoundsSY[GetHogClan(CurrentHedgehog)],clanBoundsEX[GetHogClan(CurrentHedgehog)],clanBoundsEY[GetHogClan(CurrentHedgehog)]) == true)
- and (clanPower[GetHogClan(CurrentHedgehog)] >= placedExpense)
- then
-
-
-
- if cat[cIndex] == "Girder Placement Mode" then
- PlaceGirder(x, y, CGR)
- placedSpec[placedCount] = CGR
- elseif cat[cIndex] == "Rubber Placement Mode" then
- PlaceSprite(x,y, sprAmRubber, CGR, nil, nil, nil, nil, lfBouncy)
- --PlaceGirder(x, y, CGR)
- placedSpec[placedCount] = CGR
- elseif cat[cIndex] == "Target Placement Mode" then
- gear = AddGear(x, y, gtTarget, 0, 0, 0, 0)
- elseif cat[cIndex] == "Cleaver Placement Mode" then
- gear = AddGear(x, y, gtKnife, 0, 0, 0, 0)
- elseif cat[cIndex] == "Health Crate Placement Mode" then
- gear = SpawnHealthCrate(x,y)
- SetHealth(gear, pMode[pIndex])
- setGearValue(gear,"caseType","med")
- clanCratesSpawned[GetHogClan(CurrentHedgehog)] = clanCratesSpawned[GetHogClan(CurrentHedgehog)] +1
- elseif cat[cIndex] == "Weapon Crate Placement Mode" then
- gear = SpawnAmmoCrate(x, y, atkArray[pIndex][1])
- placedSpec[placedCount] = atkArray[pIndex][2]
- setGearValue(gear,"caseType","ammo")
- setGearValue(gear,"contents",atkArray[pIndex][2])
- clanCratesSpawned[GetHogClan(CurrentHedgehog)] = clanCratesSpawned[GetHogClan(CurrentHedgehog)] +1
- elseif cat[cIndex] == "Utility Crate Placement Mode" then
- gear = SpawnUtilityCrate(x, y, utilArray[pIndex][1])
- placedSpec[placedCount] = utilArray[pIndex][2]
- setGearValue(gear,"caseType","util")
- setGearValue(gear,"contents",utilArray[pIndex][2])
- if utilArray[pIndex][1] == amExtraTime then
- clanUsedExtraTime[GetHogClan(CurrentHedgehog)] = true
- end
- clanCratesSpawned[GetHogClan(CurrentHedgehog)] = clanCratesSpawned[GetHogClan(CurrentHedgehog)] +1
- elseif cat[cIndex] == "Barrel Placement Mode" then
- gear = AddGear(x, y, gtExplosives, 0, 0, 0, 0)
- SetHealth(gear, pMode[pIndex])
- elseif cat[cIndex] == "Mine Placement Mode" then
- gear = AddGear(x, y, gtMine, 0, 0, 0, 0)
- SetTimer(gear, pMode[pIndex])
- elseif cat[cIndex] == "Sticky Mine Placement Mode" then
- gear = AddGear(x, y, gtSMine, 0, 0, 0, 0)
- elseif cat[cIndex] == "Advanced Repositioning Mode" then
-
- if pMode[pIndex] == "Selection Mode" then
- closestDist = 999999999
- closestGear = nil -- just in case
- sGear = nil
- runOnGears(SelectGear)
- sGear = closestGear
- closestGear = nil
- elseif pMode[pIndex] == "Placement Mode" then
- if sGear ~= nil then
- SetGearPosition(sGear, x, y)
- end
- end
-
- elseif cat[cIndex] == "Tagging Mode" then
-
- closestDist = 999999999
- closestGear = nil
- sGear = nil
- runOnGears(SelectGear)
-
-
- if closestGear ~= nil then
-
- if getGearValue(closestGear,"tag") == nil then
-
- --if there is no tag, add a victory/failure tag and circle
- setGearValue(closestGear, "tCirc",AddVisualGear(0,0,vgtCircle,0,true))
-
- --AddCaption("circ added",0xffba00ff,capgrpVolume)
-
- if pMode[pIndex] == "Tag Victory Mode" then
- setGearValue(closestGear, "tag","victory")
- SetVisualGearValues(getGearValue(closestGear,"tCirc"), 0, 0, 100, 255, 1, 10, 0, 40, 3, 0xff0000ff)
- elseif pMode[pIndex] == "Tag Failure Mode" then
- setGearValue(closestGear, "tag","failure")
- SetVisualGearValues(getGearValue(closestGear,"tCirc"), 0, 0, 100, 255, 1, 10, 0, 40, 3, 0x0000ffff)
- end
-
-
- else
- -- remove tag and delete circ
- --AddCaption("circ removed",0xffba00ff,capgrpVolume)
- setGearValue(closestGear, "tag", nil)
- DeleteVisualGear(getGearValue(closestGear,"tCirc"))
- setGearValue(closestGear, "tCirc", nil)
- end
-
- end
-
-
- elseif cat[cIndex] == "Sprite Testing Mode" then
-
- frameID = 1
- visualSprite = reducedSpriteIDArray[pIndex]
- --visualSprite = spriteIDArray[pIndex]
- tempE = AddVisualGear(x, y, vgtStraightShot, 0, true)
- g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(tempE)
- SetVisualGearValues(tempE, g1, g2, 0, 0, g5, frameID, g7, visualSprite, g9, g10 )
- --sprHorizonLong crashes game, so does skyL, as does flake
-
- -- reduced list of cool sprites
- -- sprBigDigit, sprKnife, sprFrozenHog, sprKowtow, sprBee, sprExplosion50, sprPiano, sprChunk, sprHHTelepMask, sprSeduction, sprSwitch, sprGirder,
- --sprAMAmmos, sprAMSlotKeys, sprTurnsLeft, sprExplosivesRoll + maybe some others like the health case, arrows, etc
-
- elseif cat[cIndex] == "Sprite Placement Mode" then
-
- PlaceSprite(x,y, reducedSpriteIDArray[pIndex], 1, nil, nil, nil, nil, landType)
- --PlaceGirder(x, y, CGR)
- placedSpec[placedCount] = reducedSpriteTextArray[pIndex]
- placedSuperSpec[placedCount] = landType
-
- if landType == lfIce then
- placedSuperSpec[placedCount] = "lfIce"
- elseif landType == lfIndestructible then
- placedSuperSpec[placedCount] = "lfIndestructible"
- elseif landType == lfBouncy then
- placedSuperSpec[placedCount] = "lfBouncy"
- else
- placedSuperSpec[placedCount] = "lfNormal"
- end
-
- elseif cat[cIndex] == "Structure Placement Mode" then
-
- AddStruc(x,y, pMode[pIndex],GetHogClan(CurrentHedgehog))
-
- end
-
- clanPower[GetHogClan(CurrentHedgehog)] = clanPower[GetHogClan(CurrentHedgehog)] - placedExpense
- placedCount = placedCount + 1
-
- else
- if (clanPower[GetHogClan(CurrentHedgehog)] >= placedExpense) then
- AddCaption(loc("Invalid Placement"),0xffba00ff,capgrpVolume)
- else
- AddCaption(loc("Insufficient Power"),0xffba00ff,capgrpVolume)
- end
- PlaySound(sndDenied)
- end
-
-
-end
-
--- called when user changes primary selection
--- either via up/down keys
--- or selecting girder/airattack
-function RedefineSubset()
-
- pIndex = 1
- pMode = {}
- placedExpense = 1
-
- if cat[cIndex] == "Girder Placement Mode" then
- pIndex = CGR
- pMode = {"Girder"}
- -- pCount = 1
- elseif cat[cIndex] == "Rubber Placement Mode" then
- pIndex = CGR
- pMode = {"Rubber"}
- placedExpense = 3
- -- pCount = 1???
- elseif cat[cIndex] == "Target Placement Mode" then
- pMode = {"Standard Target"}
- elseif cat[cIndex] == "Cleaver Placement Mode" then
- pMode = {"Standard Cleaver"}
- elseif cat[cIndex] == "Barrel Placement Mode" then
- --pMode = {1,50,75,100}
- pMode = {50}
- placedExpense = 10
- elseif cat[cIndex] == "Health Crate Placement Mode" then
- --pMode = {25,50,75,100}
- pMode = {25}
- placedExpense = 5
- elseif cat[cIndex] == "Weapon Crate Placement Mode" then
- for i = 1, #atkArray do
- pMode[i] = atkArray[i][4] -- was [2]
- --placedExpense = atkArray[5]
- end
- placedExpense = 30
- elseif cat[cIndex] == "Utility Crate Placement Mode" then
- for i = 1, #utilArray do
- pMode[i] = utilArray[i][4] -- was [2]
- --placedExpense = utilArray[5]
- end
- placedExpense = 20
- elseif cat[cIndex] == "Mine Placement Mode" then
- --pMode = {1,1000,2000,3000,4000,5000,0}
- pMode = {1,1000,2000,3000,4000,5000}
- -- 0 is dud right, or is that nil?
- placedExpense = 15
- elseif cat[cIndex] == "Sticky Mine Placement Mode" then
- pMode = {"Normal Sticky Mine"}
- --elseif cat[cIndex] == "Gear Repositioning Mode" then
- -- for i = 1, #hhs do
- -- pMode[i] = GetHogName(hhs[i])
- -- end
- placedExpense = 20
- elseif cat[cIndex] == "Advanced Repositioning Mode" then
- pMode = {"Selection Mode","Placement Mode"}
- elseif cat[cIndex] == "Tagging Mode" then
- pMode = {"Tag Victory Mode","Tag Failure Mode"}
- elseif cat[cIndex] == "Sprite Testing Mode" or cat[cIndex] == "Sprite Placement Mode" then
- --for i = 1, #spriteTextArray do
- -- pMode[i] = spriteTextArray[i]
- --end
- for i = 1, #reducedSpriteTextArray do
- pMode[i] = reducedSpriteTextArray[i]
- end
- placedExpense = 100
- elseif cat[cIndex] == "Structure Placement Mode" then
- pMode = {loc("Healing Station"), loc("Bio-Filter"), loc("Weapon Filter"), loc("Reflector Shield"), loc("Respawner"),loc("Teleportation Node"),--[[loc("Core"),]]loc("Generator"),loc("Construction Station"),loc("Support Station")}
- --placedExpense = 100
- end
-
-
-
-
-end
-
--- called in onGameTick()
-function HandleHedgeEditor()
-
- if CurrentHedgehog ~= nil then
-
- if wallsVisible == true then
- HandleBorderEffects()
- end
-
- if (CurrentHedgehog ~= nil) and (TurnTimeLeft ~= TurnTime) then
- if (lastWep ~= GetCurAmmoType()) then
- checkForSpecialWeapons()
- end
- end
-
- genTimer = genTimer + 1
-
- if genTimer >= 100 then
-
- genTimer = 0
-
- DrawTag(1)
-
- HandleStructures()
-
- curWep = GetCurAmmoType()
-
- -- change to girder mode on weapon swap
- if (cIndex ~= 1) and (curWep == amGirder) then
- cIndex = 1
- RedefineSubset()
- elseif (cIndex ~=2) and (curWep == amRubber) then
- cIndex = 2
- RedefineSubset()
- -- change to generic mode if girder no longer selected
- elseif (cIndex == 1) and (curWep ~= amGirder) then
- cIndex = 3 -- was 2
- RedefineSubset()
- elseif (cIndex == 2) and (curWep ~= amRubber) then
- cIndex = 3 --new
- RedefineSubset()
-
- end
-
- -- update display selection criteria
- if (curWep == amGirder) or (curWep == amAirAttack) or (curWep == amNapalm) or (curWep == amDrillStrike) or (curWep == amRubber) then
-
- ---------------hooolllllyyyy fucking shit this
- -- code is a broken mess now
- -- it was redesigned and compromised three times
- -- so now it is a mess trying to do what it was
- -- never designed to do
- -- needs to be rewritten badly sadface
- -- this bit here catches the new 3 types of weapons
- if ((sProx[cIndex][1] == loc("Structure Placement Mode") and (curWep ~= amAirAttack))) then
- updatePlacementDisplay(1)
- elseif (sProx[cIndex][1] == loc("Health Crate Placement Mode")) or
- (sProx[cIndex][1] == loc("Weapon Crate Placement Mode")) or
- (sProx[cIndex][1] == loc("Utility Crate Placement Mode")) then
- if curWep ~= amNapalm then
- updatePlacementDisplay(1)
- end
-
- elseif (sProx[cIndex][1] == loc("Mine Placement Mode")) or
- (sProx[cIndex][1] == loc("Sticky Mine Placement Mode")) or
- (sProx[cIndex][1] == loc("Barrel Placement Mode")) then
- if curWep ~= amDrillStrike then
- updatePlacementDisplay(1)
- end
-
- end
-
- --this is called when it happens that we have placement
- --mode selected and we are looking at something
- --we shouldn't be allowed to look at, as would be the case
- --when you WERE allowed to look at it, but then maybe
- --a bomb blows up the structure that was granting you
- --that ability
- if (sProx[cIndex][2] ~= true) then
- updatePlacementDisplay(1)
- else
- updateCost()
- end
-
-
- AddCaption(cat[cIndex],0xffba00ff,capgrpMessage)
- AddCaption(pMode[pIndex],0xffba00ff,capgrpMessage2)
- wallsVisible = true
- else
- wallsVisible = false
- end
-
- end
-
- end
-
- --update selected gear display
- if (cat[cIndex] == "Advanced Repositioning Mode") and (sGear ~= nil) then
- SetVisualGearValues(sCirc, GetX(sGear), GetY(sGear), 100, 255, 1, 10, 0, 300, 3, 0xff00ffff)
- elseif (cat[cIndex] == "Tagging Mode") then
- if (sGear ~= nil) or (closestGear ~= nil) then
- SetVisualGearValues(sCirc, GetX(sGear), GetY(sGear), 0, 1, 1, 10, 0, 1, 1, 0x00000000)
- closestGear = nil
- sGear = nil
- end
- end
-
- -- some kind of target detected, tell me your story
- if cGear ~= nil then
-
- x,y = GetGearTarget(cGear)
-
- if GetGearType(cGear) == gtAirAttack then
- DeleteGear(cGear)
- PlaceObject(x, y)
- elseif GetGearType(cGear) == gtTeleport then
-
- CheckTeleport(cGear, x, y)
- cGear = nil
- elseif GetGearType(cGear) == gtGirder then
-
- CGR = GetState(cGear)
-
- -- improve rectangle test based on CGR when you can be bothered
- --if TestRectForObstacle(x-20, y-20, x+20, y+20, true) then
- -- AddCaption("Invalid Girder Placement",0xffba00ff,capgrpVolume)
- --else
- PlaceObject(x, y)
- --end
-
- -- this allows the girder tool to be used like a mining laser
-
- --[[
-
- if CGR < 4 then
- AddGear(x, y, gtGrenade, 0, 0, 0, 1)
- elseif CGR == 4 then
- g = AddGear(x-30, y, gtGrenade, 0, 0, 0, 1)
- g = AddGear(x+30, y, gtGrenade, 0, 0, 0, 1)
- elseif CGR == 5 then -------
- g = AddGear(x+30, y+30, gtGrenade, 0, 0, 0, 1)
- g = AddGear(x-30, y-30, gtGrenade, 0, 0, 0, 1)
- elseif CGR == 6 then
- g = AddGear(x, y+30, gtGrenade, 0, 0, 0, 1)
- g = AddGear(x, y-30, gtGrenade, 0, 0, 0, 1)
- elseif CGR == 7 then -------
- g = AddGear(x+30, y-30, gtGrenade, 0, 0, 0, 1)
- g = AddGear(x-30, y+30, gtGrenade, 0, 0, 0, 1)
- end
-]]
- end
-
- end
-
-end
-
---------------------------------------------------
--- EVENT HANDLERS
---------------------------------------------------
-
-function onTaunt(t)
- tauntString = tauntString .. t
- if (tauntString == "101") and (clanPower[GetHogClan(CurrentHedgehog)] < 300) and (clanBoon[GetHogClan(CurrentHedgehog)] == false) then
- clanBoon[GetHogClan(CurrentHedgehog)] = true
- clanPower[GetHogClan(CurrentHedgehog)] = 1000
- AddCaption(loc("The Great Hog in the sky sees your sadness and grants you a boon."))
- end
-end
-
----------------------------------------------------------------
--- Cycle through selection subsets (by changing pIndex, pMode)
--- i.e health of barrels, medikits,
--- timer of mines
--- contents of crates
--- gears to reposition etc.
----------------------------------------------------------------
-
-function updateCost()
-
- if pMode[pIndex] == loc("Healing Station") then
- placedExpense = 50
- elseif pMode[pIndex] == loc("Weapon Filter") then
- placedExpense = 50
- elseif pMode[pIndex] == loc("Bio-Filter") then
- placedExpense = 100
- elseif pMode[pIndex] == loc("Respawner") then
- placedExpense = 300
- elseif pMode[pIndex] == loc("Teleportation Node") then
- placedExpense = 30
- elseif pMode[pIndex] == loc("Support Station") then
- placedExpense = 50
- elseif pMode[pIndex] == loc("Construction Station") then
- placedExpense = 50
- elseif pMode[pIndex] == loc("Generator") then
- placedExpense = 300
- elseif pMode[pIndex] == loc("Reflector Shield") then
- placedExpense = 200
- elseif pMode[pIndex] == loc("Core") then
- placedExpense = 1
- elseif cat[cIndex] == loc("Weapon Crate Placement Mode") then
- placedExpense = atkArray[pIndex][5]
- elseif cat[cIndex] == loc("Utility Crate Placement Mode") then
- placedExpense = utilArray[pIndex][5]
- end
-
- AddCaption(loc("Cost") .. ": " .. placedExpense,0xffba00ff,capgrpAmmostate)
-
-end
-
-function onLeft()
-
- pIndex = pIndex - 1
- if pIndex == 0 then
- pIndex = #pMode
- end
-
- if (curWep == amGirder) or (curWep == amAirAttack) or (curWep == amNapalm) or (curWep == amDrillStrike) then
- AddCaption(pMode[pIndex],0xffba00ff,capgrpMessage2)
- updateCost()
- end
-
-
-end
-
-function onRight()
-
- pIndex = pIndex + 1
- if pIndex > #pMode then
- pIndex = 1
- end
-
- if (curWep == amGirder) or (curWep == amAirAttack) or (curWep == amNapalm) or (curWep == amDrillStrike) then
- AddCaption(pMode[pIndex],0xffba00ff,capgrpMessage2)
- updateCost()
- end
-
-end
-
-
-function updatePlacementDisplay(pDir)
-
- foundMatch = false
- while(foundMatch == false) do
- cIndex = cIndex + pDir
-
- if (cIndex == 1) or (cIndex == 2) then --1 --we no longer hit girder by normal means
- cIndex = #cat
- elseif cIndex > #cat then
- cIndex = 3 -- 2 ----we no longer hit girder by normal means
- end
-
- -- new way of doing things
- -- sProx[cIndex][2] == true just basically means we have ACCESS to something
- -- but that doesn't neccessarily mean we are in the correct content menu, anymore
- -- so we need to refine this a little
- if sProx[cIndex][2] == true then
- if (GetCurAmmoType() == amNapalm) then
- if (sProx[cIndex][1] == loc("Health Crate Placement Mode")) or
- (sProx[cIndex][1] == loc("Weapon Crate Placement Mode")) or
- (sProx[cIndex][1] == loc("Utility Crate Placement Mode"))
- then
- foundMatch = true
- end
- elseif (GetCurAmmoType() == amDrillStrike) then
- if (sProx[cIndex][1] == loc("Mine Placement Mode")) or
- (sProx[cIndex][1] == loc("Sticky Mine Placement Mode")) or
- (sProx[cIndex][1] == loc("Barrel Placement Mode"))
- then
- foundMatch = true
- end
- elseif (GetCurAmmoType() == amAirAttack) then
- if sProx[cIndex][1] == loc("Structure Placement Mode") then
- foundMatch = true
- end
- end
- end
-
-
- if foundMatch == true then
- --if sProx[cIndex][2] == true then
- -- normal case (scrolling through)
- --foundMatch = true
- RedefineSubset()
- updateCost()
- end
-
- end
-
-end
-
----------------------------------------------------------
--- Cycle through primary categories (by changing cIndex)
--- i.e mine, sticky mine, barrels
--- health/weapon/utility crate, placement of gears
----------------------------------------------------------
-function onUp()
-
- if ((curWep == amAirAttack) or (curWep == amNapalm) or (curWep == amDrillStrike) ) then
- updatePlacementDisplay(-1)
- end
-
-end
-
-function onDown()
-
- if ((curWep == amAirAttack) or (curWep == amNapalm) or (curWep == amDrillStrike) ) then
- updatePlacementDisplay(1)
- end
-
-end
-
-----------------------------
--- standard event handlers
-----------------------------
-
-function onGameInit()
-
- Explosives = 0
- MinesNum = 0
-
- EnableGameFlags(gfInfAttack)
-
-
- RedefineSubset()
-
-end
-
-function initialSetup(gear)
-
- FindPlace(gear, false, clanBoundsSX[GetHogClan(gear)], clanBoundsEX[GetHogClan(gear)],true)
-
- -- for now, everyone should have this stuff
- AddAmmo(gear, amAirAttack, 100)
- AddAmmo(gear, amSwitch, 100)
- AddAmmo(gear, amSkip, 100)
-
-end
-
-function onGameStart()
-
- trackTeams()
-
- ShowMission (
- loc("CONSTRUCTION MODE"),
- loc("a Hedgewars mini-game"),
- " " .. "|" ..
- loc("Build a fortress and destroy your enemy.") .. "|" ..
- --loc("Defend your core from the enemy.") .. "|" ..
- loc("There are a variety of structures available to aid you.") .. "|" ..
- loc("Use the air-attack weapons and the arrow keys to select structures.") .. "|" ..
- " " .. "|" ..
- --loc("Core") .. ": " .. loc("Allows placement of structures.") .. "|" ..
- loc("Healing Station") .. ": " .. loc("Grants nearby hogs life-regeneration.") .. "|" ..
- loc("Bio-Filter") .. ": " .. loc("Aggressively removes enemy hedgehogs.") .. "|" ..
- loc("Weapon Filter") .. ": " .. loc("Dematerializes weapons and equipment carried by enemy hedgehogs.") .. "|" ..
- loc("Reflector Shield") .. ": " .. loc("Reflects enemy projectiles.") .. "|" ..
-
- loc("Generator") .. ": " .. loc("Generates power.") .. "|" ..
- loc("Respawner") .. ": " .. loc("Resurrects dead hedgehogs.") .. "|" ..
- loc("Teleporation Node") .. ": " .. loc("Allows free teleportation between other nodes.") .. "|" ..
- loc("Construction Station") .. ": " .. loc("Allows placement of girders, rubber-bands, mines, sticky mines and barrels.") .. "|" ..
- loc("Support Station") .. ": " .. loc("Allows the placement of weapons, utiliites, and health crates.") .. "|" ..
-
-
- " " .. "|" ..
- --" " .. "|" ..
- "", 4, 5000
- )
-
-
- sCirc = AddVisualGear(0,0,vgtCircle,0,true)
- SetVisualGearValues(sCirc, 0, 0, 100, 255, 1, 10, 0, 40, 3, 0x00000000)
-
- for i = 0, ClansCount-1 do
- clanPower[i] = 500
- clanBoon[i] = false
- clanLWepIndex[i] = 1 -- for ease of use let's track this stuff
- clanLUtilIndex[i] = 1
- clanLGearIndex[i] = 1
- clanUsedExtraTime[i] = false
- clanCratesSpawned[i] = 0
-
-
- end
-
- tMapWidth = RightX - LeftX
- tMapHeight = WaterLine - TopY
- clanInterval = div(tMapWidth,ClansCount)
-
- for i = 1, ClansCount do
-
- clanBoundsSX[i-1] = LeftX+(clanInterval*i)-clanInterval+20
- clanBoundsSY[i-1] = TopY
- clanBoundsEX[i-1] = LeftX+(clanInterval*i)-20
- clanBoundsEY[i-1] = WaterLine
-
- --top and bottom
- AddWall(LeftX+(clanInterval*i)-clanInterval,TopY,clanInterval,margin,GetClanColor(i-1))
- AddWall(LeftX+(clanInterval*i)-clanInterval,WaterLine-25,clanInterval,margin,GetClanColor(i-1))
-
- --add a wall to the left and right
- AddWall(LeftX+(clanInterval*i)-clanInterval+20,TopY,margin,WaterLine,GetClanColor(i-1))
- AddWall(LeftX+(clanInterval*i)-20,TopY,margin,WaterLine,GetClanColor(i-1))
-
- end
-
- runOnHogs(initialSetup)
-
-end
-
-
-function onNewTurn()
-
- tauntString = ""
- clanPower[GetHogClan(CurrentHedgehog)] = clanPower[GetHogClan(CurrentHedgehog)] + 50
- clanUsedExtraTime[GetHogClan(CurrentHedgehog)] = false
- clanCratesSpawned[GetHogClan(CurrentHedgehog)] = 0
-
-end
-
-function onGameTick()
- HandleHedgeEditor()
-end
-
-function isATrackedGear(gear)
- if (GetGearType(gear) == gtHedgehog) or
- (GetGearType(gear) == gtTarget) or
- (GetGearType(gear) == gtCase)
- then
- return(true)
- else
- return(false)
- end
-end
-
--- track hedgehogs and placement gears
-function onGearAdd(gear)
-
- if GetGearType(gear) == gtHedgehog then
- --table.insert(hhs, gear)
- elseif (GetGearType(gear) == gtAirAttack) or (GetGearType(gear) == gtTeleport) or (GetGearType(gear) == gtGirder) then
- cGear = gear
-
- end
-
- if isATrackedGear(gear) then
- trackGear(gear)
- elseif gearCanBeDeflected(gear) then
- trackGear(gear)
- setGearReflectionValues(gear)
- end
-
-end
-
-function onGearDelete(gear)
-
- if GetGearType(gear) == gtTarget then
- CheckGearForStructureLink(gear)
- end
-
- if (GetGearType(gear) == gtAirAttack) or (GetGearType(gear) == gtTeleport) or (GetGearType(gear) == gtGirder) then
- cGear = nil
- end
-
- if (isATrackedGear(gear) or gearCanBeDeflected(gear)) then
-
- if getGearValue(gear, "tCirc") ~= nil then
- DeleteVisualGear(getGearValue(gear, "tCirc"))
- end
-
- trackDeletion(gear)
-
- end
-
-end
+---------------------------------------------------------
+--- LE CONSTRUCTION MODE 0.7 (badly adapted from Hedge Editor 0.5)
+---------------------------------------------------------
+-- a hedgewars gameplay mode by mikade
+-- special thanks to all who helped test and offered suggestions
+-- additional thanks to sheepluva/nemo for adding some extra hooks
+
+-- (to do)
+-- investigate loc not working on addcaptions
+-- check for parsecommands before porting to dev
+-- test onUpDown more extensively as it may need revision (check for amRubber etc)
+-- test localization of weapons and utils and stuff
+
+-- try posistion grenades in Harmer so it blows hogs away from the struc
+-- and don't explode too close to the struc
+
+-- additional/previous balance ideas
+-- based on your money?
+-- based on the number of strucs/gens you own?
+-- based on your existing arsenal?
+-- limit number of crates spawned per round perhaps (done)
+-- limit number of generators?
+
+------------------------------------------------------------------------------
+--version history
+------------------------------------------------------------------------------
+--v0.1
+-- concept test
+
+--v0.2
+-- improved documentation (in script and in game)
+-- improved localisation (or is it? at any rate, crate placement should now say e.g. Bazooka and not amBazooka)
+-- added variable weapon costs (based on the values from Vatten's Consumerism script)
+
+-- added reflector shield (still needs work and balancing)
+-- added weapon-filter (probably ok)
+
+-- enabled super weapons like ballgun, rcplane, watermelon, hellish to test balance
+-- reduce max money to 1000
+
+--v0.3
+-- some /s removed
+
+--v0.4
+-- added support for per hog ammo (hopefully)
+
+--v0.5 (dev)
+-- added somewhat horribly implemented support for different structure sprites
+-- added override pictures for ammo menu
+-- added override message on wep select to aid understanding
+-- split menu into/between weps/parts: struc, crates, gears
+-- add a limit on crates per turn
+-- add a limit on extra time per turn
+-- add a test level
+-- restored rubber placement
+-- cleaned up some of the code a bit and removed about 280 lines of code I didn't need, lol
+
+--v0.6 (dev)
+-- added magic dance
+
+--v.07 (pushed to repo)
+-- added a cfg file
+-- removed another 903 lines of code we weren't using (lol)
+
+--------------------------------
+-- STRUCTURES LIST / IDEAS
+--------------------------------
+
+--Healing Station: heals hogs to 150 life
+--Teleportation Node: allows teleporting to any other teleporter nodes
+--Bio-filter: explodes enemy hogs
+--Respawner: if you have one of these, any slain hogs are resurrected here :D
+--Generator: generates energy (used to buy stuff, and possibly later other strucs might have upkeep costs)
+--Support Station: allows purchasing of weapons, utilities, and med-crates
+--Construction Station: allows purchasing of girders, rubber, mines, sticky mines, barrels
+--Reflector Shield: reflect projectiles
+--Weapon Filter: kill all equipement of enemy hogs passing through this area.
+
+
+--to make the grill more attractive make it vaporize flying saucers
+--and also rope, and maybe incoming gears
+
+-- make healing thing also cure poison
+-- maybe make poison more virulent and dangerous
+
+--(not implemented / abandoned ideas)
+-- Core: allows construction of other structures.
+-- Automated Turret (think red drones from space invasion)
+-- Canon (gives access to 3 fireballs per turn while near)
+-- something that allows control of wind/water
+-- Gravity Field generator : triggers world gravity change
+
+-- structures consume power over time and
+-- maybe you can turn structures OFF/ON, manually to save power.
+
+-- hacking
+-- allow hacking of structures, either being able to use enemy structures,
+-- or turning a team's structures against them.
+
+-- pylons
+-- allow hogs to put down a pylon-like gear which then allows the core
+-- to place other structures/objects within the pylon's sphere of influence
+-- this would allow aggressive structure advancement
+
+-- resouce mining?
+-- you could designate something like mines, that you could get close to,
+-- "pick up", and then "drop" back at a central location to simulate
+-- resource mining. bit complicated/meh, normal power generators probably easier
+
+-- it would be cool to have a red mask we could apply over girders
+-- that would indicate they were Indestructible
+
+HedgewarsScriptLoad("/Scripts/Locale.lua")
+HedgewarsScriptLoad("/Scripts/Tracker.lua")
+
+----------------------------------------------
+-- STRUC CRAP
+----------------------------------------------
+
+strucID = {}
+strucGear = {}
+strucClan = {}
+strucType = {}
+strucCost = {}
+strucHealth = {}
+
+strucCirc = {}
+strucCircCol = {}
+strucCircRadius = {}
+strucCircType = {}
+strucAltDisplay = {}
+
+placedExpense = 0
+
+tempID = nil
+
+sUID = 0
+
+colorRed = 0xff0000ff
+colorGreen = 0x00ff00ff
+
+clanBoundsSX = {}
+clanBoundsSY = {}
+clanBoundsEX = {}
+clanBoundsEY = {}
+
+clanPower = {}
+clanBoon = {}
+clanID = {}
+clanLStrucIndex = {}
+
+clanLWepIndex = {} -- for ease of use let's track this stuff
+clanLUtilIndex = {}
+clanLGearIndex = {}
+clanUsedExtraTime = {}
+clanCratesSpawned = {}
+
+effectTimer = 0
+
+wallsVisible = false
+wX = {}
+wY = {}
+wWidth = {}
+wHeight = {}
+wCol = {}
+margin = 20
+
+tauntString = ""
+
+vTag = {}
+lastWep = nil
+
+function HideTags()
+
+ for i = 0, 2 do
+ SetVisualGearValues(vTag[i],0,0,0,0,0,1,0, 0, 240000, 0xffffff00)
+ end
+
+end
+
+function DrawTag(i)
+
+ zoomL = 1.3
+
+ xOffset = 40
+
+ if i == 0 then
+ yOffset = 40
+ tCol = 0xffba00ff
+ tValue = 30--TimeLeft
+ elseif i == 1 then
+ zoomL = 1.1
+ xOffset = 45
+ yOffset = 70
+ tCol = 0x00ff00ff
+ tValue = clanPower[GetHogClan(CurrentHedgehog)]
+ elseif i == 2 then
+ zoomL = 1.1
+ xOffset = 60 + 35
+ yOffset = 70
+ tCol = 0xa800ffff
+ tValue = 10--shieldHealth - 80
+ end
+
+ DeleteVisualGear(vTag[i])
+ vTag[i] = AddVisualGear(0, 0, vgtHealthTag, 0, false)
+ g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(vTag[i])
+ SetVisualGearValues (
+ vTag[i], --id
+ -div(ScreenWidth,2) + xOffset, --xoffset
+ ScreenHeight - yOffset, --yoffset
+ 0, --dx
+ 0, --dy
+ zoomL, --zoom
+ 1, --~= 0 means align to screen
+ g7, --frameticks
+ tValue, --value
+ 240000, --timer
+ tCol --GetClanColor( GetHogClan(CurrentHedgehog) )
+ )
+
+end
+
+function onScreenResize()
+
+ -- redraw Tags so that their screen locations are updated
+ if (CurrentHedgehog ~= nil) then
+ DrawTag(0)
+ DrawTag(1)
+ DrawTag(2)
+ end
+
+end
+
+function XYisInRect(px, py, psx, psy, pex, pey)
+
+ if (px > psx) and (px < pex) and (py > psy) and (py < pey) then
+ return(true)
+ else
+ return(false)
+ end
+
+end
+
+function AddWall(zXMin,zYMin, zWidth, zHeight, zCol)
+
+ table.insert(wX, zXMin)
+ table.insert(wY, zYMin)
+ table.insert(wWidth, zWidth)
+ table.insert(wHeight, zHeight)
+ table.insert(wCol, zCol)
+
+end
+
+function BorderSpark(zXMin,zYMin, zWidth, zHeight, bCol)
+
+ eX = zXMin + GetRandom(zWidth+10)
+ eY = zYMin + GetRandom(zHeight+10)
+ tempE = AddVisualGear(eX, eY, vgtDust, 0, false)
+ if tempE ~= 0 then
+ g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(tempE)
+ SetVisualGearValues(tempE, eX, eY, g3, g4, g5, g6, g7, 1, g9, bCol )
+ end
+
+end
+
+function HandleBorderEffects()
+
+ effectTimer = effectTimer + 1
+ if effectTimer > 15 then --25
+ effectTimer = 1
+ for i = 1, #wX do
+ BorderSpark(wX[i],wY[i],wWidth[i],wHeight[i], wCol[i])
+ end
+ end
+
+end
+
+----
+-- old reflecting stuff from like 3 years ago lol
+---
+
+function gearCanBeDeflected(gear)
+
+ if (GetGearType(gear) == gtShell) or
+ --(GetGearType(gear) == gtBee) or
+ (GetGearType(gear) == gtGrenade) or
+ (GetGearType(gear) == gtAirBomb) or
+ --(GetGearType(gear) == gtRCPlane) or
+ --(GetGearType(gear) == gtRope) or
+ (GetGearType(gear) == gtClusterBomb) or
+ (GetGearType(gear) == gtCluster) or
+ (GetGearType(gear) == gtGasBomb) or
+ --(GetGearType(gear) == gtSeduction) or
+ (GetGearType(gear) == gtMine) or -------
+ (GetGearType(gear) == gtMortar) or
+ (GetGearType(gear) == gtHellishBomb) or
+ (GetGearType(gear) == gtWatermelon) or
+ (GetGearType(gear) == gtMelonPiece) or
+ (GetGearType(gear) == gtEgg) or
+ (GetGearType(gear) == gtDrill) or
+ (GetGearType(gear) == gtBall) or
+ (GetGearType(gear) == gtExplosives) or ------
+ (GetGearType(gear) == gtFlame) or
+ (GetGearType(gear) == gtPortal) or
+ (GetGearType(gear) == gtDynamite) or
+ (GetGearType(gear) == gtSMine) or
+ --(GetGearType(gear) == gtKamikaze) or
+ --(GetGearType(gear) == gtRCPlane) or
+ --(GetGearType(gear) == gtCake) or
+ --(GetGearType(gear) == gtHedgehog) or ------
+ (GetGearType(gear) == gtKnife) or
+ (GetGearType(gear) == gtJetpack) or -- test this and birdy plz
+ (GetGearType(gear) == gtBirdy) or -- test this and birdy plz
+ (GetGearType(gear) == gtSnowball) or
+ (GetGearType(gear) == gtMolotov)
+ then
+ return(true)
+ else
+ return(false)
+ end
+
+end
+
+function getThreatDamage(gear)
+
+ --- damage amounts for weapons
+ if (GetGearType(gear) == gtGrenade) or
+ (GetGearType(gear) == gtClusterBomb) or
+ (GetGearType(gear) == gtGasBomb) or
+ (GetGearType(gear) == gtKnife) or
+ (GetGearType(gear) == gtEgg) or
+ (GetGearType(gear) == gtMolotov) or
+ (GetGearType(gear) == gtHellishBomb) or
+ (GetGearType(gear) == gtWatermelon) or
+ (GetGearType(gear) == gtSMine)
+ then
+ dmg = 30
+
+ elseif (GetGearType(gear) == gtMelonPiece) then
+ dmg = 40
+
+ elseif (GetGearType(gear) == gtAirBomb) or
+ (GetGearType(gear) == gtDrill) or
+ (GetGearType(gear) == gtMine) or
+ (GetGearType(gear) == gtCluster) then
+ dmg = 20
+
+ elseif (GetGearType(gear) == gtFlame) or
+ (GetGearType(gear) == gtPortal) or
+ (GetGearType(gear) == gtDynamite)
+ --(GetGearType(gear) == gtKamikaze) or
+ --(GetGearType(gear) == gtRCPlane) or
+
+ --(GetGearType(gear) == gtCake)
+ then
+ dmg = 0
+
+ elseif (GetGearType(gear) == gtBall) then
+ dmg = 1
+
+ else --normal shell, snowball etc
+ dmg = 65
+ end
+
+ return(dmg)
+
+end
+
+function setGearReflectionValues(gear)
+
+ dmg = getThreatDamage(gear)
+ setGearValue(gear,"damage",dmg)
+ setGearValue(gear,"deflects",0)
+
+ if (CurrentHedgehog ~= nil) then --and (gameStarted == true) then
+ setGearValue(gear,"owner",GetHogClan(CurrentHedgehog)) -- NEW NEEDS CHANGE?
+ else
+ setGearValue(gear,"owner",10) -- nil
+ end
+
+end
+
+function AddStruc(pX,pY, pType, pClan)
+
+ sUID = sUID + 1
+
+ tempG = AddGear(0, 0, gtTarget, 0, 0, 0, 0)
+ SetGearPosition(tempG, pX, pY)
+ setGearValue(tempG, "sUID", sUID)
+
+ tempCirc = AddVisualGear(0,0,vgtCircle,0,true)
+
+ SetVisualGearValues(tempCirc, 0, 0, 100, 255, 1, 100, 0, 500, 1, 0xFFFFFF00)
+
+ table.insert(strucID, sUID)
+ table.insert(strucType, pType)
+ table.insert(strucGear,tempG)
+ table.insert(strucClan,pClan)
+ table.insert(strucCost,2)
+
+ frameID = 0
+ visualSprite = sprTarget
+ madness = AddVisualGear(GetX(tempG), GetY(tempG), vgtStraightShot, 1, true,1)
+ g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(madness) --g9
+
+
+ if pType == loc("Reflector Shield") then
+ table.insert(strucHealth,255)
+
+ --SetVisualGearValues(madness, g1, g2, 0, 0, g5, frameID, g7, visualSprite, g9, g10 )
+ --SetState(tempG, bor(GetState(tempG),gstInvisible) )
+ --table.insert(strucAltDisplay, madness)
+
+ else
+ table.insert(strucHealth,1)
+ --table.insert(strucAltDisplay, 1)
+ end
+
+ table.insert(strucCirc,tempCirc)
+
+ table.insert(strucCircType, 1)
+ if pType == loc("Bio-Filter") then
+ table.insert(strucCircCol,colorRed)
+ table.insert(strucCircRadius,1000)
+ frameID = 7
+ elseif pType == loc("Healing Station") then
+ table.insert(strucCircCol,0xFF00FF00)
+ --table.insert(strucCircCol,colorGreen)
+ table.insert(strucCircRadius,500)
+ frameID = 3
+ elseif pType == loc("Respawner") then
+ table.insert(strucCircCol,0xFF00FF00)
+ --table.insert(strucCircCol,0xFF00FFFF)
+ table.insert(strucCircRadius,75)
+ runOnHogs(EnableHogResurrectionForThisClan)
+ frameID = 1
+ elseif pType == loc("Teleportation Node") then
+ table.insert(strucCircCol,0x0000FFFF)
+ table.insert(strucCircRadius,350)
+ frameID = 6
+ elseif pType == loc("Core") then
+ table.insert(strucCircCol,0xFFFFFFFF)
+ table.insert(strucCircRadius,350)
+ elseif pType == loc("Generator") then
+ table.insert(strucCircCol,0xFFFF00FF)
+ table.insert(strucCircRadius,75)
+ setGearValue(tempG, "power", 0)
+ frameID = 2
+ elseif pType == loc("Support Station") then
+ table.insert(strucCircCol,0xFFFF00FF)
+ table.insert(strucCircRadius,500)
+ frameID = 4
+ elseif pType == loc("Construction Station") then
+ table.insert(strucCircCol,0xFFFFFFFF)
+ table.insert(strucCircRadius,500)
+ frameID = 8
+ elseif pType == loc("Reflector Shield") then
+ table.insert(strucCircCol,0xffae00ff)
+ table.insert(strucCircRadius,750)
+ frameID = 9
+ elseif pType == loc("Weapon Filter") then
+ table.insert(strucCircCol,0xa800ffff)
+ table.insert(strucCircRadius,750)
+ frameID = 5
+ end
+
+
+ SetVisualGearValues(madness, g1, g2, 0, 0, g5, frameID, g7, visualSprite, g9, g10 )
+ SetState(tempG, bor(GetState(tempG),gstInvisible) )
+ table.insert(strucAltDisplay, madness)
+
+ -- may be needed for non gear-based structures
+ --table.insert(strucX, GetX(tempG))
+ --table.insert(strucY, GetY(tempG))
+
+end
+
+-- this is basically onStructureDelete
+-- we may need to expand it for non-gear structures later
+function CheckGearForStructureLink(gear)
+
+ respawnerDestroyed = false
+
+ for i = 1, #strucID do
+ if strucID[i] == getGearValue(gear,"sUID") then
+
+ if strucType[i] == loc("Respawner") then
+ respawnerDestroyed = true
+ end
+
+ table.remove(strucID,i)
+ table.remove(strucGear,i)
+ table.remove(strucClan,i)
+ table.remove(strucType,i)
+ table.remove(strucCost,i)
+ table.remove(strucHealth,i)
+
+ DeleteVisualGear(strucCirc[i])
+ table.remove(strucCirc,i)
+
+ table.remove(strucCircCol,i)
+ table.remove(strucCircRadius,i)
+ table.remove(strucCircType,i)
+
+ if strucAltDisplay[i] ~= 1 then
+ DeleteVisualGear(strucAltDisplay[i])
+ end
+ table.remove(strucAltDisplay,i)
+
+ end
+ end
+
+ if respawnerDestroyed == true then
+ runOnHogs(RecalibrateRespawn)
+ end
+
+end
+
+-- called when we add a new respawner
+function EnableHogResurrectionForThisClan(gear)
+ if GetHogClan(gear) == GetHogClan(CurrentHedgehog) then
+ SetEffect(gear, heResurrectable, 1)
+ end
+end
+
+-- this is called when a respawner blows up
+function RecalibrateRespawn(gear)
+
+ respawnerList = {}
+ for i = 1, #strucID do
+ if (strucType[i] == loc("Respawner")) and (strucClan[i] == GetHogClan(gear)) then
+ table.insert(respawnerList, i)
+ end
+ end
+
+ if #respawnerList >= 1 then
+ SetEffect(gear, heResurrectable, 1)
+ else
+ SetEffect(gear, heResurrectable, 0)
+ end
+
+end
+
+--resposition dead hogs at a respawner if they own one
+function FindRespawner(gear)
+
+ respawnerList = {}
+ for i = 1, #strucID do
+ if (strucType[i] == loc("Respawner")) and (strucClan[i] == GetHogClan(gear)) then
+ table.insert(respawnerList, i)
+ end
+ end
+
+ if #respawnerList >= 1 then
+ i = GetRandom(#respawnerList)+1
+ SetGearPosition(gear,GetX(strucGear[respawnerList[i]]),GetY(strucGear[respawnerList[i]])-25)
+ AddVisualGear(GetX(gear), GetY(gear), vgtExplosion, 0, false)
+ else -- (this should never happen, but just in case)
+ SetEffect(gear, heResurrectable, 0)
+ DeleteGear(gear)
+ end
+
+end
+
+function onGearResurrect(gear)
+ AddVisualGear(GetX(gear), GetY(gear), vgtExplosion, 0, false)
+ FindRespawner(gear)
+end
+
+
+function CheckTeleport(gear, tX, tY)
+
+ teleportOriginSuccessful = false
+ teleportDestinationSuccessful = false
+
+ for i = 1, #strucID do
+
+ if (strucType[i] == loc("Teleportation Node")) and (strucClan[i] == GetHogClan(CurrentHedgehog)) then
+
+ dist = GetDistFromGearToXY(CurrentHedgehog,GetX(strucGear[i]), GetY(strucGear[i]))
+ if strucCircType[i] == 0 then
+ NR = strucCircRadius[i]
+ else
+ NR = (48/100*strucCircRadius[i])/2
+ --NR = div((div(48,100) * strucCircRadius[tempID]),2)
+ end
+ if dist <= NR*NR then
+ teleportOriginSuccessful = true
+ end
+
+ dist = GetDistFromXYtoXY(tX,tY,GetX(strucGear[i]), GetY(strucGear[i]))
+ if strucCircType[i] == 0 then
+ NR = strucCircRadius[i]
+ else
+ NR = (48/100*strucCircRadius[i])/2
+ --NR = div((div(48,100) * strucCircRadius[tempID]),2)
+ end
+ if dist <= NR*NR then
+ teleportDestinationSuccessful = true
+ end
+
+ end
+
+
+ end
+
+ if ((teleportDestinationSuccessful == false) or (teleportOriginSuccessful == false)) then
+ AddCaption(loc("Teleport Unsuccessful. Please teleport within a clan teleporter's sphere of influence."))
+ SetGearTarget(gear, GetX(CurrentHedgehog), GetY(CurrentHedgehog))
+ end
+
+end
+
+--Check for proximity of gears to structures, and make structures behave accordingly
+function CheckProximity(gear)
+
+ --if isAStructureEffectingGear(gear) then
+
+ dist = GetDistFromGearToXY(gear, GetX(strucGear[tempID]), GetY(strucGear[tempID]))
+
+ -- calculate my real radius if I am an aura
+ if strucCircType[tempID] == 0 then
+ NR = strucCircRadius[tempID]
+ else
+ NR = (48/100*strucCircRadius[tempID])/2
+ --NR = div((div(48,100) * strucCircRadius[tempID]),2) -- doesn't work ffff
+ --NR = div((48/100*strucCircRadius[tempID]),2) -- still works
+
+ end
+
+ -- we're in business
+ if dist <= NR*NR then
+
+
+ -- heal clan hogs
+ if strucType[tempID] == loc("Healing Station") then
+
+ if GetGearType(gear) == gtHedgehog then
+ if GetHogClan(gear) == strucClan[tempID] then
+
+ hogLife = GetHealth(gear) + 1
+ if hogLife > 150 then
+ hogLife = 150
+ end
+ SetHealth(gear, hogLife)
+
+ -- change this to the med kit sprite health ++++s later
+ tempE = AddVisualGear(GetX(strucGear[tempID]), GetY(strucGear[tempID]), vgtSmoke, 0, true)
+ g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(tempE)
+ SetVisualGearValues(tempE, g1, g2, g3, g4, g5, g6, g7, g8, g9, colorGreen )
+
+
+ end
+ end
+
+ -- explode enemy clan hogs
+ elseif strucType[tempID] == loc("Bio-Filter") then
+
+ --tempE = AddVisualGear(GetX(strucGear[tempID]), GetY(strucGear[tempID]), vgtSmoke, 0, true)
+ --g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(tempE)
+ --SetVisualGearValues(tempE, g1, g2, g3, g4, g5, g6, g7, g8, g9, colorRed )
+
+ if GetGearType(gear) == gtHedgehog then
+ if (GetHogClan(gear) ~= strucClan[tempID]) and (GetHealth(gear) > 0) then
+ AddGear(GetX(gear), GetY(gear), gtGrenade, 0, 0, 0, 1)
+ end
+ end
+
+ -- were those weapons in your pocket, or were you just happy to see me?
+ elseif strucType[tempID] == loc("Weapon Filter") then
+
+ if GetGearType(gear) == gtHedgehog then
+ if (GetHogClan(gear) ~= strucClan[tempID]) then
+
+ for wpnIndex = 1, #atkArray do
+ AddAmmo(gear, atkArray[wpnIndex][1], 0)
+ end
+
+ for wpnIndex = 1, #utilArray do
+ AddAmmo(gear, utilArray[wpnIndex][1], 0)
+ end
+
+ AddAmmo(gear, amAirAttack, 100)
+ AddAmmo(gear, amSwitch, 100)
+ AddAmmo(gear, amSkip, 100)
+
+ end
+ end
+
+ -- BOUNCE! POGO! POGO! POGO! POGO!
+ elseif strucType[tempID] == loc("Reflector Shield") then
+
+ -- add check for whose projectile it is
+ if gearCanBeDeflected(gear) == true then
+
+ gOwner = getGearValue(gear,"owner")
+ gDeflects = getGearValue(gear,"deflects")
+ gDmg = getGearValue(gear,"damage")
+
+ if gDeflects >= 3 then
+ DeleteGear(gear)
+ AddVisualGear(GetX(gear), GetY(gear), vgtSmoke, 0, false)
+ PlaySound(sndVaporize)
+ elseif gOwner ~= strucClan[tempID] then
+ --whether to vaporize gears or bounce them
+ if gDmg ~= 0 then
+ dx, dy = GetGearVelocity(gear)
+
+ if (dx == 0) and (dy == 0) then
+ -- static mine, explosive, etc encountered
+ -- do nothing
+ else
+
+ --let's bounce something!
+
+ --if dx == 0 then
+ -- bounce away eggs
+ -- dx = 0.5
+ --end
+
+ dx = dx*(-1)
+ dy = dy*(-1)
+ SetGearVelocity(gear,dx,dy)
+ setGearValue(gear,"deflects",(gDeflects+1))
+
+ AddVisualGear(GetX(gear), GetY(gear), vgtExplosion, 0, false)
+ PlaySound(sndExplosion)
+
+ strucHealth[tempID] = strucHealth[tempID] - gDmg
+ strucCircCol[tempID] = strucCircCol[tempID] - gDmg
+
+ if strucHealth[tempID] <= 0 then
+ AddVisualGear(GetX(strucGear[tempID]), GetY(strucGear[tempID]), vgtExplosion, 0, false)
+ DeleteGear(strucGear[tempID])
+ PlaySound(sndExplosion)
+ end
+
+ end
+
+ else
+ DeleteGear(gear)
+ AddVisualGear(GetX(gear), GetY(gear), vgtSmoke, 0, false)
+ PlaySound(sndVaporize)
+ end
+ end
+ end
+
+ --mark as within range of a teleporter node
+ elseif strucType[tempID] == loc("Teleportation Node") then
+
+ if GetGearType(gear) == gtHedgehog then
+ if GetHogClan(gear) == strucClan[tempID] then
+ --tempE = AddVisualGear(GetX(strucGear[tempID]), GetY(strucGear[tempID]), vgtSmoke, 0, true)
+
+ for i = 1, #sProx do
+ if sProx[i][1] == loc("Teleportation Mode") then
+ sProx[i][2] = true
+ end
+ end
+
+ end
+ end
+
+ -- mark as within range of construction station
+ -- and thus allow menu access to placement modes
+ -- for girders, mines, sticky mines and barrels
+ elseif strucType[tempID] == loc("Construction Station") then
+
+ if GetGearType(gear) == gtHedgehog then
+ if GetHogClan(gear) == strucClan[tempID] then
+ tempE = AddVisualGear(GetX(strucGear[tempID]), GetY(strucGear[tempID]), vgtSmoke, 0, true)
+
+ for i = 1, #sProx do
+ if ((sProx[i][1] == loc("Girder Placement Mode"))
+ or (sProx[i][1] == loc("Rubber Placement Mode"))
+ or (sProx[i][1] == loc("Mine Placement Mode"))
+ or (sProx[i][1] == loc("Sticky Mine Placement Mode"))
+ or (sProx[i][1] == loc("Barrel Placement Mode")))
+ then
+ sProx[i][2] = true
+ end
+ end
+
+
+ end
+ end
+
+ -- mark as within stupport station range
+ -- and thus allow menu access to placement modes
+ -- for weapon, utility, and med crates
+ elseif strucType[tempID] == loc("Support Station") then
+
+ if GetGearType(gear) == gtHedgehog then
+ if GetHogClan(gear) == strucClan[tempID] then
+ tempE = AddVisualGear(GetX(strucGear[tempID]), GetY(strucGear[tempID]), vgtSmoke, 0, true)
+
+ for i = 1, #sProx do
+ if ((sProx[i][1] == loc("Health Crate Placement Mode"))
+ or (sProx[i][1] == loc("Weapon Crate Placement Mode"))
+ or (sProx[i][1] == loc("Utility Crate Placement Mode")))
+ then
+ sProx[i][2] = true
+ --AddCaption("wahey in a support station")
+ end
+ end
+
+
+ end
+ end
+
+ -- doesn't do shit
+ elseif strucType[tempID] == loc("Core") then
+
+ if GetGearType(gear) == gtHedgehog then
+ if GetHogClan(gear) == strucClan[tempID] then
+
+ tempE = AddVisualGear(GetX(strucGear[tempID]), GetY(strucGear[tempID]), vgtSmoke, 0, true)
+ g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(tempE)
+ SetVisualGearValues(tempE, g1+20, g2, g3, g4, g5, g6, g7, g8, g9, GetClanColor(strucClan[tempID]) )
+
+ tempE = AddVisualGear(GetX(strucGear[tempID]), GetY(strucGear[tempID]), vgtSmoke, 0, true)
+ g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(tempE)
+ SetVisualGearValues(tempE, g1-20, g2, g3, g4, g5, g6, g7, g8, g9, GetClanColor(strucClan[tempID]) )
+
+ end
+ end
+
+ end
+
+ end
+
+ --end
+
+end
+
+-- used to check if we need to run through all hogs or just currenthedgehog
+function isAStructureThatAppliesToMultipleGears(pID)
+ if strucType[pID] == loc("Healing Station") or
+ strucType[pID] == loc("Reflector Shield") or
+ strucType[pID] == loc("Weapon Filter") or
+ strucType[pID] == loc("Bio-Filter")
+ then
+ return(true)
+ else
+ return(false)
+ end
+end
+
+function HandleStructures()
+
+ for i = 1, #sProx do
+ sProx[i][2] = false
+
+ if sProx[i][1] == loc("Structure Placement Mode") then
+ sProx[i][2] = true
+ end
+
+ end
+
+ for i = 1, #strucID do
+
+ g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(strucCirc[i])
+ SetVisualGearValues(strucCirc[i], GetX(strucGear[i]), GetY(strucGear[i]), g3, g4, g5, g6, g7, strucCircRadius[i], g9, strucCircCol[i])
+
+ tempID = i
+
+ g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(strucAltDisplay[i]) --8000
+ SetVisualGearValues(strucAltDisplay[i], GetX(strucGear[i]), GetY(strucGear[i]), 0, 0, g5, g6, 800000, sprTarget, g9, g10 )
+
+
+
+ -- Check For proximity of stuff to our structures
+ if isAStructureThatAppliesToMultipleGears(i) then
+ runOnGears(CheckProximity)
+ else -- only check prox on CurrentHedgehog
+ CheckProximity(CurrentHedgehog)
+ end
+
+ if strucType[i] == loc("Core") then
+ tempE = AddVisualGear(GetX(strucGear[i]), GetY(strucGear[i]), vgtSmoke, 0, true)
+ g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(tempE)
+ SetVisualGearValues(tempE, g1, g2, g3, g4, g5, g6, g7, g8, g9, GetClanColor(strucClan[i]) )
+ elseif strucType[i] == loc("Reflector Shield") then
+
+
+
+ --frameID = 1
+ --visualSprite = sprTarget
+ --g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(strucAltDisplay[i]) --frameID / g6
+ --SetVisualGearValues(strucAltDisplay[i], GetX(strucGear[i]), GetY(strucGear[i]), 0, 0, g5, g6, 8000, visualSprite, g9, g10 )
+
+ elseif strucType[i] == loc("Generator") then
+
+ --frameID = 1
+ --visualSprite = sprTarget
+ --layer
+ --tempE = AddVisualGear(GetX(strucGear[i]), GetY(strucGear[i]), vgtStraightShot, 1, true,1)
+ --g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(tempE) --g9
+ --SetVisualGearValues(tempE, g1, g2, 0, 0, g5, frameID, g7, visualSprite, g9, g10 )
+ --SetState(strucGear[i], bor(GetState(strucGear[i]),gstInvisible) )
+
+ --currently generate power for all clans.
+ -- or should power only be generated for current clan?
+ for z = 0, ClansCount-1 do
+ if z == strucClan[i] then
+ increaseGearValue(strucGear[i],"power")
+ if getGearValue(strucGear[i],"power") == 10 then
+ setGearValue(strucGear[i],"power",0)
+ clanPower[z] = clanPower[z] + 1
+ if clanPower[z] > 1000 then
+ clanPower[z] = 1000
+ end
+ end
+
+ end
+ end
+
+ end
+
+ end
+
+
+
+ -- this is kinda messy and gross (even more than usual), fix it up at some point
+ -- it just assumes that if you have access to girders, it works for rubbers
+ -- as that is what the struc implemenation means due to construction station
+ anyUIProx = false
+ for i = 1, #sProx do
+
+ if sProx[i][1] == loc("Girder Placement Mode") then
+ if sProx[i][2] == true then
+ AddAmmo(CurrentHedgehog, amGirder, 100)
+ AddAmmo(CurrentHedgehog, amRubber, 100)
+ AddAmmo(CurrentHedgehog, amDrillStrike, 100)
+ else
+ AddAmmo(CurrentHedgehog, amGirder, 0)
+ AddAmmo(CurrentHedgehog, amRubber, 0)
+ AddAmmo(CurrentHedgehog, amDrillStrike, 0) -- new
+ end
+ elseif sProx[i][1] == loc("Teleportation Mode") then
+ if sProx[i][2] == true then
+ AddAmmo(CurrentHedgehog, amTeleport, 100)
+ else
+ AddAmmo(CurrentHedgehog, amTeleport, 0)
+ end
+ elseif sProx[i][1] == loc("Weapon Crate Placement Mode") then
+ -- this is new stuff
+ if sProx[i][2] == true then
+ AddAmmo(CurrentHedgehog, amNapalm, 100)
+ else
+ AddAmmo(CurrentHedgehog, amNapalm, 0)
+ end
+ end
+
+ if (sProx[i][2] == true) then
+ anyUIProx = true
+ end
+
+ end
+
+ -- doesn't do shit atm, maybe later when we add cores we can use this
+ --if anyUIProx == true then --(and core is placed)
+ -- AddAmmo(CurrentHedgehog, amAirAttack, 100)
+ --else
+ -- AddAmmo(CurrentHedgehog, amAirAttack, 0)
+ --end
+
+
+end
+
+
+function checkForSpecialWeapons()
+
+
+
+ if (GetCurAmmoType() == amAirAttack) then
+ AddCaption(loc("Structure Placement Tool"),GetClanColor(GetHogClan(CurrentHedgehog)),capgrpAmmoinfo)
+ elseif (GetCurAmmoType() == amDrillStrike) then
+ AddCaption(loc("Object Placement Tool"),GetClanColor(GetHogClan(CurrentHedgehog)),capgrpAmmoinfo)
+ elseif (GetCurAmmoType() == amNapalm) then
+ AddCaption(loc("Crate Placement Tool"),GetClanColor(GetHogClan(CurrentHedgehog)),capgrpAmmoinfo)
+ end
+
+ lastWep = GetCurAmmoType()
+
+end
+
+----------------------------------------------------------
+-- EXCERPTS OF ADAPTED HEDGE_EDITOR CODE FOLLOWS
+----------------------------------------------------------
+-- experimental crap
+
+local landType = 0
+-----------------------------------------
+-- tracking vars for save slash load purposes
+-----------------------------------------
+
+local hhs = {}
+
+---------------------------------
+-- crates are made of this stuff
+---------------------------------
+placeholder = 20
+ atkArray =
+ {
+ {amBazooka, "amBazooka", 0, loc("Bazooka"), 2*placeholder},
+ --{amBee, "amBee", 0, loc("Homing Bee"), 4*placeholder},
+ {amMortar, "amMortar", 0, loc("Mortar"), 1*placeholder},
+ {amDrill, "amDrill", 0, loc("Drill Rocket"), 3*placeholder},
+ {amSnowball, "amSnowball", 0, loc("Mudball"), 3*placeholder},
+
+ {amGrenade, "amGrenade", 0, loc("Grenade"), 2*placeholder},
+ {amClusterBomb, "amClusterBomb", 0, loc("Cluster Bomb"), 3*placeholder},
+ {amMolotov, "amMolotov", 0, loc("Molotov Cocktail"), 3*placeholder},
+ {amWatermelon, "amWatermelon", 0, loc("Watermelon Bomb"), 25*placeholder},
+ {amHellishBomb, "amHellishBomb", 0, loc("Hellish Handgrenade"), 25*placeholder},
+ {amGasBomb, "amGasBomb", 0, loc("Limburger"), 3*placeholder},
+
+ {amShotgun, "amShotgun", 0, loc("Shotgun"), 2*placeholder},
+ {amDEagle, "amDEagle", 0, loc("Desert Eagle"), 2*placeholder},
+ {amFlamethrower,"amFlamethrower", 0, loc("Flamethrower"), 4*placeholder},
+ {amSniperRifle, "amSniperRifle", 0, loc("Sniper Rifle"), 3*placeholder},
+ --{amSineGun, "amSineGun", 0, loc("SineGun"), 6*placeholder},
+ {amIceGun, "amIceGun", 0, loc("Freezer"), 15*placeholder},
+ {amLandGun, "amLandGun", 0, loc("Land Sprayer"), 5*placeholder},
+
+ {amFirePunch, "amFirePunch", 0, loc("Shoryuken"), 3*placeholder},
+ {amWhip, "amWhip", 0, loc("Whip"), 1*placeholder},
+ {amBaseballBat, "amBaseballBat", 0, loc("Baseball Bat"), 7*placeholder},
+ --{amKamikaze, "amKamikaze", 0, loc("Kamikaze"), 1*placeholder},
+ {amSeduction, "amSeduction", 0, loc("Seduction"), 1*placeholder},
+ {amHammer, "amHammer", 0, loc("Hammer"), 1*placeholder},
+
+ {amMine, "amMine", 0, loc("Mine"), 1*placeholder},
+ {amDynamite, "amDynamite", 0, loc("Dynamite"), 9*placeholder},
+ {amCake, "amCake", 0, loc("Cake"), 25*placeholder},
+ {amBallgun, "amBallgun", 0, loc("Ballgun"), 40*placeholder},
+ --{amRCPlane, "amRCPlane", 0, loc("RC Plane"), 25*placeholder},
+ {amSMine, "amSMine", 0, loc("Sticky Mine"), 5*placeholder},
+
+ --{amAirAttack, "amAirAttack", 0, loc("Air Attack"), 10*placeholder},
+ --{amMineStrike, "amMineStrike", 0, loc("Mine Strike"), 15*placeholder},
+ --{amDrillStrike, "amDrillStrike", 0, loc("Drill Strike"), 15*placeholder},
+ --{amNapalm, "amNapalm", 0, loc("Napalm"), 15*placeholder},
+ --{amPiano, "amPiano", 0, loc("Piano Strike"), 40*placeholder},
+
+ {amKnife, "amKnife", 0, loc("Cleaver"), 2*placeholder},
+
+ {amBirdy, "amBirdy", 0, loc("Birdy"), 7*placeholder}
+
+ }
+
+ utilArray =
+ {
+ {amBlowTorch, "amBlowTorch", 0, loc("Blowtorch"), 4*placeholder},
+ {amPickHammer, "amPickHammer", 0, loc("Pickhammer"), 2*placeholder},
+ --{amGirder, "amGirder", 0, loc("Girder"), 4*placeholder},
+ --{amRubber, "amRubber", 0, loc("Rubber Band"), 5*placeholder},
+ {amPortalGun, "amPortalGun", 0, loc("Personal Portal Device"), 15*placeholder},
+
+ {amRope, "amRope", 0, loc("Rope"), 7*placeholder},
+ {amParachute, "amParachute", 0, loc("Parachute"), 2*placeholder},
+ --{amTeleport, "amTeleport", 0, loc("Teleport"), 6*placeholder},
+ {amJetpack, "amJetpack", 0, loc("Flying Saucer"), 8*placeholder},
+
+ {amInvulnerable, "amInvulnerable", 0, loc("Invulnerable"), 5*placeholder},
+ {amLaserSight, "amLaserSight", 0, loc("Laser Sight"), 2*placeholder},
+ {amVampiric, "amVampiric", 0, loc("Vampirism"), 6*placeholder},
+
+ {amLowGravity, "amLowGravity", 0, loc("Low Gravity"), 4*placeholder},
+ {amExtraDamage, "amExtraDamage", 0, loc("Extra Damage"), 6*placeholder},
+ {amExtraTime, "amExtraTime", 0, loc("Extra Time"), 8*placeholder}
+
+ --{amResurrector, "amResurrector", 0, loc("Resurrector"), 8*placeholder},
+ --{amTardis, "amTardis", 0, loc("Tardis"), 2*placeholder},
+
+ --{amSwitch, "amSwitch", 0, loc("Switch Hog"), 4*placeholder}
+ }
+
+----------------------------
+-- hog and map editting junk
+----------------------------
+
+ local reducedSpriteIDArray = {
+ sprBigDigit, sprKowtow, sprBee, sprExplosion50, sprGirder
+ }
+
+ local reducedSpriteTextArray = {
+ "sprBigDigit", "sprKowtow", "sprBee", "sprExplosion50", "sprGirder"
+ }
+
+----------------------------
+-- placement shite
+----------------------------
+
+local cGear = nil -- detects placement of girders and objects (using airattack)
+local curWep = amNothing
+
+-- primary placement categories
+local cIndex = 1 -- category index
+local cat = {
+ "Girder Placement Mode",
+ "Rubber Placement Mode",
+ "Mine Placement Mode",
+ "Sticky Mine Placement Mode",
+ "Barrel Placement Mode",
+ "Health Crate Placement Mode",
+ "Weapon Crate Placement Mode",
+ "Utility Crate Placement Mode",
+ --"Target Placement Mode",
+ --"Cleaver Placement Mode",
+
+ --"Advanced Repositioning Mode",
+ --"Tagging Mode",
+ --"Sprite Testing Mode",
+ --"Sprite Placement Mode",
+ "Structure Placement Mode"
+ }
+
+
+ sProx = {
+ {loc("Girder Placement Mode"),false},
+ {loc("Rubber Placement Mode"),false},
+ {loc("Mine Placement Mode"),false},
+ {loc("Sticky Mine Placement Mode"),false},
+ {loc("Barrel Placement Mode"),false},
+ {loc("Health Crate Placement Mode"),false},
+ {loc("Weapon Crate Placement Mode"),false},
+ {loc("Utility Crate Placement Mode"),false},
+ --{loc("Target Placement Mode"),false},
+ --{loc("Cleaver Placement Mode"),false},
+
+ --{loc("Advanced Repositioning Mode"),false},
+ --{loc("Tagging Mode"),false},
+ --{loc("Sprite Testing Mode"),false},
+ --{loc("Sprite Placement Mode"),false},
+ {loc("Structure Placement Mode"),false},
+ {loc("Teleportation Mode"),false}
+ }
+
+
+local pMode = {} -- pMode contains custom subsets of the main categories
+local pIndex = 1
+
+local genTimer = 0
+
+local CGR = 1 -- current girder rotation, we actually need this as HW remembers what rotation you last used
+
+local placedX = {}
+local placedY = {}
+local placedSpec = {}
+local placedSuperSpec = {}
+local placedType = {}
+local placedCount = 0
+
+local sCirc -- circle that appears around selected gears
+local sGear = nil
+local closestDist
+local closestGear = nil
+
+local tCirc = {} -- array of circles that appear around tagged gears
+
+------------------------
+-- SOME GENERAL METHODS
+------------------------
+
+function GetDistFromGearToXY(gear, g2X, g2Y)
+
+ g1X, g1Y = GetGearPosition(gear)
+ q = g1X - g2X
+ w = g1Y - g2Y
+
+ return ( (q*q) + (w*w) )
+
+end
+
+function GetDistFromXYtoXY(a, b, c, d)
+ q = a - c
+ w = b - d
+ return ( (q*q) + (w*w) )
+end
+
+function SelectGear(gear)
+
+ d = GetDistFromGearToXY(gear, placedX[placedCount], placedY[placedCount])
+
+ if d < closestDist then
+ closestDist = d
+ closestGear = gear
+ end
+
+end
+
+-- essentially called when user clicks the mouse
+-- with girders or an airattack
+function PlaceObject(x,y)
+
+ placedX[placedCount] = x
+ placedY[placedCount] = y
+ placedType[placedCount] = cat[cIndex]
+ placedSpec[placedCount] = pMode[pIndex]
+
+ if (clanUsedExtraTime[GetHogClan(CurrentHedgehog)] == true) and (cat[cIndex] == "Utility Crate Placement Mode") and (utilArray[pIndex][1] == amExtraTime) then
+ AddCaption(loc("You may only use 1 Extra Time per turn."),0xffba00ff,capgrpVolume)
+ PlaySound(sndDenied)
+ elseif (clanCratesSpawned[GetHogClan(CurrentHedgehog)] > 4) and ( (cat[cIndex] == "Health Crate Placement Mode") or (cat[cIndex] == "Utility Crate Placement Mode") or (cat[cIndex] == "Weapon Crate Placement Mode") ) then
+ AddCaption(loc("You may only spawn 5 crates per turn."),0xffba00ff,capgrpVolume)
+ PlaySound(sndDenied)
+ elseif (XYisInRect(x,y, clanBoundsSX[GetHogClan(CurrentHedgehog)],clanBoundsSY[GetHogClan(CurrentHedgehog)],clanBoundsEX[GetHogClan(CurrentHedgehog)],clanBoundsEY[GetHogClan(CurrentHedgehog)]) == true)
+ and (clanPower[GetHogClan(CurrentHedgehog)] >= placedExpense)
+ then
+
+
+
+ if cat[cIndex] == "Girder Placement Mode" then
+ PlaceGirder(x, y, CGR)
+ placedSpec[placedCount] = CGR
+ elseif cat[cIndex] == "Rubber Placement Mode" then
+ PlaceSprite(x,y, sprAmRubber, CGR, nil, nil, nil, nil, lfBouncy)
+ --PlaceGirder(x, y, CGR)
+ placedSpec[placedCount] = CGR
+ elseif cat[cIndex] == "Target Placement Mode" then
+ gear = AddGear(x, y, gtTarget, 0, 0, 0, 0)
+ elseif cat[cIndex] == "Cleaver Placement Mode" then
+ gear = AddGear(x, y, gtKnife, 0, 0, 0, 0)
+ elseif cat[cIndex] == "Health Crate Placement Mode" then
+ gear = SpawnHealthCrate(x,y)
+ SetHealth(gear, pMode[pIndex])
+ setGearValue(gear,"caseType","med")
+ clanCratesSpawned[GetHogClan(CurrentHedgehog)] = clanCratesSpawned[GetHogClan(CurrentHedgehog)] +1
+ elseif cat[cIndex] == "Weapon Crate Placement Mode" then
+ gear = SpawnAmmoCrate(x, y, atkArray[pIndex][1])
+ placedSpec[placedCount] = atkArray[pIndex][2]
+ setGearValue(gear,"caseType","ammo")
+ setGearValue(gear,"contents",atkArray[pIndex][2])
+ clanCratesSpawned[GetHogClan(CurrentHedgehog)] = clanCratesSpawned[GetHogClan(CurrentHedgehog)] +1
+ elseif cat[cIndex] == "Utility Crate Placement Mode" then
+ gear = SpawnUtilityCrate(x, y, utilArray[pIndex][1])
+ placedSpec[placedCount] = utilArray[pIndex][2]
+ setGearValue(gear,"caseType","util")
+ setGearValue(gear,"contents",utilArray[pIndex][2])
+ if utilArray[pIndex][1] == amExtraTime then
+ clanUsedExtraTime[GetHogClan(CurrentHedgehog)] = true
+ end
+ clanCratesSpawned[GetHogClan(CurrentHedgehog)] = clanCratesSpawned[GetHogClan(CurrentHedgehog)] +1
+ elseif cat[cIndex] == "Barrel Placement Mode" then
+ gear = AddGear(x, y, gtExplosives, 0, 0, 0, 0)
+ SetHealth(gear, pMode[pIndex])
+ elseif cat[cIndex] == "Mine Placement Mode" then
+ gear = AddGear(x, y, gtMine, 0, 0, 0, 0)
+ SetTimer(gear, pMode[pIndex])
+ elseif cat[cIndex] == "Sticky Mine Placement Mode" then
+ gear = AddGear(x, y, gtSMine, 0, 0, 0, 0)
+ elseif cat[cIndex] == "Advanced Repositioning Mode" then
+
+ if pMode[pIndex] == "Selection Mode" then
+ closestDist = 999999999
+ closestGear = nil -- just in case
+ sGear = nil
+ runOnGears(SelectGear)
+ sGear = closestGear
+ closestGear = nil
+ elseif pMode[pIndex] == "Placement Mode" then
+ if sGear ~= nil then
+ SetGearPosition(sGear, x, y)
+ end
+ end
+
+ elseif cat[cIndex] == "Tagging Mode" then
+
+ closestDist = 999999999
+ closestGear = nil
+ sGear = nil
+ runOnGears(SelectGear)
+
+
+ if closestGear ~= nil then
+
+ if getGearValue(closestGear,"tag") == nil then
+
+ --if there is no tag, add a victory/failure tag and circle
+ setGearValue(closestGear, "tCirc",AddVisualGear(0,0,vgtCircle,0,true))
+
+ --AddCaption("circ added",0xffba00ff,capgrpVolume)
+
+ if pMode[pIndex] == "Tag Victory Mode" then
+ setGearValue(closestGear, "tag","victory")
+ SetVisualGearValues(getGearValue(closestGear,"tCirc"), 0, 0, 100, 255, 1, 10, 0, 40, 3, 0xff0000ff)
+ elseif pMode[pIndex] == "Tag Failure Mode" then
+ setGearValue(closestGear, "tag","failure")
+ SetVisualGearValues(getGearValue(closestGear,"tCirc"), 0, 0, 100, 255, 1, 10, 0, 40, 3, 0x0000ffff)
+ end
+
+
+ else
+ -- remove tag and delete circ
+ --AddCaption("circ removed",0xffba00ff,capgrpVolume)
+ setGearValue(closestGear, "tag", nil)
+ DeleteVisualGear(getGearValue(closestGear,"tCirc"))
+ setGearValue(closestGear, "tCirc", nil)
+ end
+
+ end
+
+
+ elseif cat[cIndex] == "Sprite Testing Mode" then
+
+ frameID = 1
+ visualSprite = reducedSpriteIDArray[pIndex]
+ --visualSprite = spriteIDArray[pIndex]
+ tempE = AddVisualGear(x, y, vgtStraightShot, 0, true)
+ g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(tempE)
+ SetVisualGearValues(tempE, g1, g2, 0, 0, g5, frameID, g7, visualSprite, g9, g10 )
+ --sprHorizonLong crashes game, so does skyL, as does flake
+
+ -- reduced list of cool sprites
+ -- sprBigDigit, sprKnife, sprFrozenHog, sprKowtow, sprBee, sprExplosion50, sprPiano, sprChunk, sprHHTelepMask, sprSeduction, sprSwitch, sprGirder,
+ --sprAMAmmos, sprAMSlotKeys, sprTurnsLeft, sprExplosivesRoll + maybe some others like the health case, arrows, etc
+
+ elseif cat[cIndex] == "Sprite Placement Mode" then
+
+ PlaceSprite(x,y, reducedSpriteIDArray[pIndex], 1, nil, nil, nil, nil, landType)
+ --PlaceGirder(x, y, CGR)
+ placedSpec[placedCount] = reducedSpriteTextArray[pIndex]
+ placedSuperSpec[placedCount] = landType
+
+ if landType == lfIce then
+ placedSuperSpec[placedCount] = "lfIce"
+ elseif landType == lfIndestructible then
+ placedSuperSpec[placedCount] = "lfIndestructible"
+ elseif landType == lfBouncy then
+ placedSuperSpec[placedCount] = "lfBouncy"
+ else
+ placedSuperSpec[placedCount] = "lfNormal"
+ end
+
+ elseif cat[cIndex] == "Structure Placement Mode" then
+
+ AddStruc(x,y, pMode[pIndex],GetHogClan(CurrentHedgehog))
+
+ end
+
+ clanPower[GetHogClan(CurrentHedgehog)] = clanPower[GetHogClan(CurrentHedgehog)] - placedExpense
+ placedCount = placedCount + 1
+
+ else
+ if (clanPower[GetHogClan(CurrentHedgehog)] >= placedExpense) then
+ AddCaption(loc("Invalid Placement"),0xffba00ff,capgrpVolume)
+ else
+ AddCaption(loc("Insufficient Power"),0xffba00ff,capgrpVolume)
+ end
+ PlaySound(sndDenied)
+ end
+
+
+end
+
+-- called when user changes primary selection
+-- either via up/down keys
+-- or selecting girder/airattack
+function RedefineSubset()
+
+ pIndex = 1
+ pMode = {}
+ placedExpense = 1
+
+ if cat[cIndex] == "Girder Placement Mode" then
+ pIndex = CGR
+ pMode = {"Girder"}
+ -- pCount = 1
+ elseif cat[cIndex] == "Rubber Placement Mode" then
+ pIndex = CGR
+ pMode = {"Rubber"}
+ placedExpense = 3
+ -- pCount = 1???
+ elseif cat[cIndex] == "Target Placement Mode" then
+ pMode = {"Standard Target"}
+ elseif cat[cIndex] == "Cleaver Placement Mode" then
+ pMode = {"Standard Cleaver"}
+ elseif cat[cIndex] == "Barrel Placement Mode" then
+ --pMode = {1,50,75,100}
+ pMode = {50}
+ placedExpense = 10
+ elseif cat[cIndex] == "Health Crate Placement Mode" then
+ --pMode = {25,50,75,100}
+ pMode = {25}
+ placedExpense = 5
+ elseif cat[cIndex] == "Weapon Crate Placement Mode" then
+ for i = 1, #atkArray do
+ pMode[i] = atkArray[i][4] -- was [2]
+ --placedExpense = atkArray[5]
+ end
+ placedExpense = 30
+ elseif cat[cIndex] == "Utility Crate Placement Mode" then
+ for i = 1, #utilArray do
+ pMode[i] = utilArray[i][4] -- was [2]
+ --placedExpense = utilArray[5]
+ end
+ placedExpense = 20
+ elseif cat[cIndex] == "Mine Placement Mode" then
+ --pMode = {1,1000,2000,3000,4000,5000,0}
+ pMode = {1,1000,2000,3000,4000,5000}
+ -- 0 is dud right, or is that nil?
+ placedExpense = 15
+ elseif cat[cIndex] == "Sticky Mine Placement Mode" then
+ pMode = {"Normal Sticky Mine"}
+ --elseif cat[cIndex] == "Gear Repositioning Mode" then
+ -- for i = 1, #hhs do
+ -- pMode[i] = GetHogName(hhs[i])
+ -- end
+ placedExpense = 20
+ elseif cat[cIndex] == "Advanced Repositioning Mode" then
+ pMode = {"Selection Mode","Placement Mode"}
+ elseif cat[cIndex] == "Tagging Mode" then
+ pMode = {"Tag Victory Mode","Tag Failure Mode"}
+ elseif cat[cIndex] == "Sprite Testing Mode" or cat[cIndex] == "Sprite Placement Mode" then
+ --for i = 1, #spriteTextArray do
+ -- pMode[i] = spriteTextArray[i]
+ --end
+ for i = 1, #reducedSpriteTextArray do
+ pMode[i] = reducedSpriteTextArray[i]
+ end
+ placedExpense = 100
+ elseif cat[cIndex] == "Structure Placement Mode" then
+ pMode = {loc("Healing Station"), loc("Bio-Filter"), loc("Weapon Filter"), loc("Reflector Shield"), loc("Respawner"),loc("Teleportation Node"),--[[loc("Core"),]]loc("Generator"),loc("Construction Station"),loc("Support Station")}
+ --placedExpense = 100
+ end
+
+
+
+
+end
+
+-- called in onGameTick()
+function HandleHedgeEditor()
+
+ if CurrentHedgehog ~= nil then
+
+ if wallsVisible == true then
+ HandleBorderEffects()
+ end
+
+ if (CurrentHedgehog ~= nil) and (TurnTimeLeft ~= TurnTime) then
+ if (lastWep ~= GetCurAmmoType()) then
+ checkForSpecialWeapons()
+ end
+ end
+
+ genTimer = genTimer + 1
+
+ if genTimer >= 100 then
+
+ genTimer = 0
+
+ DrawTag(1)
+
+ HandleStructures()
+
+ curWep = GetCurAmmoType()
+
+ -- change to girder mode on weapon swap
+ if (cIndex ~= 1) and (curWep == amGirder) then
+ cIndex = 1
+ RedefineSubset()
+ elseif (cIndex ~=2) and (curWep == amRubber) then
+ cIndex = 2
+ RedefineSubset()
+ -- change to generic mode if girder no longer selected
+ elseif (cIndex == 1) and (curWep ~= amGirder) then
+ cIndex = 3 -- was 2
+ RedefineSubset()
+ elseif (cIndex == 2) and (curWep ~= amRubber) then
+ cIndex = 3 --new
+ RedefineSubset()
+
+ end
+
+ -- update display selection criteria
+ if (curWep == amGirder) or (curWep == amAirAttack) or (curWep == amNapalm) or (curWep == amDrillStrike) or (curWep == amRubber) then
+
+ ---------------hooolllllyyyy fucking shit this
+ -- code is a broken mess now
+ -- it was redesigned and compromised three times
+ -- so now it is a mess trying to do what it was
+ -- never designed to do
+ -- needs to be rewritten badly sadface
+ -- this bit here catches the new 3 types of weapons
+ if ((sProx[cIndex][1] == loc("Structure Placement Mode") and (curWep ~= amAirAttack))) then
+ updatePlacementDisplay(1)
+ elseif (sProx[cIndex][1] == loc("Health Crate Placement Mode")) or
+ (sProx[cIndex][1] == loc("Weapon Crate Placement Mode")) or
+ (sProx[cIndex][1] == loc("Utility Crate Placement Mode")) then
+ if curWep ~= amNapalm then
+ updatePlacementDisplay(1)
+ end
+
+ elseif (sProx[cIndex][1] == loc("Mine Placement Mode")) or
+ (sProx[cIndex][1] == loc("Sticky Mine Placement Mode")) or
+ (sProx[cIndex][1] == loc("Barrel Placement Mode")) then
+ if curWep ~= amDrillStrike then
+ updatePlacementDisplay(1)
+ end
+
+ end
+
+ --this is called when it happens that we have placement
+ --mode selected and we are looking at something
+ --we shouldn't be allowed to look at, as would be the case
+ --when you WERE allowed to look at it, but then maybe
+ --a bomb blows up the structure that was granting you
+ --that ability
+ if (sProx[cIndex][2] ~= true) then
+ updatePlacementDisplay(1)
+ else
+ updateCost()
+ end
+
+
+ AddCaption(cat[cIndex],0xffba00ff,capgrpMessage)
+ AddCaption(pMode[pIndex],0xffba00ff,capgrpMessage2)
+ wallsVisible = true
+ else
+ wallsVisible = false
+ end
+
+ end
+
+ end
+
+ --update selected gear display
+ if (cat[cIndex] == "Advanced Repositioning Mode") and (sGear ~= nil) then
+ SetVisualGearValues(sCirc, GetX(sGear), GetY(sGear), 100, 255, 1, 10, 0, 300, 3, 0xff00ffff)
+ elseif (cat[cIndex] == "Tagging Mode") then
+ if (sGear ~= nil) or (closestGear ~= nil) then
+ SetVisualGearValues(sCirc, GetX(sGear), GetY(sGear), 0, 1, 1, 10, 0, 1, 1, 0x00000000)
+ closestGear = nil
+ sGear = nil
+ end
+ end
+
+ -- some kind of target detected, tell me your story
+ if cGear ~= nil then
+
+ x,y = GetGearTarget(cGear)
+
+ if GetGearType(cGear) == gtAirAttack then
+ DeleteGear(cGear)
+ PlaceObject(x, y)
+ elseif GetGearType(cGear) == gtTeleport then
+
+ CheckTeleport(cGear, x, y)
+ cGear = nil
+ elseif GetGearType(cGear) == gtGirder then
+
+ CGR = GetState(cGear)
+
+ -- improve rectangle test based on CGR when you can be bothered
+ --if TestRectForObstacle(x-20, y-20, x+20, y+20, true) then
+ -- AddCaption("Invalid Girder Placement",0xffba00ff,capgrpVolume)
+ --else
+ PlaceObject(x, y)
+ --end
+
+ -- this allows the girder tool to be used like a mining laser
+
+ --[[
+
+ if CGR < 4 then
+ AddGear(x, y, gtGrenade, 0, 0, 0, 1)
+ elseif CGR == 4 then
+ g = AddGear(x-30, y, gtGrenade, 0, 0, 0, 1)
+ g = AddGear(x+30, y, gtGrenade, 0, 0, 0, 1)
+ elseif CGR == 5 then -------
+ g = AddGear(x+30, y+30, gtGrenade, 0, 0, 0, 1)
+ g = AddGear(x-30, y-30, gtGrenade, 0, 0, 0, 1)
+ elseif CGR == 6 then
+ g = AddGear(x, y+30, gtGrenade, 0, 0, 0, 1)
+ g = AddGear(x, y-30, gtGrenade, 0, 0, 0, 1)
+ elseif CGR == 7 then -------
+ g = AddGear(x+30, y-30, gtGrenade, 0, 0, 0, 1)
+ g = AddGear(x-30, y+30, gtGrenade, 0, 0, 0, 1)
+ end
+]]
+ end
+
+ end
+
+end
+
+--------------------------------------------------
+-- EVENT HANDLERS
+--------------------------------------------------
+
+function onTaunt(t)
+ tauntString = tauntString .. t
+ if (tauntString == "101") and (clanPower[GetHogClan(CurrentHedgehog)] < 300) and (clanBoon[GetHogClan(CurrentHedgehog)] == false) then
+ clanBoon[GetHogClan(CurrentHedgehog)] = true
+ clanPower[GetHogClan(CurrentHedgehog)] = 1000
+ AddCaption(loc("The Great Hog in the sky sees your sadness and grants you a boon."))
+ end
+end
+
+---------------------------------------------------------------
+-- Cycle through selection subsets (by changing pIndex, pMode)
+-- i.e health of barrels, medikits,
+-- timer of mines
+-- contents of crates
+-- gears to reposition etc.
+---------------------------------------------------------------
+
+function updateCost()
+
+ if pMode[pIndex] == loc("Healing Station") then
+ placedExpense = 50
+ elseif pMode[pIndex] == loc("Weapon Filter") then
+ placedExpense = 50
+ elseif pMode[pIndex] == loc("Bio-Filter") then
+ placedExpense = 100
+ elseif pMode[pIndex] == loc("Respawner") then
+ placedExpense = 300
+ elseif pMode[pIndex] == loc("Teleportation Node") then
+ placedExpense = 30
+ elseif pMode[pIndex] == loc("Support Station") then
+ placedExpense = 50
+ elseif pMode[pIndex] == loc("Construction Station") then
+ placedExpense = 50
+ elseif pMode[pIndex] == loc("Generator") then
+ placedExpense = 300
+ elseif pMode[pIndex] == loc("Reflector Shield") then
+ placedExpense = 200
+ elseif pMode[pIndex] == loc("Core") then
+ placedExpense = 1
+ elseif cat[cIndex] == loc("Weapon Crate Placement Mode") then
+ placedExpense = atkArray[pIndex][5]
+ elseif cat[cIndex] == loc("Utility Crate Placement Mode") then
+ placedExpense = utilArray[pIndex][5]
+ end
+
+ AddCaption(loc("Cost") .. ": " .. placedExpense,0xffba00ff,capgrpAmmostate)
+
+end
+
+function onLeft()
+
+ pIndex = pIndex - 1
+ if pIndex == 0 then
+ pIndex = #pMode
+ end
+
+ if (curWep == amGirder) or (curWep == amAirAttack) or (curWep == amNapalm) or (curWep == amDrillStrike) then
+ AddCaption(pMode[pIndex],0xffba00ff,capgrpMessage2)
+ updateCost()
+ end
+
+
+end
+
+function onRight()
+
+ pIndex = pIndex + 1
+ if pIndex > #pMode then
+ pIndex = 1
+ end
+
+ if (curWep == amGirder) or (curWep == amAirAttack) or (curWep == amNapalm) or (curWep == amDrillStrike) then
+ AddCaption(pMode[pIndex],0xffba00ff,capgrpMessage2)
+ updateCost()
+ end
+
+end
+
+
+function updatePlacementDisplay(pDir)
+
+ foundMatch = false
+ while(foundMatch == false) do
+ cIndex = cIndex + pDir
+
+ if (cIndex == 1) or (cIndex == 2) then --1 --we no longer hit girder by normal means
+ cIndex = #cat
+ elseif cIndex > #cat then
+ cIndex = 3 -- 2 ----we no longer hit girder by normal means
+ end
+
+ -- new way of doing things
+ -- sProx[cIndex][2] == true just basically means we have ACCESS to something
+ -- but that doesn't neccessarily mean we are in the correct content menu, anymore
+ -- so we need to refine this a little
+ if sProx[cIndex][2] == true then
+ if (GetCurAmmoType() == amNapalm) then
+ if (sProx[cIndex][1] == loc("Health Crate Placement Mode")) or
+ (sProx[cIndex][1] == loc("Weapon Crate Placement Mode")) or
+ (sProx[cIndex][1] == loc("Utility Crate Placement Mode"))
+ then
+ foundMatch = true
+ end
+ elseif (GetCurAmmoType() == amDrillStrike) then
+ if (sProx[cIndex][1] == loc("Mine Placement Mode")) or
+ (sProx[cIndex][1] == loc("Sticky Mine Placement Mode")) or
+ (sProx[cIndex][1] == loc("Barrel Placement Mode"))
+ then
+ foundMatch = true
+ end
+ elseif (GetCurAmmoType() == amAirAttack) then
+ if sProx[cIndex][1] == loc("Structure Placement Mode") then
+ foundMatch = true
+ end
+ end
+ end
+
+
+ if foundMatch == true then
+ --if sProx[cIndex][2] == true then
+ -- normal case (scrolling through)
+ --foundMatch = true
+ RedefineSubset()
+ updateCost()
+ end
+
+ end
+
+end
+
+---------------------------------------------------------
+-- Cycle through primary categories (by changing cIndex)
+-- i.e mine, sticky mine, barrels
+-- health/weapon/utility crate, placement of gears
+---------------------------------------------------------
+function onUp()
+
+ if ((curWep == amAirAttack) or (curWep == amNapalm) or (curWep == amDrillStrike) ) then
+ updatePlacementDisplay(-1)
+ end
+
+end
+
+function onDown()
+
+ if ((curWep == amAirAttack) or (curWep == amNapalm) or (curWep == amDrillStrike) ) then
+ updatePlacementDisplay(1)
+ end
+
+end
+
+----------------------------
+-- standard event handlers
+----------------------------
+
+function onGameInit()
+
+ Explosives = 0
+ MinesNum = 0
+
+ EnableGameFlags(gfInfAttack)
+
+
+ RedefineSubset()
+
+end
+
+function initialSetup(gear)
+
+ FindPlace(gear, false, clanBoundsSX[GetHogClan(gear)], clanBoundsEX[GetHogClan(gear)],true)
+
+ -- for now, everyone should have this stuff
+ AddAmmo(gear, amAirAttack, 100)
+ AddAmmo(gear, amSwitch, 100)
+ AddAmmo(gear, amSkip, 100)
+
+end
+
+function onGameStart()
+
+ trackTeams()
+
+ ShowMission (
+ loc("CONSTRUCTION MODE"),
+ loc("a Hedgewars mini-game"),
+ " " .. "|" ..
+ loc("Build a fortress and destroy your enemy.") .. "|" ..
+ --loc("Defend your core from the enemy.") .. "|" ..
+ loc("There are a variety of structures available to aid you.") .. "|" ..
+ loc("Use the air-attack weapons and the arrow keys to select structures.") .. "|" ..
+ " " .. "|" ..
+ --loc("Core") .. ": " .. loc("Allows placement of structures.") .. "|" ..
+ loc("Healing Station") .. ": " .. loc("Grants nearby hogs life-regeneration.") .. "|" ..
+ loc("Bio-Filter") .. ": " .. loc("Aggressively removes enemy hedgehogs.") .. "|" ..
+ loc("Weapon Filter") .. ": " .. loc("Dematerializes weapons and equipment carried by enemy hedgehogs.") .. "|" ..
+ loc("Reflector Shield") .. ": " .. loc("Reflects enemy projectiles.") .. "|" ..
+
+ loc("Generator") .. ": " .. loc("Generates power.") .. "|" ..
+ loc("Respawner") .. ": " .. loc("Resurrects dead hedgehogs.") .. "|" ..
+ loc("Teleporation Node") .. ": " .. loc("Allows free teleportation between other nodes.") .. "|" ..
+ loc("Construction Station") .. ": " .. loc("Allows placement of girders, rubber-bands, mines, sticky mines and barrels.") .. "|" ..
+ loc("Support Station") .. ": " .. loc("Allows the placement of weapons, utiliites, and health crates.") .. "|" ..
+
+
+ " " .. "|" ..
+ --" " .. "|" ..
+ "", 4, 5000
+ )
+
+
+ sCirc = AddVisualGear(0,0,vgtCircle,0,true)
+ SetVisualGearValues(sCirc, 0, 0, 100, 255, 1, 10, 0, 40, 3, 0x00000000)
+
+ for i = 0, ClansCount-1 do
+ clanPower[i] = 500
+ clanBoon[i] = false
+ clanLWepIndex[i] = 1 -- for ease of use let's track this stuff
+ clanLUtilIndex[i] = 1
+ clanLGearIndex[i] = 1
+ clanUsedExtraTime[i] = false
+ clanCratesSpawned[i] = 0
+
+
+ end
+
+ tMapWidth = RightX - LeftX
+ tMapHeight = WaterLine - TopY
+ clanInterval = div(tMapWidth,ClansCount)
+
+ for i = 1, ClansCount do
+
+ clanBoundsSX[i-1] = LeftX+(clanInterval*i)-clanInterval+20
+ clanBoundsSY[i-1] = TopY
+ clanBoundsEX[i-1] = LeftX+(clanInterval*i)-20
+ clanBoundsEY[i-1] = WaterLine
+
+ --top and bottom
+ AddWall(LeftX+(clanInterval*i)-clanInterval,TopY,clanInterval,margin,GetClanColor(i-1))
+ AddWall(LeftX+(clanInterval*i)-clanInterval,WaterLine-25,clanInterval,margin,GetClanColor(i-1))
+
+ --add a wall to the left and right
+ AddWall(LeftX+(clanInterval*i)-clanInterval+20,TopY,margin,WaterLine,GetClanColor(i-1))
+ AddWall(LeftX+(clanInterval*i)-20,TopY,margin,WaterLine,GetClanColor(i-1))
+
+ end
+
+ runOnHogs(initialSetup)
+
+end
+
+
+function onNewTurn()
+
+ tauntString = ""
+ clanPower[GetHogClan(CurrentHedgehog)] = clanPower[GetHogClan(CurrentHedgehog)] + 50
+ clanUsedExtraTime[GetHogClan(CurrentHedgehog)] = false
+ clanCratesSpawned[GetHogClan(CurrentHedgehog)] = 0
+
+end
+
+function onGameTick()
+ HandleHedgeEditor()
+end
+
+function isATrackedGear(gear)
+ if (GetGearType(gear) == gtHedgehog) or
+ (GetGearType(gear) == gtTarget) or
+ (GetGearType(gear) == gtCase)
+ then
+ return(true)
+ else
+ return(false)
+ end
+end
+
+-- track hedgehogs and placement gears
+function onGearAdd(gear)
+
+ if GetGearType(gear) == gtHedgehog then
+ --table.insert(hhs, gear)
+ elseif (GetGearType(gear) == gtAirAttack) or (GetGearType(gear) == gtTeleport) or (GetGearType(gear) == gtGirder) then
+ cGear = gear
+
+ end
+
+ if isATrackedGear(gear) then
+ trackGear(gear)
+ elseif gearCanBeDeflected(gear) then
+ trackGear(gear)
+ setGearReflectionValues(gear)
+ end
+
+end
+
+function onGearDelete(gear)
+
+ if GetGearType(gear) == gtTarget then
+ CheckGearForStructureLink(gear)
+ end
+
+ if (GetGearType(gear) == gtAirAttack) or (GetGearType(gear) == gtTeleport) or (GetGearType(gear) == gtGirder) then
+ cGear = nil
+ end
+
+ if (isATrackedGear(gear) or gearCanBeDeflected(gear)) then
+
+ if getGearValue(gear, "tCirc") ~= nil then
+ DeleteVisualGear(getGearValue(gear, "tCirc"))
+ end
+
+ trackDeletion(gear)
+
+ end
+
+end
--- a/share/hedgewars/Data/Scripts/Multiplayer/Frenzy.lua Wed Jul 15 00:27:12 2015 +0200
+++ b/share/hedgewars/Data/Scripts/Multiplayer/Frenzy.lua Thu Jul 16 08:39:35 2015 -0400
@@ -1,142 +1,142 @@
--------------------------------------------
--- FRENZY
--- a hedgewars mode inspired by Hysteria
--------------------------------------------
-
-HedgewarsScriptLoad("/Scripts/Locale.lua")
-HedgewarsScriptLoad("/Scripts/Tracker.lua")
-
-local cTimer = 0
-local cn = 0
-
-function initialSetup(gear)
- SetHealth(gear, 75) -- official is 80, but that assumes bazookas/grenades that do 50 damage
-end
-
-function showStartingInfo()
-
- ruleSet = "" ..
- loc("RULES") .. ": " .. "|" ..
- loc("Each turn is only ONE SECOND!") .. "|" ..
- loc("Use your ready time to think.") .. "|" ..
- loc("Slot keys save time! (F1-F10 by default)") .. "|" ..
- " |" ..
- loc("SLOTS") .. ": " .. "|" ..
- loc("Slot") .. " 1 - " .. loc("Bazooka") .. "|" ..
- loc("Slot") .. " 2 - " .. loc("Grenade") .. "|" ..
- loc("Slot") .. " 3 - " .. loc("Shotgun") .. "|" ..
- loc("Slot") .. " 4 - " .. loc("Shoryuken") .. "|" ..
- loc("Slot") .. " 5 - " .. loc("Mine") .. "|" ..
- loc("Slot") .. " 6 - " .. loc("Teleport") .. "|" ..
- loc("Slot") .. " 7 - " .. loc("Blowtorch") .. "|" ..
- loc("Slot") .. " 8 - " .. loc("Flying Saucer") .. "|" ..
- loc("Slot") .. " 9 - " .. loc("Molotov") .. "|" ..
- loc("Slot") .. " 10 - " .. loc("Low Gravity")
-
- ShowMission(loc("FRENZY"),
- loc("a frenetic Hedgewars mini-game"),
- ruleSet, 0, 4000)
-
-end
-
-function onGameInit()
-
- if TurnTime > 10001 then
- Ready = 8000
- else
- Ready = TurnTime
- end
-
- TurnTime = 1000
-
- --These are the official settings, but I think I prefer allowing customization in this regard
- --MinesNum = 8
- --MinesTime = 3000
- --MinesDudPercent = 30
- --Explosives = 0
-
- --Supposedly official settings
- HealthCaseProb = 0
- CrateFreq = 0
-
- --Approximation of Official Settings
- --SuddenDeathTurns = 10
- --WaterRise = 47
- --HealthDecrease = 0
-
-end
-
-function onGameStart()
- showStartingInfo()
- runOnHogs(initialSetup)
-end
-
-function onSlot(sln)
- cTimer = 8
- cn = sln
-end
-
-function onGameTick()
- if cTimer ~= 0 then
- cTimer = cTimer -1
- if cTimer == 1 then
- ChangeWep(cn)
- cn = 0
- cTimer = 0
- end
- end
-end
-
-function ChangeWep(s)
-
- if s == 0 then
- SetWeapon(amBazooka)
- elseif s == 1 then
- SetWeapon(amGrenade)
- elseif s == 2 then
- SetWeapon(amShotgun)
- elseif s == 3 then
- SetWeapon(amFirePunch)
- elseif s == 4 then
- SetWeapon(amMine)
- elseif s == 5 then
- SetWeapon(amTeleport)
- elseif s == 6 then
- SetWeapon(amBlowTorch)
- elseif s == 7 then
- SetWeapon(amJetpack)
- elseif s == 8 then
- SetWeapon(amMolotov)
- elseif s == 9 then
- SetWeapon(amLowGravity)
- end
-
-end
-
-function onGearAdd(gear)
- if GetGearType(gear) == gtHedgehog then
- trackGear(gear)
- end
-end
-
-function onGearDelete(gear)
- if GetGearType(gear) == gtHedgehog then
- trackDeletion(gear)
- end
-end
-
-function onAmmoStoreInit()
- SetAmmo(amBazooka, 9, 0, 0, 0)
- SetAmmo(amGrenade, 9, 0, 0, 0)
- SetAmmo(amMolotov, 9, 0, 0, 0)
- SetAmmo(amShotgun, 9, 0, 0, 0)
- --SetAmmo(amFlamethrower, 9, 0, 0, 0) -- this was suggested on hw.org but it's not present on base
- SetAmmo(amFirePunch, 9, 0, 0, 0)
- SetAmmo(amMine, 9, 0, 0, 0)
- --SetAmmo(amCake, 1, 0, 2, 0) -- maybe it's beefcake?
- SetAmmo(amJetpack, 9, 0, 0, 0)
- SetAmmo(amBlowTorch, 9, 0, 0, 0)
- SetAmmo(amTeleport, 9, 0, 0, 0)
- SetAmmo(amLowGravity, 9, 0, 0, 0)
- --SetAmmo(amSkipGo, 9, 0, 0, 0) -- not needed with 1s turn time
-end
+-------------------------------------------
+-- FRENZY
+-- a hedgewars mode inspired by Hysteria
+-------------------------------------------
+
+HedgewarsScriptLoad("/Scripts/Locale.lua")
+HedgewarsScriptLoad("/Scripts/Tracker.lua")
+
+local cTimer = 0
+local cn = 0
+
+function initialSetup(gear)
+ SetHealth(gear, 75) -- official is 80, but that assumes bazookas/grenades that do 50 damage
+end
+
+function showStartingInfo()
+
+ ruleSet = "" ..
+ loc("RULES") .. ": " .. "|" ..
+ loc("Each turn is only ONE SECOND!") .. "|" ..
+ loc("Use your ready time to think.") .. "|" ..
+ loc("Slot keys save time! (F1-F10 by default)") .. "|" ..
+ " |" ..
+ loc("SLOTS") .. ": " .. "|" ..
+ loc("Slot") .. " 1 - " .. loc("Bazooka") .. "|" ..
+ loc("Slot") .. " 2 - " .. loc("Grenade") .. "|" ..
+ loc("Slot") .. " 3 - " .. loc("Shotgun") .. "|" ..
+ loc("Slot") .. " 4 - " .. loc("Shoryuken") .. "|" ..
+ loc("Slot") .. " 5 - " .. loc("Mine") .. "|" ..
+ loc("Slot") .. " 6 - " .. loc("Teleport") .. "|" ..
+ loc("Slot") .. " 7 - " .. loc("Blowtorch") .. "|" ..
+ loc("Slot") .. " 8 - " .. loc("Flying Saucer") .. "|" ..
+ loc("Slot") .. " 9 - " .. loc("Molotov") .. "|" ..
+ loc("Slot") .. " 10 - " .. loc("Low Gravity")
+
+ ShowMission(loc("FRENZY"),
+ loc("a frenetic Hedgewars mini-game"),
+ ruleSet, 0, 4000)
+
+end
+
+function onGameInit()
+
+ if TurnTime > 10001 then
+ Ready = 8000
+ else
+ Ready = TurnTime
+ end
+
+ TurnTime = 1000
+
+ --These are the official settings, but I think I prefer allowing customization in this regard
+ --MinesNum = 8
+ --MinesTime = 3000
+ --MinesDudPercent = 30
+ --Explosives = 0
+
+ --Supposedly official settings
+ HealthCaseProb = 0
+ CrateFreq = 0
+
+ --Approximation of Official Settings
+ --SuddenDeathTurns = 10
+ --WaterRise = 47
+ --HealthDecrease = 0
+
+end
+
+function onGameStart()
+ showStartingInfo()
+ runOnHogs(initialSetup)
+end
+
+function onSlot(sln)
+ cTimer = 8
+ cn = sln
+end
+
+function onGameTick()
+ if cTimer ~= 0 then
+ cTimer = cTimer -1
+ if cTimer == 1 then
+ ChangeWep(cn)
+ cn = 0
+ cTimer = 0
+ end
+ end
+end
+
+function ChangeWep(s)
+
+ if s == 0 then
+ SetWeapon(amBazooka)
+ elseif s == 1 then
+ SetWeapon(amGrenade)
+ elseif s == 2 then
+ SetWeapon(amShotgun)
+ elseif s == 3 then
+ SetWeapon(amFirePunch)
+ elseif s == 4 then
+ SetWeapon(amMine)
+ elseif s == 5 then
+ SetWeapon(amTeleport)
+ elseif s == 6 then
+ SetWeapon(amBlowTorch)
+ elseif s == 7 then
+ SetWeapon(amJetpack)
+ elseif s == 8 then
+ SetWeapon(amMolotov)
+ elseif s == 9 then
+ SetWeapon(amLowGravity)
+ end
+
+end
+
+function onGearAdd(gear)
+ if GetGearType(gear) == gtHedgehog then
+ trackGear(gear)
+ end
+end
+
+function onGearDelete(gear)
+ if GetGearType(gear) == gtHedgehog then
+ trackDeletion(gear)
+ end
+end
+
+function onAmmoStoreInit()
+ SetAmmo(amBazooka, 9, 0, 0, 0)
+ SetAmmo(amGrenade, 9, 0, 0, 0)
+ SetAmmo(amMolotov, 9, 0, 0, 0)
+ SetAmmo(amShotgun, 9, 0, 0, 0)
+ --SetAmmo(amFlamethrower, 9, 0, 0, 0) -- this was suggested on hw.org but it's not present on base
+ SetAmmo(amFirePunch, 9, 0, 0, 0)
+ SetAmmo(amMine, 9, 0, 0, 0)
+ --SetAmmo(amCake, 1, 0, 2, 0) -- maybe it's beefcake?
+ SetAmmo(amJetpack, 9, 0, 0, 0)
+ SetAmmo(amBlowTorch, 9, 0, 0, 0)
+ SetAmmo(amTeleport, 9, 0, 0, 0)
+ SetAmmo(amLowGravity, 9, 0, 0, 0)
+ --SetAmmo(amSkipGo, 9, 0, 0, 0) -- not needed with 1s turn time
+end
--- a/share/hedgewars/Data/Scripts/Multiplayer/Mutant.lua Wed Jul 15 00:27:12 2015 +0200
+++ b/share/hedgewars/Data/Scripts/Multiplayer/Mutant.lua Thu Jul 16 08:39:35 2015 -0400
@@ -1,621 +1,621 @@
-local MUTANT_VERSION = "v0.9.5"
-
---[[ ___ ___
- ( ) ( )
-___ .-. .-. ___ ___ | |_ .---. ___ .-. | |_
-( ) ' ( )( ( __) / .-, ( ) ( __)
-| .-. .-. | | | | | | (__) ; || .-. .| |
-| | | | | | | | | | | ___ .'` || | | || | ___
-| | | | | | | | | | |( / .'| || | | || |( )
-| | | | | | | | | | | | | / | || | | || | | |
-| | | | | | | ; ' | ' | ; | ; || | | || ' | |
-| | | | | ' `-' / ' `-' ' `-' || | | |' `-' ;
-(___)(___)(___'.__.' `.__.`.__.'_(___)(___)`.__.
-
-
----- Recommended settings:
----- * one hedgehog per team
----- * 'Small' one-island map
-
---]]
-
-HedgewarsScriptLoad("/Scripts/Locale.lua")
-HedgewarsScriptLoad("/Scripts/Tracker.lua")
-HedgewarsScriptLoad("/Scripts/Params.lua")
-
---[[
- MUTANT SCRIPT
-
- To Do: -Clean-up this fucking piece of code
- -Debug
- -Find a girlfriend
- -Fix Sheepluva's hat +[p]
- -Cookies
------------------------]]
-
-local hhs = {}
-local numhhs = 0
-local meh = false
-
-local gameOver=false
-
-local mutant = nil
-local mutant_base_health = 200
-local mutant_base_disease = 25
-local disease_timer = 2000
-
-local kill_reward = nil
-local mt_hurt=false
-
-local killsCounter = 0
-
-local team_fire_punishment = 3
-local mutant_kill_reward = 2
-
-local hh_weapons = { amBazooka, amGrenade, amShotgun, amMine}
-
-local mt_weapons = {amWatermelon, amHellishBomb, amBallgun, amRCPlane, amTeleport}
-
-local disease=0
-local timer=0
-
-local winScore = 15
-local hogsLimit = 1
-
-local teams = {}
-
-local circles = {}
-local circleFrame = -1
-
-function showStartingInfo()
-
- ruleSet = loc("RULES") .. ": " ..
- " |" .. --" |" ..
- loc("The first player to kill someone becomes the Mutant.") .. "|" ..
- loc("The Mutant has super-weapons and a lot of health.") .. "|" ..
- loc("The Mutant loses health quickly if he doesn't keep scoring kills.") .. "|" ..
- " |" ..
- loc("Normal players can only score points by killing the mutant.") .. "|" ..
- " |" .. "" ..
- loc("The player with least points (or most deaths) becomes the Bottom Feeder.") .. "|" ..
- loc("The Bottom Feeder can score points by killing anyone.") .. "|" ..
- " |" ..
- loc("POINTS") .. ": " ..
- " |" ..
- loc("+2 for becoming a Mutant") .. "|" ..
- loc("+1 to a Mutant for killing anyone") .. "|" ..
- loc("+1 to a Bottom Feeder for killing anyone") .. "|" ..
- loc("-1 to anyone for a suicide") .. "|" ..
- loc("Other kills don't give you points.")
-
- ShowMission(loc("Mutant"),
- loc("a Hedgewars tag game"),
- ruleSet, 0, 5000)
-
-end
-
-function onGameInit()
- TurnTime = 20000
- WaterRise = 0
- EnableGameFlags(gfResetWeps, gfPerHogAmmo)
- HealthCaseProb=0
- HealthCaseAmount=0
- MinesTime=1000
- CaseFreq = 2
-end
-
-
-function limitHogs(gear)
- cnthhs = cnthhs + 1
- if cnthhs > 1 then
- hogLimitHit = true
- SetEffect(gear, heResurrectable, false)
- --SetHealth(gear, 0)
- SetGearPosition(gear, -100,LAND_HEIGHT)
- end
-end
-
-function onGameStart()
- trackTeams()
- teamScan()
- runOnHogs(saveStuff)
- --local str = "/say " .. MUTANT_VERSION
- --ParseCommand(str)
-
- hogLimitHit = false
- for i=0 , TeamsCount - 1 do
- cnthhs = 0
- runOnHogsInTeam(limitHogs, teams[i])
- end
- if hogLimitHit then
- AddCaption(loc("ONE HOG PER TEAM! KILLING EXCESS HEDGES"))
- end
- showStartingInfo()
-end
-
-
-
-function giveWeapons(gear)
- if gear == mutant then
- AddAmmo(gear, amRope)
- for i=1, #mt_weapons do
- AddAmmo(gear, mt_weapons[i])
- end
-
- else
- for i=1, #hh_weapons do
- AddAmmo(gear,hh_weapons[i])
- end
- end
-end
-
-function onAmmoStoreInit()
-
- SetAmmo(amSkip, 9, 0, 0, 0)
- SetAmmo(amRope,0,1,0,5)
- SetAmmo(amSnowball,0,1,0,1)
-
- for i=1, #hh_weapons do
- SetAmmo(hh_weapons[i], 0, 0, 0, 1)
- end
-
- for i=1, #mt_weapons do
- SetAmmo(mt_weapons[i], 0, 3, 0, 1)
- end
-
-end
-
-function drawCircles()
- for i = 0, #hhs do
- if circles[hhs[i]] ~= nil then
- DeleteVisualGear(circles[hhs[i]])
- circles[hhs[i]] = nil
- end
-
- if hhs[i] ~= CurrentHedgehog then
- if mutant == nil then
- circles[hhs[i]] = AddVisualGear(0, 0, vgtCircle, 0, false)
- SetVisualGearValues(circles[hhs[i]], 0, 0, 0, 0, 0, 0, 0, 22, 5, 0xff000080)
- elseif CurrentHedgehog == mutant then
- circles[hhs[i]] = AddVisualGear(0, 0, vgtCircle, 0, false)
- SetVisualGearValues(circles[hhs[i]], 0, 0, 0, 0, 0, 0, 0, 22, 3, 0xaa000070)
- elseif getGearValue(CurrentHedgehog, "Feeder") and hhs[i] ~= mutant then
- circles[hhs[i]] = AddVisualGear(0, 0, vgtCircle, 0, false)
- SetVisualGearValues(circles[hhs[i]], 0, 0, 0, 0, 0, 0, 0, 22, 3, 0xaa000070)
- elseif hhs[i] == mutant then
- circles[hhs[i]] = AddVisualGear(0, 0, vgtCircle, 0, false)
- SetVisualGearValues(circles[hhs[i]], 0, 0, 0, 0, 0, 0, 0, 22, 5, 0xff000080)
- end
- end
- end
- circleFrame = 0
-end
-
-function onNewTurn()
-
- trackTeams()
- killsCounter = 0
-
- if mutant == nil then
- AddCaption( loc("FIRST BLOOD MUTATES") )
- end
-
- checkScore()
- giveWeapons(CurrentHedgehog)
- drawCircles()
- setAIHints()
- kill_reward= numhhs*10
-
- if CurrentHedgehog == mutant then
- mt_hurt=true
- disease= mutant_base_disease - numhhs
- else
- mt_hurt=false
- end
-
- setGearValue(CurrentHedgehog, "Alive", true)
-
-end
-
-function countBodies()
- if killsCounter == 2 then
- AddCaption(loc("DOUBLE KILL"))
- elseif killsCounter == 3 then
- AddCaption(loc("MEGA KILL"))
- PlaySound(sndRegret)
- elseif killsCounter == 4 then
- AddCaption(loc("ULTRA KILL"))
- elseif killsCounter == 5 then
- AddCaption(loc("MONSTER KILL"))
- PlaySound(sndIllGetYou)
- elseif killsCounter == 6 then
- AddCaption(loc("LUDICROUS KILL"))
- PlaySound(sndNutter)
- elseif killsCounter == 7 then
- AddCaption(loc("HOLY SHYTE!"))
- PlaySound(sndLaugh)
- elseif killsCounter > 8 then
- AddCaption(loc("INSANITY"))
- end
-end
-
-function onGameTick()
-
- if circleFrame > -1 then
- for i = 0, #hhs do
- if circles[hhs[i]] ~= nil and hhs[i]~= nil then
- hhx, hhy = GetGearPosition(hhs[i])
- X, Y, dX, dY, Angle, Frame, FrameTicks, State, Timer, Tint = GetVisualGearValues(circles[hhs[i]])
- SetVisualGearValues(circles[hhs[i]], hhx + 1, hhy - 3, 0, 0, 0, 0, 0, 40 - (circleFrame % 25), Timer, Tint)
- end
- end
-
- circleFrame = circleFrame + 0.06
-
- if circleFrame >= 25 then
- for i = 0, #hhs do
- if circles[hhs[i]] ~= nil then
- DeleteVisualGear(circles[hhs[i]])
- circles[hhs[i]] = nil
- end
- end
- end
- end
-
- if TurnTimeLeft==0 and mt_hurt then
- mt_hurt = false
- end
-
- if mt_hurt and mutant~=nil then
- timer = timer + 1
- if timer > disease_timer then
- timer = 0
- SetHealth(mutant, GetHealth(mutant)-disease )
- AddVisualGear(GetX(mutant), GetY(mutant)-5, vgtHealthTag, disease, true)
- if GetHealth(mutant)<=0 then
- SetHealth(mutant,0)
- mt_hurt= false
- setGearValue(mutant,"SelfDestruct",true)
- TurnTimeLeft = 0
- end
- end
- end
-
-end
-
-function saveStuff(gear)
- setGearValue(gear,"Name",GetHogName(gear))
- setGearValue(gear,"Hat",GetHogHat(gear))
-end
-
-function armageddon(gear)
- SetState(gear, gstLoser)
- SetEffect(gear, heResurrectable, false)
- SetHealth(gear, 0)
-end
-
-function updateScore()
-
- local showScore = ""
-
- for i=0, TeamsCount-1 do
- if teams[i]~= nil then
-
- local curr_score = getTeamValue(teams[i], "Score")
- showScore = showScore .. teams[i] .. ": " .. curr_score .. " (deaths: " .. getTeamValue(teams[i], "DeadHogs") .. ") " .. "|"
-
- end
- end
-
- ShowMission(loc("Score"),
- "-------",
- showScore, 0, 200)
-
- HideMission()
-
-end
-
-function checkScore()
-local showScore = ""
-local lowest_score_team = nil
-local min_score=nil
-local winTeam = nil
-
-local only_low_score = true
-
- for i=0, TeamsCount-1 do
- if teams[i]~=nil then
- local curr_score = getTeamValue(teams[i], "Score")
-
- runOnHogsInTeam(removeFeeder, teams[i])
-
- showScore = showScore .. teams[i] ..": " .. curr_score .. " (deaths: " .. getTeamValue(teams[i], "DeadHogs") .. ") " .. "|"
-
- if curr_score >= winScore then
- gameOver = true
- winTeam = teams[i]
- end
-
- if min_score==nil then
- min_score= curr_score
- lowest_score_team = teams[i]
- else
- if curr_score <= min_score then
- if curr_score == min_score then
- if getTeamValue(teams[i], "DeadHogs") == getTeamValue(lowest_score_team, "DeadHogs") then
- only_low_score = false
- else
- if getTeamValue(teams[i], "DeadHogs") > getTeamValue(lowest_score_team, "DeadHogs") then
- lowest_score_team = teams[i]
- end
- only_low_score = true
- end
-
- else
- min_score= curr_score
- lowest_score_team = teams[i]
- only_low_score = true
- end
- end
- end
- end
- end
-
- if gameOver then
- TurnTimeLeft = 0
- for i=0, #teams do
- if teams[i]~=winTeam then
- runOnHogsInTeam(armageddon, teams[i])
- end
- end
-
- ShowMission( loc("WINNER IS ") .. winTeam,
- "~~~~~~~~~~~~~~~~~~~~~~~~~",
- showScore, 0, 200)
- else
-
- if only_low_score then
- runOnHogsInTeam(setFeeder, lowest_score_team)
- end
-
- if meh == false then
- meh = true
- else
- ShowMission( loc("Score"),
- loc("-------"),
- showScore, 0, 200)
- end
-
- end
-end
-
-function backToNormal(gear)
- SetHogName(gear, getGearValue(gear,"Name"))
- SetHogHat(gear, 'NoHat')
- SetHogHat(gear, getGearValue(gear,"Hat"))
- setGearValue(mutant,"SelfDestruct",false)
- mt_hurt=false
- mutant=nil
-end
-
-function setAIHints()
- for i = 0, #hhs do
- if mutant == nil or hhs[i] == mutant or CurrentHedgehog == mutant or getGearValue(CurrentHedgehog, "Feeder") then
- SetGearAIHints(hhs[i], aihUsual)
- else
- SetGearAIHints(hhs[i], aihDoesntMatter)
- end
- end
-end
-
-function removeFeeder(gear)
- if gear~=nil then
- setGearValue(gear,"Feeder",false)
- if gear~= mutant then
- SetHogName(gear, getGearValue(gear,"Name") )
- SetHogHat(gear, 'NoHat')
- SetHogHat(gear, getGearValue(gear,"Hat"))
- end
- end
-end
-
-function setFeeder(gear)
- if gear~= mutant and gear~= nil then
- SetHogName(gear,"BOTTOM FEEDER")
- SetHogHat(gear, 'poke_slowpoke')
- setGearValue(gear,"Feeder", true)
- end
-end
-
-function setMutantStuff(gear)
- mutant = gear
-
- SetHogName(gear,"MUTANT")
- SetHogHat(gear,'WhySoSerious')
- SetHealth(gear, ( mutant_base_health + numhhs*25) )
- SetEffect(gear, hePoisoned, 1)
- setGearValue(mutant,"SelfDestruct",false)
- setGearValue(gear, "Feeder", false)
-
- AddCaption(getGearValue(gear, "Name") .. loc(" HAS MUTATED"))
-
- TurnTimeLeft=0
-
- AddVisualGear(GetX(gear), GetY(gear), vgtSmokeRing, 0, false)
- AddVisualGear(GetX(gear), GetY(gear), vgtSmokeRing, 0, false)
- AddVisualGear(GetX(gear), GetY(gear), vgtSmokeRing, 0, false)
- AddVisualGear(GetX(gear), GetY(gear), vgtSmokeRing, 0, false)
- AddVisualGear(GetX(gear), GetY(gear), vgtSmokeRing, 0, false)
- PlaySound(sndSuddenDeath)
-end
-
-function teamScan()
-
- for i=0, TeamsCount-1 do --nil filling
- teams[i]=nil
- end
-
- for i=0, #hhs do
- for j=0, TeamsCount-1 do
- if teams[j] ==nil and hhs[i]~=nil then
- teams[j] = GetHogTeamName(hhs[i])
- setTeamValue(teams[j],"Score",0)
- setTeamValue(teams[j], "DeadHogs",0)
- break
- end
-
- if teams[j] == GetHogTeamName(hhs[i]) then
- break
- end
- end
- end
-
- ---***---
-end
-
-function set_Mutant_and_Score(gear)
-
-local curr_team = GetHogTeamName(CurrentHedgehog)
-
- if gear == CurrentHedgehog then
- if CurrentHedgehog == mutant then
- PlaySound(sndHomerun)
- if getGearValue(gear, "SelfDestruct")==false then
- decreaseTeamValue(curr_team,"Score")
- end
- backToNormal(gear)
- else
- decreaseTeamValue(curr_team,"Score")
- end
-
- else
- if gear == mutant then
- backToNormal(mutant)
- if curr_team ~=GetHogTeamName(gear) then
- if getGearValue(CurrentHedgehog, "Alive") then
- setMutantStuff(CurrentHedgehog)
- setTeamValue(curr_team,"Score",(getTeamValue(curr_team,"Score") + mutant_kill_reward))
- end
- else
- setTeamValue(curr_team,"Score",(getTeamValue(curr_team,"Score") - team_fire_punishment))
- end
- else
- if mutant==nil then
- if curr_team ~=GetHogTeamName(gear) then
- if getGearValue(CurrentHedgehog, "Alive") then
- setMutantStuff(CurrentHedgehog)
- setTeamValue(curr_team,"Score",(getTeamValue(curr_team,"Score") + mutant_kill_reward))
- else
- increaseTeamValue(curr_team,"Score")
- end
- else
- setTeamValue(curr_team,"Score",(getTeamValue(curr_team,"Score") - team_fire_punishment))
- end
- else
- if curr_team ~=GetHogTeamName(gear) then
- if CurrentHedgehog==mutant and getGearValue(mutant,"SelfDestruct")==false then
- SetHealth(CurrentHedgehog, GetHealth(CurrentHedgehog)+kill_reward)
- AddCaption("+" .. kill_reward .. loc(" HP") )
- increaseTeamValue(curr_team,"Score")
- end
- if getGearValue(CurrentHedgehog,"Feeder") then
- increaseTeamValue(curr_team,"Score")
- end
- else
- setTeamValue(curr_team,"Score",(getTeamValue(curr_team,"Score") - team_fire_punishment))
- end
- end
- end
- end
-end
-
-function onGearResurrect(gear)
-if not gameOver then
- if GetGearType(gear) == gtHedgehog then
-
- increaseTeamValue(GetHogTeamName(gear), "DeadHogs")
-
- if gear==CurrentHedgehog then
- setGearValue(CurrentHedgehog, "Alive", false)
- end
- set_Mutant_and_Score(gear)
- if gear~=CurrentHedgehog then
- killsCounter = killsCounter + 1
- countBodies()
- end
- AddVisualGear(GetX(gear), GetY(gear), vgtSmokeRing, 0, false)
- PlaySound(sndWhack)
- updateScore()
- end
-end
-end
-
-function onGearAdd(gear)
-
- -- Catch hedgehogs for the tracker
- if GetGearType(gear) == gtHedgehog then
- trackGear(gear)
- hhs[numhhs] = gear
- numhhs = numhhs + 1
- SetEffect(gear, heResurrectable, 1)
- end
-end
-
-function checkEmptyTeam (teamName)
- for i=0 , #hhs do
- if hhs[i]~=nil then
- if teamName == GetHogTeamName(hhs[i]) then
- return false
- end
- end
- end
- return true
-end
-
-function onGearDelete(gear)
- -- Remove hogs that are gone
- if GetGearType(gear) == gtHedgehog then
- numhhs = numhhs - 1
-
- local found
- for i=0, #hhs do
- if hhs[i] == gear then
- found = i
- break
- end
- end
- for i = found, #hhs - 1 do
- hhs[i] = hhs[i + 1]
- end
- hhs[#hhs] = nil
-
- local t_name = GetHogTeamName(gear)
- if checkEmptyTeam(t_name) then
- for i = 0, TeamsCount - 1 do
- if teams[i] == t_name then
- found = i
- break
- end
- end
- for i = found, TeamsCount - 2 do
- teams[i] = teams[i + 1]
- end
- teams[TeamsCount - 1] = nil
- TeamsCount = TeamsCount - 1
- end
- AddVisualGear(GetX(gear), GetY(gear), vgtBigExplosion, 0, false)
- trackDeletion(gear)
- end
-end
-
-function onParameters()
- parseParams()
- winScore = tonumber(params["winscore"]) or winScore
-end
-
---[[
-S T A R R I N G
- prof - Coding, implementing and evangelism
- vos - Initial idea and script improvements
- mikade - Moving the `how to play` into the game so that people know `how to play`, and whitespace :D
---]]
+local MUTANT_VERSION = "v0.9.5"
+
+--[[ ___ ___
+ ( ) ( )
+___ .-. .-. ___ ___ | |_ .---. ___ .-. | |_
+( ) ' ( )( ( __) / .-, ( ) ( __)
+| .-. .-. | | | | | | (__) ; || .-. .| |
+| | | | | | | | | | | ___ .'` || | | || | ___
+| | | | | | | | | | |( / .'| || | | || |( )
+| | | | | | | | | | | | | / | || | | || | | |
+| | | | | | | ; ' | ' | ; | ; || | | || ' | |
+| | | | | ' `-' / ' `-' ' `-' || | | |' `-' ;
+(___)(___)(___'.__.' `.__.`.__.'_(___)(___)`.__.
+
+
+---- Recommended settings:
+---- * one hedgehog per team
+---- * 'Small' one-island map
+
+--]]
+
+HedgewarsScriptLoad("/Scripts/Locale.lua")
+HedgewarsScriptLoad("/Scripts/Tracker.lua")
+HedgewarsScriptLoad("/Scripts/Params.lua")
+
+--[[
+ MUTANT SCRIPT
+
+ To Do: -Clean-up this fucking piece of code
+ -Debug
+ -Find a girlfriend
+ -Fix Sheepluva's hat +[p]
+ -Cookies
+-----------------------]]
+
+local hhs = {}
+local numhhs = 0
+local meh = false
+
+local gameOver=false
+
+local mutant = nil
+local mutant_base_health = 200
+local mutant_base_disease = 25
+local disease_timer = 2000
+
+local kill_reward = nil
+local mt_hurt=false
+
+local killsCounter = 0
+
+local team_fire_punishment = 3
+local mutant_kill_reward = 2
+
+local hh_weapons = { amBazooka, amGrenade, amShotgun, amMine}
+
+local mt_weapons = {amWatermelon, amHellishBomb, amBallgun, amRCPlane, amTeleport}
+
+local disease=0
+local timer=0
+
+local winScore = 15
+local hogsLimit = 1
+
+local teams = {}
+
+local circles = {}
+local circleFrame = -1
+
+function showStartingInfo()
+
+ ruleSet = loc("RULES") .. ": " ..
+ " |" .. --" |" ..
+ loc("The first player to kill someone becomes the Mutant.") .. "|" ..
+ loc("The Mutant has super-weapons and a lot of health.") .. "|" ..
+ loc("The Mutant loses health quickly if he doesn't keep scoring kills.") .. "|" ..
+ " |" ..
+ loc("Normal players can only score points by killing the mutant.") .. "|" ..
+ " |" .. "" ..
+ loc("The player with least points (or most deaths) becomes the Bottom Feeder.") .. "|" ..
+ loc("The Bottom Feeder can score points by killing anyone.") .. "|" ..
+ " |" ..
+ loc("POINTS") .. ": " ..
+ " |" ..
+ loc("+2 for becoming a Mutant") .. "|" ..
+ loc("+1 to a Mutant for killing anyone") .. "|" ..
+ loc("+1 to a Bottom Feeder for killing anyone") .. "|" ..
+ loc("-1 to anyone for a suicide") .. "|" ..
+ loc("Other kills don't give you points.")
+
+ ShowMission(loc("Mutant"),
+ loc("a Hedgewars tag game"),
+ ruleSet, 0, 5000)
+
+end
+
+function onGameInit()
+ TurnTime = 20000
+ WaterRise = 0
+ EnableGameFlags(gfResetWeps, gfPerHogAmmo)
+ HealthCaseProb=0
+ HealthCaseAmount=0
+ MinesTime=1000
+ CaseFreq = 2
+end
+
+
+function limitHogs(gear)
+ cnthhs = cnthhs + 1
+ if cnthhs > 1 then
+ hogLimitHit = true
+ SetEffect(gear, heResurrectable, false)
+ --SetHealth(gear, 0)
+ SetGearPosition(gear, -100,LAND_HEIGHT)
+ end
+end
+
+function onGameStart()
+ trackTeams()
+ teamScan()
+ runOnHogs(saveStuff)
+ --local str = "/say " .. MUTANT_VERSION
+ --ParseCommand(str)
+
+ hogLimitHit = false
+ for i=0 , TeamsCount - 1 do
+ cnthhs = 0
+ runOnHogsInTeam(limitHogs, teams[i])
+ end
+ if hogLimitHit then
+ AddCaption(loc("ONE HOG PER TEAM! KILLING EXCESS HEDGES"))
+ end
+ showStartingInfo()
+end
+
+
+
+function giveWeapons(gear)
+ if gear == mutant then
+ AddAmmo(gear, amRope)
+ for i=1, #mt_weapons do
+ AddAmmo(gear, mt_weapons[i])
+ end
+
+ else
+ for i=1, #hh_weapons do
+ AddAmmo(gear,hh_weapons[i])
+ end
+ end
+end
+
+function onAmmoStoreInit()
+
+ SetAmmo(amSkip, 9, 0, 0, 0)
+ SetAmmo(amRope,0,1,0,5)
+ SetAmmo(amSnowball,0,1,0,1)
+
+ for i=1, #hh_weapons do
+ SetAmmo(hh_weapons[i], 0, 0, 0, 1)
+ end
+
+ for i=1, #mt_weapons do
+ SetAmmo(mt_weapons[i], 0, 3, 0, 1)
+ end
+
+end
+
+function drawCircles()
+ for i = 0, #hhs do
+ if circles[hhs[i]] ~= nil then
+ DeleteVisualGear(circles[hhs[i]])
+ circles[hhs[i]] = nil
+ end
+
+ if hhs[i] ~= CurrentHedgehog then
+ if mutant == nil then
+ circles[hhs[i]] = AddVisualGear(0, 0, vgtCircle, 0, false)
+ SetVisualGearValues(circles[hhs[i]], 0, 0, 0, 0, 0, 0, 0, 22, 5, 0xff000080)
+ elseif CurrentHedgehog == mutant then
+ circles[hhs[i]] = AddVisualGear(0, 0, vgtCircle, 0, false)
+ SetVisualGearValues(circles[hhs[i]], 0, 0, 0, 0, 0, 0, 0, 22, 3, 0xaa000070)
+ elseif getGearValue(CurrentHedgehog, "Feeder") and hhs[i] ~= mutant then
+ circles[hhs[i]] = AddVisualGear(0, 0, vgtCircle, 0, false)
+ SetVisualGearValues(circles[hhs[i]], 0, 0, 0, 0, 0, 0, 0, 22, 3, 0xaa000070)
+ elseif hhs[i] == mutant then
+ circles[hhs[i]] = AddVisualGear(0, 0, vgtCircle, 0, false)
+ SetVisualGearValues(circles[hhs[i]], 0, 0, 0, 0, 0, 0, 0, 22, 5, 0xff000080)
+ end
+ end
+ end
+ circleFrame = 0
+end
+
+function onNewTurn()
+
+ trackTeams()
+ killsCounter = 0
+
+ if mutant == nil then
+ AddCaption( loc("FIRST BLOOD MUTATES") )
+ end
+
+ checkScore()
+ giveWeapons(CurrentHedgehog)
+ drawCircles()
+ setAIHints()
+ kill_reward= numhhs*10
+
+ if CurrentHedgehog == mutant then
+ mt_hurt=true
+ disease= mutant_base_disease - numhhs
+ else
+ mt_hurt=false
+ end
+
+ setGearValue(CurrentHedgehog, "Alive", true)
+
+end
+
+function countBodies()
+ if killsCounter == 2 then
+ AddCaption(loc("DOUBLE KILL"))
+ elseif killsCounter == 3 then
+ AddCaption(loc("MEGA KILL"))
+ PlaySound(sndRegret)
+ elseif killsCounter == 4 then
+ AddCaption(loc("ULTRA KILL"))
+ elseif killsCounter == 5 then
+ AddCaption(loc("MONSTER KILL"))
+ PlaySound(sndIllGetYou)
+ elseif killsCounter == 6 then
+ AddCaption(loc("LUDICROUS KILL"))
+ PlaySound(sndNutter)
+ elseif killsCounter == 7 then
+ AddCaption(loc("HOLY SHYTE!"))
+ PlaySound(sndLaugh)
+ elseif killsCounter > 8 then
+ AddCaption(loc("INSANITY"))
+ end
+end
+
+function onGameTick()
+
+ if circleFrame > -1 then
+ for i = 0, #hhs do
+ if circles[hhs[i]] ~= nil and hhs[i]~= nil then
+ hhx, hhy = GetGearPosition(hhs[i])
+ X, Y, dX, dY, Angle, Frame, FrameTicks, State, Timer, Tint = GetVisualGearValues(circles[hhs[i]])
+ SetVisualGearValues(circles[hhs[i]], hhx + 1, hhy - 3, 0, 0, 0, 0, 0, 40 - (circleFrame % 25), Timer, Tint)
+ end
+ end
+
+ circleFrame = circleFrame + 0.06
+
+ if circleFrame >= 25 then
+ for i = 0, #hhs do
+ if circles[hhs[i]] ~= nil then
+ DeleteVisualGear(circles[hhs[i]])
+ circles[hhs[i]] = nil
+ end
+ end
+ end
+ end
+
+ if TurnTimeLeft==0 and mt_hurt then
+ mt_hurt = false
+ end
+
+ if mt_hurt and mutant~=nil then
+ timer = timer + 1
+ if timer > disease_timer then
+ timer = 0
+ SetHealth(mutant, GetHealth(mutant)-disease )
+ AddVisualGear(GetX(mutant), GetY(mutant)-5, vgtHealthTag, disease, true)
+ if GetHealth(mutant)<=0 then
+ SetHealth(mutant,0)
+ mt_hurt= false
+ setGearValue(mutant,"SelfDestruct",true)
+ TurnTimeLeft = 0
+ end
+ end
+ end
+
+end
+
+function saveStuff(gear)
+ setGearValue(gear,"Name",GetHogName(gear))
+ setGearValue(gear,"Hat",GetHogHat(gear))
+end
+
+function armageddon(gear)
+ SetState(gear, gstLoser)
+ SetEffect(gear, heResurrectable, false)
+ SetHealth(gear, 0)
+end
+
+function updateScore()
+
+ local showScore = ""
+
+ for i=0, TeamsCount-1 do
+ if teams[i]~= nil then
+
+ local curr_score = getTeamValue(teams[i], "Score")
+ showScore = showScore .. teams[i] .. ": " .. curr_score .. " (deaths: " .. getTeamValue(teams[i], "DeadHogs") .. ") " .. "|"
+
+ end
+ end
+
+ ShowMission(loc("Score"),
+ "-------",
+ showScore, 0, 200)
+
+ HideMission()
+
+end
+
+function checkScore()
+local showScore = ""
+local lowest_score_team = nil
+local min_score=nil
+local winTeam = nil
+
+local only_low_score = true
+
+ for i=0, TeamsCount-1 do
+ if teams[i]~=nil then
+ local curr_score = getTeamValue(teams[i], "Score")
+
+ runOnHogsInTeam(removeFeeder, teams[i])
+
+ showScore = showScore .. teams[i] ..": " .. curr_score .. " (deaths: " .. getTeamValue(teams[i], "DeadHogs") .. ") " .. "|"
+
+ if curr_score >= winScore then
+ gameOver = true
+ winTeam = teams[i]
+ end
+
+ if min_score==nil then
+ min_score= curr_score
+ lowest_score_team = teams[i]
+ else
+ if curr_score <= min_score then
+ if curr_score == min_score then
+ if getTeamValue(teams[i], "DeadHogs") == getTeamValue(lowest_score_team, "DeadHogs") then
+ only_low_score = false
+ else
+ if getTeamValue(teams[i], "DeadHogs") > getTeamValue(lowest_score_team, "DeadHogs") then
+ lowest_score_team = teams[i]
+ end
+ only_low_score = true
+ end
+
+ else
+ min_score= curr_score
+ lowest_score_team = teams[i]
+ only_low_score = true
+ end
+ end
+ end
+ end
+ end
+
+ if gameOver then
+ TurnTimeLeft = 0
+ for i=0, #teams do
+ if teams[i]~=winTeam then
+ runOnHogsInTeam(armageddon, teams[i])
+ end
+ end
+
+ ShowMission( loc("WINNER IS ") .. winTeam,
+ "~~~~~~~~~~~~~~~~~~~~~~~~~",
+ showScore, 0, 200)
+ else
+
+ if only_low_score then
+ runOnHogsInTeam(setFeeder, lowest_score_team)
+ end
+
+ if meh == false then
+ meh = true
+ else
+ ShowMission( loc("Score"),
+ loc("-------"),
+ showScore, 0, 200)
+ end
+
+ end
+end
+
+function backToNormal(gear)
+ SetHogName(gear, getGearValue(gear,"Name"))
+ SetHogHat(gear, 'NoHat')
+ SetHogHat(gear, getGearValue(gear,"Hat"))
+ setGearValue(mutant,"SelfDestruct",false)
+ mt_hurt=false
+ mutant=nil
+end
+
+function setAIHints()
+ for i = 0, #hhs do
+ if mutant == nil or hhs[i] == mutant or CurrentHedgehog == mutant or getGearValue(CurrentHedgehog, "Feeder") then
+ SetGearAIHints(hhs[i], aihUsual)
+ else
+ SetGearAIHints(hhs[i], aihDoesntMatter)
+ end
+ end
+end
+
+function removeFeeder(gear)
+ if gear~=nil then
+ setGearValue(gear,"Feeder",false)
+ if gear~= mutant then
+ SetHogName(gear, getGearValue(gear,"Name") )
+ SetHogHat(gear, 'NoHat')
+ SetHogHat(gear, getGearValue(gear,"Hat"))
+ end
+ end
+end
+
+function setFeeder(gear)
+ if gear~= mutant and gear~= nil then
+ SetHogName(gear,"BOTTOM FEEDER")
+ SetHogHat(gear, 'poke_slowpoke')
+ setGearValue(gear,"Feeder", true)
+ end
+end
+
+function setMutantStuff(gear)
+ mutant = gear
+
+ SetHogName(gear,"MUTANT")
+ SetHogHat(gear,'WhySoSerious')
+ SetHealth(gear, ( mutant_base_health + numhhs*25) )
+ SetEffect(gear, hePoisoned, 1)
+ setGearValue(mutant,"SelfDestruct",false)
+ setGearValue(gear, "Feeder", false)
+
+ AddCaption(getGearValue(gear, "Name") .. loc(" HAS MUTATED"))
+
+ TurnTimeLeft=0
+
+ AddVisualGear(GetX(gear), GetY(gear), vgtSmokeRing, 0, false)
+ AddVisualGear(GetX(gear), GetY(gear), vgtSmokeRing, 0, false)
+ AddVisualGear(GetX(gear), GetY(gear), vgtSmokeRing, 0, false)
+ AddVisualGear(GetX(gear), GetY(gear), vgtSmokeRing, 0, false)
+ AddVisualGear(GetX(gear), GetY(gear), vgtSmokeRing, 0, false)
+ PlaySound(sndSuddenDeath)
+end
+
+function teamScan()
+
+ for i=0, TeamsCount-1 do --nil filling
+ teams[i]=nil
+ end
+
+ for i=0, #hhs do
+ for j=0, TeamsCount-1 do
+ if teams[j] ==nil and hhs[i]~=nil then
+ teams[j] = GetHogTeamName(hhs[i])
+ setTeamValue(teams[j],"Score",0)
+ setTeamValue(teams[j], "DeadHogs",0)
+ break
+ end
+
+ if teams[j] == GetHogTeamName(hhs[i]) then
+ break
+ end
+ end
+ end
+
+ ---***---
+end
+
+function set_Mutant_and_Score(gear)
+
+local curr_team = GetHogTeamName(CurrentHedgehog)
+
+ if gear == CurrentHedgehog then
+ if CurrentHedgehog == mutant then
+ PlaySound(sndHomerun)
+ if getGearValue(gear, "SelfDestruct")==false then
+ decreaseTeamValue(curr_team,"Score")
+ end
+ backToNormal(gear)
+ else
+ decreaseTeamValue(curr_team,"Score")
+ end
+
+ else
+ if gear == mutant then
+ backToNormal(mutant)
+ if curr_team ~=GetHogTeamName(gear) then
+ if getGearValue(CurrentHedgehog, "Alive") then
+ setMutantStuff(CurrentHedgehog)
+ setTeamValue(curr_team,"Score",(getTeamValue(curr_team,"Score") + mutant_kill_reward))
+ end
+ else
+ setTeamValue(curr_team,"Score",(getTeamValue(curr_team,"Score") - team_fire_punishment))
+ end
+ else
+ if mutant==nil then
+ if curr_team ~=GetHogTeamName(gear) then
+ if getGearValue(CurrentHedgehog, "Alive") then
+ setMutantStuff(CurrentHedgehog)
+ setTeamValue(curr_team,"Score",(getTeamValue(curr_team,"Score") + mutant_kill_reward))
+ else
+ increaseTeamValue(curr_team,"Score")
+ end
+ else
+ setTeamValue(curr_team,"Score",(getTeamValue(curr_team,"Score") - team_fire_punishment))
+ end
+ else
+ if curr_team ~=GetHogTeamName(gear) then
+ if CurrentHedgehog==mutant and getGearValue(mutant,"SelfDestruct")==false then
+ SetHealth(CurrentHedgehog, GetHealth(CurrentHedgehog)+kill_reward)
+ AddCaption("+" .. kill_reward .. loc(" HP") )
+ increaseTeamValue(curr_team,"Score")
+ end
+ if getGearValue(CurrentHedgehog,"Feeder") then
+ increaseTeamValue(curr_team,"Score")
+ end
+ else
+ setTeamValue(curr_team,"Score",(getTeamValue(curr_team,"Score") - team_fire_punishment))
+ end
+ end
+ end
+ end
+end
+
+function onGearResurrect(gear)
+if not gameOver then
+ if GetGearType(gear) == gtHedgehog then
+
+ increaseTeamValue(GetHogTeamName(gear), "DeadHogs")
+
+ if gear==CurrentHedgehog then
+ setGearValue(CurrentHedgehog, "Alive", false)
+ end
+ set_Mutant_and_Score(gear)
+ if gear~=CurrentHedgehog then
+ killsCounter = killsCounter + 1
+ countBodies()
+ end
+ AddVisualGear(GetX(gear), GetY(gear), vgtSmokeRing, 0, false)
+ PlaySound(sndWhack)
+ updateScore()
+ end
+end
+end
+
+function onGearAdd(gear)
+
+ -- Catch hedgehogs for the tracker
+ if GetGearType(gear) == gtHedgehog then
+ trackGear(gear)
+ hhs[numhhs] = gear
+ numhhs = numhhs + 1
+ SetEffect(gear, heResurrectable, 1)
+ end
+end
+
+function checkEmptyTeam (teamName)
+ for i=0 , #hhs do
+ if hhs[i]~=nil then
+ if teamName == GetHogTeamName(hhs[i]) then
+ return false
+ end
+ end
+ end
+ return true
+end
+
+function onGearDelete(gear)
+ -- Remove hogs that are gone
+ if GetGearType(gear) == gtHedgehog then
+ numhhs = numhhs - 1
+
+ local found
+ for i=0, #hhs do
+ if hhs[i] == gear then
+ found = i
+ break
+ end
+ end
+ for i = found, #hhs - 1 do
+ hhs[i] = hhs[i + 1]
+ end
+ hhs[#hhs] = nil
+
+ local t_name = GetHogTeamName(gear)
+ if checkEmptyTeam(t_name) then
+ for i = 0, TeamsCount - 1 do
+ if teams[i] == t_name then
+ found = i
+ break
+ end
+ end
+ for i = found, TeamsCount - 2 do
+ teams[i] = teams[i + 1]
+ end
+ teams[TeamsCount - 1] = nil
+ TeamsCount = TeamsCount - 1
+ end
+ AddVisualGear(GetX(gear), GetY(gear), vgtBigExplosion, 0, false)
+ trackDeletion(gear)
+ end
+end
+
+function onParameters()
+ parseParams()
+ winScore = tonumber(params["winscore"]) or winScore
+end
+
+--[[
+S T A R R I N G
+ prof - Coding, implementing and evangelism
+ vos - Initial idea and script improvements
+ mikade - Moving the `how to play` into the game so that people know `how to play`, and whitespace :D
+--]]
--- a/tools/hwmap.hs Wed Jul 15 00:27:12 2015 +0200
+++ b/tools/hwmap.hs Thu Jul 16 08:39:35 2015 -0400
@@ -1,164 +1,164 @@
-module Main where
-
-import qualified Data.ByteString.Char8 as B
-import qualified Data.ByteString as BW
-import qualified Data.ByteString.Lazy as BL
-import qualified Codec.Binary.Base64 as Base64
-import Data.Word
-import Data.Int
-import Data.Binary
-import Data.Binary.Put
-import Data.Bits
-import Control.Monad
-import qualified Codec.Compression.Zlib as Z
-
-data LineType = Solid | Erasing
- deriving Eq
-
-data Chunk = SpecialPoints [(Int16, Int16)]
- | Line LineType Word8 [(Int16, Int16)]
-
-transform :: ((Int16, Int16) -> (Int16, Int16)) -> [Chunk] -> [Chunk]
-transform f = map tf
- where
- tf (SpecialPoints p) = SpecialPoints $ map f p
- tf (Line t r p) = Line t r $ map f p
-
-scale f = transform (\(a, b) -> (a * f, b * f))
-mirror = transform (\(a, b) -> (4095 - a, b))
-flip' = transform (\(a, b) -> (a, 2047 - b))
-translate dx dy = transform (\(a, b) -> (a + dx, b + dy))
-
-instance Binary Chunk where
- put (SpecialPoints p) = do
- forM_ p $ \(x, y) -> do
- put x
- put y
- putWord8 0
- put (Line lt r ((x1, y1):ps)) = do
- let flags = r .|. (if lt == Solid then 0 else (1 `shift` 6))
- put x1
- put y1
- putWord8 $ flags .|. (1 `shift` 7)
- forM_ ps $ \(x, y) -> do
- put x
- put y
- putWord8 flags
- get = undefined
-
-compressWithLength :: BL.ByteString -> BL.ByteString
-compressWithLength b = BL.drop 8 . encode . runPut $ do
- put $ ((fromIntegral $ BL.length b)::Word32)
- mapM_ putWord8 $ BW.unpack $ BL.toStrict $ Z.compress b
-
-mapString :: B.ByteString
-mapString = B.pack . Base64.encode . BW.unpack . BL.toStrict . compressWithLength . BL.drop 8 . encode $ drawnMap05
-
-main = B.writeFile "out.hwmap" mapString
-
-drawnMap01 = translate (-3) (-3) $ sp ++ mirror sp ++ base ++ mirror base
- where
- sp = translate 128 128 . scale 256 $ [SpecialPoints [
- (6, 0)
- , (1, 4)
- , (4, 7)
- , (7, 5)
- ]]
- base = scale 256 $ [
- l [(5, 0), (5, 1)]
- , l [(7, 0), (7, 1)]
- , l [(8, 1), (6, 1), (6, 4)]
- , l [(8, 1), (8, 6), (6, 6), (6, 7), (8, 7)]
- , l [(7, 2), (7, 5), (5, 5)]
- , l [(5, 3), (5, 8)]
- , l [(6, 2), (4, 2)]
- , l [(1, 1), (4, 1), (4, 7)]
- , l [(3, 5), (3, 7), (2, 7), (2, 8)]
- , l [(2, 1), (2, 2)]
- , l [(0, 2), (1, 2), (1, 3), (3, 3), (3, 2)]
- , l [(0, 5), (1, 5)]
- , l [(1, 4), (4, 4)]
- , l [(2, 4), (2, 6), (1, 6), (1, 7)]
- , l [(0, 8), (8, 8)]
- ]
- l = Line Solid 0
-
-drawnMap02 = translate (-3) (-3) $ sp ++ mirror sp ++ base ++ mirror base
- where
- sp = translate 128 128 . scale 256 $ [SpecialPoints [
- (7, 0)
- , (7, 7)
- ]]
- base = scale 256 $ [
- l [(8, 0), (8, 1), (1, 1)]
- , l [(2, 1), (2, 2), (3, 2), (3, 3), (4, 3), (4, 4), (5, 4), (5, 5), (6, 5), (6, 6), (7, 6), (7, 7), (7, 1)]
- , l [(0, 2), (1, 2), (1, 3), (2, 3), (2, 4), (3, 4), (3, 5), (4, 5), (4, 6), (5, 6), (5, 7), (6, 7), (6, 8), (8, 8), (8, 2)]
- ]
- l = Line Solid 0
-
-
-drawnMap03 = translate (-3) (-3) $ sp ++ mirror sp ++ base ++ mirror base
- where
- sp = translate 128 128 . scale 256 $ [SpecialPoints [
- (3, 1)
- , (2, 4)
- ]]
- base = scale 256 $ [
- l [(6, 0), (6, 1)]
- , l [(1, 1), (5, 1)]
- , l [(4, 1), (4, 2), (3, 2)]
- , l [(0, 2), (1, 2), (1, 4)]
- , l [(0, 4), (3, 4), (3, 3), (5, 3), (5, 2), (7, 2)]
- , l [(7, 1), (7, 3)]
- , l [(8, 0), (8, 4), (4, 4), (4, 5), (1, 5), (1, 6)]
- , l [(6, 3), (6, 4)]
- , l [(0, 8), (8, 8)]
- , l [(1, 7), (1, 8)]
- , l [(2, 7), (2, 5)]
- , l [(3, 6), (3, 5)]
- , l [(3, 7), (3, 8)]
- , l [(4, 6), (4, 8)]
- , l [(5, 4), (5, 6)]
- , l [(5, 7), (5, 8)]
- , l [(6, 5), (6, 8)]
- , l [(7, 4), (7, 6)]
- , l [(7, 7), (7, 8)]
- , l [(8, 5), (8, 8)]
- ]
- l = Line Solid 0
-
-drawnMap04 = translate (-3) (-3) $ sp ++ fm sp ++ base ++ fm base
- where
- sp = translate 128 128 . scale 256 $ [SpecialPoints [
- (7, 7)
--- , (6, 6)
- , (3, 3)
- , (0, 6)
- , (3, 6)
- ]]
- base = scale 256 $ [
- l [(1, 2), (3, 2), (3, 1), (4, 1), (4, 2), (6, 2), (6, 4), (7, 4), (7, 5), (8, 5), (8, 8)]
- , l [(0, 0), (16, 0)]
- , l [(1, 5), (3, 5), (3, 7), (1, 7), (1, 5)]
- , l [(4, 5), (6, 5), (6, 7), (4, 7), (4, 5)]
- , l [(0, 4), (2, 4), (2, 3), (5, 3), (5, 4)]
- , l [(6, 1), (6, 2), (7, 2)]
- , l [(7, 1), (8, 1)]
- , l [(7, 3), (8, 3)]
- , l [(3, 4), (4, 4)]
- , l [(7, 6), (7, 8)]
- , l [(2, 0), (2, 1)]
- , l [(5, 0), (5, 1)]
- ]
- l = Line Solid 0
- fm = flip' . mirror
-
-drawnMap05 = sp ++ fullFill ++ lW
- where
- w = 320
- sh = 420
- basePoints = [(w, w), (1024 + w `div` 2, 2048 - w), (2048, w), (3072 - w `div` 2, 2048 - w), (4096 - w, w)]
- lW = [Line Erasing 60 basePoints]
- sp = [SpecialPoints $ basePoints ++ [(1024 + w `div` 2, 2048 - w - sh), (3072 - w `div` 2, 2048 - w - sh), (2048, w + sh)]]
-
-fullFill = scale 256 $ [Line Solid 63 [(0, 1), (16, 1), (16, 3), (0, 3), (0, 5), (16, 5), (16, 7), (0, 7)]]
+module Main where
+
+import qualified Data.ByteString.Char8 as B
+import qualified Data.ByteString as BW
+import qualified Data.ByteString.Lazy as BL
+import qualified Codec.Binary.Base64 as Base64
+import Data.Word
+import Data.Int
+import Data.Binary
+import Data.Binary.Put
+import Data.Bits
+import Control.Monad
+import qualified Codec.Compression.Zlib as Z
+
+data LineType = Solid | Erasing
+ deriving Eq
+
+data Chunk = SpecialPoints [(Int16, Int16)]
+ | Line LineType Word8 [(Int16, Int16)]
+
+transform :: ((Int16, Int16) -> (Int16, Int16)) -> [Chunk] -> [Chunk]
+transform f = map tf
+ where
+ tf (SpecialPoints p) = SpecialPoints $ map f p
+ tf (Line t r p) = Line t r $ map f p
+
+scale f = transform (\(a, b) -> (a * f, b * f))
+mirror = transform (\(a, b) -> (4095 - a, b))
+flip' = transform (\(a, b) -> (a, 2047 - b))
+translate dx dy = transform (\(a, b) -> (a + dx, b + dy))
+
+instance Binary Chunk where
+ put (SpecialPoints p) = do
+ forM_ p $ \(x, y) -> do
+ put x
+ put y
+ putWord8 0
+ put (Line lt r ((x1, y1):ps)) = do
+ let flags = r .|. (if lt == Solid then 0 else (1 `shift` 6))
+ put x1
+ put y1
+ putWord8 $ flags .|. (1 `shift` 7)
+ forM_ ps $ \(x, y) -> do
+ put x
+ put y
+ putWord8 flags
+ get = undefined
+
+compressWithLength :: BL.ByteString -> BL.ByteString
+compressWithLength b = BL.drop 8 . encode . runPut $ do
+ put $ ((fromIntegral $ BL.length b)::Word32)
+ mapM_ putWord8 $ BW.unpack $ BL.toStrict $ Z.compress b
+
+mapString :: B.ByteString
+mapString = B.pack . Base64.encode . BW.unpack . BL.toStrict . compressWithLength . BL.drop 8 . encode $ drawnMap05
+
+main = B.writeFile "out.hwmap" mapString
+
+drawnMap01 = translate (-3) (-3) $ sp ++ mirror sp ++ base ++ mirror base
+ where
+ sp = translate 128 128 . scale 256 $ [SpecialPoints [
+ (6, 0)
+ , (1, 4)
+ , (4, 7)
+ , (7, 5)
+ ]]
+ base = scale 256 $ [
+ l [(5, 0), (5, 1)]
+ , l [(7, 0), (7, 1)]
+ , l [(8, 1), (6, 1), (6, 4)]
+ , l [(8, 1), (8, 6), (6, 6), (6, 7), (8, 7)]
+ , l [(7, 2), (7, 5), (5, 5)]
+ , l [(5, 3), (5, 8)]
+ , l [(6, 2), (4, 2)]
+ , l [(1, 1), (4, 1), (4, 7)]
+ , l [(3, 5), (3, 7), (2, 7), (2, 8)]
+ , l [(2, 1), (2, 2)]
+ , l [(0, 2), (1, 2), (1, 3), (3, 3), (3, 2)]
+ , l [(0, 5), (1, 5)]
+ , l [(1, 4), (4, 4)]
+ , l [(2, 4), (2, 6), (1, 6), (1, 7)]
+ , l [(0, 8), (8, 8)]
+ ]
+ l = Line Solid 0
+
+drawnMap02 = translate (-3) (-3) $ sp ++ mirror sp ++ base ++ mirror base
+ where
+ sp = translate 128 128 . scale 256 $ [SpecialPoints [
+ (7, 0)
+ , (7, 7)
+ ]]
+ base = scale 256 $ [
+ l [(8, 0), (8, 1), (1, 1)]
+ , l [(2, 1), (2, 2), (3, 2), (3, 3), (4, 3), (4, 4), (5, 4), (5, 5), (6, 5), (6, 6), (7, 6), (7, 7), (7, 1)]
+ , l [(0, 2), (1, 2), (1, 3), (2, 3), (2, 4), (3, 4), (3, 5), (4, 5), (4, 6), (5, 6), (5, 7), (6, 7), (6, 8), (8, 8), (8, 2)]
+ ]
+ l = Line Solid 0
+
+
+drawnMap03 = translate (-3) (-3) $ sp ++ mirror sp ++ base ++ mirror base
+ where
+ sp = translate 128 128 . scale 256 $ [SpecialPoints [
+ (3, 1)
+ , (2, 4)
+ ]]
+ base = scale 256 $ [
+ l [(6, 0), (6, 1)]
+ , l [(1, 1), (5, 1)]
+ , l [(4, 1), (4, 2), (3, 2)]
+ , l [(0, 2), (1, 2), (1, 4)]
+ , l [(0, 4), (3, 4), (3, 3), (5, 3), (5, 2), (7, 2)]
+ , l [(7, 1), (7, 3)]
+ , l [(8, 0), (8, 4), (4, 4), (4, 5), (1, 5), (1, 6)]
+ , l [(6, 3), (6, 4)]
+ , l [(0, 8), (8, 8)]
+ , l [(1, 7), (1, 8)]
+ , l [(2, 7), (2, 5)]
+ , l [(3, 6), (3, 5)]
+ , l [(3, 7), (3, 8)]
+ , l [(4, 6), (4, 8)]
+ , l [(5, 4), (5, 6)]
+ , l [(5, 7), (5, 8)]
+ , l [(6, 5), (6, 8)]
+ , l [(7, 4), (7, 6)]
+ , l [(7, 7), (7, 8)]
+ , l [(8, 5), (8, 8)]
+ ]
+ l = Line Solid 0
+
+drawnMap04 = translate (-3) (-3) $ sp ++ fm sp ++ base ++ fm base
+ where
+ sp = translate 128 128 . scale 256 $ [SpecialPoints [
+ (7, 7)
+-- , (6, 6)
+ , (3, 3)
+ , (0, 6)
+ , (3, 6)
+ ]]
+ base = scale 256 $ [
+ l [(1, 2), (3, 2), (3, 1), (4, 1), (4, 2), (6, 2), (6, 4), (7, 4), (7, 5), (8, 5), (8, 8)]
+ , l [(0, 0), (16, 0)]
+ , l [(1, 5), (3, 5), (3, 7), (1, 7), (1, 5)]
+ , l [(4, 5), (6, 5), (6, 7), (4, 7), (4, 5)]
+ , l [(0, 4), (2, 4), (2, 3), (5, 3), (5, 4)]
+ , l [(6, 1), (6, 2), (7, 2)]
+ , l [(7, 1), (8, 1)]
+ , l [(7, 3), (8, 3)]
+ , l [(3, 4), (4, 4)]
+ , l [(7, 6), (7, 8)]
+ , l [(2, 0), (2, 1)]
+ , l [(5, 0), (5, 1)]
+ ]
+ l = Line Solid 0
+ fm = flip' . mirror
+
+drawnMap05 = sp ++ fullFill ++ lW
+ where
+ w = 320
+ sh = 420
+ basePoints = [(w, w), (1024 + w `div` 2, 2048 - w), (2048, w), (3072 - w `div` 2, 2048 - w), (4096 - w, w)]
+ lW = [Line Erasing 60 basePoints]
+ sp = [SpecialPoints $ basePoints ++ [(1024 + w `div` 2, 2048 - w - sh), (3072 - w `div` 2, 2048 - w - sh), (2048, w + sh)]]
+
+fullFill = scale 256 $ [Line Solid 63 [(0, 1), (16, 1), (16, 3), (0, 3), (0, 5), (16, 5), (16, 7), (0, 7)]]
--- a/tools/hwmap2txt/hwmapconverter/hwmapconverter.pro Wed Jul 15 00:27:12 2015 +0200
+++ b/tools/hwmap2txt/hwmapconverter/hwmapconverter.pro Thu Jul 16 08:39:35 2015 -0400
@@ -1,20 +1,20 @@
-#-------------------------------------------------
-#
-# Project created by QtCreator 2015-05-07T16:38:43
-#
-#-------------------------------------------------
-
-QT += core gui
-
-greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
-
-TARGET = hwmapconverter
-TEMPLATE = app
-
-
-SOURCES += main.cpp\
- mainwindow.cpp
-
-HEADERS += mainwindow.h
-
-FORMS += mainwindow.ui
+#-------------------------------------------------
+#
+# Project created by QtCreator 2015-05-07T16:38:43
+#
+#-------------------------------------------------
+
+QT += core gui
+
+greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
+
+TARGET = hwmapconverter
+TEMPLATE = app
+
+
+SOURCES += main.cpp\
+ mainwindow.cpp
+
+HEADERS += mainwindow.h
+
+FORMS += mainwindow.ui
--- a/tools/hwmap2txt/hwmapconverter/main.cpp Wed Jul 15 00:27:12 2015 +0200
+++ b/tools/hwmap2txt/hwmapconverter/main.cpp Thu Jul 16 08:39:35 2015 -0400
@@ -1,11 +1,11 @@
-#include "mainwindow.h"
-#include <QApplication>
-
-int main(int argc, char *argv[])
-{
- QApplication a(argc, argv);
- MainWindow w;
- w.show();
-
- return a.exec();
-}
+#include "mainwindow.h"
+#include <QApplication>
+
+int main(int argc, char *argv[])
+{
+ QApplication a(argc, argv);
+ MainWindow w;
+ w.show();
+
+ return a.exec();
+}
--- a/tools/hwmap2txt/hwmapconverter/mainwindow.cpp Wed Jul 15 00:27:12 2015 +0200
+++ b/tools/hwmap2txt/hwmapconverter/mainwindow.cpp Thu Jul 16 08:39:35 2015 -0400
@@ -1,137 +1,137 @@
-#include <QByteArray>
-#include <QFile>
-#include <QFileDialog>
-#include <QtEndian>
-#include <QRegExp>
-
-#include "mainwindow.h"
-#include "ui_mainwindow.h"
-
-MainWindow::MainWindow(QWidget *parent) :
- QMainWindow(parent),
- ui(new Ui::MainWindow)
-{
- ui->setupUi(this);
-}
-
-MainWindow::~MainWindow()
-{
- delete ui;
-}
-
-void MainWindow::on_pbLoad_clicked()
-{
- QString fileName = QFileDialog::getOpenFileName(this, QString(), QString(), "Hedgewars drawn maps (*.hwmap);;All files (*.*)");
-
- if(!fileName.isEmpty())
- {
- QFile f(fileName);
-
- if(f.open(QFile::ReadOnly))
- {
- QByteArray data = qUncompress(QByteArray::fromBase64(f.readAll()));
-
- QStringList decoded;
-
- bool isSpecial = true;
- while(data.size() >= 5)
- {
- qint16 px = qFromBigEndian(*(qint16 *)data.data());
- data.remove(0, 2);
- qint16 py = qFromBigEndian(*(qint16 *)data.data());
- data.remove(0, 2);
- quint8 flags = *(quint8 *)data.data();
- data.remove(0, 1);
-
- if(flags & 0x80)
- {
- if(isSpecial && !decoded.isEmpty())
- decoded << "// drawings";
-
- isSpecial = false;
-
- quint8 penWidth = flags & 0x3f;
- bool isErasing = flags & 0x40;
- decoded << QString("%1 %2 %3 %4")
- .arg(px, 5).arg(py, 6)
- .arg(isErasing ? "e" : "s")
- .arg(penWidth, 2);
- } else
- if(isSpecial)
- {
- if(decoded.isEmpty())
- decoded << "// special points (these are always before all drawings!)";
-
- decoded << QString("%1 %2 %3")
- .arg(px, 5).arg(py, 6)
- .arg(flags);
- } else
- {
- decoded << QString("%1 %2")
- .arg(px, 5).arg(py, 6);
- }
- }
-
- ui->textEdit->setPlainText(decoded.join("\n"));
- ui->statusBar->showMessage("Load OK");
- } else
- ui->statusBar->showMessage(QString("Can't open file %1").arg(fileName));
- }
-}
-
-void MainWindow::on_pbSave_clicked()
-{
- QRegExp rxSP("^\\s*(-?\\d+)\\s*(-?\\d+)\\s*(\\d+)\\s*$");
- QRegExp rxLS("^\\s*(-?\\d+)\\s*(-?\\d+)\\s*([es])\\s*(\\d+)\\s*$");
- QRegExp rxP("^\\s*(-?\\d+)\\s*(-?\\d+)\\s*$");
-
- QString fileName = QFileDialog::getSaveFileName(this, QString(), QString(), "Hedgewars drawn maps (*.hwmap);;All files (*.*)");
-
- QFile file(fileName);
- if(file.open(QFile::WriteOnly))
- {
- QByteArray b;
- QStringList sl = ui->textEdit->toPlainText().split('\n');
- bool isSpecial = true;
-
- foreach(const QString & line, sl)
- if(!line.startsWith("//"))
- {
- if(rxLS.indexIn(line) != -1)
- {
- isSpecial = false;
- qint16 px = qToBigEndian((qint16)rxLS.cap(1).toInt());
- qint16 py = qToBigEndian((qint16)rxLS.cap(2).toInt());
- quint8 flags = 0x80;
- if(rxLS.cap(3) == "e") flags |= 0x40;
- flags = flags + rxLS.cap(4).toUInt();
- b.append((const char *)&px, 2);
- b.append((const char *)&py, 2);
- b.append((const char *)&flags, 1);
- } else
- if(isSpecial && (rxSP.indexIn(line) != -1))
- {
- qint16 px = qToBigEndian((qint16)rxSP.cap(1).toInt());
- qint16 py = qToBigEndian((qint16)rxSP.cap(2).toInt());
- quint8 flags = rxSP.cap(3).toUInt();
-
- b.append((const char *)&px, 2);
- b.append((const char *)&py, 2);
- b.append((const char *)&flags, 1);
- } else
- if(rxP.indexIn(line) != -1)
- {
- isSpecial = false;
- qint16 px = qToBigEndian((qint16)rxP.cap(1).toInt());
- qint16 py = qToBigEndian((qint16)rxP.cap(2).toInt());
- quint8 flags = 0;
- b.append((const char *)&px, 2);
- b.append((const char *)&py, 2);
- b.append((const char *)&flags, 1);
- } else
- ui->statusBar->showMessage(QString("Can't parse or misplaced special point: %1").arg(line));
- }
-
- file.write(qCompress(b).toBase64());
- }
-}
+#include <QByteArray>
+#include <QFile>
+#include <QFileDialog>
+#include <QtEndian>
+#include <QRegExp>
+
+#include "mainwindow.h"
+#include "ui_mainwindow.h"
+
+MainWindow::MainWindow(QWidget *parent) :
+ QMainWindow(parent),
+ ui(new Ui::MainWindow)
+{
+ ui->setupUi(this);
+}
+
+MainWindow::~MainWindow()
+{
+ delete ui;
+}
+
+void MainWindow::on_pbLoad_clicked()
+{
+ QString fileName = QFileDialog::getOpenFileName(this, QString(), QString(), "Hedgewars drawn maps (*.hwmap);;All files (*.*)");
+
+ if(!fileName.isEmpty())
+ {
+ QFile f(fileName);
+
+ if(f.open(QFile::ReadOnly))
+ {
+ QByteArray data = qUncompress(QByteArray::fromBase64(f.readAll()));
+
+ QStringList decoded;
+
+ bool isSpecial = true;
+ while(data.size() >= 5)
+ {
+ qint16 px = qFromBigEndian(*(qint16 *)data.data());
+ data.remove(0, 2);
+ qint16 py = qFromBigEndian(*(qint16 *)data.data());
+ data.remove(0, 2);
+ quint8 flags = *(quint8 *)data.data();
+ data.remove(0, 1);
+
+ if(flags & 0x80)
+ {
+ if(isSpecial && !decoded.isEmpty())
+ decoded << "// drawings";
+
+ isSpecial = false;
+
+ quint8 penWidth = flags & 0x3f;
+ bool isErasing = flags & 0x40;
+ decoded << QString("%1 %2 %3 %4")
+ .arg(px, 5).arg(py, 6)
+ .arg(isErasing ? "e" : "s")
+ .arg(penWidth, 2);
+ } else
+ if(isSpecial)
+ {
+ if(decoded.isEmpty())
+ decoded << "// special points (these are always before all drawings!)";
+
+ decoded << QString("%1 %2 %3")
+ .arg(px, 5).arg(py, 6)
+ .arg(flags);
+ } else
+ {
+ decoded << QString("%1 %2")
+ .arg(px, 5).arg(py, 6);
+ }
+ }
+
+ ui->textEdit->setPlainText(decoded.join("\n"));
+ ui->statusBar->showMessage("Load OK");
+ } else
+ ui->statusBar->showMessage(QString("Can't open file %1").arg(fileName));
+ }
+}
+
+void MainWindow::on_pbSave_clicked()
+{
+ QRegExp rxSP("^\\s*(-?\\d+)\\s*(-?\\d+)\\s*(\\d+)\\s*$");
+ QRegExp rxLS("^\\s*(-?\\d+)\\s*(-?\\d+)\\s*([es])\\s*(\\d+)\\s*$");
+ QRegExp rxP("^\\s*(-?\\d+)\\s*(-?\\d+)\\s*$");
+
+ QString fileName = QFileDialog::getSaveFileName(this, QString(), QString(), "Hedgewars drawn maps (*.hwmap);;All files (*.*)");
+
+ QFile file(fileName);
+ if(file.open(QFile::WriteOnly))
+ {
+ QByteArray b;
+ QStringList sl = ui->textEdit->toPlainText().split('\n');
+ bool isSpecial = true;
+
+ foreach(const QString & line, sl)
+ if(!line.startsWith("//"))
+ {
+ if(rxLS.indexIn(line) != -1)
+ {
+ isSpecial = false;
+ qint16 px = qToBigEndian((qint16)rxLS.cap(1).toInt());
+ qint16 py = qToBigEndian((qint16)rxLS.cap(2).toInt());
+ quint8 flags = 0x80;
+ if(rxLS.cap(3) == "e") flags |= 0x40;
+ flags = flags + rxLS.cap(4).toUInt();
+ b.append((const char *)&px, 2);
+ b.append((const char *)&py, 2);
+ b.append((const char *)&flags, 1);
+ } else
+ if(isSpecial && (rxSP.indexIn(line) != -1))
+ {
+ qint16 px = qToBigEndian((qint16)rxSP.cap(1).toInt());
+ qint16 py = qToBigEndian((qint16)rxSP.cap(2).toInt());
+ quint8 flags = rxSP.cap(3).toUInt();
+
+ b.append((const char *)&px, 2);
+ b.append((const char *)&py, 2);
+ b.append((const char *)&flags, 1);
+ } else
+ if(rxP.indexIn(line) != -1)
+ {
+ isSpecial = false;
+ qint16 px = qToBigEndian((qint16)rxP.cap(1).toInt());
+ qint16 py = qToBigEndian((qint16)rxP.cap(2).toInt());
+ quint8 flags = 0;
+ b.append((const char *)&px, 2);
+ b.append((const char *)&py, 2);
+ b.append((const char *)&flags, 1);
+ } else
+ ui->statusBar->showMessage(QString("Can't parse or misplaced special point: %1").arg(line));
+ }
+
+ file.write(qCompress(b).toBase64());
+ }
+}
--- a/tools/hwmap2txt/hwmapconverter/mainwindow.h Wed Jul 15 00:27:12 2015 +0200
+++ b/tools/hwmap2txt/hwmapconverter/mainwindow.h Thu Jul 16 08:39:35 2015 -0400
@@ -1,27 +1,27 @@
-#ifndef MAINWINDOW_H
-#define MAINWINDOW_H
-
-#include <QMainWindow>
-
-namespace Ui {
-class MainWindow;
-}
-
-class MainWindow : public QMainWindow
-{
- Q_OBJECT
-
-public:
- explicit MainWindow(QWidget *parent = 0);
- ~MainWindow();
-
-private slots:
- void on_pbLoad_clicked();
-
- void on_pbSave_clicked();
-
-private:
- Ui::MainWindow *ui;
-};
-
-#endif // MAINWINDOW_H
+#ifndef MAINWINDOW_H
+#define MAINWINDOW_H
+
+#include <QMainWindow>
+
+namespace Ui {
+class MainWindow;
+}
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ explicit MainWindow(QWidget *parent = 0);
+ ~MainWindow();
+
+private slots:
+ void on_pbLoad_clicked();
+
+ void on_pbSave_clicked();
+
+private:
+ Ui::MainWindow *ui;
+};
+
+#endif // MAINWINDOW_H