share/hedgewars/Data/Scripts/Multiplayer/Highlander.lua
author nemo
Tue, 28 Jan 2014 23:14:02 -0500
changeset 10088 6d4cd54dd343
parent 10083 b20f9481e5cb
child 10096 51d6b80ba43c
permissions -rw-r--r--
tweaks
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
9085
092051fda7e1 As per request, add ice-gun (untested!)
mikade <redgrinner@gmail.com>
parents: 8713
diff changeset
     3
-- version 0.4b
6349
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
     4
-- by mikade
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
     5
--------------------------------
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
     6
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
     7
-----------
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
     8
--0.1
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
     9
-----------
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
    10
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
    11
-- concept test
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
    12
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
    13
-----------
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
    14
--0.2
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
    15
-----------
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
    16
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
    17
-- remove tardis till Henek fixes his tracker
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
    18
-- change wep crates to health crates
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
    19
-- reset arb turntimevalue
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
    20
-- include randomOrder
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
    21
-- Until fixed .17 methods come out, remove switches and resurrector
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
    22
-- on request, removed kamikaze and piano weapons
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
    23
-- provisional fixing of bugs that can't actually be fixed yet
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
    24
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
    25
-----------
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
    26
--0.3
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
    27
-----------
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
    28
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
    29
-- meh, update incorrect display
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
    30
-- may change this in the future to have switches
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
    31
-- but for now people are used to it without, so~
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
    32
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
    33
-- mudball is now counted as a utility
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
    34
6378
b812bfcfeb49 Make Highlander moar awesome.
mikade
parents: 6349
diff changeset
    35
-----------
b812bfcfeb49 Make Highlander moar awesome.
mikade
parents: 6349
diff changeset
    36
--0.3b
b812bfcfeb49 Make Highlander moar awesome.
mikade
parents: 6349
diff changeset
    37
-----------
6349
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
    38
6378
b812bfcfeb49 Make Highlander moar awesome.
mikade
parents: 6349
diff changeset
    39
-- cleaned up code and got rid of unneccessary vars
b812bfcfeb49 Make Highlander moar awesome.
mikade
parents: 6349
diff changeset
    40
-- mudball is a weapon again
b812bfcfeb49 Make Highlander moar awesome.
mikade
parents: 6349
diff changeset
    41
-- landgun is now a utility
b812bfcfeb49 Make Highlander moar awesome.
mikade
parents: 6349
diff changeset
    42
-- extra time, vampirism utility removed
b812bfcfeb49 Make Highlander moar awesome.
mikade
parents: 6349
diff changeset
    43
-- hammer wep removed
b812bfcfeb49 Make Highlander moar awesome.
mikade
parents: 6349
diff changeset
    44
-- all hogs have kamikaze
6349
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
    45
6820
7db9e89b3f80 - don't give hogs air weps when border is enabled
mikade <redgrinner@gmail.com>
parents: 6378
diff changeset
    46
-----------
7db9e89b3f80 - don't give hogs air weps when border is enabled
mikade <redgrinner@gmail.com>
parents: 6378
diff changeset
    47
--0.3c
7db9e89b3f80 - don't give hogs air weps when border is enabled
mikade <redgrinner@gmail.com>
parents: 6378
diff changeset
    48
-----------
7db9e89b3f80 - don't give hogs air weps when border is enabled
mikade <redgrinner@gmail.com>
parents: 6378
diff changeset
    49
7db9e89b3f80 - don't give hogs air weps when border is enabled
mikade <redgrinner@gmail.com>
parents: 6378
diff changeset
    50
-- restructured some code
7db9e89b3f80 - don't give hogs air weps when border is enabled
mikade <redgrinner@gmail.com>
parents: 6378
diff changeset
    51
-- added napalm (whoops) to list of possible weapons you can get
7db9e89b3f80 - don't give hogs air weps when border is enabled
mikade <redgrinner@gmail.com>
parents: 6378
diff changeset
    52
-- hogs no longer recieve airstrike-related weps on border maps
7db9e89b3f80 - don't give hogs air weps when border is enabled
mikade <redgrinner@gmail.com>
parents: 6378
diff changeset
    53
8682
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
    54
-----------
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
    55
--0.4
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
    56
-----------
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
    57
-- fix same name/blank weapon transfer bug (issue 541)
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
    58
-- show next hog ammo set in full (issue 312)
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
    59
-- allow mid-kill multi-shot weapon transfers (issue 503)
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
    60
-- allow users to configure hog health
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
    61
-- remove 'switched to' message
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
    62
-- remove some extraeneous code
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
    63
-- add more whitespace
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
    64
-- break everything
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
    65
9085
092051fda7e1 As per request, add ice-gun (untested!)
mikade <redgrinner@gmail.com>
parents: 8713
diff changeset
    66
-----------
092051fda7e1 As per request, add ice-gun (untested!)
mikade <redgrinner@gmail.com>
parents: 8713
diff changeset
    67
--0.4b
092051fda7e1 As per request, add ice-gun (untested!)
mikade <redgrinner@gmail.com>
parents: 8713
diff changeset
    68
-----------
092051fda7e1 As per request, add ice-gun (untested!)
mikade <redgrinner@gmail.com>
parents: 8713
diff changeset
    69
-- as per request, add ice-gun
092051fda7e1 As per request, add ice-gun (untested!)
mikade <redgrinner@gmail.com>
parents: 8713
diff changeset
    70
8682
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
    71
-------------------------
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
    72
-- ideas for the future
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
    73
-------------------------
9085
092051fda7e1 As per request, add ice-gun (untested!)
mikade <redgrinner@gmail.com>
parents: 8713
diff changeset
    74
-- add structure
8682
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
    75
-- allow switcher, resurrector
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
    76
-- add abuse
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
    77
-- nerf teleport
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
    78
-- allow more customization
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
    79
-- poison hogs using the default team? :/
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
    80
-- balance weapon distribution across entire team / all teams
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
    81
-- add other inequalities/bonuses like... ???
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
    82
-- some hogs start off with an extra 25 health?
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
    83
-- some hogs start off poisoned?
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
    84
-- some hogs start off with a rope and 2 drills but die after their turn?
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
    85
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
    86
-------------------------------
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
    87
-- derp, script follows
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
    88
-------------------------------
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
    89
8713
5611011e40b5 fix highlander - needed new script load function
nemo
parents: 8692
diff changeset
    90
HedgewarsScriptLoad("/Scripts/Locale.lua")
5611011e40b5 fix highlander - needed new script load function
nemo
parents: 8692
diff changeset
    91
HedgewarsScriptLoad("/Scripts/Tracker.lua")
6349
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
    92
10083
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
    93
-- These define weps allowed by the script. At present Tardis and Resurrection is banned for example
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
    94
-- 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
    95
-- in a moderately odd syntax.
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
    96
local atkWeps = 	{
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
    97
					[amBazooka]=true, [amBee]=true, [amMortar]=true, [amDrill]=true, [amSnowball]=true,
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
    98
                    [amGrenade]=true, [amClusterBomb]=true, [amMolotov]=true, [amWatermelon]=true,
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
    99
                    [amHellishBomb]=true, [amGasBomb]=true, [amShotgun]=true, [amDEagle]=true,
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
   100
                    [amFlamethrower]=true, [amSniperRifle]=true, [amSineGun]=true, 
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
   101
					[amFirePunch]=true, [amWhip]=true, [amBaseballBat]=true, [amKamikaze]=true,
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
   102
                    [amSeduction]=true, [amHammer]=true, [amMine]=true, [amDynamite]=true, [amCake]=true,
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
   103
                    [amBallgun]=true, [amSMine]=true, [amRCPlane]=true, [amBirdy]=true, [amKnife]=true,
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
   104
                    [amAirAttack]=true, [amMineStrike]=true, [amNapalm]=true, [amDrillStrike]=true, [amPiano]=true
6820
7db9e89b3f80 - don't give hogs air weps when border is enabled
mikade <redgrinner@gmail.com>
parents: 6378
diff changeset
   105
					}
7db9e89b3f80 - don't give hogs air weps when border is enabled
mikade <redgrinner@gmail.com>
parents: 6378
diff changeset
   106
10083
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
   107
local utilWeps =  {
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
   108
					[amBlowTorch]=true, [amPickHammer]=true, [amGirder]=true, [amPortalGun]=true,
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
   109
					[amRope]=true, [amParachute]=true, [amTeleport]=true, [amJetpack]=true,
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
   110
					[amInvulnerable]=true, [amLaserSight]=true, [amVampiric]=true,
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
   111
					[amLowGravity]=true, [amExtraDamage]=true, [amExtraTime]=true,
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
   112
					[amLandGun]=true, [amSwitch]=true, [amRubber]=true, [amIceGun]=true,
6820
7db9e89b3f80 - don't give hogs air weps when border is enabled
mikade <redgrinner@gmail.com>
parents: 6378
diff changeset
   113
					}
7db9e89b3f80 - don't give hogs air weps when border is enabled
mikade <redgrinner@gmail.com>
parents: 6378
diff changeset
   114
10088
nemo
parents: 10083
diff changeset
   115
local wepArray = {}
6349
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   116
10083
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
   117
local atkChoices = {}
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
   118
local utilChoices = {}
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
   119
8682
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   120
local currHog
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   121
local lastHog
6349
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   122
local started = false
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   123
local switchStage = 0
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   124
8682
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   125
local lastWep = amNothing
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   126
local shotsFired = 0
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   127
10088
nemo
parents: 10083
diff changeset
   128
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
   129
local atktot = 0
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
   130
local utiltot = 0
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
   131
local maxWep = 56 -- game crashes if you exceed supported #
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
   132
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
   133
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
   134
8682
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   135
function CheckForWeaponSwap()
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   136
	if GetCurAmmoType() ~= lastWep then
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   137
		shotsFired = 0
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   138
	end
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   139
	lastWep = GetCurAmmoType()
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   140
end
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   141
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   142
function onSlot()
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   143
	CheckForWeaponSwap()
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   144
end
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   145
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   146
function onSetWeapon()
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   147
	CheckForWeaponSwap()
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   148
end
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   149
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   150
function onHogAttack()
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   151
	CheckForWeaponSwap()
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   152
	shotsFired = shotsFired + 1
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   153
end
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   154
6349
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   155
function StartingSetUp(gear)
10083
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
   156
    for i = 1,maxWep do
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
   157
        setGearValue(gear,i,0)
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
   158
    end
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
   159
    for w,c in pairs(wepArray) do
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
   160
        if c == 9 then
10088
nemo
parents: 10083
diff changeset
   161
            setGearValue(gear,w,1)
10083
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
   162
        end
6349
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   163
	end
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   164
8682
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   165
	setGearValue(gear,amSkip,100)
10083
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
   166
   
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
   167
    local r = 0
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
   168
    if atktot > 0 then
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
   169
        r = GetRandom(atktot)+1
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
   170
        for w,c in pairs(atkChoices) do
10088
nemo
parents: 10083
diff changeset
   171
            --WriteLnToConsole('     c: '..c..' w:'..w..' r:'..r)
10083
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
   172
            if c >= r then
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
   173
                setGearValue(gear,w,1)
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
   174
                break
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
   175
            end
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
   176
        end
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
   177
    end
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
   178
    if utiltot > 0 then
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
   179
        r = GetRandom(utiltot)+1
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
   180
        for w,c in pairs(utilChoices) do
10088
nemo
parents: 10083
diff changeset
   181
            --WriteLnToConsole('util c: '..c..' w:'..w..' r:'..r)
10083
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
   182
            if c >= r then
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
   183
                setGearValue(gear,w,1)
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
   184
                break
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
   185
            end
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
   186
        end
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
   187
    end
6349
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   188
end
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   189
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   190
--[[function SaveWeapons(gear)
8682
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   191
-- er, this has no 0 check so presumably if you use a weapon then when it saves  you wont have it
6349
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   192
6378
b812bfcfeb49 Make Highlander moar awesome.
mikade
parents: 6349
diff changeset
   193
	for i = 1, (#wepArray) do
6349
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   194
		setGearValue(gear, wepArray[i], GetAmmoCount(gear, wepArray[i]) )
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   195
		 --AddAmmo(gear, wepArray[i], getGearValue(gear,wepArray[i]) )
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   196
	end
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   197
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   198
end]]
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   199
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   200
function ConvertValues(gear)
10083
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
   201
    for w,c in pairs(wepArray) do
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
   202
		AddAmmo(gear, w, getGearValue(gear,w) )
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
   203
    end
6349
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   204
end
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   205
8682
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   206
-- this is called when a hog dies
6349
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   207
function TransferWeps(gear)
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   208
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   209
	if CurrentHedgehog ~= nil then
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   210
10083
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
   211
        for w,c in pairs(wepArray) do
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
   212
			val = getGearValue(gear,w)
6349
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   213
			if val ~= 0 then
10083
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
   214
				setGearValue(CurrentHedgehog, w, val)
8682
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   215
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   216
				-- 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
   217
				if (GetCurAmmoType() == w) and (shotsFired ~= 0) then
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
   218
					AddAmmo(CurrentHedgehog, w, val+1)
8682
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   219
				-- assign ammo as per normal
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   220
				else
10083
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
   221
					AddAmmo(CurrentHedgehog, w, val)
8682
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   222
				end
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   223
6349
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   224
			end
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   225
		end
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   226
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   227
	end
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   228
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   229
end
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   230
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   231
function onGameInit()
10036
3be36d2fdca6 use new API for changing GameFlags
sheepluva
parents: 9085
diff changeset
   232
	EnableGameFlags(gfInfAttack, gfRandomOrder, gfPerHogAmmo)
6349
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   233
	HealthCaseProb = 100
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   234
end
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   235
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   236
function onGameStart()
10083
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
   237
    utilChoices[amSkip] = 0
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
   238
    local c = 0
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
   239
    for i = 1,maxWep do
10088
nemo
parents: 10083
diff changeset
   240
        atkChoices[i] = 0
nemo
parents: 10083
diff changeset
   241
        utilChoices[i] = 0
10083
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
   242
        if i ~= 7 then
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
   243
            wepArray[i] = 0
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
   244
            c = GetAmmoCount(someHog, i)
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
   245
            if c > 8 then c = 9 end
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
   246
            wepArray[i] = c
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
   247
            if c < 9 and c > 0 then
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
   248
                if atkWeps[i] then
10088
nemo
parents: 10083
diff changeset
   249
                    --WriteLnToConsole('a    c: '..c..' w:'..i)
10083
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
   250
                    atktot = atktot + probability[c]
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
   251
                    atkChoices[i] = atktot
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
   252
                elseif utilWeps[i] then
10088
nemo
parents: 10083
diff changeset
   253
                    --WriteLnToConsole('u    c: '..c..' w:'..i)
10083
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
   254
                    utiltot = utiltot + probability[c]
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
   255
                    utilChoices[i] = utiltot
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
   256
                end
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
   257
            end
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
   258
        end
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
   259
    end
6349
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   260
10088
nemo
parents: 10083
diff changeset
   261
    --WriteLnToConsole('utiltot:'..utiltot..' atktot:'..atktot)
10083
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
   262
        
6349
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   263
	ShowMission	(
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   264
				loc("HIGHLANDER"),
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   265
				loc("Not all hogs are born equal."),
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   266
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   267
				"- " .. loc("Eliminate enemy hogs and take their weapons.") .. "|" ..
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   268
				"- " .. loc("Per-Hog Ammo") .. "|" ..
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   269
				"- " .. loc("Weapons reset.") .. "|" ..
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   270
				"- " .. loc("Unlimited Attacks") .. "|" ..
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   271
				"", 4, 4000
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   272
				)
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   273
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   274
	runOnGears(StartingSetUp)
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   275
	runOnGears(ConvertValues)
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   276
end
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   277
8682
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   278
function CheckForHogSwitch()
6349
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   279
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   280
	if (CurrentHedgehog ~= nil) then
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   281
8682
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   282
		currHog = CurrentHedgehog
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   283
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   284
		if currHog ~= lastHog then
6349
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   285
8682
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   286
			-- re-assign ammo to this guy, so that his entire ammo set will
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   287
			-- be visible during another player's turn
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   288
			if lastHog ~= nil then
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   289
				ConvertValues(lastHog)
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   290
			end
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   291
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   292
			-- give the new hog what he is supposed to have, too
6349
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   293
			ConvertValues(CurrentHedgehog)
8682
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   294
6349
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   295
		end
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   296
8682
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   297
		lastHog = currHog
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   298
6349
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   299
	end
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   300
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   301
end
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   302
8682
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   303
function onNewTurn()
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   304
	CheckForHogSwitch()
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   305
end
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   306
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   307
--function onGameTick20()
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   308
--CheckForHogSwitch()
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   309
-- if we use gfPerHogAmmo is this even needed? Err, well, weapons reset, so... yes?
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   310
-- orrrr, should we rather call the re-assignment of weapons onNewTurn()? probably not because
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   311
-- then you cant switch hogs... unless we add a thing in onSwitch or whatever
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   312
-- ye, that is probably better actually, but I'll add that when/if I add switch
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   313
--end
158d7b36b18e hopefully closes issues 541, 312 and 503
mikade
parents: 8043
diff changeset
   314
6349
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   315
--[[function onHogHide(gear)
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   316
	-- waiting for Henek
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   317
end
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   318
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   319
function onHogRestore(gear)
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   320
	-- waiting for Henek
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   321
end]]
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   322
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) == gtSwitcher then
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   326
	--	SaveWeapons(CurrentHedgehog)
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   327
	--end
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   328
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   329
	if (GetGearType(gear) == gtHedgehog) then
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   330
		trackGear(gear)
10083
b20f9481e5cb Make highlander configurable using weapons, commit weaponset mimicking old values
nemo
parents: 10036
diff changeset
   331
        if someHog == nil then someHog = gear end
6349
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
end
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   335
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   336
function onGearDelete(gear)
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   337
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   338
	if (GetGearType(gear) == gtHedgehog) then --or (GetGearType(gear) == gtResurrector) then
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   339
		TransferWeps(gear)
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   340
		trackDeletion(gear)
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   341
	end
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   342
b10715d6b986 Correct outdated feedback.
mikade
parents:
diff changeset
   343
end