share/hedgewars/Data/Scripts/Multiplayer/Highlander.lua
author Wuzzy <Wuzzy2@mail.ru>
Sat, 07 Jul 2018 22:48:56 +0200
changeset 13455 f38b72d64157
parent 13280 7ed4ab32f351
child 13456 7d69c5605a9d
permissions -rw-r--r--
Highlander: Clean up code style, indents and delete useless old comments
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... ???
13455
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
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: 13280
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: 13280
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
13455
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
    18
------------------
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
    19
-- script follows
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
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
12711
b5e2834cd7b3 Fix rubber duck not being used in Highlander
Wuzzy <almikes@aol.com>
parents: 12709
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.
13455
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
    29
local atkWeps = {
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
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: 13280
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: 13280
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: 13280
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: 13280
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: 13280
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: 13280
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: 13280
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: 13280
diff changeset
    38
	[amDuck]=true,
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
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 =  {
13455
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
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: 13280
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: 13280
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: 13280
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: 13280
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: 13280
diff changeset
    47
}
6820
7db9e89b3f80 - don't give hogs air weps when border is enabled
mikade <redgrinner@gmail.com>
parents: 6378
diff changeset
    48
12711
b5e2834cd7b3 Fix rubber duck not being used in Highlander
Wuzzy <almikes@aol.com>
parents: 12709
diff changeset
    49
-- Intentionally left out:
b5e2834cd7b3 Fix rubber duck not being used in Highlander
Wuzzy <almikes@aol.com>
parents: 12709
diff changeset
    50
-- * Resurrector (guaranteed to screw up the game)
b5e2834cd7b3 Fix rubber duck not being used in Highlander
Wuzzy <almikes@aol.com>
parents: 12709
diff changeset
    51
-- * Time Box
b5e2834cd7b3 Fix rubber duck not being used in Highlander
Wuzzy <almikes@aol.com>
parents: 12709
diff changeset
    52
-- * Switch Hedgehog (not sure why)
b5e2834cd7b3 Fix rubber duck not being used in Highlander
Wuzzy <almikes@aol.com>
parents: 12709
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
12325
a85212a8d0e0 Backed out changeset 82951b9b3c2f
Wuzzy <almikes@aol.com>
parents: 12314
diff changeset
    59
local currHog
a85212a8d0e0 Backed out changeset 82951b9b3c2f
Wuzzy <almikes@aol.com>
parents: 12314
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
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
    71
local someHog = nil -- just for looking up the weps
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
    72
12708
6726d5edfdfb Loyal Highlander: loyal=true in Highlander script param, you only get stuff for *enemy* kills
Wuzzy <almikes@aol.com>
parents: 12345
diff changeset
    73
-- Script parameter stuff
13280
7ed4ab32f351 Highlander: Rename “mode=orig” to “multiuse=true” and explain the meaning of this scriptparam in mision panel
Wuzzy <Wuzzy2@mail.ru>
parents: 12961
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: 12961
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: 12961
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: 12961
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: 12961
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: 12961
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: 12961
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: 12961
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: 12961
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: 12961
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: 12961
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: 12961
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: 12961
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: 12961
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: 12961
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: 12961
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: 12961
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
13280
7ed4ab32f351 Highlander: Rename “mode=orig” to “multiuse=true” and explain the meaning of this scriptparam in mision panel
Wuzzy <Wuzzy2@mail.ru>
parents: 12961
diff changeset
    92
No Multi-Use (default):
13455
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
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: 13280
diff changeset
    94
	but not your inventory, you DO NOT get this weapon again.
13280
7ed4ab32f351 Highlander: Rename “mode=orig” to “multiuse=true” and explain the meaning of this scriptparam in mision panel
Wuzzy <Wuzzy2@mail.ru>
parents: 12961
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: 12961
diff changeset
    96
Multi-Use:
13455
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
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: 13280
diff changeset
    98
	but not your inventory, you DO get this weapon.
13280
7ed4ab32f351 Highlander: Rename “mode=orig” to “multiuse=true” and explain the meaning of this scriptparam in mision panel
Wuzzy <Wuzzy2@mail.ru>
parents: 12961
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: 12961
diff changeset
   100
Example 1:
13455
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
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: 13280
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: 13280
diff changeset
   103
	reset inventory.
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   104
	Multi-Use: You get another ballgun.
13280
7ed4ab32f351 Highlander: Rename “mode=orig” to “multiuse=true” and explain the meaning of this scriptparam in mision panel
Wuzzy <Wuzzy2@mail.ru>
parents: 12961
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: 12961
diff changeset
   106
Example 2:
13455
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
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: 13280
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: 13280
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: 13280
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: 13280
diff changeset
   111
	rule “no more than 1 ammo per type” applies.
13280
7ed4ab32f351 Highlander: Rename “mode=orig” to “multiuse=true” and explain the meaning of this scriptparam in mision panel
Wuzzy <Wuzzy2@mail.ru>
parents: 12961
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: 12961
diff changeset
   113
local multiUse = false
12708
6726d5edfdfb Loyal Highlander: loyal=true in Highlander script param, you only get stuff for *enemy* kills
Wuzzy <almikes@aol.com>
parents: 12345
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()
13455
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   116
	parseParams()
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   117
	multiUse = params["multiuse"] == "true"
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
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)
13455
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
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: 13280
diff changeset
   143
		if i ~= amNothing then
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   144
			setGearValue(gear,i,0)
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   145
		end
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   146
	end
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
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: 13280
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: 13280
diff changeset
   149
			setGearValue(gear,w,1)
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
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
   
13455
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   155
	local r = 0
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   156
	if atktot > 0 then
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   157
		r = GetRandom(atktot)+1
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
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: 13280
diff changeset
   159
			if i ~= amNothing then
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
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: 13280
diff changeset
   161
					setGearValue(gear,i,1)
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   162
					break
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   163
				end
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   164
			end
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   165
		end
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   166
	end
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   167
	if utiltot > 0 then
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   168
		r = GetRandom(utiltot)+1
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
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: 13280
diff changeset
   170
			if i ~= amNothing then
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
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: 13280
diff changeset
   172
					setGearValue(gear,i,1)
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   173
					break
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   174
				end
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   175
			end
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   176
		end
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   177
	end
6349
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   178
end
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   179
13455
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   180
function ConvertValues(gear)
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   181
	for w,c in pairs(wepArray) do
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   182
		AddAmmo(gear, w, getGearValue(gear,w) )
6349
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   183
	end
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   184
end
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   185
8682
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   186
-- this is called when a hog dies
6349
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   187
function TransferWeps(gear)
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   188
12708
6726d5edfdfb Loyal Highlander: loyal=true in Highlander script param, you only get stuff for *enemy* kills
Wuzzy <almikes@aol.com>
parents: 12345
diff changeset
   189
	if CurrentHedgehog ~= nil and CurrentHedgehog ~= gear and (not loyal or (GetHogClan(CurrentHedgehog) ~= GetHogClan(gear))) then
11853
6a0d6b00dac8 Highlander: give visual and acustic feedback when weapons are collected from a kill, similar to collecting a crate
sheepluva
parents: 11499
diff changeset
   190
13455
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   191
		local x,y,color
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   192
		local vgear
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   193
		local vgtX, vgtY, vgtdX, vgtdY, vgtAngle, vgtFrame, vgtFrameTicks, vgtState, vgtTimer, vgtTint
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   194
		local dspl = IsHogLocal(CurrentHedgehog)
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   195
		local ammolist = ''
11853
6a0d6b00dac8 Highlander: give visual and acustic feedback when weapons are collected from a kill, similar to collecting a crate
sheepluva
parents: 11499
diff changeset
   196
13455
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   197
		if dspl then
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   198
			x,y = GetGearPosition(CurrentHedgehog)
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   199
			color = GetClanColor(GetHogClan(CurrentHedgehog))
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   200
		end
6349
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   201
13455
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   202
		for w,c in pairs(wepArray) do
10083
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
   203
			val = getGearValue(gear,w)
13280
7ed4ab32f351 Highlander: Rename “mode=orig” to “multiuse=true” and explain the meaning of this scriptparam in mision panel
Wuzzy <Wuzzy2@mail.ru>
parents: 12961
diff changeset
   204
			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
   205
				setGearValue(CurrentHedgehog, w, val)
8682
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   206
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   207
				-- 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
   208
				if (GetCurAmmoType() == w) and (shotsFired ~= 0) then
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
   209
					AddAmmo(CurrentHedgehog, w, val+1)
8682
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   210
				-- assign ammo as per normal
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   211
				else
10083
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
   212
					AddAmmo(CurrentHedgehog, w, val)
8682
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   213
				end
13455
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   214
				if dspl then
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   215
					if ammolist == '' then
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   216
						ammolist = GetAmmoName(w)
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   217
					else
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   218
						ammolist = ammolist .. ' • ' .. GetAmmoName(w)
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   219
					end
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   220
					x = x + 2
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   221
					y = y + 32
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   222
					vgear = AddVisualGear(x, y, vgtAmmo, 0, true)
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   223
					if vgear ~= nil then
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   224
						vgtX,vgtY,vgtdX,vgtdY,vgtAngle,vgtFrame,vgtFrameTicks,vgtState,vgtTimer,vgtTint = GetVisualGearValues(vgear)
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   225
						vgtFrame = w
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   226
						SetVisualGearValues(vgear,vgtX,vgtY,vgtdX,vgtdY,vgtAngle,vgtFrame,vgtFrameTicks,vgtState,vgtTimer,vgtTint)
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   227
					end
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   228
				end
8682
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   229
6349
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   230
			end
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   231
		end
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   232
13455
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   233
		if dspl and ammolist ~= '' then
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   234
			PlaySound(sndShotgunReload);
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   235
			AddCaption(ammolist, color, capgrpAmmoinfo)
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   236
		end
6349
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   237
	end
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   238
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
function onGameInit()
10036
3be36d2fdca6 use new API for changing GameFlags
sheepluva
parents: 9085
diff changeset
   242
	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
   243
	DisableGameFlags(gfResetWeps, gfSharedAmmo)
6349
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   244
	HealthCaseProb = 100
12708
6726d5edfdfb Loyal Highlander: loyal=true in Highlander script param, you only get stuff for *enemy* kills
Wuzzy <almikes@aol.com>
parents: 12345
diff changeset
   245
	if loyal then
6726d5edfdfb Loyal Highlander: loyal=true in Highlander script param, you only get stuff for *enemy* kills
Wuzzy <almikes@aol.com>
parents: 12345
diff changeset
   246
		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: 12345
diff changeset
   247
	else
6726d5edfdfb Loyal Highlander: loyal=true in Highlander script param, you only get stuff for *enemy* kills
Wuzzy <almikes@aol.com>
parents: 12345
diff changeset
   248
		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: 12345
diff changeset
   249
	end
12709
c4ea9f8fb483 Highlander: Mention the "max. 1 ammo per type" rule in mission panel
Wuzzy <almikes@aol.com>
parents: 12708
diff changeset
   250
	Goals = Goals .. loc("Replenishment: Weapons are restocked on turn start of a new hog") .. "|" ..
13280
7ed4ab32f351 Highlander: Rename “mode=orig” to “multiuse=true” and explain the meaning of this scriptparam in mision panel
Wuzzy <Wuzzy2@mail.ru>
parents: 12961
diff changeset
   251
	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: 12961
diff changeset
   252
	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: 12961
diff changeset
   253
		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: 12961
diff changeset
   254
	else
7ed4ab32f351 Highlander: Rename “mode=orig” to “multiuse=true” and explain the meaning of this scriptparam in mision panel
Wuzzy <Wuzzy2@mail.ru>
parents: 12961
diff changeset
   255
		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: 12961
diff changeset
   256
	end
6349
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   257
end
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   258
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   259
function onGameStart()
13455
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   260
	utilChoices[amSkip] = 0
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   261
	local c = 0
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   262
	for i = 0, AmmoTypeMax do
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   263
		if i ~= amNothing then
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   264
			atkChoices[i] = 0
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   265
			utilChoices[i] = 0
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   266
			if i ~= 7 then
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   267
				wepArray[i] = 0
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   268
				c = GetAmmoCount(someHog, i)
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   269
				if c > 8 then
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   270
					c = 9
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   271
				end
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   272
				wepArray[i] = c
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   273
				if c < 9 and c > 0 then
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   274
					if atkWeps[i] then
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   275
						atktot = atktot + probability[c]
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   276
						atkChoices[i] = atktot
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   277
					elseif utilWeps[i] then
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   278
						utiltot = utiltot + probability[c]
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   279
						utilChoices[i] = utiltot
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   280
					end
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   281
				end
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   282
			end
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   283
		end
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   284
	end
6349
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   285
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   286
	runOnGears(StartingSetUp)
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   287
	runOnGears(ConvertValues)
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   288
end
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   289
12325
a85212a8d0e0 Backed out changeset 82951b9b3c2f
Wuzzy <almikes@aol.com>
parents: 12314
diff changeset
   290
function CheckForHogSwitch()
a85212a8d0e0 Backed out changeset 82951b9b3c2f
Wuzzy <almikes@aol.com>
parents: 12314
diff changeset
   291
12326
1be56fa243c8 Clarify how the weapons restocking works in Highlander
Wuzzy <almikes@aol.com>
parents: 12325
diff changeset
   292
	--[[ 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: 12325
diff changeset
   293
	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: 12325
diff changeset
   294
	hog and takes consecutive turns. ]]
1be56fa243c8 Clarify how the weapons restocking works in Highlander
Wuzzy <almikes@aol.com>
parents: 12325
diff changeset
   295
12314
6b34067a6344 Fix broken ammo preview caused by previous commit
Wuzzy <almikes@aol.com>
parents: 12313
diff changeset
   296
	if (CurrentHedgehog ~= nil) then
12325
a85212a8d0e0 Backed out changeset 82951b9b3c2f
Wuzzy <almikes@aol.com>
parents: 12314
diff changeset
   297
a85212a8d0e0 Backed out changeset 82951b9b3c2f
Wuzzy <almikes@aol.com>
parents: 12314
diff changeset
   298
		currHog = CurrentHedgehog
a85212a8d0e0 Backed out changeset 82951b9b3c2f
Wuzzy <almikes@aol.com>
parents: 12314
diff changeset
   299
a85212a8d0e0 Backed out changeset 82951b9b3c2f
Wuzzy <almikes@aol.com>
parents: 12314
diff changeset
   300
		if currHog ~= lastHog then
a85212a8d0e0 Backed out changeset 82951b9b3c2f
Wuzzy <almikes@aol.com>
parents: 12314
diff changeset
   301
a85212a8d0e0 Backed out changeset 82951b9b3c2f
Wuzzy <almikes@aol.com>
parents: 12314
diff changeset
   302
			-- re-assign ammo to this guy, so that his entire ammo set will
a85212a8d0e0 Backed out changeset 82951b9b3c2f
Wuzzy <almikes@aol.com>
parents: 12314
diff changeset
   303
			-- be visible during another player's turn
a85212a8d0e0 Backed out changeset 82951b9b3c2f
Wuzzy <almikes@aol.com>
parents: 12314
diff changeset
   304
			if lastHog ~= nil then
a85212a8d0e0 Backed out changeset 82951b9b3c2f
Wuzzy <almikes@aol.com>
parents: 12314
diff changeset
   305
				ConvertValues(lastHog)
a85212a8d0e0 Backed out changeset 82951b9b3c2f
Wuzzy <almikes@aol.com>
parents: 12314
diff changeset
   306
			end
a85212a8d0e0 Backed out changeset 82951b9b3c2f
Wuzzy <almikes@aol.com>
parents: 12314
diff changeset
   307
a85212a8d0e0 Backed out changeset 82951b9b3c2f
Wuzzy <almikes@aol.com>
parents: 12314
diff changeset
   308
			-- give the new hog what he is supposed to have, too
a85212a8d0e0 Backed out changeset 82951b9b3c2f
Wuzzy <almikes@aol.com>
parents: 12314
diff changeset
   309
			ConvertValues(CurrentHedgehog)
a85212a8d0e0 Backed out changeset 82951b9b3c2f
Wuzzy <almikes@aol.com>
parents: 12314
diff changeset
   310
12314
6b34067a6344 Fix broken ammo preview caused by previous commit
Wuzzy <almikes@aol.com>
parents: 12313
diff changeset
   311
		end
6b34067a6344 Fix broken ammo preview caused by previous commit
Wuzzy <almikes@aol.com>
parents: 12313
diff changeset
   312
12325
a85212a8d0e0 Backed out changeset 82951b9b3c2f
Wuzzy <almikes@aol.com>
parents: 12314
diff changeset
   313
		lastHog = currHog
12314
6b34067a6344 Fix broken ammo preview caused by previous commit
Wuzzy <almikes@aol.com>
parents: 12313
diff changeset
   314
6349
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   315
	end
12325
a85212a8d0e0 Backed out changeset 82951b9b3c2f
Wuzzy <almikes@aol.com>
parents: 12314
diff changeset
   316
6349
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   317
end
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   318
8682
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   319
function onNewTurn()
12325
a85212a8d0e0 Backed out changeset 82951b9b3c2f
Wuzzy <almikes@aol.com>
parents: 12314
diff changeset
   320
	CheckForHogSwitch()
8682
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   321
end
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   322
6349
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   323
function onGearAdd(gear)
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   324
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   325
	if (GetGearType(gear) == gtHedgehog) then
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   326
		trackGear(gear)
13455
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   327
		if someHog == nil then
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   328
			someHog = gear
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   329
		end
6349
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   330
	end
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   331
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   332
end
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   333
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   334
function onGearDelete(gear)
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   335
13455
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   336
	if (GetGearType(gear) == gtHedgehog) then
6349
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   337
		TransferWeps(gear)
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   338
		trackDeletion(gear)
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   339
	end
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   340
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   341
end