share/hedgewars/Data/Scripts/Multiplayer/Battalion.lua
author Wuzzy <Wuzzy2@mail.ru>
Fri, 27 Sep 2019 04:05:04 +0200
changeset 15450 c0ad952894d9
parent 15449 c95efbab66e6
child 15995 634d017650dc
permissions -rwxr-xr-x
Battalion points: Update displayed LastTeam points each turn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
12412
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
     1
--[[
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
     2
  ########################################################################
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
     3
  Name:      Battalion
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
     4
  Made by:   Anachron 
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
     5
  ########################################################################
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
     6
]]--
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
     7
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
     8
--[[
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
     9
  
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
    10
  Readme:
12419
6944a9161cdb Update readme link in Battalion script
Wuzzy <almikes@aol.com>
parents: 12418
diff changeset
    11
  https://hedgewars.org/wiki/Battalion
12412
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
    12
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
    13
  ########################################################################
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
    14
]]--
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
    15
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
    16
--[[
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
    17
  ########################################################################
12980
263d006c56a9 Battalion: Clean up and remove dead code
Wuzzy <Wuzzy2@mail.ru>
parents: 12979
diff changeset
    18
  TODO / ideas list
12412
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
    19
  ########################################################################
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
    20
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
    21
  - Make Hogs sorted by rareness for teams with less hogs (more fair)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
    22
  - Keep first picked up unused crate utitlity until next round
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
    23
  - Ship default scheme but let user overwrite it
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
    24
  - Make SuddenDeathWaterRise dynamic
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
    25
  - Make SuddenDeathTurns dynamic
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
    26
  - Add Hog Variants like Crazy Scientist or Astronaut
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
    27
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
    28
  ########################################################################
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
    29
]]--
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
    30
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
    31
--[[
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
    32
  ##############################################################################
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
    33
  ### GENERAL SCRIPT LOADING AND VARIABLE INITIALISATION                     ###
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
    34
  ##############################################################################
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
    35
]]--
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
    36
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
    37
HedgewarsScriptLoad("/Scripts/Locale.lua")
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
    38
HedgewarsScriptLoad("/Scripts/Tracker.lua")
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
    39
HedgewarsScriptLoad("/Scripts/Params.lua")
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
    40
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
    41
-- List of all hog variants with belonging weapons,
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
    42
--  hitpoints, chances and more
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
    43
local variants = {}
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
    44
local varName = ""
12980
263d006c56a9 Battalion: Clean up and remove dead code
Wuzzy <Wuzzy2@mail.ru>
parents: 12979
diff changeset
    45
local newLine = ""
12412
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
    46
local gmAny = 0xFFFFFFFF
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
    47
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
    48
--[[
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
    49
  ##############################################################################
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
    50
  ### VARIANT SETUP                                                          ###
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
    51
  ##############################################################################
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
    52
]]--
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
    53
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
    54
varName = "Pyromancer"
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
    55
variants[varName] = {}
12420
bdf81e6c00eb Battalion: Make mutated hog names translatable
Wuzzy <almikes@aol.com>
parents: 12419
diff changeset
    56
variants[varName]["name"] = loc("Pyromancer")
12412
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
    57
variants[varName]["chance"] = 7
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
    58
variants[varName]["hat"] = "Gasmask"
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
    59
variants[varName]["hp"] = 70
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
    60
variants[varName]["hogLimit"] = 2
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
    61
variants[varName]["weaponLimit"] = 1
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
    62
variants[varName]["weapons"] = {amFlamethrower, amMolotov, amWhip}
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
    63
variants[varName]["helperLimit"] = 1
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
    64
variants[varName]["helpers"] = {amRope, amParachute}
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
    65
variants[varName]["special"] = false
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
    66
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
    67
varName = "Builder"
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
    68
variants[varName] = {}
12420
bdf81e6c00eb Battalion: Make mutated hog names translatable
Wuzzy <almikes@aol.com>
parents: 12419
diff changeset
    69
variants[varName]["name"] = loc("Builder")
12412
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
    70
variants[varName]["chance"] = 10
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
    71
variants[varName]["hat"] = "constructor"
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
    72
variants[varName]["hp"] = 100
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
    73
variants[varName]["hogLimit"] = 1
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
    74
variants[varName]["weaponLimit"] = 1
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
    75
variants[varName]["weapons"] = {amDynamite, amWhip, amHammer}
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
    76
variants[varName]["helperLimit"] = 1
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
    77
variants[varName]["helpers"] = {amGirder, amBlowTorch}
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
    78
variants[varName]["special"] = false
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
    79
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
    80
varName = "Rifleman"
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
    81
variants[varName] = {}
12420
bdf81e6c00eb Battalion: Make mutated hog names translatable
Wuzzy <almikes@aol.com>
parents: 12419
diff changeset
    82
variants[varName]["name"] = loc("Rifleman")
12412
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
    83
variants[varName]["chance"] = 7
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
    84
variants[varName]["hat"] = "Sniper"
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
    85
variants[varName]["hp"] = 70
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
    86
variants[varName]["hogLimit"] = 2
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
    87
variants[varName]["weaponLimit"] = 1
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
    88
variants[varName]["weapons"] = {amRCPlane, amShotgun, amSniperRifle}
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
    89
variants[varName]["helperLimit"] = 1
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
    90
variants[varName]["helpers"] = {amLowGravity, amParachute}
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
    91
variants[varName]["special"] = false
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
    92
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
    93
varName = "Warrior"
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
    94
variants[varName] = {}
12420
bdf81e6c00eb Battalion: Make mutated hog names translatable
Wuzzy <almikes@aol.com>
parents: 12419
diff changeset
    95
variants[varName]["name"] = loc("Warrior")
12412
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
    96
variants[varName]["chance"] = 12
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
    97
variants[varName]["hat"] = "spartan"
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
    98
variants[varName]["hp"] = 120
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
    99
variants[varName]["hogLimit"] = 2
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   100
variants[varName]["weaponLimit"] = 1
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   101
variants[varName]["weapons"] = {amClusterBomb, amGrenade, amBazooka}
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   102
variants[varName]["helperLimit"] = 1
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   103
variants[varName]["helpers"] = {amParachute, amRope}
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   104
variants[varName]["special"] = false
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   105
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   106
varName = "Chef"
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   107
variants[varName] = {}
12420
bdf81e6c00eb Battalion: Make mutated hog names translatable
Wuzzy <almikes@aol.com>
parents: 12419
diff changeset
   108
variants[varName]["name"] = loc("Chef")
12412
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   109
variants[varName]["chance"] = 7
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   110
variants[varName]["hat"] = "chef"
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   111
variants[varName]["hp"] = 70
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   112
variants[varName]["hogLimit"] = 1
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   113
variants[varName]["weaponLimit"] = 1
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   114
variants[varName]["weapons"] = {amCake, amKnife, amWhip}
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   115
variants[varName]["helperLimit"] = 1
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   116
variants[varName]["helpers"] = {amRubber, amParachute}
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   117
variants[varName]["special"] = false
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   118
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   119
varName = "Medic"
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   120
variants[varName] = {}
12420
bdf81e6c00eb Battalion: Make mutated hog names translatable
Wuzzy <almikes@aol.com>
parents: 12419
diff changeset
   121
variants[varName]["name"] = loc("Medic")
12412
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   122
variants[varName]["chance"] = 12
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   123
variants[varName]["hat"] = "war_desertmedic"
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   124
variants[varName]["hp"] = 120
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   125
variants[varName]["hogLimit"] = 1
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   126
variants[varName]["weaponLimit"] = 1
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   127
variants[varName]["weapons"] = {amResurrector, amMine, amGasBomb}
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   128
variants[varName]["helperLimit"] = 1
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   129
variants[varName]["helpers"] = {amTeleport, amParachute}
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   130
variants[varName]["special"] = false
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   131
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   132
varName = "Ninja"
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   133
variants[varName] = {}
12420
bdf81e6c00eb Battalion: Make mutated hog names translatable
Wuzzy <almikes@aol.com>
parents: 12419
diff changeset
   134
variants[varName]["name"] = loc("Ninja")
12412
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   135
variants[varName]["chance"] = 8
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   136
variants[varName]["hat"] = "NinjaTriangle"
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   137
variants[varName]["hp"] = 80
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   138
variants[varName]["hogLimit"] = 2
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   139
variants[varName]["weaponLimit"] = 1
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   140
variants[varName]["weapons"] = {amSMine, amMine, amFirePunch}
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   141
variants[varName]["helperLimit"] = 1
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   142
variants[varName]["helpers"] = {amRope, amParachute}
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   143
variants[varName]["special"] = false
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   144
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   145
varName = "Athlete"
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   146
variants[varName] = {}
12420
bdf81e6c00eb Battalion: Make mutated hog names translatable
Wuzzy <almikes@aol.com>
parents: 12419
diff changeset
   147
variants[varName]["name"] = loc("Athlete")
12412
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   148
variants[varName]["chance"] = 8
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   149
variants[varName]["hat"] = "footballhelmet"
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   150
variants[varName]["hp"] = 80
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   151
variants[varName]["hogLimit"] = 1
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   152
variants[varName]["weaponLimit"] = 1
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   153
variants[varName]["weapons"] = {amBaseballBat, amFirePunch, amSeduction}
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   154
variants[varName]["helperLimit"] = 1
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   155
variants[varName]["helpers"] = {amRope, amPickHammer}
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   156
variants[varName]["special"] = false
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   157
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   158
varName = "Scientist"
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   159
variants[varName] = {}
12420
bdf81e6c00eb Battalion: Make mutated hog names translatable
Wuzzy <almikes@aol.com>
parents: 12419
diff changeset
   160
variants[varName]["name"] = loc("Scientist")
12412
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   161
variants[varName]["chance"] = 7
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   162
variants[varName]["hat"] = "doctor"
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   163
variants[varName]["hp"] = 80
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   164
variants[varName]["hogLimit"] = 1
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   165
variants[varName]["weaponLimit"] = 1
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   166
variants[varName]["weapons"] = {amPortalGun, amSineGun, amIceGun}
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   167
variants[varName]["helperLimit"] = 1
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   168
variants[varName]["helpers"] = {amTeleport, amJetpack}  
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   169
variants[varName]["special"] = false
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   170
12417
f6fc84c55bfa Battalion: Rename “Air-General” to “Air General”
Wuzzy <almikes@aol.com>
parents: 12416
diff changeset
   171
varName = "Air General"
12412
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   172
variants[varName] = {}
12420
bdf81e6c00eb Battalion: Make mutated hog names translatable
Wuzzy <almikes@aol.com>
parents: 12419
diff changeset
   173
variants[varName]["name"] = loc("Air General")
12412
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   174
variants[varName]["chance"] = 5
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   175
variants[varName]["hat"] = "war_desertofficer"
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   176
variants[varName]["hp"] = 50
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   177
variants[varName]["hogLimit"] = 1
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   178
variants[varName]["weaponLimit"] = 1
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   179
variants[varName]["weapons"] = {amMineStrike, amNapalm, amAirAttack}
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   180
variants[varName]["helperLimit"] = 1
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   181
variants[varName]["helpers"] = {amRope, amParachute}
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   182
variants[varName]["special"] = true
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   183
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   184
varName = "Hunter"
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   185
variants[varName] = {}
12420
bdf81e6c00eb Battalion: Make mutated hog names translatable
Wuzzy <almikes@aol.com>
parents: 12419
diff changeset
   186
variants[varName]["name"] = loc("Hunter")
12412
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   187
variants[varName]["chance"] = 10
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   188
variants[varName]["hat"] = "Skull"
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   189
variants[varName]["hp"] = 100
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   190
variants[varName]["hogLimit"] = 1
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   191
variants[varName]["weaponLimit"] = 1
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   192
variants[varName]["weapons"] = {amBee, amMortar, amDrill}
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   193
variants[varName]["helperLimit"] = 1
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   194
variants[varName]["helpers"] = {amRope, amParachute}
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   195
variants[varName]["special"] = false
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   196
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   197
varName = "King"
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   198
variants[varName] = {}
12420
bdf81e6c00eb Battalion: Make mutated hog names translatable
Wuzzy <almikes@aol.com>
parents: 12419
diff changeset
   199
variants[varName]["name"] = loc("King")
12412
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   200
variants[varName]["chance"] = 3
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   201
variants[varName]["hat"] = "crown"
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   202
variants[varName]["hp"] = 60
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   203
variants[varName]["hogLimit"] = 1
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   204
variants[varName]["weaponLimit"] = 1
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   205
variants[varName]["weapons"] = {amWatermelon, amHellishBomb, amBallgun}
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   206
variants[varName]["helperLimit"] = 1
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   207
variants[varName]["helpers"] = {amRope, amParachute}
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   208
variants[varName]["special"] = true
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   209
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   210
varName = "Knight"
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   211
variants[varName] = {}
12420
bdf81e6c00eb Battalion: Make mutated hog names translatable
Wuzzy <almikes@aol.com>
parents: 12419
diff changeset
   212
variants[varName]["name"] = loc("Knight")
12412
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   213
variants[varName]["chance"] = 0
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   214
variants[varName]["hat"] = "knight"
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   215
variants[varName]["hp"] = 80
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   216
variants[varName]["hogLimit"] = 1
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   217
variants[varName]["weaponLimit"] = 1
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   218
variants[varName]["weapons"] = {amShotgun, amBazooka, amMine}
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   219
variants[varName]["helperLimit"] = 1
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   220
variants[varName]["helpers"] = {amParachute, amRope}
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   221
variants[varName]["special"] = true
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   222
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   223
--[[
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   224
  ##############################################################################
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   225
  ### GENERAL VARIABLES USED FOR GAMEPLAY                                    ###
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   226
  ##############################################################################
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   227
]]--
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   228
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   229
local unused = {amSnowball, amDrillStrike, amTardis}
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   230
local lowWeaps = {amKamikaze}
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   231
local lowTresh = 25
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   232
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   233
local counter = {} -- Saves how many hogs of a variant a team has
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   234
local group = {} -- Saves randomized variants for all teams
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   235
local teamIndex = {} -- Temporary counter for amount of mutated hogs in team
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   236
local teamHogs = {} -- Saves a list of all hogs belonging to a team
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   237
local hogCount = {} -- Saves how many hogs a team has
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   238
local teamNames = {} -- Saves all teams and names
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   239
local hogInfo = {} -- Saves all hogs with their original values
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   240
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   241
local LastHog = nil -- Last Hedgehog
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   242
local CurHog = nil -- Current Hedgehog
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   243
local LastTeam = nil -- Last Team
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   244
local CurTeam = nil -- Current Team
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   245
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   246
local mode = 'default' -- Which game type to play
12984
353603f5cec3 Tweak some misleading Battalion texts
Wuzzy <Wuzzy2@mail.ru>
parents: 12983
diff changeset
   247
local modeExplicit = false -- Whether the mode was set in script param
12412
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   248
local luck = 100 -- Multiplier for bonuses like crates
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   249
local strength = 1 -- Multiplier for more weapons
12987
ba99ecc53cf0 Battalion: Mutate hogs by default again, but not the names. Add script param mutatenames. Force crowns in King Mode
Wuzzy <Wuzzy2@mail.ru>
parents: 12986
diff changeset
   250
local useVariantHats = true -- Whether to overwrite the hog hats to those of their variants
ba99ecc53cf0 Battalion: Mutate hogs by default again, but not the names. Add script param mutatenames. Force crowns in King Mode
Wuzzy <Wuzzy2@mail.ru>
parents: 12986
diff changeset
   251
                            -- In King Mode, crowns are always enforced regardless of this setting
ba99ecc53cf0 Battalion: Mutate hogs by default again, but not the names. Add script param mutatenames. Force crowns in King Mode
Wuzzy <Wuzzy2@mail.ru>
parents: 12986
diff changeset
   252
local useVariantNames = false -- Whether to overwrite the hog names to those of their variants
12412
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   253
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   254
local highHasBonusWeps = false -- whether or not a hog got bonus weapons on current turn
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   255
local highHasBonusHelp = false -- whether or not a hog got bonus helpers on current turn
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   256
local highPickupCount = 1
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   257
local highPickupSDCount = 2
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   258
local highHelperCount = 1
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   259
local highHelperSDCount = 1
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   260
local highEnemyKillHPBonus = 10
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   261
local highFriendlyKillHPBonus = 15
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   262
local highWeapons = {} -- Saves the weapons from kills
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   263
local highHelpers = {} -- Saves the helpers from kills
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   264
local highSpecialBonus = {amTeleport, amJetpack}
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   265
local highSpecialPool = {amExtraDamage, amVampiric}
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   266
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   267
local kingLinkPerc = 50 -- Percentage of life to share from the team
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   268
15149
40537955de63 Battalion (King): At end of turn, re-kill all minions without king
Wuzzy <Wuzzy2@mail.ru>
parents: 15147
diff changeset
   269
local teamKingsAlive = {} -- whether the king of each team is still alive
40537955de63 Battalion (King): At end of turn, re-kill all minions without king
Wuzzy <Wuzzy2@mail.ru>
parents: 15147
diff changeset
   270
12412
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   271
local pointsWepBase = 5 -- Game start points weapons
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   272
local pointsHlpBase = 2 -- Game start points helpers
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   273
local pointsKeepPerc = 80 -- Percentage of points to take to next round
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   274
local pointsWepTurn = 5 -- Round bonus points weapons
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   275
local pointsHlpTurn = 2 -- Round bonus points helpers
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   276
local pointsWepMax = 25 -- Maximum points for weapons
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   277
local pointsHlpMax = 10 -- Maximum points for helpers
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   278
local pointsKeepSDPerc = 60 -- Percentage of points to take to next round on SD
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   279
local pointsWepSDTurn = 7 -- Round bonus points weapons on SD
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   280
local pointsHlpSDTurn = 3 -- Round bonus points helpers on SD
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   281
local pointsWepSDMax = 35 -- Maximum points for weapons on SD
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   282
local pointsHlpSDMax = 15 -- Maximum points for helpers on SD
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   283
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   284
local pointsWeaponVal = {}
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   285
pointsWeaponVal[amBazooka] = 5
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   286
pointsWeaponVal[amShotgun] = 4
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   287
pointsWeaponVal[amFirePunch] = 3
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   288
pointsWeaponVal[amMine] = 5
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   289
--pointsWeaponVal[amAirAttack] = 10
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   290
pointsWeaponVal[amBee] = 6
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   291
pointsWeaponVal[amClusterBomb] = 7
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   292
pointsWeaponVal[amGrenade] = 5
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   293
pointsWeaponVal[amDEagle] = 3
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   294
pointsWeaponVal[amWhip] = 3
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   295
pointsWeaponVal[amDynamite] = 7
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   296
--pointsWeaponVal[amMineStrike] = 14
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   297
pointsWeaponVal[amMortar] = 4
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   298
pointsWeaponVal[amWatermelon] = 30
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   299
pointsWeaponVal[amSniperRifle] = 3
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   300
pointsWeaponVal[amBaseballBat] = 3
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   301
pointsWeaponVal[amCake] = 7
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   302
--pointsWeaponVal[amNapalm] = 11
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   303
pointsWeaponVal[amDrill] = 6
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   304
pointsWeaponVal[amHellishBomb] = 20
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   305
pointsWeaponVal[amSineGun] = 4
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   306
--pointsWeaponVal[amKamikaze] = 3
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   307
--pointsWeaponVal[amBallgun] = 12
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   308
--pointsWeaponVal[amPianoStrike] = 15
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   309
pointsWeaponVal[amSnowball] = 2
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   310
pointsWeaponVal[amMolotov] = 3
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   311
pointsWeaponVal[amFlamethrower] = 4
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   312
pointsWeaponVal[amRCPlane] = 7
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   313
--pointsWeaponVal[amDrillStrike] = 12
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   314
pointsWeaponVal[amGasBomb] = 2
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   315
pointsWeaponVal[amHammer] = 3
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   316
pointsWeaponVal[amSMine] = 4
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   317
pointsWeaponVal[amAirMine] = 3
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   318
pointsWeaponVal[amKnife] = 3
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   319
pointsWeaponVal[amPortalGun] = 5
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   320
--pointsWeaponVal[amIceGun] = 6
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   321
pointsWeaponVal[amSeduction] = 2
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   322
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   323
local pointsHelperVal = {}
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   324
pointsHelperVal[amRope] = 5
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   325
pointsHelperVal[amParachute] = 2
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   326
--pointsHelperVal[amGirder] = 3
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   327
pointsHelperVal[amBlowTorch] = 2
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   328
pointsHelperVal[amLowGravity] = 3
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   329
--pointsHelperVal[amRubber] = 4
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   330
pointsHelperVal[amPickHammer] = 2
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   331
pointsHelperVal[amTeleport] = 10
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   332
pointsHelperVal[amJetpack] = 8
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   333
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   334
local pointsPerTeam = {}
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   335
local pointsToWep = {} -- List of [points] = {ammo1, ammo2}
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   336
local pointsToHlp = {} -- List of [points] = {ammo1, ammo2}
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   337
local wepPoints = {}
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   338
local hlpPoints = {}
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   339
12985
add647b0036e Battalion: Reduce amount of SD messages
Wuzzy <Wuzzy2@mail.ru>
parents: 12984
diff changeset
   340
local firstTurnOver = false
12412
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   341
local suddenDeath = false
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   342
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   343
local healthCrateChance = 7
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   344
local utilCrateChance = 9
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   345
local weaponCrateChance = 12
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   346
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   347
local healthCrateChanceSD = 12
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   348
local utilCrateChanceSD = 16
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   349
local weaponCrateChanceSD = 21
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   350
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   351
local emptyCrateChance = 7
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   352
local bonusCrateChance = 5
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   353
local cratePickupGap = 35
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   354
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   355
local utilities = {amInvulnerable, amVampiric, amExtraTime, amExtraDamage, amRope, amLandGun}
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   356
local autoSelectHelpers = {amRope, amParachute}
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   357
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   358
local LastWaterLine = 0 -- Saves WaterLine to make sure a water rise wont trigger highland kill
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   359
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   360
local helpers = {}
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   361
helpers[amSkip] = true
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   362
helpers[amRope] = true
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   363
helpers[amParachute] = true
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   364
helpers[amBlowTorch] = true
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   365
helpers[amGirder] = true
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   366
helpers[amTeleport] = true
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   367
helpers[amSwitch] = true
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   368
helpers[amJetpack] = true
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   369
helpers[amBirdy] = true
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   370
helpers[amPortalGun] = true
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   371
helpers[amResurrector] = true
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   372
helpers[amTardis] = true
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   373
helpers[amLandGun] = true
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   374
helpers[amRubber] = true
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   375
--helpers[amKamikaze] = true
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   376
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   377
local posCaseAmmo    = 1
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   378
local posCaseHealth  = 2
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   379
local posCaseUtility = 4
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   380
local posCaseDummy   = 8
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   381
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   382
--[[
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   383
  ##############################################################################
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   384
  ### GENERAL BONUS LUA FUNCTIONS                                            ###
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   385
  ##############################################################################
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   386
]]--
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   387
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   388
function swap(array, index1, index2)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   389
    array[index1], array[index2] = array[index2], array[index1]
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   390
end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   391
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   392
function shuffle(array)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   393
    local cnt = #array
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   394
    while cnt > 1 do
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   395
        local index = GetRandom(cnt) +1
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   396
        swap(array, index, cnt)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   397
        cnt = cnt - 1
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   398
    end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   399
end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   400
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   401
function table.clone(org)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   402
  local copy = {}
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   403
  for orig_key, orig_value in pairs(org) do
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   404
      copy[orig_key] = orig_value
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   405
  end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   406
  return copy
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   407
end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   408
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   409
--[[
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   410
  ##############################################################################
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   411
  ### WEAPON, UTILITY AND AMMO FUNCTIONS                                     ###
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   412
  ##############################################################################
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   413
]]--
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   414
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   415
function clearHogAmmo(hog)
13029
905449169319 Battalion: Use AmmoTypeMax for ammo type iterations
Wuzzy <Wuzzy2@mail.ru>
parents: 12987
diff changeset
   416
  for val=0, AmmoTypeMax do
12412
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   417
    AddAmmo(hog, val, 0)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   418
  end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   419
end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   420
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   421
function autoSelectAmmo(hog, var)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   422
  -- Check if hog has any "useful" helper, select helper, if yes
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   423
  for key, val in pairs(autoSelectHelpers) do
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   424
    if GetAmmoCount(hog, val) > 0 then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   425
      SetWeapon(val)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   426
      return
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   427
    end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   428
  end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   429
end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   430
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   431
function AddHogAmmo(hog, ammo)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   432
  -- Add weapons of variant
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   433
  for key, val in pairs(ammo) do
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   434
    AddAmmo(hog, val, GetAmmoCount(hog, val) +1)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   435
  end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   436
end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   437
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   438
function GetRandomAmmo(hog, sourceType)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   439
  local var = getHogInfo(hog, 'variant')
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   440
  ammo = {}
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   441
  local source = ''
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   442
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   443
  if variants[var] == nil then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   444
    return ammo
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   445
  end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   446
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   447
  if sourceType == "weapons" then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   448
    source = variants[var][sourceType]
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   449
    sourceLimit = variants[var]["weaponLimit"]
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   450
  elseif sourceType == "helpers" then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   451
    source = variants[var][sourceType]
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   452
    sourceLimit = variants[var]["helperLimit"]
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   453
  elseif sourceType == 'poolWeapons' then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   454
    if highWeapons[hog] == nil then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   455
      highWeapons[hog] = {}
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   456
    end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   457
    source = highWeapons[hog]
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   458
    if suddenDeath == false then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   459
      sourceLimit = highPickupCount
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   460
    else
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   461
      sourceLimit = highPickupSDCount
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   462
    end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   463
  elseif sourceType == 'poolHelpers' then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   464
    if highHelpers[hog] == nil then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   465
      highHelpers[hog] = {}
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   466
    end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   467
    source = highHelpers[hog]
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   468
    if suddenDeath == false then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   469
      sourceLimit = highHelperCount
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   470
    else
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   471
      sourceLimit = highHelperSDCount
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   472
    end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   473
  else
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   474
    return ammo
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   475
  end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   476
  
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   477
  local varAmmo = {}
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   478
  for key, val in pairs(source) do
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   479
      varAmmo[key] = val
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   480
  end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   481
  
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   482
  -- If the amount of random weapons is equally to the amount of weapons possible
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   483
  -- We don't need to randomize
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   484
  if sourceLimit >= table.getn(source) then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   485
    return varAmmo
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   486
  end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   487
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   488
  local randIndex = 0
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   489
  local i = 0
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   490
  while i < sourceLimit and #varAmmo > 0 do
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   491
    randIndex = GetRandom(#varAmmo) +1
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   492
    ammo[i] = varAmmo[randIndex]
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   493
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   494
    -- Shift last value to the current index
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   495
    varAmmo[randIndex] = varAmmo[#varAmmo]
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   496
    -- And remove the last index from the array
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   497
    varAmmo[#varAmmo] = nil
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   498
    i = i +1
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   499
  end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   500
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   501
  return ammo
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   502
end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   503
13030
da691787fcd2 Battalion, Points Mode: Show points next to team bars
Wuzzy <Wuzzy2@mail.ru>
parents: 13029
diff changeset
   504
function updatePointsLabel(team)
da691787fcd2 Battalion, Points Mode: Show points next to team bars
Wuzzy <Wuzzy2@mail.ru>
parents: 13029
diff changeset
   505
  SetTeamLabel(team, string.format(loc("%d / %d"), pointsPerTeam[team]["weapons"], pointsPerTeam[team]["helpers"]))
da691787fcd2 Battalion, Points Mode: Show points next to team bars
Wuzzy <Wuzzy2@mail.ru>
parents: 13029
diff changeset
   506
end
da691787fcd2 Battalion, Points Mode: Show points next to team bars
Wuzzy <Wuzzy2@mail.ru>
parents: 13029
diff changeset
   507
12412
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   508
function addTurnAmmo(hog)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   509
  -- Check if hog is valid
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   510
  if hog == nil then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   511
    return
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   512
  end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   513
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   514
  -- Check if hog is alive
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   515
  local hp = GetHealth(hog)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   516
  if hp == nil or hp <= 0 then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   517
    return
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   518
  end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   519
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   520
  -- Unless its points mode, get weapons normally by variant
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   521
  if mode ~= "points" then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   522
    local maxHp = getHogInfo(hog, 'maxHp')
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   523
    local hpPer = div(hp * 100, maxHp)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   524
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   525
    local wep = getHogInfo(hog, 'weapons')
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   526
    local hlp = getHogInfo(hog, 'helpers')
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   527
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   528
    if wep == nil or table.getn(wep) == 0 then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   529
      hogInfo[hog]['weapons'] = GetRandomAmmo(hog, "weapons")
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   530
      wep = getHogInfo(hog, 'weapons')
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   531
    end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   532
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   533
    if hlp == nil or table.getn(hlp) == 0 then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   534
      hogInfo[hog]['helpers'] = GetRandomAmmo(hog, "helpers")
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   535
      hlp = getHogInfo(hog, 'helpers')
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   536
    end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   537
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   538
    AddHogAmmo(hog, wep)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   539
    AddHogAmmo(hog, hlp)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   540
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   541
    if mode == 'highland' then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   542
      local poolWeapons = GetRandomAmmo(hog, 'poolWeapons')
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   543
      local poolHelpers = GetRandomAmmo(hog, 'poolHelpers')
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   544
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   545
      AddHogAmmo(hog, poolWeapons)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   546
      AddHogAmmo(hog, poolHelpers)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   547
    end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   548
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   549
    if hpPer < lowTresh or suddenDeath == true then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   550
      AddHogAmmo(hog, lowWeaps)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   551
    end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   552
  -- We are on points mode, so we need to generate weapons based on points
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   553
  else
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   554
    setupPointsAmmo(hog)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   555
  end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   556
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   557
  AddAmmo(hog, amSkip, -1)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   558
end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   559
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   560
function setupPointsAmmo(hog)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   561
  local teamName = getHogInfo(hog, 'team')
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   562
  local turnWepPoints = pointsPerTeam[teamName]['weapons']
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   563
  local turnHlpPoints = pointsPerTeam[teamName]['helpers']
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   564
  local weps = {}
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   565
  local help = {}
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   566
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   567
  local wepPointsTmp = table.clone(wepPoints)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   568
  local wepMinPnt = wepPointsTmp[1]
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   569
  local wepMaxPnt = wepPointsTmp[#wepPointsTmp]
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   570
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   571
  --AddCaption("Hog: " .. hog .. " Wep: " .. turnWepPoints .. " - Hlp: " .. turnHlpPoints, GetClanColor(GetHogClan(CurHog)),  capgrpGameState)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   572
  --WriteLnToConsole("BEFORE ## Team: " .. teamName .. " Wep: " .. pointsPerTeam[teamName]['weapons'] .. " - Hlp: " .. pointsPerTeam[teamName]['helpers'])
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   573
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   574
  while true do
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   575
    if turnWepPoints < wepMinPnt then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   576
      break
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   577
    end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   578
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   579
    if wepPointsTmp[#wepPointsTmp] > turnWepPoints then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   580
      while wepPointsTmp[#wepPointsTmp] > turnWepPoints do
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   581
        table.remove(wepPointsTmp)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   582
      end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   583
      wepMaxPnt = turnWepPoints
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   584
    end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   585
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   586
    local randPoint = wepPointsTmp[GetRandom(#wepPointsTmp) +1]
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   587
    local randWepList = pointsToWep[randPoint]
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   588
    local randWep = randWepList[GetRandom(#randWepList) +1]
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   589
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   590
    table.insert(weps, randWep)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   591
    turnWepPoints = turnWepPoints -randPoint
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   592
  end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   593
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   594
  local hlpPointsTmp = table.clone(hlpPoints)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   595
  local hlpMinPnt = hlpPointsTmp[1]
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   596
  local hlpMaxPnt = hlpPointsTmp[#hlpPointsTmp]
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   597
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   598
  while true do
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   599
    if turnHlpPoints < hlpMinPnt then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   600
      break
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   601
    end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   602
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   603
    if hlpPointsTmp[#hlpPointsTmp] > turnHlpPoints then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   604
      while hlpPointsTmp[#hlpPointsTmp] > turnHlpPoints do
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   605
        table.remove(hlpPointsTmp)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   606
      end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   607
      hlpMaxPnt = turnHlpPoints
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   608
    end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   609
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   610
    local randPoint = hlpPointsTmp[GetRandom(#hlpPointsTmp) +1]
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   611
    local randHlpList = pointsToHlp[randPoint]
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   612
    local randHlp = randHlpList[GetRandom(#randHlpList) +1]
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   613
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   614
    table.insert(help, randHlp)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   615
    turnHlpPoints = turnHlpPoints -randPoint
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   616
  end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   617
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   618
  AddHogAmmo(hog, weps)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   619
  AddHogAmmo(hog, help)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   620
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   621
  -- Save remaining points
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   622
  pointsPerTeam[teamName]['weaponsRem'] = turnWepPoints
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   623
  pointsPerTeam[teamName]['helpersRem'] = turnHlpPoints
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   624
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   625
  -- Save already collected points so that they wont be "taxed"
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   626
  pointsPerTeam[teamName]['weaponsFix'] = pointsPerTeam[teamName]['weapons']
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   627
  pointsPerTeam[teamName]['helpersFix'] = pointsPerTeam[teamName]['helpers']
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   628
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   629
  --WriteLnToConsole("AFTER ## Team: " .. teamName .. " Wep: " .. pointsPerTeam[teamName]['weapons'] .. " - Hlp: " .. pointsPerTeam[teamName]['helpers'])
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   630
end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   631
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   632
--[[
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   633
  ##############################################################################
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   634
  ### HOG SETUP  FUNCTIONS                                                   ###
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   635
  ##############################################################################
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   636
]]--
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   637
12987
ba99ecc53cf0 Battalion: Mutate hogs by default again, but not the names. Add script param mutatenames. Force crowns in King Mode
Wuzzy <Wuzzy2@mail.ru>
parents: 12986
diff changeset
   638
-- Overwrite hog hat to that of its variant
ba99ecc53cf0 Battalion: Mutate hogs by default again, but not the names. Add script param mutatenames. Force crowns in King Mode
Wuzzy <Wuzzy2@mail.ru>
parents: 12986
diff changeset
   639
function SetHogVariantHat(hog)
12412
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   640
  local var = getHogInfo(hog, 'variant')
12987
ba99ecc53cf0 Battalion: Mutate hogs by default again, but not the names. Add script param mutatenames. Force crowns in King Mode
Wuzzy <Wuzzy2@mail.ru>
parents: 12986
diff changeset
   641
  SetHogHat(hog, variants[var]["hat"])
ba99ecc53cf0 Battalion: Mutate hogs by default again, but not the names. Add script param mutatenames. Force crowns in King Mode
Wuzzy <Wuzzy2@mail.ru>
parents: 12986
diff changeset
   642
end
12412
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   643
12987
ba99ecc53cf0 Battalion: Mutate hogs by default again, but not the names. Add script param mutatenames. Force crowns in King Mode
Wuzzy <Wuzzy2@mail.ru>
parents: 12986
diff changeset
   644
-- Give a crown if the hog is a king.
ba99ecc53cf0 Battalion: Mutate hogs by default again, but not the names. Add script param mutatenames. Force crowns in King Mode
Wuzzy <Wuzzy2@mail.ru>
parents: 12986
diff changeset
   645
-- Strip the hog from its crown if
ba99ecc53cf0 Battalion: Mutate hogs by default again, but not the names. Add script param mutatenames. Force crowns in King Mode
Wuzzy <Wuzzy2@mail.ru>
parents: 12986
diff changeset
   646
-- it is not a king.
ba99ecc53cf0 Battalion: Mutate hogs by default again, but not the names. Add script param mutatenames. Force crowns in King Mode
Wuzzy <Wuzzy2@mail.ru>
parents: 12986
diff changeset
   647
function SetHogVariantHatKingMode(hog)
ba99ecc53cf0 Battalion: Mutate hogs by default again, but not the names. Add script param mutatenames. Force crowns in King Mode
Wuzzy <Wuzzy2@mail.ru>
parents: 12986
diff changeset
   648
  local var = getHogInfo(hog, 'variant')
ba99ecc53cf0 Battalion: Mutate hogs by default again, but not the names. Add script param mutatenames. Force crowns in King Mode
Wuzzy <Wuzzy2@mail.ru>
parents: 12986
diff changeset
   649
  if var == "King" then
ba99ecc53cf0 Battalion: Mutate hogs by default again, but not the names. Add script param mutatenames. Force crowns in King Mode
Wuzzy <Wuzzy2@mail.ru>
parents: 12986
diff changeset
   650
    SetHogHat(hog, variants[var]["hat"])
ba99ecc53cf0 Battalion: Mutate hogs by default again, but not the names. Add script param mutatenames. Force crowns in King Mode
Wuzzy <Wuzzy2@mail.ru>
parents: 12986
diff changeset
   651
  elseif GetHogHat(hog) == "crown" then
ba99ecc53cf0 Battalion: Mutate hogs by default again, but not the names. Add script param mutatenames. Force crowns in King Mode
Wuzzy <Wuzzy2@mail.ru>
parents: 12986
diff changeset
   652
    SetHogHat(hog, "NoHat")
ba99ecc53cf0 Battalion: Mutate hogs by default again, but not the names. Add script param mutatenames. Force crowns in King Mode
Wuzzy <Wuzzy2@mail.ru>
parents: 12986
diff changeset
   653
  end
ba99ecc53cf0 Battalion: Mutate hogs by default again, but not the names. Add script param mutatenames. Force crowns in King Mode
Wuzzy <Wuzzy2@mail.ru>
parents: 12986
diff changeset
   654
end
ba99ecc53cf0 Battalion: Mutate hogs by default again, but not the names. Add script param mutatenames. Force crowns in King Mode
Wuzzy <Wuzzy2@mail.ru>
parents: 12986
diff changeset
   655
ba99ecc53cf0 Battalion: Mutate hogs by default again, but not the names. Add script param mutatenames. Force crowns in King Mode
Wuzzy <Wuzzy2@mail.ru>
parents: 12986
diff changeset
   656
-- Overwrite hog name to that of its variant
ba99ecc53cf0 Battalion: Mutate hogs by default again, but not the names. Add script param mutatenames. Force crowns in King Mode
Wuzzy <Wuzzy2@mail.ru>
parents: 12986
diff changeset
   657
function SetHogVariantName(hog)
ba99ecc53cf0 Battalion: Mutate hogs by default again, but not the names. Add script param mutatenames. Force crowns in King Mode
Wuzzy <Wuzzy2@mail.ru>
parents: 12986
diff changeset
   658
  local var = getHogInfo(hog, 'variant')
12420
bdf81e6c00eb Battalion: Make mutated hog names translatable
Wuzzy <almikes@aol.com>
parents: 12419
diff changeset
   659
  SetHogName(hog, variants[var]["name"])
12412
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   660
end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   661
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   662
function GetRandomVariant()
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   663
  local maxNum = 0
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   664
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   665
  for key, val in pairs(variants) do
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   666
    maxNum = maxNum + variants[key]["chance"]
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   667
  end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   668
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   669
  local rand = GetRandom(maxNum)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   670
  local lowBound = 0
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   671
  local highBound = 0
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   672
  local var = nil
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   673
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   674
  for key, val in pairs(variants) do
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   675
    highBound = lowBound + variants[key]["chance"]
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   676
    if rand <= highBound then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   677
      var = key
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   678
      break
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   679
    end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   680
    lowBound = highBound
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   681
  end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   682
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   683
  return var
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   684
end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   685
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   686
function addRandomVariantToTeam(team)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   687
  if counter[team] == nil then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   688
    counter[team] = {}
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   689
  end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   690
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   691
  while true do
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   692
    local var = GetRandomVariant()
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   693
    if counter[team][var] == nil and variants[var]["hogLimit"] > 0 then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   694
      counter[team][var] = 1
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   695
      break
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   696
    elseif counter[team][var] ~= nil and counter[team][var] < variants[var]["hogLimit"] then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   697
      counter[team][var] = counter[team][var] +1
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   698
      break
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   699
    end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   700
  end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   701
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   702
  return var
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   703
end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   704
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   705
function setTeamHogs(team)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   706
  local maxHog = hogCount[team]
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   707
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   708
  group[team] = {}
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   709
  counter[team] = {}
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   710
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   711
  if mode == 'king' then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   712
    maxHog = maxHog -1
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   713
  end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   714
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   715
  for i=1,maxHog do
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   716
    table.insert(group[team], group['all'][i])
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   717
  end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   718
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   719
  if mode == 'king' then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   720
    counter[team]['King'] = 1
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   721
    table.insert(group[team], 'King')
15149
40537955de63 Battalion (King): At end of turn, re-kill all minions without king
Wuzzy <Wuzzy2@mail.ru>
parents: 15147
diff changeset
   722
    teamKingsAlive[team] = true
12412
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   723
  end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   724
end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   725
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   726
function countTeamHogs(hog)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   727
  local team = GetHogTeamName(hog)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   728
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   729
  if hogCount[team] == nil then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   730
    hogCount[team] = 1
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   731
    teamHogs[team] = {}
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   732
  else
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   733
    hogCount[team] = hogCount[team] +1
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   734
  end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   735
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   736
  teamHogs[team][hogCount[team]] = hog
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   737
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   738
  teamNames[team] = 1
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   739
end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   740
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   741
function setHogVariant(hog)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   742
  local team = getHogInfo(hog, 'team')
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   743
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   744
  if teamIndex[team] == nil then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   745
    teamIndex[team] = 1
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   746
  else
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   747
    teamIndex[team] = teamIndex[team] +1
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   748
  end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   749
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   750
  local hogNum = teamIndex[team]
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   751
  local hogVar = group[team][hogNum]
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   752
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   753
  hogInfo[hog]['variant'] = hogVar
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   754
  SetHealth(hog, variants[hogVar]["hp"])
15449
c95efbab66e6 Battalion Highland: Fix incorrect health bonus (bug 788)
Wuzzy <Wuzzy2@mail.ru>
parents: 15149
diff changeset
   755
  hogInfo[hog]['maxHp'] = variants[hogVar]["hp"]
12412
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   756
end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   757
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   758
function getHogInfo(hog, info)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   759
  if hog == nil then
12980
263d006c56a9 Battalion: Clean up and remove dead code
Wuzzy <Wuzzy2@mail.ru>
parents: 12979
diff changeset
   760
    WriteLnToChat("ERROR [getHogInfo]: hog is nil!")
263d006c56a9 Battalion: Clean up and remove dead code
Wuzzy <Wuzzy2@mail.ru>
parents: 12979
diff changeset
   761
    WriteLnToConsole("ERROR [getHogInfo]: hog is nil!")
12412
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   762
    return
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   763
  end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   764
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   765
  if hogInfo[hog] == nil then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   766
    return nil
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   767
  end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   768
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   769
  return hogInfo[hog][info]
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   770
end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   771
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   772
function setHogInfo(hog)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   773
  if hog == nil then
12980
263d006c56a9 Battalion: Clean up and remove dead code
Wuzzy <Wuzzy2@mail.ru>
parents: 12979
diff changeset
   774
    WriteLnToChat("ERROR [setHogInfo]: hog is nil!")
263d006c56a9 Battalion: Clean up and remove dead code
Wuzzy <Wuzzy2@mail.ru>
parents: 12979
diff changeset
   775
    WriteLnToConsole("ERROR [setHogInfo]: hog is nil!")
12412
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   776
    return
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   777
  end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   778
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   779
  hogInfo[hog] = {}
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   780
  hogInfo[hog]['maxHp'] = GetHealth(hog)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   781
  hogInfo[hog]['name'] = GetHogName(hog)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   782
  hogInfo[hog]['hat'] = GetHogHat(hog)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   783
  hogInfo[hog]['team'] = GetHogTeamName(hog)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   784
  hogInfo[hog]['clan'] = GetHogClan(hog)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   785
  hogInfo[hog]['clanColor'] = GetClanColor(hogInfo[hog]['clan'])
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   786
end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   787
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   788
--[[
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   789
  ##############################################################################
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   790
  ### CRATE SPAWN AND PICKUP FUNCTIONS                                       ###
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   791
  ##############################################################################
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   792
]]--
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   793
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   794
--[[
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   795
 : Heals either 10 (95% chance) or 15 (5% chance) hitpoints
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   796
 : Plus 10% of the hogs base hitpoints. 
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   797
 :
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   798
 : Has a 7% chance to be empty.
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   799
]]--
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   800
function onHealthCratePickup()
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   801
  local factor = 2
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   802
  local msgColor = getHogInfo(CurHog, 'clanColor')
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   803
  local healHp = 0
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   804
  PlaySound(sndShotgunReload)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   805
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   806
  if GetRandom(100) < emptyCrateChance then
12415
e11758f70cce Rewrite all Battalion strings to be more translator-friendly
Wuzzy <almikes@aol.com>
parents: 12412
diff changeset
   807
    AddCaption(loc("It's empty!"), msgColor, capgrpMessage)
12412
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   808
    return
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   809
  elseif GetRandom(100) < bonusCrateChance then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   810
    factor = 3
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   811
  end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   812
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   813
  local var = getHogInfo(CurHog, 'variant')
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   814
  local hogHealth = GetHealth(CurHog)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   815
  healHp = 5 * factor
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   816
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   817
  -- Add extra 10% of hogs base hp to heal
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   818
  healHp = healHp + div(getHogInfo(CurHog, 'maxHp'), 10)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   819
12979
b6d67e975b51 Battalion: Standardize the crate pickup message
Wuzzy <Wuzzy2@mail.ru>
parents: 12978
diff changeset
   820
  HealHog(CurHog, healHp)
12412
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   821
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   822
  SetEffect(CurHog, hePoisoned, 0)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   823
end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   824
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   825
--[[
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   826
 : Adds either 1 (95% chance) or 2 (5% chance) random weapon(s) based on the hog variant.
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   827
 :
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   828
 : Has a 7% chance to be empty.
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   829
]]--
12983
7c3454083489 Battalion: Move crate pickup animation to crate
Wuzzy <Wuzzy2@mail.ru>
parents: 12982
diff changeset
   830
function onWeaponCratePickup(crate)
12412
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   831
  local factor = 1 * strength
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   832
  local msgColor = GetClanColor(GetHogClan(CurHog))
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   833
  PlaySound(sndShotgunReload)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   834
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   835
  if GetRandom(100) < emptyCrateChance then
12628
96e30c42c318 Battalion: Only show collected ammo to local player
Wuzzy <almikes@aol.com>
parents: 12422
diff changeset
   836
    if IsHogLocal(CurHog) then
96e30c42c318 Battalion: Only show collected ammo to local player
Wuzzy <almikes@aol.com>
parents: 12422
diff changeset
   837
      AddCaption(loc("It's empty!"), msgColor, capgrpMessage)
96e30c42c318 Battalion: Only show collected ammo to local player
Wuzzy <almikes@aol.com>
parents: 12422
diff changeset
   838
    end
12412
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   839
    return
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   840
  elseif GetRandom(100) < bonusCrateChance then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   841
    factor = 2 * strength
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   842
  end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   843
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   844
  local randIndex
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   845
  local randAmmo
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   846
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   847
  if mode ~= 'points' then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   848
    local var = getHogInfo(CurHog, 'variant')
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   849
    randIndex = GetRandom(table.getn(variants[var]["weapons"])) +1
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   850
    randAmmo = variants[var]["weapons"][randIndex]
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   851
  else
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   852
    local possibleWeapons = {}
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   853
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   854
    for key, val in pairs(pointsWeaponVal) do
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   855
      if val > 2 and val < 8 then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   856
        table.insert(possibleWeapons, key)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   857
      end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   858
    end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   859
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   860
    randIndex = GetRandom(table.getn(possibleWeapons)) +1
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   861
    randAmmo = possibleWeapons[randIndex]
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   862
  end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   863
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   864
  AddAmmo(CurHog, randAmmo, GetAmmoCount(CurHog, randAmmo) +factor)
12628
96e30c42c318 Battalion: Only show collected ammo to local player
Wuzzy <almikes@aol.com>
parents: 12422
diff changeset
   865
  if IsHogLocal(CurHog) then
12979
b6d67e975b51 Battalion: Standardize the crate pickup message
Wuzzy <Wuzzy2@mail.ru>
parents: 12978
diff changeset
   866
    AddCaption(string.format(loc("%s (+%d)"), GetAmmoName(randAmmo), factor), msgColor, capgrpMessage)
12983
7c3454083489 Battalion: Move crate pickup animation to crate
Wuzzy <Wuzzy2@mail.ru>
parents: 12982
diff changeset
   867
    local effect = AddVisualGear(GetX(crate), GetY(crate) +cratePickupGap, vgtAmmo, 0, true)
12628
96e30c42c318 Battalion: Only show collected ammo to local player
Wuzzy <almikes@aol.com>
parents: 12422
diff changeset
   868
    SetVisualGearValues(effect, nil, nil, nil, nil, nil, randAmmo, nil, nil, nil, msgColor)
96e30c42c318 Battalion: Only show collected ammo to local player
Wuzzy <almikes@aol.com>
parents: 12422
diff changeset
   869
  end
12412
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   870
end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   871
--[[
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   872
 : Adds either 1 (95% chance) or 2 (5% chance) random helper(s) based on the hog variant.
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   873
 :
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   874
 : Has a 7% chance to be empty.
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   875
]]--
12983
7c3454083489 Battalion: Move crate pickup animation to crate
Wuzzy <Wuzzy2@mail.ru>
parents: 12982
diff changeset
   876
function onUtilityCratePickup(crate)
12412
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   877
  local factor = 1 * strength
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   878
  local msgColor = GetClanColor(GetHogClan(CurHog))
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   879
  PlaySound(sndShotgunReload)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   880
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   881
  if GetRandom(100) < emptyCrateChance then
12628
96e30c42c318 Battalion: Only show collected ammo to local player
Wuzzy <almikes@aol.com>
parents: 12422
diff changeset
   882
    if IsHogLocal(CurHog) then
96e30c42c318 Battalion: Only show collected ammo to local player
Wuzzy <almikes@aol.com>
parents: 12422
diff changeset
   883
      AddCaption(loc("It's empty!"), msgColor, capgrpMessage)
96e30c42c318 Battalion: Only show collected ammo to local player
Wuzzy <almikes@aol.com>
parents: 12422
diff changeset
   884
    end
12412
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   885
    return
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   886
  elseif GetRandom(100) < bonusCrateChance then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   887
    factor = 2 * strength
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   888
  end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   889
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   890
  local randIndex
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   891
  local randUtility
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   892
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   893
  if mode ~= 'points' then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   894
    randIndex = GetRandom(table.getn(utilities)) +1
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   895
    randUtility = utilities[randIndex]
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   896
  else
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   897
    local possibleHelpers = {}
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   898
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   899
    for key, val in pairs(pointsHelperVal) do
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   900
      table.insert(possibleHelpers, key)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   901
    end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   902
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   903
    randIndex = GetRandom(table.getn(possibleHelpers)) +1
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   904
    randUtility = possibleHelpers[randIndex]
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   905
  end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   906
  
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   907
  AddAmmo(CurHog, randUtility, GetAmmoCount(CurHog, randUtility) +factor)
12628
96e30c42c318 Battalion: Only show collected ammo to local player
Wuzzy <almikes@aol.com>
parents: 12422
diff changeset
   908
  if IsHogLocal(CurHog) then
12979
b6d67e975b51 Battalion: Standardize the crate pickup message
Wuzzy <Wuzzy2@mail.ru>
parents: 12978
diff changeset
   909
    AddCaption(string.format(loc("%s (+%d)"), GetAmmoName(randUtility), factor), msgColor, capgrpMessage)
12983
7c3454083489 Battalion: Move crate pickup animation to crate
Wuzzy <Wuzzy2@mail.ru>
parents: 12982
diff changeset
   910
    local effect = AddVisualGear(GetX(crate), GetY(crate) +cratePickupGap, vgtAmmo, 0, true)
12628
96e30c42c318 Battalion: Only show collected ammo to local player
Wuzzy <almikes@aol.com>
parents: 12422
diff changeset
   911
    SetVisualGearValues(effect, nil, nil, nil, nil, nil, randUtility, nil, nil, nil, msgColor)
96e30c42c318 Battalion: Only show collected ammo to local player
Wuzzy <almikes@aol.com>
parents: 12422
diff changeset
   912
  end
12412
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   913
end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   914
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   915
function onPickupCrate(crate)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   916
  local pos = GetGearPos(crate)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   917
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   918
  -- Check if the crate is fake
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   919
  if pos % posCaseDummy >= 1 then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   920
    if pos % posCaseDummy == posCaseAmmo then
12983
7c3454083489 Battalion: Move crate pickup animation to crate
Wuzzy <Wuzzy2@mail.ru>
parents: 12982
diff changeset
   921
      onWeaponCratePickup(crate)
12412
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   922
    elseif pos % posCaseDummy == posCaseHealth then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   923
      onHealthCratePickup()
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   924
    elseif pos % posCaseDummy == posCaseUtility then
12983
7c3454083489 Battalion: Move crate pickup animation to crate
Wuzzy <Wuzzy2@mail.ru>
parents: 12982
diff changeset
   925
      onUtilityCratePickup(crate)
12412
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   926
    end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   927
  end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   928
end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   929
14790
dd4daa216398 Battalion: Properly spawn crate between turns
Wuzzy <Wuzzy2@mail.ru>
parents: 14788
diff changeset
   930
function onCaseDrop()
12412
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   931
  if GetRandom(100) < weaponCrateChance then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   932
    SpawnFakeAmmoCrate(0, 0, false, false)
14790
dd4daa216398 Battalion: Properly spawn crate between turns
Wuzzy <Wuzzy2@mail.ru>
parents: 14788
diff changeset
   933
    PlaySound(sndReinforce, CurrentHedgehog)
12412
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   934
  elseif GetRandom(100) < utilCrateChance then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   935
    SpawnFakeUtilityCrate(0, 0, false, false)
14790
dd4daa216398 Battalion: Properly spawn crate between turns
Wuzzy <Wuzzy2@mail.ru>
parents: 14788
diff changeset
   936
    PlaySound(sndReinforce, CurrentHedgehog)
12412
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   937
  elseif GetRandom(100) < healthCrateChance then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   938
    SpawnFakeHealthCrate(0, 0, false, false)
14790
dd4daa216398 Battalion: Properly spawn crate between turns
Wuzzy <Wuzzy2@mail.ru>
parents: 14788
diff changeset
   939
    PlaySound(sndReinforce, CurrentHedgehog)
12412
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   940
  end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   941
end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   942
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   943
--[[
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   944
  ##############################################################################
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   945
  ### SUDDEN DEATH FUNCTIONS                                                 ###
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   946
  ##############################################################################
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   947
]]--
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   948
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   949
function onSuddenDeathDamage(hog)
14788
458a8c4e65ca Clean up Sudden Death messages and animations in Battalion
Wuzzy <Wuzzy2@mail.ru>
parents: 13643
diff changeset
   950
  if GetEffect(hog, heInvulnerable) ~= 0 then
458a8c4e65ca Clean up Sudden Death messages and animations in Battalion
Wuzzy <Wuzzy2@mail.ru>
parents: 13643
diff changeset
   951
    return
458a8c4e65ca Clean up Sudden Death messages and animations in Battalion
Wuzzy <Wuzzy2@mail.ru>
parents: 13643
diff changeset
   952
  end
12412
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   953
  local hp = GetHealth(hog)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   954
  local maxHp = getHogInfo(hog, 'maxHp')
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   955
  local newHp = 0
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   956
  local hpDec = 0
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   957
  local hpPer = div(hp * 100, maxHp)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   958
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   959
  if hp > 1 then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   960
    local msgColor = GetClanColor(GetHogClan(hog))
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   961
    if hpPer <= 25 then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   962
      newHp = hp -2
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   963
    elseif hpPer <= 50 then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   964
      newHp = hp -3
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   965
    elseif hpPer <= 75 then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   966
      newHp = hp -4
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   967
    elseif hpPer <= 100 then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   968
      newHp = hp -5
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   969
    elseif hpPer <= 125 then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   970
      newHp = hp -6
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   971
    elseif hpPer <= 150 then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   972
      newHp = hp -7
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   973
    else
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   974
      newHp = div(hp * 93, 100)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   975
    end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   976
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   977
    if newHp <= 0 then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   978
      newHp = 1
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   979
    end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   980
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   981
    hpDec = hp - newHp
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   982
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   983
    SetHealth(hog, newHp)
14788
458a8c4e65ca Clean up Sudden Death messages and animations in Battalion
Wuzzy <Wuzzy2@mail.ru>
parents: 13643
diff changeset
   984
    if hpDec > 0 then
458a8c4e65ca Clean up Sudden Death messages and animations in Battalion
Wuzzy <Wuzzy2@mail.ru>
parents: 13643
diff changeset
   985
      local r = math.random(1, 2)
458a8c4e65ca Clean up Sudden Death messages and animations in Battalion
Wuzzy <Wuzzy2@mail.ru>
parents: 13643
diff changeset
   986
      if r == 1 then
458a8c4e65ca Clean up Sudden Death messages and animations in Battalion
Wuzzy <Wuzzy2@mail.ru>
parents: 13643
diff changeset
   987
         PlaySound(sndPoisonCough, hog, true)
458a8c4e65ca Clean up Sudden Death messages and animations in Battalion
Wuzzy <Wuzzy2@mail.ru>
parents: 13643
diff changeset
   988
      else
458a8c4e65ca Clean up Sudden Death messages and animations in Battalion
Wuzzy <Wuzzy2@mail.ru>
parents: 13643
diff changeset
   989
         PlaySound(sndPoisonMoan, hog, true)
458a8c4e65ca Clean up Sudden Death messages and animations in Battalion
Wuzzy <Wuzzy2@mail.ru>
parents: 13643
diff changeset
   990
      end
458a8c4e65ca Clean up Sudden Death messages and animations in Battalion
Wuzzy <Wuzzy2@mail.ru>
parents: 13643
diff changeset
   991
      local effect = AddVisualGear(GetX(hog), GetY(hog) +cratePickupGap, vgtHealthTag, hpDec, false)
458a8c4e65ca Clean up Sudden Death messages and animations in Battalion
Wuzzy <Wuzzy2@mail.ru>
parents: 13643
diff changeset
   992
      SetVisualGearValues(effect, nil, nil, nil, nil, nil, nil, nil, nil, nil, msgColor)
458a8c4e65ca Clean up Sudden Death messages and animations in Battalion
Wuzzy <Wuzzy2@mail.ru>
parents: 13643
diff changeset
   993
    end
12412
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   994
  end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   995
end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   996
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   997
function onSuddenDeathTurn()
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   998
  runOnGears(onSuddenDeathDamage)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
   999
end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1000
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1001
function onSuddenDeath()
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1002
  suddenDeath = true
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1003
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1004
  healthCrateChance = healthCrateChanceSD
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1005
  utilCrateChance = utilCrateChanceSD
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1006
  weaponCrateChance = weaponCrateChanceSD
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1007
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1008
  if mode == 'highland' then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1009
    highEnemyKillHPBonus = highEnemyKillHPBonus +5
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1010
    highFriendlyKillHPBonus = highFriendlyKillHPBonus +10
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1011
  end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1012
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1013
  if mode ~= 'points' then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1014
    for key, val in pairs(variants) do
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1015
      if not variants[key]["special"] then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1016
        variants[key]["weaponLimit"] = variants[key]["weaponLimit"] +1
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1017
      end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1018
    end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1019
  end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1020
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1021
  if mode ~= 'points' then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1022
    for hog, val in pairs(hogInfo) do
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1023
      hogInfo[hog]['weapons'] = {}
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1024
      hogInfo[hog]['helpers'] = {}
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1025
    end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1026
    
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1027
    runOnGears(setupHogTurn)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1028
  end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1029
end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1030
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1031
--[[
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1032
  ##############################################################################
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1033
  ### GEAR TRACKING FUNCTIONS                                                ###
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1034
  ##############################################################################
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1035
]]--
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1036
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1037
function onGearAdd(gear)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1038
  local gearType = GetGearType(gear)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1039
  
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1040
  if gearType == gtHedgehog then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1041
    trackGear(gear)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1042
  elseif gearType == gtRCPlane then
12422
959d1f4dff25 Battalion: RC Plane gets 2 bombs, set air bomb dmg to 20
Wuzzy <almikes@aol.com>
parents: 12421
diff changeset
  1043
    SetHealth(gear, 2)
12412
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1044
  elseif gearType == gtAirBomb then
12980
263d006c56a9 Battalion: Clean up and remove dead code
Wuzzy <Wuzzy2@mail.ru>
parents: 12979
diff changeset
  1045
    -- Set Boom
12422
959d1f4dff25 Battalion: RC Plane gets 2 bombs, set air bomb dmg to 20
Wuzzy <almikes@aol.com>
parents: 12421
diff changeset
  1046
    SetGearValues(gear, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 20)
12412
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1047
  elseif gearType == gtCake then
12980
263d006c56a9 Battalion: Clean up and remove dead code
Wuzzy <Wuzzy2@mail.ru>
parents: 12979
diff changeset
  1048
    -- Set Boom
12412
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1049
    SetGearValues(gear, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 50)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1050
  elseif gearType == gtDEagleShot then
12980
263d006c56a9 Battalion: Clean up and remove dead code
Wuzzy <Wuzzy2@mail.ru>
parents: 12979
diff changeset
  1051
    -- Set Boom
12412
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1052
    SetGearValues(gear, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 12)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1053
  end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1054
end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1055
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1056
function onHighlandKill(gear)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1057
  local deathVar = getHogInfo(gear, 'variant')
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1058
  local killVar = getHogInfo(CurHog, 'variant')
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1059
  local bonAmmo = {}
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1060
  local deathMaxHP = getHogInfo(gear, 'maxHp')
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1061
  local curHP = GetHealth(CurHog)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1062
  local newHP = 0
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1063
  local hpDiff = 0
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1064
  local addAmmo = false
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1065
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1066
  -- Killer hog is dead! Don't do anything
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1067
  if curHP == nil or curHP <= 0 then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1068
    return
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1069
  end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1070
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1071
  -- Killer and victim is equal! Don't do anything
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1072
  if CurHog == gear then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1073
    return
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1074
  end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1075
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1076
  -- Hog drowned because of water, not enemy
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1077
  if LastWaterLine ~= WaterLine then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1078
    return
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1079
  end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1080
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1081
  -- Enemy kill! Add weapons to pool and to hog
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1082
  if getHogInfo(gear, 'clan') ~= getHogInfo(CurHog, 'clan') then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1083
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1084
    -- Initialize weapons if required
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1085
    if highWeapons[CurHog] == nil then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1086
      highWeapons[CurHog] = {}
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1087
    end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1088
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1089
    if highHelpers[CurHog] == nil then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1090
      highHelpers[CurHog] = {}
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1091
    end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1092
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1093
    -- If not a special hog, use the victims weapons
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1094
    if variants[deathVar]['special'] == false then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1095
      bonAmmo = variants[deathVar]['weapons']
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1096
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1097
      if suddenDeath == true then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1098
        ammoCount = highPickupSDCount
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1099
      else
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1100
        ammoCount = highPickupCount
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1101
      end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1102
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1103
      -- Check if hog already got bonus weapons
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1104
      if table.getn(highWeapons[CurHog]) == 0 and highHasBonusWeps == false then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1105
        highHasBonusWeps = true
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1106
        addAmmo = true
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1107
      end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1108
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1109
      -- Pass turn bonus weapons to hog pool
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1110
      for key, val in pairs(bonAmmo) do
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1111
        local idx = table.getn(highWeapons[CurHog]) +1
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1112
        highWeapons[CurHog][idx] = val
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1113
      end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1114
    -- It's a special hog, use special pool
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1115
    else
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1116
      bonAmmo = highSpecialBonus
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1117
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1118
      ammoCount = 1
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1119
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1120
      -- Check if hog already got bonus helpers
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1121
      if table.getn(highWeapons[CurHog]) == 0 and highHasBonusHelp == false then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1122
        highHasBonusHelp = true
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1123
        addAmmo = true
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1124
      end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1125
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1126
      -- Pass turn bonus weapons to hog pool
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1127
      for key, val in pairs(highSpecialPool) do
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1128
        local idx = table.getn(highHelpers[CurHog]) +1
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1129
        highHelpers[CurHog][idx] = val
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1130
      end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1131
    end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1132
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1133
    if addAmmo then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1134
      local i = 1
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1135
      while i <= ammoCount and #bonAmmo > 0 do
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1136
        local randAmmo = GetRandom(#bonAmmo) +1
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1137
        local randAmmoType = bonAmmo[randAmmo]
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1138
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1139
        -- Remove the randomized weapon so it cannot be picked up twice
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1140
        table.remove(bonAmmo, randAmmo)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1141
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1142
        AddAmmo(CurHog, randAmmoType, GetAmmoCount(CurHog, randAmmoType) +1)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1143
12628
96e30c42c318 Battalion: Only show collected ammo to local player
Wuzzy <almikes@aol.com>
parents: 12422
diff changeset
  1144
        if IsHogLocal(CurHog) then
96e30c42c318 Battalion: Only show collected ammo to local player
Wuzzy <almikes@aol.com>
parents: 12422
diff changeset
  1145
           local effect = AddVisualGear(GetX(CurHog), GetY(CurHog) + (cratePickupGap * i), vgtAmmo, 0, true)
96e30c42c318 Battalion: Only show collected ammo to local player
Wuzzy <almikes@aol.com>
parents: 12422
diff changeset
  1146
           SetVisualGearValues(effect, nil, nil, nil, nil, nil, randAmmoType, nil, nil, nil, nil)
96e30c42c318 Battalion: Only show collected ammo to local player
Wuzzy <almikes@aol.com>
parents: 12422
diff changeset
  1147
        end
12412
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1148
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1149
        i = i +1
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1150
      end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1151
    end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1152
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1153
    hpDiff = div(deathMaxHP * highEnemyKillHPBonus, 100)
15449
c95efbab66e6 Battalion Highland: Fix incorrect health bonus (bug 788)
Wuzzy <Wuzzy2@mail.ru>
parents: 15149
diff changeset
  1154
    HealHog(CurHog, hpDiff)
12981
4c7472d3d483 Battalion: Add more health change effects
Wuzzy <Wuzzy2@mail.ru>
parents: 12980
diff changeset
  1155
  -- Friendly fire! Punish hog by removing weapons and helpers from pool
4c7472d3d483 Battalion: Add more health change effects
Wuzzy <Wuzzy2@mail.ru>
parents: 12980
diff changeset
  1156
  -- and reduce health
12412
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1157
  else
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1158
    highWeapons[CurHog] = {}
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1159
    highHelpers[CurHog] = {}
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1160
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1161
    hpDiff = div(deathMaxHP * highFriendlyKillHPBonus, 100)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1162
    newHP = curHP - hpDiff
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1163
    if newHP > 0 then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1164
      SetHealth(CurHog, newHP)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1165
    else
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1166
      SetHealth(CurHog, 0)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1167
    end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1168
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1169
    local effect = AddVisualGear(GetX(CurHog), GetY(CurHog) - cratePickupGap, vgtHealthTag, hpDiff, false)
12980
263d006c56a9 Battalion: Clean up and remove dead code
Wuzzy <Wuzzy2@mail.ru>
parents: 12979
diff changeset
  1170
    -- Set Tint
12412
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1171
    SetVisualGearValues(effect, nil, nil, nil, nil, nil, nil, nil, nil, nil, GetClanColor(GetHogClan(CurHog)))
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1172
  end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1173
end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1174
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1175
function onKingDeath(KingHog)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1176
  local team = getHogInfo(KingHog, 'team')
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1177
  local msgColor = getHogInfo(KingHog, 'clanColor')
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1178
13643
690cc84e9fd6 Use capcolDefault in Lua scripts
Wuzzy <Wuzzy2@mail.ru>
parents: 13030
diff changeset
  1179
  AddCaption(string.format(loc("The king of %s has died!"), team), capcolDefault, capgrpGameState)
15147
ab21cbb0e3a0 Battalion (King): Kill minions with default boom
Wuzzy <Wuzzy2@mail.ru>
parents: 15146
diff changeset
  1180
  SetState(KingHog, gstHHDeath)
12412
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1181
12986
1c38d4370943 Battalion (mode=king): Kill the team when the king died instea of dismissing
Wuzzy <Wuzzy2@mail.ru>
parents: 12985
diff changeset
  1182
  -- Kill the rest of the team normally, just like the official King Mode game modifier
1c38d4370943 Battalion (mode=king): Kill the team when the king died instea of dismissing
Wuzzy <Wuzzy2@mail.ru>
parents: 12985
diff changeset
  1183
  for hog, val in pairs(hogInfo) do
1c38d4370943 Battalion (mode=king): Kill the team when the king died instea of dismissing
Wuzzy <Wuzzy2@mail.ru>
parents: 12985
diff changeset
  1184
    if getHogInfo(hog, 'team') == team then
1c38d4370943 Battalion (mode=king): Kill the team when the king died instea of dismissing
Wuzzy <Wuzzy2@mail.ru>
parents: 12985
diff changeset
  1185
      hp = GetHealth(hog)
1c38d4370943 Battalion (mode=king): Kill the team when the king died instea of dismissing
Wuzzy <Wuzzy2@mail.ru>
parents: 12985
diff changeset
  1186
      if hp ~= nil and hp > 0 then
1c38d4370943 Battalion (mode=king): Kill the team when the king died instea of dismissing
Wuzzy <Wuzzy2@mail.ru>
parents: 12985
diff changeset
  1187
        SetHealth(hog, 0)
1c38d4370943 Battalion (mode=king): Kill the team when the king died instea of dismissing
Wuzzy <Wuzzy2@mail.ru>
parents: 12985
diff changeset
  1188
      end
1c38d4370943 Battalion (mode=king): Kill the team when the king died instea of dismissing
Wuzzy <Wuzzy2@mail.ru>
parents: 12985
diff changeset
  1189
    end
1c38d4370943 Battalion (mode=king): Kill the team when the king died instea of dismissing
Wuzzy <Wuzzy2@mail.ru>
parents: 12985
diff changeset
  1190
  end
15149
40537955de63 Battalion (King): At end of turn, re-kill all minions without king
Wuzzy <Wuzzy2@mail.ru>
parents: 15147
diff changeset
  1191
  teamKingsAlive[team] = false
12986
1c38d4370943 Battalion (mode=king): Kill the team when the king died instea of dismissing
Wuzzy <Wuzzy2@mail.ru>
parents: 12985
diff changeset
  1192
1c38d4370943 Battalion (mode=king): Kill the team when the king died instea of dismissing
Wuzzy <Wuzzy2@mail.ru>
parents: 12985
diff changeset
  1193
  -- We don't use DismissTeam, it causes a lot of problems and nasty side-effects.
1c38d4370943 Battalion (mode=king): Kill the team when the king died instea of dismissing
Wuzzy <Wuzzy2@mail.ru>
parents: 12985
diff changeset
  1194
12412
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1195
end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1196
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1197
function onPointsKill(gear)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1198
  local deathVar = getHogInfo(gear, 'variant')
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1199
  local killVar = getHogInfo(CurHog, 'variant')
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1200
  local deathClan = getHogInfo(gear, 'clan')
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1201
  local killClan = getHogInfo(CurHog, 'clan')
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1202
  local team = getHogInfo(CurHog, 'team')
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1203
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1204
  local curHP = GetHealth(CurHog)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1205
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1206
  -- Killer hog is dead! Don't do anything
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1207
  if curHP == nil or curHP <= 0 then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1208
    return
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1209
  end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1210
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1211
  -- Hog drowned because of water, not enemy
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1212
  if LastWaterLine ~= WaterLine then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1213
    return
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1214
  end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1215
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1216
  -- Same clan, friendly kill, skip
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1217
  if killClan == deathClan then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1218
    return
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1219
  end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1220
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1221
  pointsPerTeam[team]['weapons'] = pointsPerTeam[team]['weapons'] + 2
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1222
  pointsPerTeam[team]['helpers'] = pointsPerTeam[team]['helpers'] + 1
13030
da691787fcd2 Battalion, Points Mode: Show points next to team bars
Wuzzy <Wuzzy2@mail.ru>
parents: 13029
diff changeset
  1223
  updatePointsLabel(team)
12412
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1224
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1225
  local effect = AddVisualGear(GetX(CurHog) - (cratePickupGap / 2), GetY(CurHog), vgtHealthTag, 2, false)
12980
263d006c56a9 Battalion: Clean up and remove dead code
Wuzzy <Wuzzy2@mail.ru>
parents: 12979
diff changeset
  1226
  -- Set Tint
12412
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1227
  SetVisualGearValues(effect, nil, nil, nil, nil, nil, nil, nil, nil, nil, 0xFFFFFFFF)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1228
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1229
  local effect = AddVisualGear(GetX(CurHog) + (cratePickupGap / 2), GetY(CurHog), vgtHealthTag, 1, false)
12980
263d006c56a9 Battalion: Clean up and remove dead code
Wuzzy <Wuzzy2@mail.ru>
parents: 12979
diff changeset
  1230
  -- Set Tint
12412
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1231
  SetVisualGearValues(effect, nil, nil, nil, nil, nil, nil, nil, nil, nil, 0x444444FF)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1232
end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1233
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1234
function onGearDelete(gear)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1235
  trackDeletion(gear)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1236
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1237
  if GetGearType(gear) == gtCase and band(GetGearMessage(gear), gmDestroy) ~= 0 then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1238
    onPickupCrate(gear)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1239
  end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1240
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1241
  if GetGearType(gear) == gtHedgehog then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1242
    if mode ~= 'points' then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1243
      hogInfo[gear]['weapons'] = {}
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1244
      hogInfo[gear]['helpers'] = {}
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1245
    end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1246
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1247
    -- If dying gear is a hog and mode is highland, check for kills
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1248
    if mode == 'highland' then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1249
      onHighlandKill(gear)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1250
    -- If current hog is dying and we are on points mode, we need to save the unused weapons/helpers
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1251
    elseif mode == 'points' and CurHog == gear then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1252
      savePoints(gear)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1253
    elseif mode == 'points' and CurHog ~= gear then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1254
      onPointsKill(gear)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1255
    end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1256
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1257
    if mode == 'king' and getHogInfo(gear, 'variant') == 'King' then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1258
      onKingDeath(gear)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1259
    end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1260
  end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1261
end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1262
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1263
--[[
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1264
  ##############################################################################
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1265
  ### TURN BASED FUNCTIONS                                                   ###
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1266
  ##############################################################################
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1267
]]--
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1268
12981
4c7472d3d483 Battalion: Add more health change effects
Wuzzy <Wuzzy2@mail.ru>
parents: 12980
diff changeset
  1269
function calcKingHP(doEffects)
4c7472d3d483 Battalion: Add more health change effects
Wuzzy <Wuzzy2@mail.ru>
parents: 12980
diff changeset
  1270
  if doEffects == nil then
4c7472d3d483 Battalion: Add more health change effects
Wuzzy <Wuzzy2@mail.ru>
parents: 12980
diff changeset
  1271
     doEffects = true
4c7472d3d483 Battalion: Add more health change effects
Wuzzy <Wuzzy2@mail.ru>
parents: 12980
diff changeset
  1272
  end
12412
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1273
  local teamKings = {}
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1274
  local teamHealth = {}
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1275
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1276
  for hog, val in pairs(hogInfo) do
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1277
    local hp = GetHealth(hog)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1278
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1279
    if hp ~= nil and hp > 0 then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1280
      local team = getHogInfo(hog, 'team')
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1281
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1282
      if teamHealth[team] == nil then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1283
        teamHealth[team] = 0
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1284
      end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1285
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1286
      if getHogInfo(hog, 'variant') == 'King' then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1287
        teamKings[team] = hog
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1288
      else
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1289
        teamHealth[team] = teamHealth[team] + hp
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1290
      end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1291
    end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1292
  end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1293
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1294
  for team, hog in pairs(teamKings) do
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1295
    local hp = GetHealth(hog)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1296
    local newHP = div(teamHealth[team] * kingLinkPerc, 100)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1297
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1298
    -- Set hitpoints to 1 if no other hog is alive or only has 1 hitpoint
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1299
    if newHP <= 0 then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1300
      newHP = 1
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1301
    end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1302
12981
4c7472d3d483 Battalion: Add more health change effects
Wuzzy <Wuzzy2@mail.ru>
parents: 12980
diff changeset
  1303
    local diff = math.abs(newHP - hp)
12412
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1304
12981
4c7472d3d483 Battalion: Add more health change effects
Wuzzy <Wuzzy2@mail.ru>
parents: 12980
diff changeset
  1305
    -- Change HP and do some nice effects
4c7472d3d483 Battalion: Add more health change effects
Wuzzy <Wuzzy2@mail.ru>
parents: 12980
diff changeset
  1306
    if newHP ~= hp then
4c7472d3d483 Battalion: Add more health change effects
Wuzzy <Wuzzy2@mail.ru>
parents: 12980
diff changeset
  1307
        if not doEffects then
4c7472d3d483 Battalion: Add more health change effects
Wuzzy <Wuzzy2@mail.ru>
parents: 12980
diff changeset
  1308
            SetHealth(hog, newHP)
4c7472d3d483 Battalion: Add more health change effects
Wuzzy <Wuzzy2@mail.ru>
parents: 12980
diff changeset
  1309
        else
4c7472d3d483 Battalion: Add more health change effects
Wuzzy <Wuzzy2@mail.ru>
parents: 12980
diff changeset
  1310
            if newHP > hp then
4c7472d3d483 Battalion: Add more health change effects
Wuzzy <Wuzzy2@mail.ru>
parents: 12980
diff changeset
  1311
                HealHog(hog, diff, false)
4c7472d3d483 Battalion: Add more health change effects
Wuzzy <Wuzzy2@mail.ru>
parents: 12980
diff changeset
  1312
            elseif newHP < hp then
4c7472d3d483 Battalion: Add more health change effects
Wuzzy <Wuzzy2@mail.ru>
parents: 12980
diff changeset
  1313
                SetHealth(hog, newHP)
4c7472d3d483 Battalion: Add more health change effects
Wuzzy <Wuzzy2@mail.ru>
parents: 12980
diff changeset
  1314
                if doEffects then
4c7472d3d483 Battalion: Add more health change effects
Wuzzy <Wuzzy2@mail.ru>
parents: 12980
diff changeset
  1315
                    local effect = AddVisualGear(GetX(hog), GetY(hog) - cratePickupGap, vgtHealthTag, diff, false)
4c7472d3d483 Battalion: Add more health change effects
Wuzzy <Wuzzy2@mail.ru>
parents: 12980
diff changeset
  1316
                    -- Set Tint
4c7472d3d483 Battalion: Add more health change effects
Wuzzy <Wuzzy2@mail.ru>
parents: 12980
diff changeset
  1317
                    SetVisualGearValues(effect, nil, nil, nil, nil, nil, nil, nil, nil, nil, GetClanColor(GetHogClan(hog)))
4c7472d3d483 Battalion: Add more health change effects
Wuzzy <Wuzzy2@mail.ru>
parents: 12980
diff changeset
  1318
                end
4c7472d3d483 Battalion: Add more health change effects
Wuzzy <Wuzzy2@mail.ru>
parents: 12980
diff changeset
  1319
            end
4c7472d3d483 Battalion: Add more health change effects
Wuzzy <Wuzzy2@mail.ru>
parents: 12980
diff changeset
  1320
        end
12412
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1321
    end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1322
  end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1323
end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1324
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1325
function setupHogTurn(hog)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1326
  clearHogAmmo(hog)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1327
  addTurnAmmo(hog)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1328
end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1329
15149
40537955de63 Battalion (King): At end of turn, re-kill all minions without king
Wuzzy <Wuzzy2@mail.ru>
parents: 15147
diff changeset
  1330
function checkKingAlive(gear)
40537955de63 Battalion (King): At end of turn, re-kill all minions without king
Wuzzy <Wuzzy2@mail.ru>
parents: 15147
diff changeset
  1331
  -- This workaround works because in King Mode, we made
40537955de63 Battalion (King): At end of turn, re-kill all minions without king
Wuzzy <Wuzzy2@mail.ru>
parents: 15147
diff changeset
  1332
  -- sure only kings can have the crown.
40537955de63 Battalion (King): At end of turn, re-kill all minions without king
Wuzzy <Wuzzy2@mail.ru>
parents: 15147
diff changeset
  1333
  if GetHogHat(gear) == 'crown' then
40537955de63 Battalion (King): At end of turn, re-kill all minions without king
Wuzzy <Wuzzy2@mail.ru>
parents: 15147
diff changeset
  1334
    teamKingsAlive[getHogInfo(gear, 'team')] = true
40537955de63 Battalion (King): At end of turn, re-kill all minions without king
Wuzzy <Wuzzy2@mail.ru>
parents: 15147
diff changeset
  1335
  end
40537955de63 Battalion (King): At end of turn, re-kill all minions without king
Wuzzy <Wuzzy2@mail.ru>
parents: 15147
diff changeset
  1336
end
40537955de63 Battalion (King): At end of turn, re-kill all minions without king
Wuzzy <Wuzzy2@mail.ru>
parents: 15147
diff changeset
  1337
40537955de63 Battalion (King): At end of turn, re-kill all minions without king
Wuzzy <Wuzzy2@mail.ru>
parents: 15147
diff changeset
  1338
function killLonelyMinion(gear)
40537955de63 Battalion (King): At end of turn, re-kill all minions without king
Wuzzy <Wuzzy2@mail.ru>
parents: 15147
diff changeset
  1339
  if teamKingsAlive[getHogInfo(gear, 'team')] == false then
40537955de63 Battalion (King): At end of turn, re-kill all minions without king
Wuzzy <Wuzzy2@mail.ru>
parents: 15147
diff changeset
  1340
    SetHealth(gear, 0)
40537955de63 Battalion (King): At end of turn, re-kill all minions without king
Wuzzy <Wuzzy2@mail.ru>
parents: 15147
diff changeset
  1341
  end
40537955de63 Battalion (King): At end of turn, re-kill all minions without king
Wuzzy <Wuzzy2@mail.ru>
parents: 15147
diff changeset
  1342
end
40537955de63 Battalion (King): At end of turn, re-kill all minions without king
Wuzzy <Wuzzy2@mail.ru>
parents: 15147
diff changeset
  1343
12982
ba577e0b8c27 Battalion: Use official onEndTurn callback
Wuzzy <Wuzzy2@mail.ru>
parents: 12981
diff changeset
  1344
function onEndTurn()
12985
add647b0036e Battalion: Reduce amount of SD messages
Wuzzy <Wuzzy2@mail.ru>
parents: 12984
diff changeset
  1345
  if not firstTurnOver then
add647b0036e Battalion: Reduce amount of SD messages
Wuzzy <Wuzzy2@mail.ru>
parents: 12984
diff changeset
  1346
    firstTurnOver = true
add647b0036e Battalion: Reduce amount of SD messages
Wuzzy <Wuzzy2@mail.ru>
parents: 12984
diff changeset
  1347
  end
12412
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1348
  local anyHog = nil
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1349
  for team, val in pairs(teamNames) do
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1350
    -- Count amount of alive hogs in team
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1351
    local c = 0
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1352
    for idx, hog in pairs(teamHogs[team]) do
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1353
      if GetHealth(hog) ~= nil then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1354
        anyHog = hog
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1355
        c = c + 1
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1356
      end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1357
    end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1358
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1359
    -- Only one hog left, unfreeze the hog
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1360
    if c == 1 then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1361
      if GetHealth(anyHog) ~= nil then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1362
        SetEffect(anyHog, heFrozen, 0)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1363
      end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1364
    end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1365
  end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1366
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1367
  -- When we are on points mode count remaining weapon/helper points
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1368
  if mode == 'points' and GetHealth(CurHog) ~= nil then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1369
    savePoints(CurHog)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1370
  end
15149
40537955de63 Battalion (King): At end of turn, re-kill all minions without king
Wuzzy <Wuzzy2@mail.ru>
parents: 15147
diff changeset
  1371
40537955de63 Battalion (King): At end of turn, re-kill all minions without king
Wuzzy <Wuzzy2@mail.ru>
parents: 15147
diff changeset
  1372
  -- In King Mode, kill all hogs without king in their team
40537955de63 Battalion (King): At end of turn, re-kill all minions without king
Wuzzy <Wuzzy2@mail.ru>
parents: 15147
diff changeset
  1373
  if mode == 'king' then
40537955de63 Battalion (King): At end of turn, re-kill all minions without king
Wuzzy <Wuzzy2@mail.ru>
parents: 15147
diff changeset
  1374
    runOnGears(checkKingAlive)
40537955de63 Battalion (King): At end of turn, re-kill all minions without king
Wuzzy <Wuzzy2@mail.ru>
parents: 15147
diff changeset
  1375
    runOnGears(killLonelyMinion)
40537955de63 Battalion (King): At end of turn, re-kill all minions without king
Wuzzy <Wuzzy2@mail.ru>
parents: 15147
diff changeset
  1376
  end
12412
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1377
end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1378
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1379
function savePoints(hog)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1380
  local team = getHogInfo(hog, 'team')
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1381
  local hogWepPoints = 0
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1382
  local hogHlpPoints = 0
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1383
13029
905449169319 Battalion: Use AmmoTypeMax for ammo type iterations
Wuzzy <Wuzzy2@mail.ru>
parents: 12987
diff changeset
  1384
  for ammoType=0, AmmoTypeMax do
12412
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1385
    local ammoCount = GetAmmoCount(hog, ammoType)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1386
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1387
    if pointsWeaponVal[ammoType] ~= nil then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1388
      hogWepPoints = hogWepPoints + (pointsWeaponVal[ammoType] * ammoCount)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1389
    elseif pointsHelperVal[ammoType] ~= nil then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1390
      hogHlpPoints = hogHlpPoints + (pointsHelperVal[ammoType] * ammoCount)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1391
    end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1392
  end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1393
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1394
  local wepWoTax = pointsPerTeam[team]['weaponsFix']
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1395
  local hlpWoTax = pointsPerTeam[team]['helpersFix']
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1396
  local wepToTax = 0
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1397
  local hlpToTax = 0
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1398
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1399
  if hogWepPoints <= wepWoTax then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1400
    wepWoTax = hogWepPoints
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1401
  else
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1402
    wepToTax = hogWepPoints - wepWoTax
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1403
  end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1404
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1405
  if hogHlpPoints <= hlpWoTax then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1406
    hlpWoTax = hogHlpPoints
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1407
  else
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1408
    hlpToTax = hogHlpPoints - hlpWoTax
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1409
  end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1410
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1411
  if suddenDeath == false then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1412
    pointsPerTeam[team]['weapons'] = pointsPerTeam[team]['weaponsRem'] + wepWoTax + div(wepToTax * pointsKeepPerc, 100)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1413
    pointsPerTeam[team]['helpers'] = pointsPerTeam[team]['helpersRem'] + hlpWoTax + div(hlpToTax * pointsKeepPerc, 100)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1414
  else
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1415
    pointsPerTeam[team]['weapons'] = pointsPerTeam[team]['weaponsRem'] + wepWoTax + div(wepToTax * pointsKeepSDPerc, 100)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1416
    pointsPerTeam[team]['helpers'] = pointsPerTeam[team]['helpersRem'] + hlpWoTax + div(hlpToTax * pointsKeepSDPerc, 100)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1417
  end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1418
13030
da691787fcd2 Battalion, Points Mode: Show points next to team bars
Wuzzy <Wuzzy2@mail.ru>
parents: 13029
diff changeset
  1419
  updatePointsLabel(team)
da691787fcd2 Battalion, Points Mode: Show points next to team bars
Wuzzy <Wuzzy2@mail.ru>
parents: 13029
diff changeset
  1420
12412
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1421
  local effect = AddVisualGear(GetX(hog) - (cratePickupGap / 2), GetY(hog), vgtHealthTag, pointsPerTeam[team]['weapons'], false)
12980
263d006c56a9 Battalion: Clean up and remove dead code
Wuzzy <Wuzzy2@mail.ru>
parents: 12979
diff changeset
  1422
  -- Set Tint
12412
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1423
  SetVisualGearValues(effect, nil, nil, nil, nil, nil, nil, nil, nil, nil, 0xFFFFFFFF)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1424
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1425
  local effect = AddVisualGear(GetX(hog) + (cratePickupGap / 2), GetY(hog), vgtHealthTag, pointsPerTeam[team]['helpers'], false)
12980
263d006c56a9 Battalion: Clean up and remove dead code
Wuzzy <Wuzzy2@mail.ru>
parents: 12979
diff changeset
  1426
  -- Set Tint
12412
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1427
  SetVisualGearValues(effect, nil, nil, nil, nil, nil, nil, nil, nil, nil, 0x444444FF)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1428
end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1429
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1430
function onPointsTurn()
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1431
  local hogWepPoints = 0
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1432
  local hogHlpPoints = 0
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1433
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1434
  if suddenDeath == false then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1435
    pointsPerTeam[LastTeam]['weapons'] = pointsPerTeam[LastTeam]['weapons'] + pointsWepTurn
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1436
    pointsPerTeam[LastTeam]['helpers'] = pointsPerTeam[LastTeam]['helpers'] + pointsHlpTurn
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1437
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1438
    if pointsPerTeam[LastTeam]['weapons'] > pointsWepMax then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1439
      pointsPerTeam[LastTeam]['weapons'] = pointsWepMax
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1440
    end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1441
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1442
    if pointsPerTeam[LastTeam]['helpers'] > pointsHlpMax then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1443
      pointsPerTeam[LastTeam]['helpers'] = pointsHlpMax
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1444
    end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1445
  else
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1446
    pointsPerTeam[LastTeam]['weapons'] = pointsPerTeam[LastTeam]['weapons'] + pointsWepSDTurn
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1447
    pointsPerTeam[LastTeam]['helpers'] = pointsPerTeam[LastTeam]['helpers'] + pointsHlpSDTurn
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1448
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1449
    if pointsPerTeam[LastTeam]['weapons'] > pointsWepSDMax then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1450
      pointsPerTeam[LastTeam]['weapons'] = pointsWepSDMax
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1451
    end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1452
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1453
    if pointsPerTeam[LastTeam]['helpers'] > pointsHlpSDMax then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1454
      pointsPerTeam[LastTeam]['helpers'] = pointsHlpSDMax
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1455
    end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1456
  end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1457
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1458
  -- Take the first alive hog from LastTeam and setup new weapons and helpers
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1459
  -- Since the weapons and helpers are shared the whole team, this is sufficent
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1460
  for idx, teamHog in pairs(teamHogs[LastTeam]) do
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1461
    if GetHealth(teamHog) ~= nil then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1462
      clearHogAmmo(teamHog)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1463
      addTurnAmmo(teamHog)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1464
      break
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1465
    end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1466
  end
15450
c0ad952894d9 Battalion points: Update displayed LastTeam points each turn
Wuzzy <Wuzzy2@mail.ru>
parents: 15449
diff changeset
  1467
c0ad952894d9 Battalion points: Update displayed LastTeam points each turn
Wuzzy <Wuzzy2@mail.ru>
parents: 15449
diff changeset
  1468
  updatePointsLabel(LastTeam)
12412
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1469
end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1470
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1471
function onNewTurn()
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1472
  LastHog = CurHog
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1473
  LastTeam = CurTeam
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1474
  CurHog = CurrentHedgehog
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1475
  CurTeam = getHogInfo(CurHog, 'team')
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1476
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1477
  if suddenDeath == true then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1478
    onSuddenDeathTurn()
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1479
  end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1480
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1481
  -- Generate new weapons for last hog if it's still alive
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1482
  if LastHog ~= nil and LastHog ~= CurHog then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1483
    if mode == 'points' then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1484
      onPointsTurn()
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1485
    else
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1486
      hogInfo[LastHog]['weapons'] = {}
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1487
      hogInfo[LastHog]['helpers'] = {}
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1488
      setupHogTurn(LastHog)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1489
    end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1490
  end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1491
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1492
  -- Recalculate the kings hp if required
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1493
  if mode == 'king' then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1494
    calcKingHP()
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1495
  end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1496
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1497
  if mode == 'highland' then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1498
    highHasBonusWeps = false
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1499
    highHasBonusHelp = false
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1500
  end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1501
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1502
  -- Set LastWaterLine to the current water line
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1503
  LastWaterLine = WaterLine
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1504
end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1505
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1506
--[[
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1507
  ##############################################################################
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1508
  ### GAME START FUNCTIONS                                                   ###
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1509
  ##############################################################################
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1510
]]--
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1511
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1512
function onAmmoStoreInit()
13029
905449169319 Battalion: Use AmmoTypeMax for ammo type iterations
Wuzzy <Wuzzy2@mail.ru>
parents: 12987
diff changeset
  1513
  for val=0, AmmoTypeMax do
12412
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1514
    SetAmmo(val, 0, 0, 0, 0)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1515
  end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1516
end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1517
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1518
function onParameters()
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1519
  parseParams()
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1520
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1521
  if params['mode'] ~= nil then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1522
    mode = params['mode']
12984
353603f5cec3 Tweak some misleading Battalion texts
Wuzzy <Wuzzy2@mail.ru>
parents: 12983
diff changeset
  1523
    if mode == "default" or mode == "king" or mode == "points" or mode == "highland" then
353603f5cec3 Tweak some misleading Battalion texts
Wuzzy <Wuzzy2@mail.ru>
parents: 12983
diff changeset
  1524
       modeExplicit = true
353603f5cec3 Tweak some misleading Battalion texts
Wuzzy <Wuzzy2@mail.ru>
parents: 12983
diff changeset
  1525
    end
12412
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1526
  end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1527
12987
ba99ecc53cf0 Battalion: Mutate hogs by default again, but not the names. Add script param mutatenames. Force crowns in King Mode
Wuzzy <Wuzzy2@mail.ru>
parents: 12986
diff changeset
  1528
  if params['mutatenames'] ~= nil then
ba99ecc53cf0 Battalion: Mutate hogs by default again, but not the names. Add script param mutatenames. Force crowns in King Mode
Wuzzy <Wuzzy2@mail.ru>
parents: 12986
diff changeset
  1529
    useVariantNames = params['mutatenames']
ba99ecc53cf0 Battalion: Mutate hogs by default again, but not the names. Add script param mutatenames. Force crowns in King Mode
Wuzzy <Wuzzy2@mail.ru>
parents: 12986
diff changeset
  1530
  end
12412
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1531
  if params['mutate'] ~= nil then
12987
ba99ecc53cf0 Battalion: Mutate hogs by default again, but not the names. Add script param mutatenames. Force crowns in King Mode
Wuzzy <Wuzzy2@mail.ru>
parents: 12986
diff changeset
  1532
    useVariantHats = params['mutate']
12412
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1533
  end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1534
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1535
  if params['strength'] ~= nil and tonumber(params['strength']) > 0 then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1536
    strength = tonumber(params['strength'])
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1537
    -- Highland
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1538
    if mode == 'highland' then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1539
      highPickupCount = highPickupCount * strength
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1540
      highPickupSDCount = highPickupSDCount * strength
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1541
      highHelperCount = highHelperCount * strength
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1542
      highHelperSDCount = highHelperSDCount * strength
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1543
    -- Points
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1544
    elseif mode == 'points' then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1545
      pointsWepBase = pointsWepBase * strength
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1546
      pointsHlpBase = pointsHlpBase * strength
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1547
      pointsWepTurn = pointsWepTurn * strength
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1548
      pointsHlpTurn = pointsHlpTurn * strength
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1549
      pointsWepMax = pointsWepMax * strength
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1550
      pointsHlpMax = pointsHlpMax * strength
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1551
      pointsWepSDTurn = pointsWepSDTurn * strength
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1552
      pointsHlpSDTurn = pointsHlpSDTurn * strength
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1553
      pointsWepSDMax = pointsWepSDMax * strength
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1554
      pointsHlpSDMax = pointsHlpSDMax * strength
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1555
    -- Either king or normal mode, change variants
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1556
    else
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1557
      for name, data in pairs(variants) do
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1558
        variants[name]["weaponLimit"] = variants[name]["weaponLimit"] * strength
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1559
        variants[name]["helperLimit"] = variants[name]["helperLimit"] * strength
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1560
      end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1561
    end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1562
  end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1563
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1564
  if params['luck'] ~= nil and tonumber(params['luck']) > 0 then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1565
    luck = tonumber(params['luck'])
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1566
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1567
    healthCrateChance = div(healthCrateChance * luck, 100)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1568
    utilCrateChance = div(utilCrateChance * luck, 100)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1569
    weaponCrateChance = div(weaponCrateChance * luck, 100)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1570
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1571
    healthCrateChanceSD = div(healthCrateChanceSD * luck, 100)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1572
    utilCrateChanceSD = div(utilCrateChanceSD * luck, 100)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1573
    weaponCrateChanceSD = div(weaponCrateChanceSD * luck, 100)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1574
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1575
    emptyCrateChance = div(emptyCrateChance * 100, luck)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1576
    bonusCrateChance = div(bonusCrateChance * luck, 100)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1577
  end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1578
end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1579
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1580
function onGameStart()
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1581
  -- If we are not on points mode, we start randomizing everything
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1582
  if mode ~= 'points' then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1583
    if GetGameFlag(gfBorder) or MapHasBorder() then
12417
f6fc84c55bfa Battalion: Rename “Air-General” to “Air General”
Wuzzy <almikes@aol.com>
parents: 12416
diff changeset
  1584
      variants["Air General"] = nil
12412
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1585
      variants['Athlete'] = nil
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1586
    end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1587
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1588
    if mode == 'king' then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1589
      variants['King']['chance'] = 0
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1590
    end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1591
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1592
    for i=1,8 do
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1593
      addRandomVariantToTeam("all")
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1594
    end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1595
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1596
    -- Translate randomized team to a flat group
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1597
    group['all'] = {}
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1598
    for key, val in pairs(counter["all"]) do
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1599
      for i=1, counter["all"][key] do
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1600
        table.insert(group['all'], key)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1601
      end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1602
    end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1603
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1604
    -- Shuffle group for more randomness
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1605
    shuffle(group['all'])
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1606
  -- We are in points mode, setup other weapons
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1607
  elseif mode == 'points' then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1608
    -- Translate [ammo] -> points to [points] -> {ammo1, ammo2}
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1609
    for ammoType, ammoPoints in pairs(pointsWeaponVal) do
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1610
      if pointsToWep[ammoPoints] == nil then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1611
        pointsToWep[ammoPoints] = {}
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1612
      end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1613
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1614
      table.insert(pointsToWep[ammoPoints], ammoType)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1615
    end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1616
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1617
    for ammoType, ammoPoints in pairs(pointsHelperVal) do
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1618
      if pointsToHlp[ammoPoints] == nil then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1619
        pointsToHlp[ammoPoints] = {}
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1620
      end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1621
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1622
      table.insert(pointsToHlp[ammoPoints], ammoType)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1623
    end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1624
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1625
    for points, ammoList in pairs(pointsToWep) do
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1626
      table.insert(wepPoints, points)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1627
    end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1628
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1629
    for points, ammoList in pairs(pointsToHlp) do
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1630
      table.insert(hlpPoints, points)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1631
    end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1632
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1633
    table.sort(wepPoints)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1634
    table.sort(hlpPoints)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1635
  end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1636
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1637
  -- Initial Hog Setup
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1638
  runOnGears(countTeamHogs)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1639
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1640
  for key, val in pairs(teamNames) do
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1641
    if mode == 'points' then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1642
      pointsPerTeam[key] = {}
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1643
      pointsPerTeam[key]['weapons'] = pointsWepBase
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1644
      pointsPerTeam[key]['helpers'] = pointsHlpBase
13030
da691787fcd2 Battalion, Points Mode: Show points next to team bars
Wuzzy <Wuzzy2@mail.ru>
parents: 13029
diff changeset
  1645
      updatePointsLabel(key)
12412
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1646
    else
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1647
      setTeamHogs(key)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1648
    end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1649
  end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1650
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1651
  runOnGears(setHogInfo)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1652
  
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1653
  if mode ~= 'points' then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1654
    runOnGears(setHogVariant)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1655
    runOnGears(setupHogTurn)
12987
ba99ecc53cf0 Battalion: Mutate hogs by default again, but not the names. Add script param mutatenames. Force crowns in King Mode
Wuzzy <Wuzzy2@mail.ru>
parents: 12986
diff changeset
  1656
    if useVariantNames ~= false and useVariantNames ~= 'false' then
ba99ecc53cf0 Battalion: Mutate hogs by default again, but not the names. Add script param mutatenames. Force crowns in King Mode
Wuzzy <Wuzzy2@mail.ru>
parents: 12986
diff changeset
  1657
      runOnGears(SetHogVariantName)
ba99ecc53cf0 Battalion: Mutate hogs by default again, but not the names. Add script param mutatenames. Force crowns in King Mode
Wuzzy <Wuzzy2@mail.ru>
parents: 12986
diff changeset
  1658
    end
ba99ecc53cf0 Battalion: Mutate hogs by default again, but not the names. Add script param mutatenames. Force crowns in King Mode
Wuzzy <Wuzzy2@mail.ru>
parents: 12986
diff changeset
  1659
    if useVariantHats ~= false and useVariantHats ~= 'false' then
ba99ecc53cf0 Battalion: Mutate hogs by default again, but not the names. Add script param mutatenames. Force crowns in King Mode
Wuzzy <Wuzzy2@mail.ru>
parents: 12986
diff changeset
  1660
        runOnGears(SetHogVariantHat)
ba99ecc53cf0 Battalion: Mutate hogs by default again, but not the names. Add script param mutatenames. Force crowns in King Mode
Wuzzy <Wuzzy2@mail.ru>
parents: 12986
diff changeset
  1661
    elseif mode == 'king' then
ba99ecc53cf0 Battalion: Mutate hogs by default again, but not the names. Add script param mutatenames. Force crowns in King Mode
Wuzzy <Wuzzy2@mail.ru>
parents: 12986
diff changeset
  1662
        -- If variant hats are disabled but we're in King Mode,
ba99ecc53cf0 Battalion: Mutate hogs by default again, but not the names. Add script param mutatenames. Force crowns in King Mode
Wuzzy <Wuzzy2@mail.ru>
parents: 12986
diff changeset
  1663
        -- we still change *some* hats to make sure only kings
ba99ecc53cf0 Battalion: Mutate hogs by default again, but not the names. Add script param mutatenames. Force crowns in King Mode
Wuzzy <Wuzzy2@mail.ru>
parents: 12986
diff changeset
  1664
        -- wear crows. Otherwise, you don't know who's the king!
ba99ecc53cf0 Battalion: Mutate hogs by default again, but not the names. Add script param mutatenames. Force crowns in King Mode
Wuzzy <Wuzzy2@mail.ru>
parents: 12986
diff changeset
  1665
        runOnGears(SetHogVariantHatKingMode)
12412
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1666
    end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1667
  end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1668
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1669
  if mode == 'points' then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1670
    for key, val in pairs(teamNames) do
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1671
      clearHogAmmo(teamHogs[key][1])
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1672
      addTurnAmmo(teamHogs[key][1])
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1673
    end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1674
  end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1675
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1676
  if mode == 'king' then
12981
4c7472d3d483 Battalion: Add more health change effects
Wuzzy <Wuzzy2@mail.ru>
parents: 12980
diff changeset
  1677
    calcKingHP(false)
12412
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1678
  end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1679
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1680
  local txt = ''
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1681
  local icon = 0
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1682
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1683
  if mode ~= 'points' then
12415
e11758f70cce Rewrite all Battalion strings to be more translator-friendly
Wuzzy <almikes@aol.com>
parents: 12412
diff changeset
  1684
    txt = txt .. loc("Variants: Hogs will be randomized from 12 different variants") .. "|"
e11758f70cce Rewrite all Battalion strings to be more translator-friendly
Wuzzy <almikes@aol.com>
parents: 12412
diff changeset
  1685
    txt = txt .. loc("Weapons: Hogs will get 1 out of 3 weapons randomly each turn") .. "|"
e11758f70cce Rewrite all Battalion strings to be more translator-friendly
Wuzzy <almikes@aol.com>
parents: 12412
diff changeset
  1686
    txt = txt .. loc("Helpers: Hogs will get 1 out of 2 helpers randomly each turn") .. "|"
e11758f70cce Rewrite all Battalion strings to be more translator-friendly
Wuzzy <almikes@aol.com>
parents: 12412
diff changeset
  1687
    txt = txt .. loc("Crates: Crates drop randomly with chance of being empty") .. "|"
e11758f70cce Rewrite all Battalion strings to be more translator-friendly
Wuzzy <almikes@aol.com>
parents: 12412
diff changeset
  1688
    txt = txt .. loc("Last Resort: Having less than 25% base health gives kamikaze") .. "|"
12984
353603f5cec3 Tweak some misleading Battalion texts
Wuzzy <Wuzzy2@mail.ru>
parents: 12983
diff changeset
  1689
    txt = txt .. loc("Modifiers: Unlimited attacks, per-hog ammo") .. "|"
12412
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1690
  else
12415
e11758f70cce Rewrite all Battalion strings to be more translator-friendly
Wuzzy <almikes@aol.com>
parents: 12412
diff changeset
  1691
    txt = txt .. loc("Crates: Crates drop randomly and may be empty") .. "|"
12984
353603f5cec3 Tweak some misleading Battalion texts
Wuzzy <Wuzzy2@mail.ru>
parents: 12983
diff changeset
  1692
    txt = txt .. loc("Modifiers: Unlimited attacks, shared clan ammo") .. "|"
12412
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1693
  end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1694
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1695
  if luck ~= 100 then
12415
e11758f70cce Rewrite all Battalion strings to be more translator-friendly
Wuzzy <almikes@aol.com>
parents: 12412
diff changeset
  1696
    txt = txt .. string.format(loc("Luck: %d%% (modifier for crates)"), luck) .. "|"
12412
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1697
  end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1698
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1699
  if strength > 1 then
12415
e11758f70cce Rewrite all Battalion strings to be more translator-friendly
Wuzzy <almikes@aol.com>
parents: 12412
diff changeset
  1700
    txt = txt .. string.format(loc("Strength: %d (multiplier for ammo)"), strength) .. "|"
12412
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1701
  end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1702
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1703
  if mode == 'highland' then
12415
e11758f70cce Rewrite all Battalion strings to be more translator-friendly
Wuzzy <almikes@aol.com>
parents: 12412
diff changeset
  1704
    txt = txt .. " |"
12984
353603f5cec3 Tweak some misleading Battalion texts
Wuzzy <Wuzzy2@mail.ru>
parents: 12983
diff changeset
  1705
    txt = txt .. loc("--- Highland Mode ---").."|"
12415
e11758f70cce Rewrite all Battalion strings to be more translator-friendly
Wuzzy <almikes@aol.com>
parents: 12412
diff changeset
  1706
    txt = txt .. string.format(loc("Enemy kills: Collect victim's weapons and +%d%% of its base health"), highEnemyKillHPBonus).."|"
e11758f70cce Rewrite all Battalion strings to be more translator-friendly
Wuzzy <almikes@aol.com>
parents: 12412
diff changeset
  1707
    txt = txt .. string.format(loc("Friendly kills: Clear killer's pool and -%d%% of its base health"), highFriendlyKillHPBonus).."|"
e11758f70cce Rewrite all Battalion strings to be more translator-friendly
Wuzzy <almikes@aol.com>
parents: 12412
diff changeset
  1708
    txt = txt .. string.format(loc("Turns: Hogs get %d random weapon(s) from their pool"), highPickupCount).."|"
e11758f70cce Rewrite all Battalion strings to be more translator-friendly
Wuzzy <almikes@aol.com>
parents: 12412
diff changeset
  1709
    txt = txt .. loc("Hint: Kills won't transfer a hog's pool to the killer's pool").."|"
e11758f70cce Rewrite all Battalion strings to be more translator-friendly
Wuzzy <almikes@aol.com>
parents: 12412
diff changeset
  1710
    txt = txt .. loc("Specials: Kings and air generals drop helpers, not weapons").."|"
12412
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1711
    icon = 1 -- Target
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1712
  elseif mode == 'king' then
12415
e11758f70cce Rewrite all Battalion strings to be more translator-friendly
Wuzzy <almikes@aol.com>
parents: 12412
diff changeset
  1713
    txt = txt .. " |"
12984
353603f5cec3 Tweak some misleading Battalion texts
Wuzzy <Wuzzy2@mail.ru>
parents: 12983
diff changeset
  1714
    txt = txt .. loc("--- King Mode ---").."|"
12986
1c38d4370943 Battalion (mode=king): Kill the team when the king died instea of dismissing
Wuzzy <Wuzzy2@mail.ru>
parents: 12985
diff changeset
  1715
    txt = txt .. loc("Protect the King: When the king dies, so does the team").."|"
12415
e11758f70cce Rewrite all Battalion strings to be more translator-friendly
Wuzzy <almikes@aol.com>
parents: 12412
diff changeset
  1716
    txt = txt .. string.format(loc("Turns: King's health is set to %d%% of the team health"), kingLinkPerc).."|"
12980
263d006c56a9 Battalion: Clean up and remove dead code
Wuzzy <Wuzzy2@mail.ru>
parents: 12979
diff changeset
  1717
    icon = 0 -- Golden Crown
12412
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1718
  elseif mode == 'points' then
12415
e11758f70cce Rewrite all Battalion strings to be more translator-friendly
Wuzzy <almikes@aol.com>
parents: 12412
diff changeset
  1719
    txt = txt .. " |"
12984
353603f5cec3 Tweak some misleading Battalion texts
Wuzzy <Wuzzy2@mail.ru>
parents: 12983
diff changeset
  1720
    txt = txt .. loc("--- Points Mode ---").."|"
12417
f6fc84c55bfa Battalion: Rename “Air-General” to “Air General”
Wuzzy <almikes@aol.com>
parents: 12416
diff changeset
  1721
    txt = txt .. loc("Variants: Kings and air generals are disabled").."|"
12415
e11758f70cce Rewrite all Battalion strings to be more translator-friendly
Wuzzy <almikes@aol.com>
parents: 12412
diff changeset
  1722
    txt = txt .. string.format(loc("Weapons: Each team starts with %d weapon points"), pointsWepBase).."|"
e11758f70cce Rewrite all Battalion strings to be more translator-friendly
Wuzzy <almikes@aol.com>
parents: 12412
diff changeset
  1723
    txt = txt .. string.format(loc("Helpers: Each team starts with %d helper points"), pointsHlpBase).."|"
e11758f70cce Rewrite all Battalion strings to be more translator-friendly
Wuzzy <almikes@aol.com>
parents: 12412
diff changeset
  1724
    txt = txt .. string.format(loc("Turns: Refill %d weapon and %d helper points|and randomize weapons and helpers based on team points"), pointsWepTurn, pointsHlpTurn).."|"
12412
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1725
    icon = 4 -- Golden Star
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1726
  else
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1727
    icon = -amGrenade -- Grenade
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1728
  end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1729
12415
e11758f70cce Rewrite all Battalion strings to be more translator-friendly
Wuzzy <almikes@aol.com>
parents: 12412
diff changeset
  1730
  txt = txt .. " |"
e11758f70cce Rewrite all Battalion strings to be more translator-friendly
Wuzzy <almikes@aol.com>
parents: 12412
diff changeset
  1731
  txt = txt .. loc("--- Sudden Death ---").."|"
e11758f70cce Rewrite all Battalion strings to be more translator-friendly
Wuzzy <almikes@aol.com>
parents: 12412
diff changeset
  1732
  txt = txt .. loc("Weapons: Nearly every hog variant gets 1 kamikaze").."|"
e11758f70cce Rewrite all Battalion strings to be more translator-friendly
Wuzzy <almikes@aol.com>
parents: 12412
diff changeset
  1733
  txt = txt .. loc("Crates: Crates drop more often with a higher chance of bonus ammo").."|"
e11758f70cce Rewrite all Battalion strings to be more translator-friendly
Wuzzy <almikes@aol.com>
parents: 12412
diff changeset
  1734
  txt = txt .. loc("Water: Rises by 37 per turn").."|"
e11758f70cce Rewrite all Battalion strings to be more translator-friendly
Wuzzy <almikes@aol.com>
parents: 12412
diff changeset
  1735
  txt = txt .. loc("Health: Hogs lose up to 7% base health per turn").."|"
12412
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1736
12984
353603f5cec3 Tweak some misleading Battalion texts
Wuzzy <Wuzzy2@mail.ru>
parents: 12983
diff changeset
  1737
  -- Add hint if mode was not set in script parameter, or set incorrectly
353603f5cec3 Tweak some misleading Battalion texts
Wuzzy <Wuzzy2@mail.ru>
parents: 12983
diff changeset
  1738
  if not modeExplicit then
12415
e11758f70cce Rewrite all Battalion strings to be more translator-friendly
Wuzzy <almikes@aol.com>
parents: 12412
diff changeset
  1739
    txt = txt .. " |"
e11758f70cce Rewrite all Battalion strings to be more translator-friendly
Wuzzy <almikes@aol.com>
parents: 12412
diff changeset
  1740
    txt = txt .. loc("--- Hint ---").."|"
e11758f70cce Rewrite all Battalion strings to be more translator-friendly
Wuzzy <almikes@aol.com>
parents: 12412
diff changeset
  1741
    txt = txt .. loc("Modes: Activate “highland”, “king” or “points” mode by putting mode=<name>|into the script parameter").."|"
12412
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1742
  end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1743
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1744
  if mode == 'highland' then
12415
e11758f70cce Rewrite all Battalion strings to be more translator-friendly
Wuzzy <almikes@aol.com>
parents: 12412
diff changeset
  1745
    txt = txt .. string.format(loc("Highland: Hogs get %d random weapons from their pool"), highPickupSDCount) .. "|"
12412
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1746
  end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1747
12422
959d1f4dff25 Battalion: RC Plane gets 2 bombs, set air bomb dmg to 20
Wuzzy <almikes@aol.com>
parents: 12421
diff changeset
  1748
  SetAmmoDescriptionAppendix(amRCPlane, loc("The RC plane only carries 2 weak bombs."))
12421
a0c655e38cc8 Battalion: Extend weapon tooltips for modified weapons
Wuzzy <almikes@aol.com>
parents: 12420
diff changeset
  1749
  SetAmmoDescriptionAppendix(amAirAttack, loc("The air bombs are weaker than usual."))
a0c655e38cc8 Battalion: Extend weapon tooltips for modified weapons
Wuzzy <almikes@aol.com>
parents: 12420
diff changeset
  1750
  SetAmmoDescriptionAppendix(amCake, loc("The explosion is weaker than usual."))
a0c655e38cc8 Battalion: Extend weapon tooltips for modified weapons
Wuzzy <almikes@aol.com>
parents: 12420
diff changeset
  1751
  SetAmmoDescriptionAppendix(amDEagle, loc("Base damage has been modified to 12 per shot."))
a0c655e38cc8 Battalion: Extend weapon tooltips for modified weapons
Wuzzy <almikes@aol.com>
parents: 12420
diff changeset
  1752
12418
665317ace94e Show Battalion mission panel for the default time
Wuzzy <almikes@aol.com>
parents: 12417
diff changeset
  1753
  ShowMission(loc("Battalion"), loc("Less tools, more fun"), txt, icon, 0)
12412
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1754
end
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1755
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1756
function onGameInit()
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1757
  --[[ CONFIGURATEABLE FOR PLAYERS ]]--
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1758
  --[[ ONCE IT HAS BEEN ADDED TO HW ]]--
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1759
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1760
  --[[ REQUIRED CONFIGURATIONS ]]--
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1761
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1762
  WaterRise = 37 -- Water rises by 37
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1763
  HealthDecrease = 0 -- No health decrease by game, script with 7%
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1764
  CaseFreq = 0 -- don't spawn crates
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1765
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1766
  -- Removed gfResetWeps to see weapons next turn
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1767
  EnableGameFlags(gfInfAttack)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1768
  DisableGameFlags(gfResetWeps)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1769
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1770
  if mode ~= 'points' then
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1771
    EnableGameFlags(gfPerHogAmmo)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1772
  else
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1773
    DisableGameFlags(gfPerHogAmmo)
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1774
  end
15146
9e1e234a417c Battalion: Handle gfKing properly
Wuzzy <Wuzzy2@mail.ru>
parents: 14790
diff changeset
  1775
  if mode ~= 'points' and mode ~= 'highland' and mode ~= 'king' then
9e1e234a417c Battalion: Handle gfKing properly
Wuzzy <Wuzzy2@mail.ru>
parents: 14790
diff changeset
  1776
    if GetGameFlag(gfKing) then
9e1e234a417c Battalion: Handle gfKing properly
Wuzzy <Wuzzy2@mail.ru>
parents: 14790
diff changeset
  1777
      mode = 'king'
9e1e234a417c Battalion: Handle gfKing properly
Wuzzy <Wuzzy2@mail.ru>
parents: 14790
diff changeset
  1778
      modeExplicit = true
9e1e234a417c Battalion: Handle gfKing properly
Wuzzy <Wuzzy2@mail.ru>
parents: 14790
diff changeset
  1779
    end
9e1e234a417c Battalion: Handle gfKing properly
Wuzzy <Wuzzy2@mail.ru>
parents: 14790
diff changeset
  1780
  end
9e1e234a417c Battalion: Handle gfKing properly
Wuzzy <Wuzzy2@mail.ru>
parents: 14790
diff changeset
  1781
  DisableGameFlags(gfKing)
12412
ed33ef8a0fc5 New Game-Style: Battalion (version 0.33)
sheepluva
parents:
diff changeset
  1782
end