share/hedgewars/Data/Scripts/Multiplayer/Highlander.lua
author Wuzzy <Wuzzy2@mail.ru>
Sun, 08 Jul 2018 02:46:59 +0200
changeset 13461 7a0a56c52fd2
parent 13456 7d69c5605a9d
child 13690 09ea1faf97ca
permissions -rw-r--r--
Highlander: Fix all hogs getting teleport after hog placement phase
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
13461
7a0a56c52fd2 Highlander: Fix all hogs getting teleport after hog placement phase
Wuzzy <Wuzzy2@mail.ru>
parents: 13456
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
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
13461
7a0a56c52fd2 Highlander: Fix all hogs getting teleport after hog placement phase
Wuzzy <Wuzzy2@mail.ru>
parents: 13456
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: 13456
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: 13456
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: 13456
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: 13456
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
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
   193
	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
   194
13455
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   195
		local x,y,color
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   196
		local vgear
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   197
		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
   198
		local dspl = IsHogLocal(CurrentHedgehog)
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   199
		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
   200
13455
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   201
		if dspl then
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   202
			x,y = GetGearPosition(CurrentHedgehog)
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   203
			color = GetClanColor(GetHogClan(CurrentHedgehog))
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   204
		end
6349
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   205
13455
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   206
		for w,c in pairs(wepArray) do
13456
7d69c5605a9d Highlander: Localize global variable
Wuzzy <Wuzzy2@mail.ru>
parents: 13455
diff changeset
   207
			local 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
   208
			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
   209
				setGearValue(CurrentHedgehog, w, val)
8682
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   210
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   211
				-- 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
   212
				if (GetCurAmmoType() == w) and (shotsFired ~= 0) then
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
   213
					AddAmmo(CurrentHedgehog, w, val+1)
8682
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   214
				-- assign ammo as per normal
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   215
				else
10083
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
   216
					AddAmmo(CurrentHedgehog, w, val)
8682
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   217
				end
13455
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   218
				if dspl then
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   219
					if ammolist == '' then
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   220
						ammolist = GetAmmoName(w)
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   221
					else
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   222
						ammolist = ammolist .. ' • ' .. GetAmmoName(w)
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   223
					end
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   224
					x = x + 2
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   225
					y = y + 32
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   226
					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
   227
					if vgear ~= nil then
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   228
						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
   229
						vgtFrame = w
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   230
						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
   231
					end
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   232
				end
8682
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   233
6349
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   234
			end
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   235
		end
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   236
13455
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   237
		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
   238
			PlaySound(sndShotgunReload);
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   239
			AddCaption(ammolist, color, capgrpAmmoinfo)
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   240
		end
6349
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
end
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   244
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   245
function onGameInit()
10036
3be36d2fdca6 use new API for changing GameFlags
sheepluva
parents: 9085
diff changeset
   246
	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
   247
	DisableGameFlags(gfResetWeps, gfSharedAmmo)
6349
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   248
	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
   249
	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
   250
		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
   251
	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
   252
		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
   253
	end
12709
c4ea9f8fb483 Highlander: Mention the "max. 1 ammo per type" rule in mission panel
Wuzzy <almikes@aol.com>
parents: 12708
diff changeset
   254
	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
   255
	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
   256
	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
   257
		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
   258
	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
   259
		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
   260
	end
6349
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   261
end
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   262
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   263
function onGameStart()
13455
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   264
	utilChoices[amSkip] = 0
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   265
	local c = 0
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   266
	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
   267
		if i ~= amNothing then
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   268
			atkChoices[i] = 0
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   269
			utilChoices[i] = 0
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   270
			if i ~= 7 then
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   271
				wepArray[i] = 0
13461
7a0a56c52fd2 Highlander: Fix all hogs getting teleport after hog placement phase
Wuzzy <Wuzzy2@mail.ru>
parents: 13456
diff changeset
   272
				c = GetAmmo(i)
13455
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   273
				if c > 8 then
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   274
					c = 9
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   275
				end
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   276
				wepArray[i] = c
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   277
				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
   278
					if atkWeps[i] then
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   279
						atktot = atktot + probability[c]
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   280
						atkChoices[i] = atktot
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   281
					elseif utilWeps[i] then
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   282
						utiltot = utiltot + probability[c]
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   283
						utilChoices[i] = utiltot
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   284
					end
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   285
				end
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   286
			end
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   287
		end
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   288
	end
6349
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   289
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   290
	runOnGears(StartingSetUp)
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   291
	runOnGears(ConvertValues)
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   292
end
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   293
12325
a85212a8d0e0 Backed out changeset 82951b9b3c2f
Wuzzy <almikes@aol.com>
parents: 12314
diff changeset
   294
function CheckForHogSwitch()
a85212a8d0e0 Backed out changeset 82951b9b3c2f
Wuzzy <almikes@aol.com>
parents: 12314
diff changeset
   295
12326
1be56fa243c8 Clarify how the weapons restocking works in Highlander
Wuzzy <almikes@aol.com>
parents: 12325
diff changeset
   296
	--[[ 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
   297
	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
   298
	hog and takes consecutive turns. ]]
1be56fa243c8 Clarify how the weapons restocking works in Highlander
Wuzzy <almikes@aol.com>
parents: 12325
diff changeset
   299
12314
6b34067a6344 Fix broken ammo preview caused by previous commit
Wuzzy <almikes@aol.com>
parents: 12313
diff changeset
   300
	if (CurrentHedgehog ~= nil) then
12325
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
		currHog = CurrentHedgehog
a85212a8d0e0 Backed out changeset 82951b9b3c2f
Wuzzy <almikes@aol.com>
parents: 12314
diff changeset
   303
a85212a8d0e0 Backed out changeset 82951b9b3c2f
Wuzzy <almikes@aol.com>
parents: 12314
diff changeset
   304
		if currHog ~= lastHog then
a85212a8d0e0 Backed out changeset 82951b9b3c2f
Wuzzy <almikes@aol.com>
parents: 12314
diff changeset
   305
a85212a8d0e0 Backed out changeset 82951b9b3c2f
Wuzzy <almikes@aol.com>
parents: 12314
diff changeset
   306
			-- 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
   307
			-- be visible during another player's turn
13461
7a0a56c52fd2 Highlander: Fix all hogs getting teleport after hog placement phase
Wuzzy <Wuzzy2@mail.ru>
parents: 13456
diff changeset
   308
			if lastHog ~= nil and GetHealth(lastHog) then
12325
a85212a8d0e0 Backed out changeset 82951b9b3c2f
Wuzzy <almikes@aol.com>
parents: 12314
diff changeset
   309
				ConvertValues(lastHog)
a85212a8d0e0 Backed out changeset 82951b9b3c2f
Wuzzy <almikes@aol.com>
parents: 12314
diff changeset
   310
			end
a85212a8d0e0 Backed out changeset 82951b9b3c2f
Wuzzy <almikes@aol.com>
parents: 12314
diff changeset
   311
a85212a8d0e0 Backed out changeset 82951b9b3c2f
Wuzzy <almikes@aol.com>
parents: 12314
diff changeset
   312
			-- give the new hog what he is supposed to have, too
a85212a8d0e0 Backed out changeset 82951b9b3c2f
Wuzzy <almikes@aol.com>
parents: 12314
diff changeset
   313
			ConvertValues(CurrentHedgehog)
a85212a8d0e0 Backed out changeset 82951b9b3c2f
Wuzzy <almikes@aol.com>
parents: 12314
diff changeset
   314
12314
6b34067a6344 Fix broken ammo preview caused by previous commit
Wuzzy <almikes@aol.com>
parents: 12313
diff changeset
   315
		end
6b34067a6344 Fix broken ammo preview caused by previous commit
Wuzzy <almikes@aol.com>
parents: 12313
diff changeset
   316
12325
a85212a8d0e0 Backed out changeset 82951b9b3c2f
Wuzzy <almikes@aol.com>
parents: 12314
diff changeset
   317
		lastHog = currHog
12314
6b34067a6344 Fix broken ammo preview caused by previous commit
Wuzzy <almikes@aol.com>
parents: 12313
diff changeset
   318
6349
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   319
	end
12325
a85212a8d0e0 Backed out changeset 82951b9b3c2f
Wuzzy <almikes@aol.com>
parents: 12314
diff changeset
   320
6349
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   321
end
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   322
8682
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   323
function onNewTurn()
12325
a85212a8d0e0 Backed out changeset 82951b9b3c2f
Wuzzy <almikes@aol.com>
parents: 12314
diff changeset
   324
	CheckForHogSwitch()
13461
7a0a56c52fd2 Highlander: Fix all hogs getting teleport after hog placement phase
Wuzzy <Wuzzy2@mail.ru>
parents: 13456
diff changeset
   325
7a0a56c52fd2 Highlander: Fix all hogs getting teleport after hog placement phase
Wuzzy <Wuzzy2@mail.ru>
parents: 13456
diff changeset
   326
	-- 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: 13456
diff changeset
   327
	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: 13456
diff changeset
   328
		runOnHogs(function(gear)
7a0a56c52fd2 Highlander: Fix all hogs getting teleport after hog placement phase
Wuzzy <Wuzzy2@mail.ru>
parents: 13456
diff changeset
   329
			AddAmmo(gear, amTeleport, getGearValue(gear, amTeleport))
7a0a56c52fd2 Highlander: Fix all hogs getting teleport after hog placement phase
Wuzzy <Wuzzy2@mail.ru>
parents: 13456
diff changeset
   330
		end)
7a0a56c52fd2 Highlander: Fix all hogs getting teleport after hog placement phase
Wuzzy <Wuzzy2@mail.ru>
parents: 13456
diff changeset
   331
		-- 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: 13456
diff changeset
   332
		teleportConverted = true
7a0a56c52fd2 Highlander: Fix all hogs getting teleport after hog placement phase
Wuzzy <Wuzzy2@mail.ru>
parents: 13456
diff changeset
   333
	end
8682
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   334
end
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   335
6349
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   336
function onGearAdd(gear)
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   337
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   338
	if (GetGearType(gear) == gtHedgehog) then
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   339
		trackGear(gear)
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
end
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   343
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   344
function onGearDelete(gear)
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   345
13455
f38b72d64157 Highlander: Clean up code style, indents and delete useless old comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13280
diff changeset
   346
	if (GetGearType(gear) == gtHedgehog) then
6349
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   347
		TransferWeps(gear)
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   348
		trackDeletion(gear)
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   349
	end
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   350
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   351
end