share/hedgewars/Data/Scripts/Multiplayer/Highlander.lua
author Wuzzy <Wuzzy2@mail.ru>
Mon, 03 Sep 2018 21:19:15 +0200
changeset 13756 5525f69bf76b
parent 13685 09ea1faf97ca
child 13872 f01798038c2e
permissions -rw-r--r--
Fix stats screwing up in Rope Knock Challenge if you lose
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6349
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
     1
--------------------------------
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
     2
-- HIGHLANDER / HOGS OF WAR
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
     3
-- by mikade
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
     4
--------------------------------
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
     5
8682
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
     6
-------------------------
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
     7
-- ideas for the future
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
     8
-------------------------
9085
092051fda7e1 As per request, add ice-gun (untested!)
mikade <redgrinner@gmail.com>
parents: 8713
diff changeset
     9
-- add structure
8682
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
    10
-- allow switcher, resurrector
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
    11
-- nerf teleport
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
    12
-- balance weapon distribution across entire team / all teams
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
    13
-- add other inequalities/bonuses like... ???
13452
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
    14
-- * some hogs start off with an extra 25 health?
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
    15
-- * some hogs start off poisoned?
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
    16
-- * some hogs start off with a rope and 2 drills but die after their turn?
8682
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
    17
13452
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
    18
------------------
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
    19
-- script follows
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
    20
------------------
8682
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
    21
8713
5611011e40b5 fix highlander - needed new script load function
nemo
parents: 8692
diff changeset
    22
HedgewarsScriptLoad("/Scripts/Locale.lua")
5611011e40b5 fix highlander - needed new script load function
nemo
parents: 8692
diff changeset
    23
HedgewarsScriptLoad("/Scripts/Tracker.lua")
10219
bbeb1e9aaa65 param for original highlander mode - right now just allows getting another copy of a weapon you already had, but had used that turn.
nemo
parents: 10096
diff changeset
    24
HedgewarsScriptLoad("/Scripts/Params.lua")
6349
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
    25
12706
b5e2834cd7b3 Fix rubber duck not being used in Highlander
Wuzzy <almikes@aol.com>
parents: 12704
diff changeset
    26
-- These define weps allowed by the script.
10083
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
    27
-- These were arbitrarily defined out-of-order in initial script, so that was preserved here, resulting 
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
    28
-- in a moderately odd syntax.
13452
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
    29
local atkWeps = {
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
    30
	[amBazooka]=true, [amBee]=true, [amMortar]=true, [amDrill]=true, [amSnowball]=true,
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
    31
	[amGrenade]=true, [amClusterBomb]=true, [amMolotov]=true, [amWatermelon]=true,
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
    32
	[amHellishBomb]=true, [amGasBomb]=true, [amShotgun]=true, [amDEagle]=true,
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
    33
	[amFlamethrower]=true, [amSniperRifle]=true, [amSineGun]=true, [amMinigun]=true,
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
    34
	[amFirePunch]=true, [amWhip]=true, [amBaseballBat]=true, [amKamikaze]=true,
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
    35
	[amSeduction]=true, [amHammer]=true, [amMine]=true, [amDynamite]=true, [amCake]=true,
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
    36
	[amBallgun]=true, [amSMine]=true, [amRCPlane]=true, [amBirdy]=true, [amKnife]=true,
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
    37
	[amAirAttack]=true, [amMineStrike]=true, [amNapalm]=true, [amDrillStrike]=true, [amPiano]=true, [amAirMine] = true,
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
    38
	[amDuck]=true,
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
    39
}
6820
7db9e89b3f80 - don't give hogs air weps when border is enabled
mikade <redgrinner@gmail.com>
parents: 6378
diff changeset
    40
10083
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
    41
local utilWeps =  {
13452
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
    42
	[amBlowTorch]=true, [amPickHammer]=true, [amGirder]=true, [amPortalGun]=true,
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
    43
	[amRope]=true, [amParachute]=true, [amTeleport]=true, [amJetpack]=true,
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
    44
	[amInvulnerable]=true, [amLaserSight]=true, [amVampiric]=true,
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
    45
	[amLowGravity]=true, [amExtraDamage]=true, [amExtraTime]=true,
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
    46
	[amLandGun]=true, [amRubber]=true, [amIceGun]=true,
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
    47
}
6820
7db9e89b3f80 - don't give hogs air weps when border is enabled
mikade <redgrinner@gmail.com>
parents: 6378
diff changeset
    48
12706
b5e2834cd7b3 Fix rubber duck not being used in Highlander
Wuzzy <almikes@aol.com>
parents: 12704
diff changeset
    49
-- Intentionally left out:
b5e2834cd7b3 Fix rubber duck not being used in Highlander
Wuzzy <almikes@aol.com>
parents: 12704
diff changeset
    50
-- * Resurrector (guaranteed to screw up the game)
b5e2834cd7b3 Fix rubber duck not being used in Highlander
Wuzzy <almikes@aol.com>
parents: 12704
diff changeset
    51
-- * Time Box
b5e2834cd7b3 Fix rubber duck not being used in Highlander
Wuzzy <almikes@aol.com>
parents: 12704
diff changeset
    52
-- * Switch Hedgehog (not sure why)
b5e2834cd7b3 Fix rubber duck not being used in Highlander
Wuzzy <almikes@aol.com>
parents: 12704
diff changeset
    53
10088
nemo
parents: 10083
diff changeset
    54
local wepArray = {}
6349
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
    55
10083
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
    56
local atkChoices = {}
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
    57
local utilChoices = {}
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
    58
12320
a85212a8d0e0 Backed out changeset 82951b9b3c2f
Wuzzy <almikes@aol.com>
parents: 12309
diff changeset
    59
local currHog
a85212a8d0e0 Backed out changeset 82951b9b3c2f
Wuzzy <almikes@aol.com>
parents: 12309
diff changeset
    60
local lastHog
6349
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
    61
local started = false
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
    62
local switchStage = 0
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
    63
8682
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
    64
local lastWep = amNothing
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
    65
local shotsFired = 0
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
    66
10088
nemo
parents: 10083
diff changeset
    67
local probability = {1,2,5,10,20,50,200,500,1000000};
10083
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
    68
local atktot = 0
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
    69
local utiltot = 0
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
    70
13458
7a0a56c52fd2 Highlander: Fix all hogs getting teleport after hog placement phase
Wuzzy <Wuzzy2@mail.ru>
parents: 13453
diff changeset
    71
local teleportConverted = false -- used for special handling of teleport when gfPlaceHog is active
10083
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
    72
12703
6726d5edfdfb Loyal Highlander: loyal=true in Highlander script param, you only get stuff for *enemy* kills
Wuzzy <almikes@aol.com>
parents: 12340
diff changeset
    73
-- Script parameter stuff
13275
7ed4ab32f351 Highlander: Rename “mode=orig” to “multiuse=true” and explain the meaning of this scriptparam in mision panel
Wuzzy <Wuzzy2@mail.ru>
parents: 12956
diff changeset
    74
7ed4ab32f351 Highlander: Rename “mode=orig” to “multiuse=true” and explain the meaning of this scriptparam in mision panel
Wuzzy <Wuzzy2@mail.ru>
parents: 12956
diff changeset
    75
--[[ Loyal Highlander.
7ed4ab32f351 Highlander: Rename “mode=orig” to “multiuse=true” and explain the meaning of this scriptparam in mision panel
Wuzzy <Wuzzy2@mail.ru>
parents: 12956
diff changeset
    76
If true, killing hogs of your own clan doesn't give you their weapons.
7ed4ab32f351 Highlander: Rename “mode=orig” to “multiuse=true” and explain the meaning of this scriptparam in mision panel
Wuzzy <Wuzzy2@mail.ru>
parents: 12956
diff changeset
    77
Otherwise, killing any hog gives you their weapons. ]]
7ed4ab32f351 Highlander: Rename “mode=orig” to “multiuse=true” and explain the meaning of this scriptparam in mision panel
Wuzzy <Wuzzy2@mail.ru>
parents: 12956
diff changeset
    78
local loyal = false
7ed4ab32f351 Highlander: Rename “mode=orig” to “multiuse=true” and explain the meaning of this scriptparam in mision panel
Wuzzy <Wuzzy2@mail.ru>
parents: 12956
diff changeset
    79
7ed4ab32f351 Highlander: Rename “mode=orig” to “multiuse=true” and explain the meaning of this scriptparam in mision panel
Wuzzy <Wuzzy2@mail.ru>
parents: 12956
diff changeset
    80
7ed4ab32f351 Highlander: Rename “mode=orig” to “multiuse=true” and explain the meaning of this scriptparam in mision panel
Wuzzy <Wuzzy2@mail.ru>
parents: 12956
diff changeset
    81
--[[ Multiple weapon usages.
7ed4ab32f351 Highlander: Rename “mode=orig” to “multiuse=true” and explain the meaning of this scriptparam in mision panel
Wuzzy <Wuzzy2@mail.ru>
parents: 12956
diff changeset
    82
This is a bit tricky to explain.
7ed4ab32f351 Highlander: Rename “mode=orig” to “multiuse=true” and explain the meaning of this scriptparam in mision panel
Wuzzy <Wuzzy2@mail.ru>
parents: 12956
diff changeset
    83
First, remind yourselves that hogs can never hold more than 1 of the same ammo type.
7ed4ab32f351 Highlander: Rename “mode=orig” to “multiuse=true” and explain the meaning of this scriptparam in mision panel
Wuzzy <Wuzzy2@mail.ru>
parents: 12956
diff changeset
    84
7ed4ab32f351 Highlander: Rename “mode=orig” to “multiuse=true” and explain the meaning of this scriptparam in mision panel
Wuzzy <Wuzzy2@mail.ru>
parents: 12956
diff changeset
    85
This param changes how ammo will be restocked after killing a hog if you
7ed4ab32f351 Highlander: Rename “mode=orig” to “multiuse=true” and explain the meaning of this scriptparam in mision panel
Wuzzy <Wuzzy2@mail.ru>
parents: 12956
diff changeset
    86
already owned this ammo.
7ed4ab32f351 Highlander: Rename “mode=orig” to “multiuse=true” and explain the meaning of this scriptparam in mision panel
Wuzzy <Wuzzy2@mail.ru>
parents: 12956
diff changeset
    87
Basically this is about if you can use the same weapon multiple times in a
7ed4ab32f351 Highlander: Rename “mode=orig” to “multiuse=true” and explain the meaning of this scriptparam in mision panel
Wuzzy <Wuzzy2@mail.ru>
parents: 12956
diff changeset
    88
turn by killing enemies in a clever way.
7ed4ab32f351 Highlander: Rename “mode=orig” to “multiuse=true” and explain the meaning of this scriptparam in mision panel
Wuzzy <Wuzzy2@mail.ru>
parents: 12956
diff changeset
    89
We need to distinguish between your current inventory and the “reset inventory”,
7ed4ab32f351 Highlander: Rename “mode=orig” to “multiuse=true” and explain the meaning of this scriptparam in mision panel
Wuzzy <Wuzzy2@mail.ru>
parents: 12956
diff changeset
    90
that is, the state to which your inventory will get reset in the next turn.
10219
bbeb1e9aaa65 param for original highlander mode - right now just allows getting another copy of a weapon you already had, but had used that turn.
nemo
parents: 10096
diff changeset
    91
13275
7ed4ab32f351 Highlander: Rename “mode=orig” to “multiuse=true” and explain the meaning of this scriptparam in mision panel
Wuzzy <Wuzzy2@mail.ru>
parents: 12956
diff changeset
    92
No Multi-Use (default):
13452
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
    93
	If you kill a hog who owns a weapon you currently have in your reset inventory,
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
    94
	but not your inventory, you DO NOT get this weapon again.
13275
7ed4ab32f351 Highlander: Rename “mode=orig” to “multiuse=true” and explain the meaning of this scriptparam in mision panel
Wuzzy <Wuzzy2@mail.ru>
parents: 12956
diff changeset
    95
7ed4ab32f351 Highlander: Rename “mode=orig” to “multiuse=true” and explain the meaning of this scriptparam in mision panel
Wuzzy <Wuzzy2@mail.ru>
parents: 12956
diff changeset
    96
Multi-Use:
13452
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
    97
	If you kill a hog who owns a weapon you currently have in your reset inventory,
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
    98
	but not your inventory, you DO get this weapon.
13275
7ed4ab32f351 Highlander: Rename “mode=orig” to “multiuse=true” and explain the meaning of this scriptparam in mision panel
Wuzzy <Wuzzy2@mail.ru>
parents: 12956
diff changeset
    99
7ed4ab32f351 Highlander: Rename “mode=orig” to “multiuse=true” and explain the meaning of this scriptparam in mision panel
Wuzzy <Wuzzy2@mail.ru>
parents: 12956
diff changeset
   100
Example 1:
13452
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   101
	You have a ballgun, and use it to kill a hog who also owns a ballgun.
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   102
	No Multi-Use: You will NOT get another ballgun, since it's in your
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   103
	reset inventory.
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   104
	Multi-Use: You get another ballgun.
13275
7ed4ab32f351 Highlander: Rename “mode=orig” to “multiuse=true” and explain the meaning of this scriptparam in mision panel
Wuzzy <Wuzzy2@mail.ru>
parents: 12956
diff changeset
   105
7ed4ab32f351 Highlander: Rename “mode=orig” to “multiuse=true” and explain the meaning of this scriptparam in mision panel
Wuzzy <Wuzzy2@mail.ru>
parents: 12956
diff changeset
   106
Example 2:
13452
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   107
	You have a grenade and a bazooka in your inventory. You use the bazooka
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   108
	to kill a hedgehog who owns a grenade.
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   109
	In both ammo limit modes, you do NOT win any ammo since you already have
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   110
	a grenade in your inventory (not just your reset inventory), and the
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   111
	rule “no more than 1 ammo per type” applies.
13275
7ed4ab32f351 Highlander: Rename “mode=orig” to “multiuse=true” and explain the meaning of this scriptparam in mision panel
Wuzzy <Wuzzy2@mail.ru>
parents: 12956
diff changeset
   112
]]
7ed4ab32f351 Highlander: Rename “mode=orig” to “multiuse=true” and explain the meaning of this scriptparam in mision panel
Wuzzy <Wuzzy2@mail.ru>
parents: 12956
diff changeset
   113
local multiUse = false
12703
6726d5edfdfb Loyal Highlander: loyal=true in Highlander script param, you only get stuff for *enemy* kills
Wuzzy <almikes@aol.com>
parents: 12340
diff changeset
   114
10219
bbeb1e9aaa65 param for original highlander mode - right now just allows getting another copy of a weapon you already had, but had used that turn.
nemo
parents: 10096
diff changeset
   115
function onParameters()
13452
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   116
	parseParams()
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   117
	multiUse = params["multiuse"] == "true"
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   118
	loyal = params["loyal"] == "true"
10219
bbeb1e9aaa65 param for original highlander mode - right now just allows getting another copy of a weapon you already had, but had used that turn.
nemo
parents: 10096
diff changeset
   119
end
bbeb1e9aaa65 param for original highlander mode - right now just allows getting another copy of a weapon you already had, but had used that turn.
nemo
parents: 10096
diff changeset
   120
8682
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   121
function CheckForWeaponSwap()
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   122
	if GetCurAmmoType() ~= lastWep then
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   123
		shotsFired = 0
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   124
	end
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   125
	lastWep = GetCurAmmoType()
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   126
end
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   127
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   128
function onSlot()
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   129
	CheckForWeaponSwap()
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   130
end
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   131
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   132
function onSetWeapon()
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   133
	CheckForWeaponSwap()
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   134
end
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   135
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   136
function onHogAttack()
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   137
	CheckForWeaponSwap()
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   138
	shotsFired = shotsFired + 1
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   139
end
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   140
6349
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   141
function StartingSetUp(gear)
13452
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   142
	for i = 0, AmmoTypeMax do
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   143
		if i ~= amNothing then
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   144
			setGearValue(gear,i,0)
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   145
		end
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   146
	end
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   147
	for w,c in pairs(wepArray) do
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   148
		if c == 9 and (atkWeps[w] or utilWeps[w])  then
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   149
			setGearValue(gear,w,1)
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   150
		end
6349
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   151
	end
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   152
8682
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   153
	setGearValue(gear,amSkip,100)
10083
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
   154
   
13452
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   155
	local r = 0
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   156
	if atktot > 0 then
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   157
		r = GetRandom(atktot)+1
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   158
		for i = 0, AmmoTypeMax do
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   159
			if i ~= amNothing then
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   160
				if atkChoices[i] >= r then
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   161
					setGearValue(gear,i,1)
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   162
					break
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   163
				end
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   164
			end
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   165
		end
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   166
	end
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   167
	if utiltot > 0 then
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   168
		r = GetRandom(utiltot)+1
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   169
		for i = 0, AmmoTypeMax do
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   170
			if i ~= amNothing then
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   171
				if utilChoices[i] >= r then
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   172
					setGearValue(gear,i,1)
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   173
					break
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   174
				end
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   175
			end
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   176
		end
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   177
	end
6349
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   178
end
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   179
13452
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   180
function ConvertValues(gear)
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   181
	for w,c in pairs(wepArray) do
13458
7a0a56c52fd2 Highlander: Fix all hogs getting teleport after hog placement phase
Wuzzy <Wuzzy2@mail.ru>
parents: 13453
diff changeset
   182
		-- Add hog ammo loadout, but don't touch teleport if in hog placement phase.
7a0a56c52fd2 Highlander: Fix all hogs getting teleport after hog placement phase
Wuzzy <Wuzzy2@mail.ru>
parents: 13453
diff changeset
   183
		-- If in hog placement phase, teleport will be touched later (see onNewTurn).
7a0a56c52fd2 Highlander: Fix all hogs getting teleport after hog placement phase
Wuzzy <Wuzzy2@mail.ru>
parents: 13453
diff changeset
   184
		if not (GetGameFlag(gfPlaceHog) and TotalRounds == -1 and (w == amTeleport)) then
7a0a56c52fd2 Highlander: Fix all hogs getting teleport after hog placement phase
Wuzzy <Wuzzy2@mail.ru>
parents: 13453
diff changeset
   185
			AddAmmo(gear, w, getGearValue(gear,w) )
7a0a56c52fd2 Highlander: Fix all hogs getting teleport after hog placement phase
Wuzzy <Wuzzy2@mail.ru>
parents: 13453
diff changeset
   186
		end
6349
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   187
	end
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   188
end
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   189
8682
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   190
-- this is called when a hog dies
6349
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   191
function TransferWeps(gear)
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   192
12703
6726d5edfdfb Loyal Highlander: loyal=true in Highlander script param, you only get stuff for *enemy* kills
Wuzzy <almikes@aol.com>
parents: 12340
diff changeset
   193
	if CurrentHedgehog ~= nil and CurrentHedgehog ~= gear and (not loyal or (GetHogClan(CurrentHedgehog) ~= GetHogClan(gear))) then
11848
6a0d6b00dac8 Highlander: give visual and acustic feedback when weapons are collected from a kill, similar to collecting a crate
sheepluva
parents: 11494
diff changeset
   194
13452
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   195
		local x,y,color
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   196
		local vgear
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   197
		local dspl = IsHogLocal(CurrentHedgehog)
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   198
		local ammolist = ''
11848
6a0d6b00dac8 Highlander: give visual and acustic feedback when weapons are collected from a kill, similar to collecting a crate
sheepluva
parents: 11494
diff changeset
   199
13452
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   200
		if dspl then
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   201
			x,y = GetGearPosition(CurrentHedgehog)
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   202
			color = GetClanColor(GetHogClan(CurrentHedgehog))
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   203
		end
6349
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   204
13452
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   205
		for w,c in pairs(wepArray) do
13453
7d69c5605a9d Highlander: Localize global variable
Wuzzy <Wuzzy2@mail.ru>
parents: 13452
diff changeset
   206
			local val = getGearValue(gear,w)
13275
7ed4ab32f351 Highlander: Rename “mode=orig” to “multiuse=true” and explain the meaning of this scriptparam in mision panel
Wuzzy <Wuzzy2@mail.ru>
parents: 12956
diff changeset
   207
			if val ~= 0 and (multiUse or (wepArray[w] ~= 9 and getGearValue(CurrentHedgehog, w) == 0))  then
10083
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
   208
				setGearValue(CurrentHedgehog, w, val)
8682
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   209
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   210
				-- if you are using multi-shot weapon, gimme one more
10083
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
   211
				if (GetCurAmmoType() == w) and (shotsFired ~= 0) then
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
   212
					AddAmmo(CurrentHedgehog, w, val+1)
8682
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   213
				-- assign ammo as per normal
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   214
				else
10083
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
   215
					AddAmmo(CurrentHedgehog, w, val)
8682
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   216
				end
13452
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   217
				if dspl then
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   218
					if ammolist == '' then
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   219
						ammolist = GetAmmoName(w)
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   220
					else
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   221
						ammolist = ammolist .. ' • ' .. GetAmmoName(w)
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   222
					end
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   223
					x = x + 2
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   224
					y = y + 32
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   225
					vgear = AddVisualGear(x, y, vgtAmmo, 0, true)
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   226
					if vgear ~= nil then
13685
09ea1faf97ca Remove calls to GetVisualGearValues where it's not needed
Wuzzy <Wuzzy2@mail.ru>
parents: 13458
diff changeset
   227
						local vgtFrame = w
09ea1faf97ca Remove calls to GetVisualGearValues where it's not needed
Wuzzy <Wuzzy2@mail.ru>
parents: 13458
diff changeset
   228
						SetVisualGearValues(vgear,nil,nil,nil,nil,nil,vgtFrame)
13452
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   229
					end
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   230
				end
8682
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   231
6349
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   232
			end
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   233
		end
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   234
13452
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   235
		if dspl and ammolist ~= '' then
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   236
			PlaySound(sndShotgunReload);
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   237
			AddCaption(ammolist, color, capgrpAmmoinfo)
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   238
		end
6349
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   239
	end
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   240
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   241
end
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   242
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   243
function onGameInit()
10036
3be36d2fdca6 use new API for changing GameFlags
sheepluva
parents: 9085
diff changeset
   244
	EnableGameFlags(gfInfAttack, gfRandomOrder, gfPerHogAmmo)
10250
887610b44848 disable these weaponset flags. they bug up highlander and otherwise have no useful impact on the script.
nemo
parents: 10219
diff changeset
   245
	DisableGameFlags(gfResetWeps, gfSharedAmmo)
6349
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   246
	HealthCaseProb = 100
12703
6726d5edfdfb Loyal Highlander: loyal=true in Highlander script param, you only get stuff for *enemy* kills
Wuzzy <almikes@aol.com>
parents: 12340
diff changeset
   247
	if loyal then
6726d5edfdfb Loyal Highlander: loyal=true in Highlander script param, you only get stuff for *enemy* kills
Wuzzy <almikes@aol.com>
parents: 12340
diff changeset
   248
		Goals = loc("Loyal Highlander: Eliminate enemy hogs to take their weapons") .. "|"
6726d5edfdfb Loyal Highlander: loyal=true in Highlander script param, you only get stuff for *enemy* kills
Wuzzy <almikes@aol.com>
parents: 12340
diff changeset
   249
	else
6726d5edfdfb Loyal Highlander: loyal=true in Highlander script param, you only get stuff for *enemy* kills
Wuzzy <almikes@aol.com>
parents: 12340
diff changeset
   250
		Goals = loc("Highlander: Eliminate hogs to take their weapons") .. "|"
6726d5edfdfb Loyal Highlander: loyal=true in Highlander script param, you only get stuff for *enemy* kills
Wuzzy <almikes@aol.com>
parents: 12340
diff changeset
   251
	end
12704
c4ea9f8fb483 Highlander: Mention the "max. 1 ammo per type" rule in mission panel
Wuzzy <almikes@aol.com>
parents: 12703
diff changeset
   252
	Goals = Goals .. loc("Replenishment: Weapons are restocked on turn start of a new hog") .. "|" ..
13275
7ed4ab32f351 Highlander: Rename “mode=orig” to “multiuse=true” and explain the meaning of this scriptparam in mision panel
Wuzzy <Wuzzy2@mail.ru>
parents: 12956
diff changeset
   253
	loc("Ammo Limit: Hogs can’t have more than 1 ammo per type") .. "|"
7ed4ab32f351 Highlander: Rename “mode=orig” to “multiuse=true” and explain the meaning of this scriptparam in mision panel
Wuzzy <Wuzzy2@mail.ru>
parents: 12956
diff changeset
   254
	if multiUse then
7ed4ab32f351 Highlander: Rename “mode=orig” to “multiuse=true” and explain the meaning of this scriptparam in mision panel
Wuzzy <Wuzzy2@mail.ru>
parents: 12956
diff changeset
   255
		Goals = Goals .. loc("Multi-Use: You can take and use the same ammo type multiple times in a turn")
7ed4ab32f351 Highlander: Rename “mode=orig” to “multiuse=true” and explain the meaning of this scriptparam in mision panel
Wuzzy <Wuzzy2@mail.ru>
parents: 12956
diff changeset
   256
	else
7ed4ab32f351 Highlander: Rename “mode=orig” to “multiuse=true” and explain the meaning of this scriptparam in mision panel
Wuzzy <Wuzzy2@mail.ru>
parents: 12956
diff changeset
   257
		Goals = Goals .. loc("No Multi-Use: Once you used an ammo, you can’t take it again in this turn")
7ed4ab32f351 Highlander: Rename “mode=orig” to “multiuse=true” and explain the meaning of this scriptparam in mision panel
Wuzzy <Wuzzy2@mail.ru>
parents: 12956
diff changeset
   258
	end
6349
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   259
end
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   260
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   261
function onGameStart()
13452
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   262
	utilChoices[amSkip] = 0
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   263
	local c = 0
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   264
	for i = 0, AmmoTypeMax do
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   265
		if i ~= amNothing then
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   266
			atkChoices[i] = 0
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   267
			utilChoices[i] = 0
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   268
			if i ~= 7 then
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   269
				wepArray[i] = 0
13458
7a0a56c52fd2 Highlander: Fix all hogs getting teleport after hog placement phase
Wuzzy <Wuzzy2@mail.ru>
parents: 13453
diff changeset
   270
				c = GetAmmo(i)
13452
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   271
				if c > 8 then
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   272
					c = 9
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   273
				end
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   274
				wepArray[i] = c
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   275
				if c < 9 and c > 0 then
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   276
					if atkWeps[i] then
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   277
						atktot = atktot + probability[c]
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   278
						atkChoices[i] = atktot
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   279
					elseif utilWeps[i] then
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   280
						utiltot = utiltot + probability[c]
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   281
						utilChoices[i] = utiltot
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   282
					end
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   283
				end
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   284
			end
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   285
		end
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   286
	end
6349
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   287
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   288
	runOnGears(StartingSetUp)
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   289
	runOnGears(ConvertValues)
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   290
end
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   291
12320
a85212a8d0e0 Backed out changeset 82951b9b3c2f
Wuzzy <almikes@aol.com>
parents: 12309
diff changeset
   292
function CheckForHogSwitch()
a85212a8d0e0 Backed out changeset 82951b9b3c2f
Wuzzy <almikes@aol.com>
parents: 12309
diff changeset
   293
12321
1be56fa243c8 Clarify how the weapons restocking works in Highlander
Wuzzy <almikes@aol.com>
parents: 12320
diff changeset
   294
	--[[ Restock the weapons of the hog on turn start, provided it is not the same hog as before.
1be56fa243c8 Clarify how the weapons restocking works in Highlander
Wuzzy <almikes@aol.com>
parents: 12320
diff changeset
   295
	This exception is done do avoid a single hog receiving tons of weapons when it is the only unfrozen
1be56fa243c8 Clarify how the weapons restocking works in Highlander
Wuzzy <almikes@aol.com>
parents: 12320
diff changeset
   296
	hog and takes consecutive turns. ]]
1be56fa243c8 Clarify how the weapons restocking works in Highlander
Wuzzy <almikes@aol.com>
parents: 12320
diff changeset
   297
12309
6b34067a6344 Fix broken ammo preview caused by previous commit
Wuzzy <almikes@aol.com>
parents: 12308
diff changeset
   298
	if (CurrentHedgehog ~= nil) then
12320
a85212a8d0e0 Backed out changeset 82951b9b3c2f
Wuzzy <almikes@aol.com>
parents: 12309
diff changeset
   299
a85212a8d0e0 Backed out changeset 82951b9b3c2f
Wuzzy <almikes@aol.com>
parents: 12309
diff changeset
   300
		currHog = CurrentHedgehog
a85212a8d0e0 Backed out changeset 82951b9b3c2f
Wuzzy <almikes@aol.com>
parents: 12309
diff changeset
   301
a85212a8d0e0 Backed out changeset 82951b9b3c2f
Wuzzy <almikes@aol.com>
parents: 12309
diff changeset
   302
		if currHog ~= lastHog then
a85212a8d0e0 Backed out changeset 82951b9b3c2f
Wuzzy <almikes@aol.com>
parents: 12309
diff changeset
   303
a85212a8d0e0 Backed out changeset 82951b9b3c2f
Wuzzy <almikes@aol.com>
parents: 12309
diff changeset
   304
			-- re-assign ammo to this guy, so that his entire ammo set will
a85212a8d0e0 Backed out changeset 82951b9b3c2f
Wuzzy <almikes@aol.com>
parents: 12309
diff changeset
   305
			-- be visible during another player's turn
13458
7a0a56c52fd2 Highlander: Fix all hogs getting teleport after hog placement phase
Wuzzy <Wuzzy2@mail.ru>
parents: 13453
diff changeset
   306
			if lastHog ~= nil and GetHealth(lastHog) then
12320
a85212a8d0e0 Backed out changeset 82951b9b3c2f
Wuzzy <almikes@aol.com>
parents: 12309
diff changeset
   307
				ConvertValues(lastHog)
a85212a8d0e0 Backed out changeset 82951b9b3c2f
Wuzzy <almikes@aol.com>
parents: 12309
diff changeset
   308
			end
a85212a8d0e0 Backed out changeset 82951b9b3c2f
Wuzzy <almikes@aol.com>
parents: 12309
diff changeset
   309
a85212a8d0e0 Backed out changeset 82951b9b3c2f
Wuzzy <almikes@aol.com>
parents: 12309
diff changeset
   310
			-- give the new hog what he is supposed to have, too
a85212a8d0e0 Backed out changeset 82951b9b3c2f
Wuzzy <almikes@aol.com>
parents: 12309
diff changeset
   311
			ConvertValues(CurrentHedgehog)
a85212a8d0e0 Backed out changeset 82951b9b3c2f
Wuzzy <almikes@aol.com>
parents: 12309
diff changeset
   312
12309
6b34067a6344 Fix broken ammo preview caused by previous commit
Wuzzy <almikes@aol.com>
parents: 12308
diff changeset
   313
		end
6b34067a6344 Fix broken ammo preview caused by previous commit
Wuzzy <almikes@aol.com>
parents: 12308
diff changeset
   314
12320
a85212a8d0e0 Backed out changeset 82951b9b3c2f
Wuzzy <almikes@aol.com>
parents: 12309
diff changeset
   315
		lastHog = currHog
12309
6b34067a6344 Fix broken ammo preview caused by previous commit
Wuzzy <almikes@aol.com>
parents: 12308
diff changeset
   316
6349
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   317
	end
12320
a85212a8d0e0 Backed out changeset 82951b9b3c2f
Wuzzy <almikes@aol.com>
parents: 12309
diff changeset
   318
6349
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   319
end
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   320
8682
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   321
function onNewTurn()
12320
a85212a8d0e0 Backed out changeset 82951b9b3c2f
Wuzzy <almikes@aol.com>
parents: 12309
diff changeset
   322
	CheckForHogSwitch()
13458
7a0a56c52fd2 Highlander: Fix all hogs getting teleport after hog placement phase
Wuzzy <Wuzzy2@mail.ru>
parents: 13453
diff changeset
   323
7a0a56c52fd2 Highlander: Fix all hogs getting teleport after hog placement phase
Wuzzy <Wuzzy2@mail.ru>
parents: 13453
diff changeset
   324
	-- If hog placement phase is over, set the hog's actual teleport loadout
7a0a56c52fd2 Highlander: Fix all hogs getting teleport after hog placement phase
Wuzzy <Wuzzy2@mail.ru>
parents: 13453
diff changeset
   325
	if GetGameFlag(gfPlaceHog) and TotalRounds == 0 and not teleportConverted then
7a0a56c52fd2 Highlander: Fix all hogs getting teleport after hog placement phase
Wuzzy <Wuzzy2@mail.ru>
parents: 13453
diff changeset
   326
		runOnHogs(function(gear)
7a0a56c52fd2 Highlander: Fix all hogs getting teleport after hog placement phase
Wuzzy <Wuzzy2@mail.ru>
parents: 13453
diff changeset
   327
			AddAmmo(gear, amTeleport, getGearValue(gear, amTeleport))
7a0a56c52fd2 Highlander: Fix all hogs getting teleport after hog placement phase
Wuzzy <Wuzzy2@mail.ru>
parents: 13453
diff changeset
   328
		end)
7a0a56c52fd2 Highlander: Fix all hogs getting teleport after hog placement phase
Wuzzy <Wuzzy2@mail.ru>
parents: 13453
diff changeset
   329
		-- This makes sure this code is only run once
7a0a56c52fd2 Highlander: Fix all hogs getting teleport after hog placement phase
Wuzzy <Wuzzy2@mail.ru>
parents: 13453
diff changeset
   330
		teleportConverted = true
7a0a56c52fd2 Highlander: Fix all hogs getting teleport after hog placement phase
Wuzzy <Wuzzy2@mail.ru>
parents: 13453
diff changeset
   331
	end
8682
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   332
end
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   333
6349
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   334
function onGearAdd(gear)
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   335
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   336
	if (GetGearType(gear) == gtHedgehog) then
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   337
		trackGear(gear)
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   338
	end
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   339
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   340
end
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   341
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   342
function onGearDelete(gear)
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   343
13452
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13275
diff changeset
   344
	if (GetGearType(gear) == gtHedgehog) then
6349
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   345
		TransferWeps(gear)
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   346
		trackDeletion(gear)
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   347
	end
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   348
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   349
end