Lua Script Help Needed

16 replies [Last post]
doomy
doomy's picture
User offline. Last seen 20 hours 3 min ago. Offline
Joined: 2011-01-16
Posts: 132

I could use some help creating a lua script,but there's some things I just don't get.I've looked at the lua script guide and was wondering what the two numbers in AddHog("Hedgehog", 0, 1, "NoHat") meant.What Does it mean?

KoBeWi
KoBeWi's picture
User offline. Last seen 3 days 2 hours ago. Offline
Joined: 2010-12-25
Posts: 564

I checked it and the second number is hedgehog's health. The first number seems to be a CPU flag. 0 is player's hog, 1 is CPU.
Couldn't you figure it yourself?

nemo
nemo's picture
User is online Online
Joined: 2009-01-28
Posts: 1861

http://code.google.com/p/hedgewars/wiki/LuaAPI#AddHog_(hogname,_botlevel,_health,_hat)

Are you aware of this page?

--
Oh, what the heck. 1PLXzL1CBUD1kdEWqMrwNUfGrGiirV1WpH <= tip a hedgewars dev

doomy
doomy's picture
User offline. Last seen 20 hours 3 min ago. Offline
Joined: 2011-01-16
Posts: 132

KoBeWi allegedly wrote:

I checked it and the second number is hedgehog's health. The first number seems to be a CPU flag. 0 is player's hog, 1 is CPU.
Couldn't you figure it yourself?

Thanks,that really helped.

doomy
doomy's picture
User offline. Last seen 20 hours 3 min ago. Offline
Joined: 2011-01-16
Posts: 132

Just one more problem,I'm trying to test my script,but when I try playing it it says Some parameters not set (flags=0).What does that mean and how can I fix it?

nemo
nemo's picture
User is online Online
Joined: 2009-01-28
Posts: 1861

Need to pick a map or theme.
(static or random terrain)

--
Oh, what the heck. 1PLXzL1CBUD1kdEWqMrwNUfGrGiirV1WpH <= tip a hedgewars dev

doomy
doomy's picture
User offline. Last seen 20 hours 3 min ago. Offline
Joined: 2011-01-16
Posts: 132

chose a map and theme,still doesn't work Sad Smiley

mikade
mikade's picture
User offline. Last seen 11 weeks 1 day ago. Offline
Joined: 2010-10-22
Posts: 355

Send me your script and I'll see if I can sort you out.
Chances are you did some kind of basic error like no closing parentheses or wrong number of parameters etc.

mikade
Hedgewars Developer

doomy
doomy's picture
User offline. Last seen 20 hours 3 min ago. Offline
Joined: 2011-01-16
Posts: 132

loadfile(GetDataPath() .. "Scripts/Locale.lua")()

----------------------------------------------------------------

function onGameInit()
Seed = 0
GameFlags = gfRandomOrder + gfSharedAmmo
SuddenDeathTurns = 9999
TurnTime = 45000
CaseFreq = 1
MinesNum = 0
MinesTime = 0
Explosives = 0
Delay = 10
Map = "Hogville"
Theme = "Nature"

AddTeam("Spare Me!", 14483456,"Simple", "Island", "Russian",cm_hurrah)
player = AddHog("I Shall Save the World!", 0, 100, "StrawHat")
AddTeam("Robots", 1175851, "Earth", "Island", "Robot", cm_binary)
enemy = AddHog("We Shall Rule the World", 5, 100, "Cyborg")
enemy = AddHog("We Shall Rule the World", 5, 100, "Cyborg")
enemy = AddHog("We Shall Rule the World", 5, 100, "Cyborg")
enemy = AddHog("We Shall Rule the World", 5, 100, "Cyborg")
enemy = AddHog("We Shall Rule the World", 5, 100, "Cyborg")
enemy = AddHog("We Shall Rule the World", 5, 100, "Cyborg")
enemy = AddHog("We Shall Rule the World", 5, 100, "Cyborg")
enemy = AddHog("We Shall Rule the World", 5, 100, "Cyborg")
AddTeam("More Robots", 1175851, "Earth", "Island", "Robot", cm_binary)
enemy = AddHog("We Shall Rule the World", 5, 100, "Cyborg")
enemy = AddHog("We Shall Rule the World", 5, 100, "Cyborg")
enemy = AddHog("We Shall Rule the World", 5, 100, "Cyborg")
enemy = AddHog("We Shall Rule the World", 5, 100, "Cyborg")
enemy = AddHog("We Shall Rule the World", 5, 100, "Cyborg")
enemy = AddHog("We Shall Rule the World", 5, 100, "Cyborg")
enemy = AddHog("We Shall Rule the World", 5, 100, "Cyborg")
enemy = AddHog("We Shall Rule the World", 5, 100, "Cyborg")
AddTeam("Lots of Robots", 1175851, "Earth", "Island", "Robot", cm_binary)
enemy = AddHog("We Shall Rule the World", 5, 100, "Cyborg")
enemy = AddHog("We Shall Rule the World", 5, 100, "Cyborg")
enemy = AddHog("We Shall Rule the World", 5, 100, "Cyborg")
enemy = AddHog("We Shall Rule the World", 5, 100, "Cyborg")
enemy = AddHog("We Shall Rule the World", 5, 100, "Cyborg")
enemy = AddHog("We Shall Rule the World", 5, 100, "Cyborg")
enemy = AddHog("We Shall Rule the World", 5, 100, "Cyborg")
enemy = AddHog("We Shall Rule the World", 5, 100, "Cyborg")
AddTeam("Even More Robots", 1175851, "Earth", "Island", "Robot", cm_binary)
enemy = AddHog("We Shall Rule the World", 5, 100, "Cyborg")
enemy = AddHog("We Shall Rule the World", 5, 100, "Cyborg")
enemy = AddHog("We Shall Rule the World", 5, 100, "Cyborg")
enemy = AddHog("We Shall Rule the World", 5, 100, "Cyborg")
enemy = AddHog("We Shall Rule the World", 5, 100, "Cyborg")
enemy = AddHog("We Shall Rule the World", 5, 100, "Cyborg")
enemy = AddHog("We Shall Rule the World", 5, 100, "Cyborg")
enemy = AddHog("We Shall Rule the World", 5, 100, "Cyborg")
AddTeam("OMG More Robots", 1175851, "Earth", "Island", "Robot", cm_binary)
enemy = AddHog("We Shall Rule the World", 5, 100, "Cyborg")
enemy = AddHog("We Shall Rule the World", 5, 100, "Cyborg")
enemy = AddHog("We Shall Rule the World", 5, 100, "Cyborg")
enemy = AddHog("We Shall Rule the World", 5, 100, "Cyborg")
enemy = AddHog("We Shall Rule the World", 5, 100, "Cyborg")
enemy = AddHog("We Shall Rule the World", 5, 100, "Cyborg")
enemy = AddHog("We Shall Rule the World", 5, 100, "Cyborg")
enemy = AddHog("We Shall Rule the World", 5, 100, "Cyborg")
end
onAmmoStoreInit
SetAmmo(amShotGun, 9, 0, 0, 0)
SetAmmo(amPickHammer, 2, 1, 0, 2)
SetAmmo(amBlowTorch, 3, 1, 0, 2)
SetAmmo(amMudball, 2, 1, 0, 2)
SetAmmo(amWhip, 9, 0, 0, 0)
SetAmmo(amFirePunch, 9, 0, 0, 0)
SetAmmo(amKamikaze, 1, 1, 0, 2)
SetAmmo(amJetPack, 1, 1, 0, 2)
SetAmmo(amGrenade, 9, 0, 0, 0)
SetAmmo(amDEagle, 2, 1, 0, 2)
SetAmmo(amBaseballBat, 1, 1, 0, 2)
SetAmmo(amMortar, 5, 1, 0, 2)
SetAmmo(amSniperRifle, 2, 1, 0, 2)
SetAmmo(amDynamite, 1, 1, 0, 2)
SetAmmo(amParachute, 2, 1, 0, 2)
SetAmmo(amGirder, 2, 1, 0, 2)
SetAmmo(amBazooka, 9, 0, 0, 0)
SetAmmo(amRope, 4, 1, 0, 2)
SetAmmo(amCake, 1, 1, 0, 2)
SetAmmo(amSMine, 2, 1, 0, 2)
SetAmmo(RCPlane, 1, 1, 0, 1)
SetAmmo(amPortalGun, 1, 1, 0, 2,)
SetAmmo(amSKip, 9, 0, 0, 0,)
SetAmmo(amDrillStrike, 1, 1, 0, 2,)
SetAmmo(amFlamethrower, 1, 1, 0, 2,)
SetAmmo(amClusterBomb, 3, 1, 0, 2,)
SetAmmo(amAirAttack, 1, 1, 0, 2,)
SetAmmo(amTeleport, 2, 1, 0, 2,)
SetAmmo(amNapalm, 1, 1, 0, 2,)
SetAmmo(amMotolov, 1, 1, 0, 2,)
SetAmmo(amGasBomb, 1, 1, 0, 2,)
SetAmmo(amHammer, 1, 1, 0, 2,)
SetAmmo(amBee, 1, 1, 0, 2,)
SetAmmo(amSwitch, 3, 1, 0, 2,)
SetAmmo(amSeduction, 1, 1, 0, 2,)
SetAmmo(amDrill, 2, 1, 0, 2,)
SetAmmo(amBirdy, 1, 1, 0, 2,)
SetAmmo(amResurrector, 1, 1, 0, 2,)
end
onGameStart()
ShowMission loc("Save the World!"), loc(by doomy), loc("Ultimate Practice"), loc("Eliminate all robots before they elimiante you!")
end
onNewTurn
HogSay(player, loc"I Shall Win This Battle!),SAY_SHOUT
if player health = 0 then
ShowMission loc("Oh no!"), loc("Try Again!")
GameOver()
end
if enemy health = 0 then
ShowMission loc("Hurray!"), loc("The world is safe because of you!")
GameOver()
end
end

mikade
mikade's picture
User offline. Last seen 11 weeks 1 day ago. Offline
Joined: 2010-10-22
Posts: 355

... is that pseudocode or the actual script?

mikade
Hedgewars Developer

doomy
doomy's picture
User offline. Last seen 20 hours 3 min ago. Offline
Joined: 2011-01-16
Posts: 132

what do you mean?

mikade
mikade's picture
User offline. Last seen 11 weeks 1 day ago. Offline
Joined: 2010-10-22
Posts: 355

You have... a lot... of problems, assuming this is the actual script. :P

What I would advise you to do is, don't try make everything at once. Start simple, small, and build your way up to a fully finished script. Verify first that you can add ONE hog to the level and that map, theme, etc. details are working correctly.

Then try get your ammo working. Test the map, make sure it works.

Then fill out custom things like stuff happening every turn, victory/failure conditions etc.

Test at each stage you add something, this will reduce the work you have when you're looking for errors. Where possible, look at the scripts that have already been coded to get a feel for how other script-writers have done the things and use those as examples for how your script should be laid out and what you can/can not do.

For instance, you seem to be missing a lot of parentheses, or just not putting things in parentheses at all. Often you have the wrong number of parameters and you are also calling a lot of functions without actually saying "function", e.g.

onGameStart()
ShowMission loc("Save the World!"), loc(by doomy), loc("Ultimate Practice"), loc("Eliminate all robots before they elimiante you!")
end

should be something like:

function onGameStart()
ShowMission( loc("Save the World!"), loc("by doomy"), loc("Ultimate Practice"), 0, 0 )
end

mikade
Hedgewars Developer

doomy
doomy's picture
User offline. Last seen 20 hours 3 min ago. Offline
Joined: 2011-01-16
Posts: 132

Are there any problems here?

loadfile(GetDataPath() .. "Scripts/Locale.lua")()

----------------------------------------------------------------

local player = nil
local enemy = nil

function onGameInit()
Seed = 0
GameFlags = gfRandomOrder + gfSharedAmmo
SuddenDeathTurns = 9999
TurnTime = 45000
CaseFreq = 1
MinesNum = 0
MinesTime = 0
Explosives = 0
Delay = 10
Map = "Hogville"
Theme = "Nature"

AddTeam(loc("Spare Me!"), 14483456,"Simple", "Island", "Russian","cm_hurrah")
player = AddHog(loc("I Shall Save the World"), 0, 100, "StrawHat")
AddTeam(loc("Robots"), 1175851, "Earth", "Island", "Robot", "cm_binary")
enemy = AddHog(loc("We Shall Rule the World"), 5, 100, "Cyborg")
SetGearPosition(player, 1000, 1000)
SetGearPosition(enemy, 1500, 1500)
end
function onAmmoStoreInit
SetAmmo(amShotgun, 9 0, 0, 0)
end

mikade
mikade's picture
User offline. Last seen 11 weeks 1 day ago. Offline
Joined: 2010-10-22
Posts: 355

Missing parentheses on function onAmmoStoreInit and lack of comma in your SetAmmo call. Should be:

loadfile(GetDataPath() .. "Scripts/Locale.lua")()

local player = nil
local enemy = nil

function onGameInit()

  Seed = 0
  GameFlags = gfRandomOrder + gfSharedAmmo
  SuddenDeathTurns = 9999
  TurnTime = 45000
  CaseFreq = 1
  MinesNum = 0
  MinesTime = 0
  Explosives = 0
  Delay = 10
  Map = "Hogville"
  Theme = "Nature"

  AddTeam(loc("Spare Me!"), 14483456,"Simple", "Island", "Russian","cm_hurrah")
  player = AddHog(loc("I Shall Save the World"), 0, 100, "StrawHat")
  AddTeam(loc("Robots"), 1175851, "Earth", "Island", "Robot", "cm_binary")
  enemy = AddHog(loc("We Shall Rule the World"), 5, 100, "Cyborg")
  SetGearPosition(player, 1000, 1000)
  SetGearPosition(enemy, 1500, 1500)

end

function onAmmoStoreInit()
  SetAmmo(amShotgun, 9, 0, 0, 0)
end

Otherwise, it looks good so far. Wink Smiley

mikade
Hedgewars Developer

doomy
doomy's picture
User offline. Last seen 20 hours 3 min ago. Offline
Joined: 2011-01-16
Posts: 132

Here's the almost finished script.There's a problem that I can't find.Could you find it for me?

loadfile(GetDataPath() .. "Scripts/Locale.lua")()

local player = nil
local enemy = nil
local e2 = nil
local e3 = nil
local e4 = nil
local e5 = nil
local e6 = nil
local e7 = nil
local e8 = nil
local e9 = nil
local e10 = nil
local e11 = nil
local e12 = nil
local e13 = nil
local e14 = nil
local e15 = nil
local e16 = nil
local e17 = nil
local e18 = nil
local e19 = nil
local e20 = nil
local e21 = nil
local e22 = nil
local e23 = nil
local e24 = nil
local e25 = nil
local e26 = nil
local e27 = nil
local e28 = nil
local e29 = nil
local e30 = nil
local e31 = nil
local e32 = nil
local e33 = nil
local e34 = nil
local e35 = nil
local e36 = nil
local e37 = nil
local e38 = nil
local e39 = nil
local e40 = nil
local GameOver == false

function onGameInit()
Seed = 0
GameFlags = gfRandomOrder + gfSharedAmmo
SuddenDeathTurns = 9999
TurnTime = 45000
CaseFreq = 1
MinesNum = 0
MinesTime = 0
Explosives = 0
Delay = 10
Map = "Hogville"
Theme = "Nature"

AddTeam(loc("Spare Me!"), 14483456,"Simple", "Island", "Russian","cm_hurrah")
player = AddHog(loc("I Shall Save the World"), 0, 100, "StrawHat")
AddTeam(loc("Robots"), 1175851, "Earth", "Island", "Robot", "cm_binary")
enemy = AddHog(loc("Controller of the robots"), 5, 100, "SunGlasses")
e2 = AddHog(loc("We Shall Rule the World"), 5, 100, "Cyborg")
e3 = AddHog(loc("We Shall Rule the World"), 5, 100, "Cyborg")
e4 = AddHog(loc("We Shall Rule the World"), 5, 100, "Cyborg")
e5 = AddHog(loc("We Shall Rule the World"), 5, 100, "Cyborg")
e6 = AddHog(loc("We Shall Rule the World"), 5, 100, "Cyborg")
e7 = AddHog(loc("We Shall Rule the World"), 5, 100, "Cyborg")
e8 = AddHog(loc("We Shall Rule the World"), 5, 100, "Cyborg")
AddTeam(loc("More Robots"), 1175851, "Earth", "Island", "Robot", "cm_binary")
e9 = AddHog(loc("We Shall Rule the World"), 5, 100, "Cyborg")
e10 = AddHog(loc("We Shall Rule the World"), 5, 100, "Cyborg")
e11 = AddHog(loc("We Shall Rule the World"), 5, 100, "Cyborg")
e12 = AddHog(loc("We Shall Rule the World"), 5, 100, "Cyborg")
e13 = AddHog(loc("We Shall Rule the World"), 5, 100, "Cyborg")
e14 = AddHog(loc("We Shall Rule the World"), 5, 100, "Cyborg")
e15 = AddHog(loc("We Shall Rule the World"), 5, 100, "Cyborg")
e16 = AddHog(loc("We Shall Rule the World"), 5, 100, "Cyborg")
AddTeam(loc("Even More Robots"), 1175851, "Earth", "Island", "Robot", "cm_binary")
e17 = AddHog(loc("We Shall Rule the World"), 5, 100, "Cyborg")
e18 = AddHog(loc("We Shall Rule the World"), 5, 100, "Cyborg")
e19 = AddHog(loc("We Shall Rule the World"), 5, 100, "Cyborg")
e20 = AddHog(loc("We Shall Rule the World"), 5, 100, "Cyborg")
e21 = AddHog(loc("We Shall Rule the World"), 5, 100, "Cyborg")
e22 = AddHog(loc("We Shall Rule the World"), 5, 100, "Cyborg")
e23 = AddHog(loc("We Shall Rule the World"), 5, 100, "Cyborg")
e24 = AddHog(loc("We Shall Rule the World"), 5, 100, "Cyborg")
AddTeam(loc("Lots of Robots"), 1175851, "Earth", "Island", "Robot", "cm_binary")
e25 = AddHog(loc("We Shall Rule the World"), 5, 100, "Cyborg")
e26 = AddHog(loc("We Shall Rule the World"), 5, 100, "Cyborg")
e27 = AddHog(loc("We Shall Rule the World"), 5, 100, "Cyborg")
e28 = AddHog(loc("We Shall Rule the World"), 5, 100, "Cyborg")
e29 = AddHog(loc("We Shall Rule the World"), 5, 100, "Cyborg")
e30 = AddHog(loc("We Shall Rule the World"), 5, 100, "Cyborg")
e31 = AddHog(loc("We Shall Rule the World"), 5, 100, "Cyborg")
e32 = AddHog(loc("We Shall Rule the World"), 5, 100, "Cyborg")
AddTeam(loc("Tons of Robots"), 1175851, "Earth", "Island", "Robot", "cm_binary")
e33 = AddHog(loc("We Shall Rule the World"), 5, 100, "Cyborg")
e34 = AddHog(loc("We Shall Rule the World"), 5, 100, "Cyborg")
e35 = AddHog(loc("We Shall Rule the World"), 5, 100, "Cyborg")
e36 = AddHog(loc("We Shall Rule the World"), 5, 100, "Cyborg")
e37 = AddHog(loc("We Shall Rule the World"), 5, 100, "Cyborg")
e38 = AddHog(loc("We Shall Rule the World"), 5, 100, "Cyborg")
e39 = AddHog(loc("We Shall Rule the World"), 5, 100, "Cyborg")
e40 = AddHog(loc("We Shall Rule the World"), 5, 100, "Cyborg")
end
function onAmmoStoreInit()
SetAmmo(amShotgun, 9, 0, 0, 0)
SetAmmo(amBazooka, 9, 0, 0, 0)
SetAmmo(amGrenade, 9, 0, 0, 0)
SetAmmo(amDEagle, 2, 1, 0, 2)
SetAmmo(amBaseballBat, 1, 6, 2, 1)
SetAmmo(amBlowTorch, 3, 4, 0, 2)
SetAmmo(amMortar, 5, 4, 0, 4)
SetAmmo(amSniperRifle, 2, 1, 0, 2)
SetAmmo(amPortalGun, 1, 1, 0, 1)
SetAmmo(amParachute, 2, 5, 0, 1)
SetAmmo(amGirder, 2, 6, 0, 3)
SetAmmo(amRCPlane, 1, 6, 4, 1)
SetAmmo(amJetpack, 1, 5, 0, 1)
SetAmmo(amRope, 4, 5, 0, 3)
SetAmmo(amFirePunch, 9, 0, 0, 0)
SetAmmo(amAirAttack, 1, 5, 5, 1)
SetAmmo(amTeleport, 2, 5, 0, 1)
SetAmmo(amCake, 1, 6, 4, 1)
SetAmmo(amNapalm, 1, 6, 7, 1)
SetAmmo(amMotolov, 1, 5, 0, 1)
SetAmmo(amGasBomb, 1, 1, 0, 1)
SetAmmo(amHammer, 1, 1, 0, 1)
SetAmmo(amBee, 1, 5, 0, 1)
SetAmmo(amMine, 2, 4, 0, 1)
SetAmmo(amWhip, 9, 0, 0, 0)
SetAmmo(amSwitch, 3, 5, 0, 1)
SetAmmo(amSeduction, 1, 4, 0, 1)
SetAmmo(amDrill, 2, 5, 0, 1)
SetAmmo(amBirdy, 1, 5, 0, 1)
SetAmmo(amWatermelon, 0, 7, 0, 1)
SetAmmo(amBallgun, 0, 7, 0, 1)
SetAmmo(amInvulnerable, 0, 6, 0, 1)
SetAmmo(amSMine, 0, 1, 0, 1)
SetAmmo(amHellishBomb, 0, 7, 0, 1)
SetAmmo(amExtraTime, 0, 6, 0, 1)
SetAmmo(amLowGravity, 0, 6, 0, 1)
SetAmmo(amLaserSight, 0, 6, 0, 1)
SetAmmo(amMineStrike, 0, 5, 5, 1)
SetAmmo(amExtraDamage, 0, 6, 0, 1)
SetAmmo(amVampiric, 0, 6, 0, 1)
SetAmmo(amFlamethrower, 1, 1, 0, 1)
SetAmmo(amDrillStrike, 1, 4, 6, 1)
SetAmmo(amClusterBomb, 3, 4, 0, 3)
SetAmmo(amPickHammer, 2, 4, 0, 1)
SetAmmo(amDynamite, 1, 6, 0, 1)
SetAmmo(amSkip, 9, 0, 0, 0)
end
function onGameStart()
ShowMission(loc("Save the World!"), loc("by doomy with help from mikade"), loc("Eliminate the robots before they eliminate you!"),0,0)
HogSay(player, loc("I Shall Win This Battle!"),SAY_SHOUT)
end
function onGearDelete(gear)
if (gear == enemy and GameOver == false)then
ShowMission(loc("Save the World!"), loc("The World has been saved from the evil robots!"), loc("Congratulations!"),0,0)
SetHealth(e2, 0)
SetHealth(e3, 0)
SetHealth(e4, 0)
SetHealth(e5, 0)
SetHealth(e6, 0)
SetHealth(e7, 0)
SetHealth(e8, 0)
SetHealth(e9, 0)
SetHealth(e10, 0)
SetHealth(e11, 0)
SetHealth(e12, 0)
SetHealth(e13, 0)
SetHealth(e14, 0)
SetHealth(e15, 0)
SetHealth(e16, 0)
SetHealth(e17, 0)
SetHealth(e18, 0)
SetHealth(e19, 0)
SetHealth(e20, 0)
SetHealth(e21, 0)
SetHealth(e22, 0)
SetHealth(e23, 0)
SetHealth(e24, 0)
SetHealth(e25, 0)
SetHealth(e26, 0)
SetHealth(e27, 0)
SetHealth(e28, 0)
SetHealth(e29, 0)
SetHealth(e30, 0)
SetHealth(e31, 0)
SetHealth(e32, 0)
SetHealth(e33, 0)
SetHealth(e34, 0)
SetHealth(e35, 0)
SetHealth(e36, 0)
SetHealth(e37, 0)
SetHealth(e38, 0)
SetHealth(e39, 0)
SetHealth(e40, 0)
GameOver()
elseif (gear == player and GameOver == false)then
ShowMission(loc("Save the World!"), loc("The robots have taken over the world!"), loc("Just try again!"), 0, 0)
GameOver()

mikade
mikade's picture
User offline. Last seen 11 weeks 1 day ago. Offline
Joined: 2010-10-22
Posts: 355

Problems that I remember:
Two or three missing "end"s
"==" instead of "="
Hogsay without priority
User-branding
If you kill the first robot, the rest die.

Took the liberty of fixing / cleaning it up a little.
Feel free to ask questions about anything you don't understand.


loadfile(GetDataPath() .. "Scripts/Locale.lua")()

local player = nil
local robot = {}
local robotTNames = {}
local robotsKilled = 0

function onGameInit()

  Seed = 0
  GameFlags = gfRandomOrder + gfSharedAmmo
  SuddenDeathTurns = 9999
  TurnTime = 45000
  CaseFreq = 1
  MinesNum = 0
  MinesTime = 0
  Explosives = 0
  Delay = 10
  Map = "Hogville"
  Theme = "Nature"

  AddTeam(loc("Spare Me!"), 14483456,"Simple", "Island", "Russian","cm_hurrah")
  player = AddHog(loc("I Shall Save the World"), 0, 100, "StrawHat")

  robotTNames[0] = loc("Robots")
  robotTNames[1] = loc("More Robots")
  robotTNames[2] = loc("Even More Robots")
  robotTNames[3] = loc("Lots of Robots")
  robotTNames[4] = loc("Tons of Robots")

  for z = 0, 4 do

    AddTeam(robotTNames[z], 1175851, "Earth", "Island", "Robot", "cm_binary")
    for i = (z*8) , (z*8)+7 do
      robot[i] = AddHog(loc("Robot") .. " #" .. i, 5, 100, "Cyborg")
    end

  end

  FollowGear(player)

end

function onAmmoStoreInit()
  SetAmmo(amShotgun, 9, 0, 0, 0)
  SetAmmo(amBazooka, 9, 0, 0, 0)
  SetAmmo(amGrenade, 9, 0, 0, 0)
  SetAmmo(amDEagle, 2, 1, 0, 2)
  SetAmmo(amBaseballBat, 1, 6, 2, 1)
  SetAmmo(amBlowTorch, 3, 4, 0, 2)
  SetAmmo(amMortar, 5, 4, 0, 4)
  SetAmmo(amSniperRifle, 2, 1, 0, 2)
  SetAmmo(amPortalGun, 1, 1, 0, 1)
  SetAmmo(amParachute, 2, 5, 0, 1)
  SetAmmo(amGirder, 2, 6, 0, 3)
  SetAmmo(amRCPlane, 1, 6, 4, 1)
  SetAmmo(amJetpack, 1, 5, 0, 1)
  SetAmmo(amRope, 4, 5, 0, 3)
  SetAmmo(amFirePunch, 9, 0, 0, 0)
  SetAmmo(amAirAttack, 1, 5, 5, 1)
  SetAmmo(amTeleport, 2, 5, 0, 1)
  SetAmmo(amCake, 1, 6, 4, 1)
  SetAmmo(amNapalm, 1, 6, 7, 1)
  SetAmmo(amMotolov, 1, 5, 0, 1)
  SetAmmo(amGasBomb, 1, 1, 0, 1)
  SetAmmo(amHammer, 1, 1, 0, 1)
  SetAmmo(amBee, 1, 5, 0, 1)
  SetAmmo(amMine, 2, 4, 0, 1)
  SetAmmo(amWhip, 9, 0, 0, 0)
  SetAmmo(amSwitch, 3, 5, 0, 1)
  SetAmmo(amSeduction, 1, 4, 0, 1)
  SetAmmo(amDrill, 2, 5, 0, 1)
  SetAmmo(amBirdy, 1, 5, 0, 1)
  SetAmmo(amWatermelon, 0, 7, 0, 1)
  SetAmmo(amBallgun, 0, 7, 0, 1)
  SetAmmo(amInvulnerable, 0, 6, 0, 1)
  SetAmmo(amSMine, 0, 1, 0, 1)
  SetAmmo(amHellishBomb, 0, 7, 0, 1)
  SetAmmo(amExtraTime, 0, 6, 0, 1)
  SetAmmo(amLowGravity, 0, 6, 0, 1)
  SetAmmo(amLaserSight, 0, 6, 0, 1)
  SetAmmo(amMineStrike, 0, 5, 5, 1)
  SetAmmo(amExtraDamage, 0, 6, 0, 1)
  SetAmmo(amVampiric, 0, 6, 0, 1)
  SetAmmo(amFlamethrower, 1, 1, 0, 1)
  SetAmmo(amDrillStrike, 1, 4, 6, 1)
  SetAmmo(amClusterBomb, 3, 4, 0, 3)
  SetAmmo(amPickHammer, 2, 4, 0, 1)
  SetAmmo(amDynamite, 1, 6, 0, 1)
  SetAmmo(amSkip, 9, 0, 0, 0)
end

function onGameStart()
  ShowMission(	loc("Save the World!"),
		loc("Ultimate Practice"),
		loc("Eliminate the robots before they eliminate you!"),
		0,0)
  HogSay(player, loc("I Shall Win This Battle!"),SAY_SHOUT,2)
end

function onGearDelete(gear)

  if (GetGearType(gear) == gtHedgehog) and (gear ~= player) then
    robotsKilled = robotsKilled + 1
    if robotsKilled == 40 then
      ShowMission(	loc("Save the World!"),
			loc("The World has been saved from the evil robots!"),
			loc("Congratulations!"),
			0,0)
    end
  elseif (gear == player) then
    ShowMission(	loc("Save the World!"),
			loc("The robots have taken over the world!"),
			loc("Just try again!"),
			0, 0)
  end

end

Enjoy
Big Grin

mikade
Hedgewars Developer

doomy
doomy's picture
User offline. Last seen 20 hours 3 min ago. Offline
Joined: 2011-01-16
Posts: 132

Thank you so much!

Copyright © 2004-2023 Hedgewars Project. All rights reserved. [ contact ]