share/hedgewars/Data/Scripts/Multiplayer/Construction_Mode.lua
author Wuzzy <Wuzzy2@mail.ru>
Fri, 09 Feb 2018 16:27:32 +0100
changeset 12943 3feab46234dd
parent 12942 ca23981ec219
child 12944 712ae7ff8c3d
permissions -rw-r--r--
Construction Mode: Sort structure types roughly by importance and convenience
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
     1
---------------------------------------------------------
11733
67049c8dedd1 make construction mode work with fort mode without mixing up clans and forts
sheepluva
parents: 11732
diff changeset
     2
--- LE CONSTRUCTION MODE 0.7+ (badly adapted from Hedge Editor 0.5)
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
     3
---------------------------------------------------------
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
     4
-- a hedgewars gameplay mode by mikade
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
     5
-- special thanks to all who helped test and offered suggestions
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
     6
-- additional thanks to sheepluva/nemo for adding some extra hooks
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
     7
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
     8
-- (to do)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
     9
-- investigate loc not working on addcaptions
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
    10
-- check for parsecommands before porting to dev
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
    11
-- test onUpDown more extensively as it may need revision (check for amRubber etc)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
    12
-- test localization of weapons and utils and stuff
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
    13
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
    14
-- try posistion grenades in Harmer so it blows hogs away from the struc
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
    15
-- and don't explode too close to the struc
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
    16
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
    17
-- additional/previous balance ideas
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
    18
-- based on your money?
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
    19
-- based on the number of strucs/gens you own?
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
    20
-- based on your existing arsenal?
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
    21
-- limit number of crates spawned per round perhaps (done)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
    22
-- limit number of generators?
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
    23
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
    24
------------------------------------------------------------------------------
11720
5cb2f245ee2f Add script parameter support to Construction Mode
Wuzzy <almikes@aol.com>
parents: 11719
diff changeset
    25
-- SCRIPT PARAMETER
5cb2f245ee2f Add script parameter support to Construction Mode
Wuzzy <almikes@aol.com>
parents: 11719
diff changeset
    26
------------------------------------------------------------------------------
5cb2f245ee2f Add script parameter support to Construction Mode
Wuzzy <almikes@aol.com>
parents: 11719
diff changeset
    27
-- The script parameter can be used to configure the energy
5cb2f245ee2f Add script parameter support to Construction Mode
Wuzzy <almikes@aol.com>
parents: 11719
diff changeset
    28
-- of the game. It is a comma-seperated list of key=value pairs, where each
11729
2d57eed66d41 Fix bad comment in Construction Mode
Wuzzy <almikes@aol.com>
parents: 11728
diff changeset
    29
-- key is a word and each value is an integer between 0 and 4294967295.
11720
5cb2f245ee2f Add script parameter support to Construction Mode
Wuzzy <almikes@aol.com>
parents: 11719
diff changeset
    30
--
5cb2f245ee2f Add script parameter support to Construction Mode
Wuzzy <almikes@aol.com>
parents: 11719
diff changeset
    31
-- Possible keys:
11721
8c1a30d4cbc8 Construction Mode: Fix giving round energy boost at first round
Wuzzy <almikes@aol.com>
parents: 11720
diff changeset
    32
--- initialenergy: Amount of energy that each team starts with (default: 550)
11982
6f4b96669f9d Fix Construction Mode screwing up when initialenergy > maxenergy
Wuzzy <almikes@aol.com>
parents: 11981
diff changeset
    33
---                Note: Must be smaller than or equal to maxenergy
11720
5cb2f245ee2f Add script parameter support to Construction Mode
Wuzzy <almikes@aol.com>
parents: 11719
diff changeset
    34
--- energyperround: Amount of energy that each team gets per round (default: 50)
11729
2d57eed66d41 Fix bad comment in Construction Mode
Wuzzy <almikes@aol.com>
parents: 11728
diff changeset
    35
--- maxenergy: Maximum amount of energy each team can hold (default: 1000)
12092
9fe7eb1f7df2 Construction Mode: Turn crate limit into a script parameter
Wuzzy <almikes@aol.com>
parents: 12091
diff changeset
    36
--- cratesperround: Maximum number of crates you can place per round (default: 5)
9fe7eb1f7df2 Construction Mode: Turn crate limit into a script parameter
Wuzzy <almikes@aol.com>
parents: 12091
diff changeset
    37
9fe7eb1f7df2 Construction Mode: Turn crate limit into a script parameter
Wuzzy <almikes@aol.com>
parents: 12091
diff changeset
    38
-- For the previous 2 keys, you can use the value “inf” for an unlimited amount
11720
5cb2f245ee2f Add script parameter support to Construction Mode
Wuzzy <almikes@aol.com>
parents: 11719
diff changeset
    39
5cb2f245ee2f Add script parameter support to Construction Mode
Wuzzy <almikes@aol.com>
parents: 11719
diff changeset
    40
-- Example: “initialenergy=750, maxenergy=2000” starts thee game with 750 energy
12092
9fe7eb1f7df2 Construction Mode: Turn crate limit into a script parameter
Wuzzy <almikes@aol.com>
parents: 12091
diff changeset
    41
--          and sets the maximum energy to 2000.
9fe7eb1f7df2 Construction Mode: Turn crate limit into a script parameter
Wuzzy <almikes@aol.com>
parents: 12091
diff changeset
    42
-- Example: “craterperround=inf” disables the crate placement limit.
11720
5cb2f245ee2f Add script parameter support to Construction Mode
Wuzzy <almikes@aol.com>
parents: 11719
diff changeset
    43
5cb2f245ee2f Add script parameter support to Construction Mode
Wuzzy <almikes@aol.com>
parents: 11719
diff changeset
    44
------------------------------------------------------------------------------
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
    45
--version history
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
    46
------------------------------------------------------------------------------
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
    47
--v0.1
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
    48
-- concept test
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
    49
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
    50
--v0.2
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
    51
-- improved documentation (in script and in game)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
    52
-- improved localisation (or is it? at any rate, crate placement should now say e.g. Bazooka and not amBazooka)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
    53
-- added variable weapon costs (based on the values from Vatten's Consumerism script)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
    54
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
    55
-- added reflector shield (still needs work and balancing)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
    56
-- added weapon-filter (probably ok)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
    57
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
    58
-- enabled super weapons like ballgun, rcplane, watermelon, hellish to test balance
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
    59
-- reduce max money to 1000
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
    60
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
    61
--v0.3
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
    62
-- some /s removed
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
    63
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
    64
--v0.4
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
    65
-- added support for per hog ammo (hopefully)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
    66
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
    67
--v0.5 (dev)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
    68
-- added somewhat horribly implemented support for different structure sprites
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
    69
-- added override pictures for ammo menu
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
    70
-- added override message on wep select to aid understanding
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
    71
-- split menu into/between weps/parts: struc, crates, gears
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
    72
-- add a limit on crates per turn
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
    73
-- add a limit on extra time per turn
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
    74
-- add a test level
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
    75
-- restored rubber placement
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
    76
-- cleaned up some of the code a bit and removed about 280 lines of code I didn't need, lol
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
    77
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
    78
--v0.6 (dev)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
    79
-- added magic dance
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
    80
11732
e28b534188d3 update construction mode in-file version info
sheepluva
parents: 11730
diff changeset
    81
--v0.7 (pushed to repo)
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
    82
-- added a cfg file
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
    83
-- removed another 903 lines of code we weren't using (lol)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
    84
11733
67049c8dedd1 make construction mode work with fort mode without mixing up clans and forts
sheepluva
parents: 11732
diff changeset
    85
--v0.7+ (merged in repo)
11732
e28b534188d3 update construction mode in-file version info
sheepluva
parents: 11730
diff changeset
    86
-- applied Wuzzy's patches:
e28b534188d3 update construction mode in-file version info
sheepluva
parents: 11730
diff changeset
    87
--   script parameters: initialenergy, energyperround, maxenergy
e28b534188d3 update construction mode in-file version info
sheepluva
parents: 11730
diff changeset
    88
--   fix crate costs
e28b534188d3 update construction mode in-file version info
sheepluva
parents: 11730
diff changeset
    89
--   various minor tweaks and fixes
e28b534188d3 update construction mode in-file version info
sheepluva
parents: 11730
diff changeset
    90
--   (see commits in official repo)
11733
67049c8dedd1 make construction mode work with fort mode without mixing up clans and forts
sheepluva
parents: 11732
diff changeset
    91
-- make Construction Mode play well together with fort mode (clan order = fort order)
11732
e28b534188d3 update construction mode in-file version info
sheepluva
parents: 11730
diff changeset
    92
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
    93
--------------------------------
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
    94
-- STRUCTURES LIST / IDEAS
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
    95
--------------------------------
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
    96
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
    97
--Healing Station: heals hogs to 150 life
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
    98
--Teleportation Node: allows teleporting to any other teleporter nodes
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
    99
--Bio-filter: explodes enemy hogs
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   100
--Respawner: if you have one of these, any slain hogs are resurrected here :D
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   101
--Generator: generates energy (used to buy stuff, and possibly later other strucs might have upkeep costs)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   102
--Support Station: allows purchasing of weapons, utilities, and med-crates
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   103
--Construction Station: allows purchasing of girders, rubber, mines, sticky mines, barrels
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   104
--Reflector Shield: reflect projectiles
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   105
--Weapon Filter: kill all equipement of enemy hogs passing through this area.
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   106
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   107
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   108
--to make the grill more attractive make it vaporize flying saucers
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   109
--and also rope, and maybe incoming gears
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   110
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   111
-- make healing thing also cure poison
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   112
-- maybe make poison more virulent and dangerous
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   113
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   114
--(not implemented / abandoned ideas)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   115
-- Core: allows construction of other structures.
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   116
-- Automated Turret (think red drones from space invasion)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   117
-- Canon (gives access to 3 fireballs per turn while near)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   118
-- something that allows control of wind/water
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   119
-- Gravity Field generator : triggers world gravity change
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   120
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   121
-- structures consume power over time and
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   122
-- maybe you can turn structures OFF/ON, manually to save power.
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   123
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   124
-- hacking
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   125
-- allow hacking of structures, either being able to use enemy structures,
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   126
-- or turning a team's structures against them.
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   127
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   128
-- pylons
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   129
-- allow hogs to put down a pylon-like gear which then allows the core
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   130
-- to place other structures/objects within the pylon's sphere of influence
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   131
-- this would allow aggressive structure advancement
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   132
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   133
-- resouce mining?
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   134
-- you could designate something like mines, that you could get close to,
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   135
-- "pick up", and then "drop" back at a central location to simulate
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   136
-- resource mining. bit complicated/meh, normal power generators probably easier
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   137
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   138
-- it would be cool to have a red mask we could apply over girders
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   139
-- that would indicate they were Indestructible
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   140
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   141
HedgewarsScriptLoad("/Scripts/Locale.lua")
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   142
HedgewarsScriptLoad("/Scripts/Tracker.lua")
11720
5cb2f245ee2f Add script parameter support to Construction Mode
Wuzzy <almikes@aol.com>
parents: 11719
diff changeset
   143
HedgewarsScriptLoad("/Scripts/Params.lua")
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   144
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   145
----------------------------------------------
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   146
-- STRUC CRAP
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   147
----------------------------------------------
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   148
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   149
strucID = {}
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   150
strucGear = {}
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   151
strucClan = {}
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   152
strucType = {}
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   153
strucCost = {}
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   154
strucHealth = {}
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   155
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   156
strucCirc = {}
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   157
strucCircCol = {}
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   158
strucCircRadius = {}
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   159
strucCircType = {}
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   160
strucAltDisplay = {}
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   161
11733
67049c8dedd1 make construction mode work with fort mode without mixing up clans and forts
sheepluva
parents: 11732
diff changeset
   162
fortMode = false
67049c8dedd1 make construction mode work with fort mode without mixing up clans and forts
sheepluva
parents: 11732
diff changeset
   163
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   164
placedExpense = 0
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   165
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   166
tempID = nil
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   167
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   168
sUID = 0
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   169
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   170
colorRed = 0xff0000ff
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   171
colorGreen = 0x00ff00ff
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   172
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   173
clanBoundsSX = {}
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   174
clanBoundsSY = {}
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   175
clanBoundsEX = {}
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   176
clanBoundsEY = {}
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   177
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   178
clanPower = {}
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   179
clanID = {}
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   180
clanLStrucIndex = {}
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   181
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   182
clanLWepIndex = {} -- for ease of use let's track this stuff
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   183
clanLUtilIndex = {}
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   184
clanLGearIndex = {}
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   185
clanUsedExtraTime = {}
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   186
clanCratesSpawned = {}
11721
8c1a30d4cbc8 Construction Mode: Fix giving round energy boost at first round
Wuzzy <almikes@aol.com>
parents: 11720
diff changeset
   187
clanFirstTurn = {}
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   188
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   189
effectTimer = 0
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   190
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   191
wallsVisible = false
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   192
wX = {}
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   193
wY = {}
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   194
wWidth = {}
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   195
wHeight = {}
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   196
wCol = {}
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   197
margin = 20
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   198
12836
8610462e3d33 Remove 2 unused number tags in Construction Mode GUI
Wuzzy <Wuzzy2@mail.ru>
parents: 12682
diff changeset
   199
clanPowerTag = nil
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   200
lastWep = nil
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   201
11717
f35139700d22 Construction Mode: Disable setting drill strike timer in object placement mode
Wuzzy <almikes@aol.com>
parents: 11716
diff changeset
   202
checkForSpecialWeaponsIn = -1
f35139700d22 Construction Mode: Disable setting drill strike timer in object placement mode
Wuzzy <almikes@aol.com>
parents: 11716
diff changeset
   203
12941
ffbd31afed96 HedgeEditor, Construction Mode: Refactor code by adding fake ammo type variables
Wuzzy <Wuzzy2@mail.ru>
parents: 12940
diff changeset
   204
-- Fake ammo types, for the overwritten weapons in Construction Mode
ffbd31afed96 HedgeEditor, Construction Mode: Refactor code by adding fake ammo type variables
Wuzzy <Wuzzy2@mail.ru>
parents: 12940
diff changeset
   205
amCMStructurePlacer = amAirAttack
ffbd31afed96 HedgeEditor, Construction Mode: Refactor code by adding fake ammo type variables
Wuzzy <Wuzzy2@mail.ru>
parents: 12940
diff changeset
   206
amCMCratePlacer = amNapalm
ffbd31afed96 HedgeEditor, Construction Mode: Refactor code by adding fake ammo type variables
Wuzzy <Wuzzy2@mail.ru>
parents: 12940
diff changeset
   207
amCMObjectPlacer = amDrillStrike
ffbd31afed96 HedgeEditor, Construction Mode: Refactor code by adding fake ammo type variables
Wuzzy <Wuzzy2@mail.ru>
parents: 12940
diff changeset
   208
11720
5cb2f245ee2f Add script parameter support to Construction Mode
Wuzzy <almikes@aol.com>
parents: 11719
diff changeset
   209
-- Config variables (script parameter)
11721
8c1a30d4cbc8 Construction Mode: Fix giving round energy boost at first round
Wuzzy <almikes@aol.com>
parents: 11720
diff changeset
   210
conf_initialEnergy = 550
11720
5cb2f245ee2f Add script parameter support to Construction Mode
Wuzzy <almikes@aol.com>
parents: 11719
diff changeset
   211
conf_energyPerRound = 50
5cb2f245ee2f Add script parameter support to Construction Mode
Wuzzy <almikes@aol.com>
parents: 11719
diff changeset
   212
conf_maxEnergy = 1000
12092
9fe7eb1f7df2 Construction Mode: Turn crate limit into a script parameter
Wuzzy <almikes@aol.com>
parents: 12091
diff changeset
   213
conf_cratesPerRound = 5
11720
5cb2f245ee2f Add script parameter support to Construction Mode
Wuzzy <almikes@aol.com>
parents: 11719
diff changeset
   214
12836
8610462e3d33 Remove 2 unused number tags in Construction Mode GUI
Wuzzy <Wuzzy2@mail.ru>
parents: 12682
diff changeset
   215
function DrawClanPowerTag()
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   216
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   217
	zoomL = 1.3
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   218
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   219
	xOffset = 40
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   220
12836
8610462e3d33 Remove 2 unused number tags in Construction Mode GUI
Wuzzy <Wuzzy2@mail.ru>
parents: 12682
diff changeset
   221
	zoomL = 1.1
8610462e3d33 Remove 2 unused number tags in Construction Mode GUI
Wuzzy <Wuzzy2@mail.ru>
parents: 12682
diff changeset
   222
	xOffset = 45
8610462e3d33 Remove 2 unused number tags in Construction Mode GUI
Wuzzy <Wuzzy2@mail.ru>
parents: 12682
diff changeset
   223
	yOffset = 70
8610462e3d33 Remove 2 unused number tags in Construction Mode GUI
Wuzzy <Wuzzy2@mail.ru>
parents: 12682
diff changeset
   224
	tCol = 0x00ff00ff
8610462e3d33 Remove 2 unused number tags in Construction Mode GUI
Wuzzy <Wuzzy2@mail.ru>
parents: 12682
diff changeset
   225
	tValue = clanPower[GetHogClan(CurrentHedgehog)]
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   226
12836
8610462e3d33 Remove 2 unused number tags in Construction Mode GUI
Wuzzy <Wuzzy2@mail.ru>
parents: 12682
diff changeset
   227
	DeleteVisualGear(clanPowerTag)
8610462e3d33 Remove 2 unused number tags in Construction Mode GUI
Wuzzy <Wuzzy2@mail.ru>
parents: 12682
diff changeset
   228
	clanPowerTag = AddVisualGear(0, 0, vgtHealthTag, 0, false)
8610462e3d33 Remove 2 unused number tags in Construction Mode GUI
Wuzzy <Wuzzy2@mail.ru>
parents: 12682
diff changeset
   229
	g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(clanPowerTag)
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   230
	SetVisualGearValues	(
12836
8610462e3d33 Remove 2 unused number tags in Construction Mode GUI
Wuzzy <Wuzzy2@mail.ru>
parents: 12682
diff changeset
   231
				clanPowerTag, 		--id
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   232
				-div(ScreenWidth,2) + xOffset,	--xoffset
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   233
				ScreenHeight - yOffset, --yoffset
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   234
				0, 			--dx
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   235
				0, 			--dy
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   236
				zoomL, 			--zoom
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   237
				1, 			--~= 0 means align to screen
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   238
				g7, 			--frameticks
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   239
				tValue, 		--value
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   240
				240000, 		--timer
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   241
				tCol		--GetClanColor( GetHogClan(CurrentHedgehog) )
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   242
				)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   243
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   244
end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   245
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   246
function onScreenResize()
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   247
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   248
	-- redraw Tags so that their screen locations are updated
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   249
	if (CurrentHedgehog ~= nil) then
12836
8610462e3d33 Remove 2 unused number tags in Construction Mode GUI
Wuzzy <Wuzzy2@mail.ru>
parents: 12682
diff changeset
   250
		DrawClanPowerTag()
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   251
	end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   252
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   253
end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   254
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   255
function XYisInRect(px, py, psx, psy, pex, pey)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   256
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   257
	if (px > psx) and (px < pex) and (py > psy) and (py < pey) then
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   258
		return(true)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   259
	else
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   260
		return(false)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   261
	end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   262
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   263
end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   264
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   265
function AddWall(zXMin,zYMin, zWidth, zHeight, zCol)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   266
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   267
	table.insert(wX, zXMin)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   268
	table.insert(wY, zYMin)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   269
	table.insert(wWidth, zWidth)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   270
	table.insert(wHeight, zHeight)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   271
	table.insert(wCol, zCol)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   272
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   273
end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   274
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   275
function BorderSpark(zXMin,zYMin, zWidth, zHeight, bCol)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   276
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   277
	eX = zXMin + GetRandom(zWidth+10)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   278
	eY = zYMin + GetRandom(zHeight+10)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   279
	tempE = AddVisualGear(eX, eY, vgtDust, 0, false)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   280
	if tempE ~= 0 then
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   281
		g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(tempE)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   282
		SetVisualGearValues(tempE, eX, eY, g3, g4, g5, g6, g7, 1, g9, bCol )
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   283
	end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   284
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   285
end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   286
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   287
function HandleBorderEffects()
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   288
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   289
	effectTimer = effectTimer + 1
11718
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   290
	if effectTimer > 15 then
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   291
		effectTimer = 1
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   292
		for i = 1, #wX do
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   293
			BorderSpark(wX[i],wY[i],wWidth[i],wHeight[i], wCol[i])
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   294
		end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   295
	end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   296
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   297
end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   298
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   299
----
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   300
-- old reflecting stuff from like 3 years ago lol
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   301
---
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   302
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   303
function gearCanBeDeflected(gear)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   304
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   305
	if 	(GetGearType(gear) == gtShell) or
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   306
		(GetGearType(gear) == gtGrenade) or
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   307
		(GetGearType(gear) == gtAirBomb) or
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   308
		(GetGearType(gear) == gtClusterBomb) or
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   309
		(GetGearType(gear) == gtCluster) or
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   310
		(GetGearType(gear) == gtGasBomb) or
11718
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   311
		(GetGearType(gear) == gtMine) or
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   312
		(GetGearType(gear) == gtMortar) or
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   313
		(GetGearType(gear) == gtHellishBomb) or
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   314
		(GetGearType(gear) == gtWatermelon) or
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   315
		(GetGearType(gear) == gtMelonPiece)	or
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   316
		(GetGearType(gear) == gtEgg) or
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   317
		(GetGearType(gear) == gtDrill) or
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   318
		(GetGearType(gear) == gtBall) or
11718
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   319
		(GetGearType(gear) == gtExplosives) or
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   320
			(GetGearType(gear) == gtFlame) or
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   321
			(GetGearType(gear) == gtPortal) or
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   322
			(GetGearType(gear) == gtDynamite) or
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   323
			(GetGearType(gear) == gtSMine) or
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   324
		(GetGearType(gear) == gtKnife) or
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   325
		(GetGearType(gear) == gtJetpack) or -- test this and birdy plz
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   326
		(GetGearType(gear) == gtBirdy) or -- test this and birdy plz
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   327
		(GetGearType(gear) == gtSnowball) or
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   328
		(GetGearType(gear) == gtMolotov)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   329
	then
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   330
		return(true)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   331
	else
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   332
		return(false)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   333
	end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   334
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   335
end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   336
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   337
function getThreatDamage(gear)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   338
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   339
	--- damage amounts for weapons
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   340
	if 	(GetGearType(gear) == gtGrenade) or
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   341
		(GetGearType(gear) == gtClusterBomb) or
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   342
		(GetGearType(gear) == gtGasBomb) or
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   343
		(GetGearType(gear) == gtKnife) or
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   344
		(GetGearType(gear) == gtEgg) or
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   345
		(GetGearType(gear) == gtMolotov) or
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   346
		(GetGearType(gear) == gtHellishBomb) or
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   347
		(GetGearType(gear) == gtWatermelon) or
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   348
		(GetGearType(gear) == gtSMine)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   349
	then
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   350
		dmg = 30
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   351
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   352
	elseif (GetGearType(gear) == gtMelonPiece) then
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   353
		dmg = 40
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   354
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   355
	elseif (GetGearType(gear) == gtAirBomb) or
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   356
			(GetGearType(gear) == gtDrill) or
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   357
			(GetGearType(gear) == gtMine) or
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   358
			(GetGearType(gear) == gtCluster) then
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   359
		dmg = 20
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   360
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   361
	elseif (GetGearType(gear) == gtFlame) or
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   362
			(GetGearType(gear) == gtPortal) or
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   363
			(GetGearType(gear) == gtDynamite)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   364
	then
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   365
		dmg = 0
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   366
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   367
	elseif (GetGearType(gear) == gtBall) then
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   368
		dmg = 1
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   369
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   370
	else	--normal shell, snowball etc
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   371
		dmg = 65
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   372
	end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   373
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   374
	return(dmg)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   375
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   376
end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   377
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   378
function setGearReflectionValues(gear)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   379
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   380
	dmg = getThreatDamage(gear)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   381
	setGearValue(gear,"damage",dmg)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   382
	setGearValue(gear,"deflects",0)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   383
11718
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   384
	if (CurrentHedgehog ~= nil) then
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   385
		setGearValue(gear,"owner",GetHogClan(CurrentHedgehog)) -- NEW NEEDS CHANGE?
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   386
	else
11718
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   387
		setGearValue(gear,"owner",10)
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   388
	end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   389
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   390
end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   391
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   392
function AddStruc(pX,pY, pType, pClan)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   393
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   394
	sUID = sUID + 1
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   395
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   396
	tempG = AddGear(0, 0, gtTarget, 0, 0, 0, 0)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   397
	SetGearPosition(tempG, pX, pY)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   398
	setGearValue(tempG, "sUID", sUID)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   399
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   400
	tempCirc = AddVisualGear(0,0,vgtCircle,0,true)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   401
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   402
	SetVisualGearValues(tempCirc, 0, 0, 100, 255, 1, 100, 0, 500, 1, 0xFFFFFF00)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   403
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   404
	table.insert(strucID, sUID)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   405
	table.insert(strucType, pType)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   406
	table.insert(strucGear,tempG)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   407
	table.insert(strucClan,pClan)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   408
	table.insert(strucCost,2)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   409
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   410
	frameID = 0
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   411
	visualSprite = sprTarget
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   412
	madness = AddVisualGear(GetX(tempG), GetY(tempG), vgtStraightShot, 1, true,1)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   413
	g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(madness)	--g9
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   414
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   415
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   416
	if pType == loc("Reflector Shield") then
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   417
		table.insert(strucHealth,255)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   418
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   419
	else
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   420
		table.insert(strucHealth,1)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   421
	end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   422
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   423
	table.insert(strucCirc,tempCirc)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   424
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   425
	table.insert(strucCircType, 1)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   426
	if pType == loc("Bio-Filter") then
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   427
		table.insert(strucCircCol,colorRed)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   428
		table.insert(strucCircRadius,1000)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   429
		frameID = 7
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   430
	elseif pType == loc("Healing Station") then
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   431
		table.insert(strucCircCol,0xFF00FF00)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   432
		table.insert(strucCircRadius,500)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   433
		frameID = 3
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   434
	elseif pType == loc("Respawner") then
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   435
		table.insert(strucCircCol,0xFF00FF00)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   436
		table.insert(strucCircRadius,75)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   437
		runOnHogs(EnableHogResurrectionForThisClan)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   438
		frameID = 1
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   439
	elseif pType == loc("Teleportation Node") then
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   440
		table.insert(strucCircCol,0x0000FFFF)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   441
		table.insert(strucCircRadius,350)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   442
		frameID = 6
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   443
	elseif pType == loc("Generator") then
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   444
		table.insert(strucCircCol,0xFFFF00FF)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   445
		table.insert(strucCircRadius,75)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   446
		setGearValue(tempG, "power", 0)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   447
		frameID = 2
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   448
	elseif pType == loc("Support Station") then
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   449
		table.insert(strucCircCol,0xFFFF00FF)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   450
		table.insert(strucCircRadius,500)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   451
		frameID = 4
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   452
	elseif pType == loc("Construction Station") then
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   453
		table.insert(strucCircCol,0xFFFFFFFF)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   454
		table.insert(strucCircRadius,500)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   455
		frameID = 8
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   456
	elseif pType == loc("Reflector Shield") then
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   457
		table.insert(strucCircCol,0xffae00ff)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   458
		table.insert(strucCircRadius,750)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   459
		frameID = 9
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   460
	elseif pType == loc("Weapon Filter") then
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   461
		table.insert(strucCircCol,0xa800ffff)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   462
		table.insert(strucCircRadius,750)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   463
		frameID = 5
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   464
	end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   465
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   466
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   467
	SetVisualGearValues(madness, g1, g2, 0, 0, g5, frameID, g7, visualSprite, g9, g10 )
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   468
	SetState(tempG, bor(GetState(tempG),gstInvisible) )
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   469
	table.insert(strucAltDisplay, madness)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   470
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   471
end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   472
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   473
-- this is basically onStructureDelete
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   474
-- we may need to expand it for non-gear structures later
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   475
function CheckGearForStructureLink(gear)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   476
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   477
	respawnerDestroyed = false
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   478
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   479
	for i = 1, #strucID do
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   480
		if strucID[i] == getGearValue(gear,"sUID") then
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   481
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   482
			if strucType[i] == loc("Respawner") then
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   483
				respawnerDestroyed = true
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   484
			end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   485
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   486
			table.remove(strucID,i)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   487
			table.remove(strucGear,i)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   488
			table.remove(strucClan,i)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   489
			table.remove(strucType,i)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   490
			table.remove(strucCost,i)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   491
			table.remove(strucHealth,i)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   492
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   493
			DeleteVisualGear(strucCirc[i])
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   494
			table.remove(strucCirc,i)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   495
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   496
			table.remove(strucCircCol,i)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   497
			table.remove(strucCircRadius,i)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   498
			table.remove(strucCircType,i)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   499
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   500
			if strucAltDisplay[i] ~= 1 then
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   501
				DeleteVisualGear(strucAltDisplay[i])
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   502
			end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   503
			table.remove(strucAltDisplay,i)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   504
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   505
		end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   506
	end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   507
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   508
	if respawnerDestroyed == true then
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   509
		runOnHogs(RecalibrateRespawn)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   510
	end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   511
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   512
end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   513
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   514
-- called when we add a new respawner
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   515
function EnableHogResurrectionForThisClan(gear)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   516
	if GetHogClan(gear) == GetHogClan(CurrentHedgehog) then
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   517
		SetEffect(gear, heResurrectable, 1)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   518
	end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   519
end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   520
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   521
-- this is called when a respawner blows up
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   522
function RecalibrateRespawn(gear)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   523
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   524
	respawnerList = {}
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   525
	for i = 1, #strucID do
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   526
		if (strucType[i] == loc("Respawner")) and (strucClan[i] == GetHogClan(gear)) then
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   527
			table.insert(respawnerList, i)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   528
		end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   529
	end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   530
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   531
	if #respawnerList >= 1 then
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   532
		SetEffect(gear, heResurrectable, 1)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   533
	else
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   534
		SetEffect(gear, heResurrectable, 0)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   535
	end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   536
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   537
end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   538
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   539
--resposition dead hogs at a respawner if they own one
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   540
function FindRespawner(gear)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   541
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   542
	respawnerList = {}
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   543
	for i = 1, #strucID do
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   544
		if (strucType[i] == loc("Respawner")) and (strucClan[i] == GetHogClan(gear)) then
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   545
			table.insert(respawnerList, i)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   546
		end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   547
	end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   548
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   549
	if #respawnerList >= 1 then
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   550
		i = GetRandom(#respawnerList)+1
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   551
		SetGearPosition(gear,GetX(strucGear[respawnerList[i]]),GetY(strucGear[respawnerList[i]])-25)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   552
		AddVisualGear(GetX(gear), GetY(gear), vgtExplosion, 0, false)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   553
	else	-- (this should never happen, but just in case)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   554
		SetEffect(gear, heResurrectable, 0)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   555
		DeleteGear(gear)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   556
	end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   557
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   558
end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   559
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   560
function onGearResurrect(gear)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   561
	AddVisualGear(GetX(gear), GetY(gear), vgtExplosion, 0, false)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   562
	FindRespawner(gear)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   563
end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   564
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   565
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   566
function CheckTeleport(gear, tX, tY)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   567
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   568
	teleportOriginSuccessful = false
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   569
	teleportDestinationSuccessful = false
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   570
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   571
	for i = 1, #strucID do
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   572
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   573
		if (strucType[i] == loc("Teleportation Node")) and (strucClan[i] == GetHogClan(CurrentHedgehog)) then
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   574
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   575
			dist = GetDistFromGearToXY(CurrentHedgehog,GetX(strucGear[i]), GetY(strucGear[i]))
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   576
			if strucCircType[i] == 0 then
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   577
				NR = strucCircRadius[i]
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   578
			else
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   579
				NR = (48/100*strucCircRadius[i])/2
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   580
			end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   581
			if dist <= NR*NR then
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   582
				teleportOriginSuccessful = true
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   583
			end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   584
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   585
			dist = GetDistFromXYtoXY(tX,tY,GetX(strucGear[i]), GetY(strucGear[i]))
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   586
			if strucCircType[i] == 0 then
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   587
				NR = strucCircRadius[i]
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   588
			else
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   589
				NR = (48/100*strucCircRadius[i])/2
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   590
			end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   591
			if dist <= NR*NR then
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   592
				teleportDestinationSuccessful = true
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   593
			end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   594
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   595
		end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   596
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   597
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   598
	end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   599
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   600
	if ((teleportDestinationSuccessful == false) or (teleportOriginSuccessful == false)) then
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   601
		AddCaption(loc("Teleport Unsuccessful. Please teleport within a clan teleporter's sphere of influence."))
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   602
		SetGearTarget(gear, GetX(CurrentHedgehog), GetY(CurrentHedgehog))
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   603
	end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   604
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   605
end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   606
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   607
--Check for proximity of gears to structures, and make structures behave accordingly
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   608
function CheckProximity(gear)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   609
11718
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   610
	dist = GetDistFromGearToXY(gear, GetX(strucGear[tempID]), GetY(strucGear[tempID]))
12682
b7fd7ab8ddf9 Construction Mode: Fix Lua error spam when using time box with filters on map
Wuzzy <almikes@aol.com>
parents: 12397
diff changeset
   611
	if not dist then
b7fd7ab8ddf9 Construction Mode: Fix Lua error spam when using time box with filters on map
Wuzzy <almikes@aol.com>
parents: 12397
diff changeset
   612
		return
b7fd7ab8ddf9 Construction Mode: Fix Lua error spam when using time box with filters on map
Wuzzy <almikes@aol.com>
parents: 12397
diff changeset
   613
	end
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   614
11718
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   615
	-- calculate my real radius if I am an aura
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   616
	if strucCircType[tempID] == 0 then
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   617
		NR = strucCircRadius[tempID]
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   618
	else
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   619
		NR = (48/100*strucCircRadius[tempID])/2
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   620
	end
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   621
11718
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   622
	-- we're in business
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   623
	if dist <= NR*NR then
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   624
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   625
11718
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   626
		-- heal clan hogs
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   627
		if strucType[tempID] == loc("Healing Station") then
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   628
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   629
			if GetGearType(gear) == gtHedgehog then
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   630
				if GetHogClan(gear) == strucClan[tempID] then
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   631
12940
39b7b3ed619e Add healing visual effect + heal msg in scripts
Wuzzy <Wuzzy2@mail.ru>
parents: 12836
diff changeset
   632
					local hogLife = GetHealth(gear)
39b7b3ed619e Add healing visual effect + heal msg in scripts
Wuzzy <Wuzzy2@mail.ru>
parents: 12836
diff changeset
   633
					-- Heal hog by 1 HP, up to 150 HP total
39b7b3ed619e Add healing visual effect + heal msg in scripts
Wuzzy <Wuzzy2@mail.ru>
parents: 12836
diff changeset
   634
					if hogLife < 150 then
39b7b3ed619e Add healing visual effect + heal msg in scripts
Wuzzy <Wuzzy2@mail.ru>
parents: 12836
diff changeset
   635
						if ((hogLife + 1) % 5) == 0 then
39b7b3ed619e Add healing visual effect + heal msg in scripts
Wuzzy <Wuzzy2@mail.ru>
parents: 12836
diff changeset
   636
							-- Health anim every 5 HP
39b7b3ed619e Add healing visual effect + heal msg in scripts
Wuzzy <Wuzzy2@mail.ru>
parents: 12836
diff changeset
   637
							HealHog(gear, 1, false)
39b7b3ed619e Add healing visual effect + heal msg in scripts
Wuzzy <Wuzzy2@mail.ru>
parents: 12836
diff changeset
   638
						else
39b7b3ed619e Add healing visual effect + heal msg in scripts
Wuzzy <Wuzzy2@mail.ru>
parents: 12836
diff changeset
   639
							SetHealth(gear, hogLife+1)
39b7b3ed619e Add healing visual effect + heal msg in scripts
Wuzzy <Wuzzy2@mail.ru>
parents: 12836
diff changeset
   640
						end
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   641
					end
11718
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   642
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   643
					-- change this to the med kit sprite health ++++s later
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   644
					tempE = AddVisualGear(GetX(strucGear[tempID]), GetY(strucGear[tempID]), vgtSmoke, 0, true)
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   645
					g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(tempE)
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   646
					SetVisualGearValues(tempE, g1, g2, g3, g4, g5, g6, g7, g8, g9, colorGreen )
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   647
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   648
				end
11718
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   649
			end
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   650
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   651
		-- explode enemy clan hogs
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   652
		elseif strucType[tempID] == loc("Bio-Filter") then
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   653
11718
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   654
			if GetGearType(gear) == gtHedgehog then
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   655
				if (GetHogClan(gear) ~= strucClan[tempID]) and (GetHealth(gear) > 0) then
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   656
					AddGear(GetX(gear), GetY(gear), gtGrenade, 0, 0, 0, 1)
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   657
				end
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   658
			end
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   659
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   660
		-- were those weapons in your pocket, or were you just happy to see me?
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   661
		elseif strucType[tempID] == loc("Weapon Filter") then
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   662
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   663
			if GetGearType(gear) == gtHedgehog then
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   664
				if (GetHogClan(gear) ~= strucClan[tempID]) then
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   665
11718
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   666
					for wpnIndex = 1, #atkArray do
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   667
						AddAmmo(gear, atkArray[wpnIndex][1], 0)
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   668
					end
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   669
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   670
					for wpnIndex = 1, #utilArray do
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   671
						AddAmmo(gear, utilArray[wpnIndex][1], 0)
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   672
					end
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   673
12941
ffbd31afed96 HedgeEditor, Construction Mode: Refactor code by adding fake ammo type variables
Wuzzy <Wuzzy2@mail.ru>
parents: 12940
diff changeset
   674
					AddAmmo(gear, amCMStructurePlacer, 100)
11718
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   675
					AddAmmo(gear, amSwitch, 100)
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   676
					AddAmmo(gear, amSkip, 100)
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   677
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   678
				end
11718
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   679
			end
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   680
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   681
		-- BOUNCE! POGO! POGO! POGO! POGO!
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   682
		elseif strucType[tempID] == loc("Reflector Shield") then
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   683
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   684
			-- add check for whose projectile it is
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   685
			if gearCanBeDeflected(gear) == true then
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   686
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   687
				gOwner = getGearValue(gear,"owner")
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   688
				gDeflects = getGearValue(gear,"deflects")
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   689
				gDmg = getGearValue(gear,"damage")
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   690
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   691
				if gDeflects >= 3 then
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   692
					DeleteGear(gear)
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   693
					AddVisualGear(GetX(gear), GetY(gear), vgtSmoke, 0, false)
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   694
					PlaySound(sndVaporize)
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   695
				elseif gOwner ~= strucClan[tempID] then
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   696
					--whether to vaporize gears or bounce them
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   697
					if gDmg ~= 0 then
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   698
						dx, dy = GetGearVelocity(gear)
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   699
11718
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   700
						if (dx == 0) and (dy == 0) then
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   701
							-- static mine, explosive, etc encountered
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   702
							-- do nothing
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   703
							else
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   704
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   705
							--let's bounce something!
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   706
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   707
							dx = dx*(-1)
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   708
							dy = dy*(-1)
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   709
							SetGearVelocity(gear,dx,dy)
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   710
							setGearValue(gear,"deflects",(gDeflects+1))
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   711
11718
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   712
							AddVisualGear(GetX(gear), GetY(gear), vgtExplosion, 0, false)
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   713
							PlaySound(sndExplosion)
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   714
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   715
							strucHealth[tempID] = strucHealth[tempID] - gDmg
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   716
							strucCircCol[tempID] = strucCircCol[tempID] - gDmg
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   717
11718
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   718
							if strucHealth[tempID] <= 0 then
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   719
								AddVisualGear(GetX(strucGear[tempID]), GetY(strucGear[tempID]), vgtExplosion, 0, false)
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   720
								DeleteGear(strucGear[tempID])
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   721
								PlaySound(sndExplosion)
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   722
							end
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   723
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   724
						end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   725
11718
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   726
					else
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   727
						DeleteGear(gear)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   728
						AddVisualGear(GetX(gear), GetY(gear), vgtSmoke, 0, false)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   729
						PlaySound(sndVaporize)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   730
					end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   731
				end
11718
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   732
			end
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   733
11718
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   734
		--mark as within range of a teleporter node
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   735
		elseif strucType[tempID] == loc("Teleportation Node") then
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   736
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   737
			if GetGearType(gear) == gtHedgehog then
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   738
				if GetHogClan(gear) == strucClan[tempID] then
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   739
11718
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   740
					for i = 1, #sProx do
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   741
						if sProx[i][1] == loc("Teleportation Mode") then
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   742
							sProx[i][2] = true
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   743
						end
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   744
					end
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   745
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   746
				end
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   747
			end
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   748
11718
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   749
		-- mark as within range of construction station
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   750
		-- and thus allow menu access to placement modes
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   751
		-- for girders, mines, sticky mines and barrels
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   752
		elseif strucType[tempID] == loc("Construction Station") then
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   753
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   754
			if GetGearType(gear) == gtHedgehog then
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   755
				if GetHogClan(gear) == strucClan[tempID] then
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   756
					tempE = AddVisualGear(GetX(strucGear[tempID]), GetY(strucGear[tempID]), vgtSmoke, 0, true)
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   757
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   758
					for i = 1, #sProx do
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   759
						if ((sProx[i][1] == loc("Girder Placement Mode"))
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   760
						or (sProx[i][1] == loc("Rubber Placement Mode"))
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   761
						or (sProx[i][1] == loc("Mine Placement Mode"))
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   762
						or (sProx[i][1] == loc("Sticky Mine Placement Mode"))
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   763
						or (sProx[i][1] == loc("Barrel Placement Mode")))
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   764
						then
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   765
							sProx[i][2] = true
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   766
						end
11718
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   767
					end
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   768
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   769
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   770
				end
11718
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   771
			end
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   772
11718
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   773
		-- mark as within stupport station range
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   774
		-- and thus allow menu access to placement modes
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   775
		-- for weapon, utility, and med crates
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   776
		elseif strucType[tempID] == loc("Support Station") then
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   777
11718
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   778
			if GetGearType(gear) == gtHedgehog then
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   779
				if GetHogClan(gear) == strucClan[tempID] then
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   780
					tempE = AddVisualGear(GetX(strucGear[tempID]), GetY(strucGear[tempID]), vgtSmoke, 0, true)
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   781
11718
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   782
					for i = 1, #sProx do
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   783
						if ((sProx[i][1] == loc("Health Crate Placement Mode"))
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   784
						or (sProx[i][1] == loc("Weapon Crate Placement Mode"))
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   785
						or (sProx[i][1] == loc("Utility Crate Placement Mode")))
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   786
						then
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   787
							sProx[i][2] = true
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   788
						end
11718
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   789
					end
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   790
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   791
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   792
				end
11718
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   793
			end
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   794
		end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   795
11718
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
   796
	end
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   797
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   798
end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   799
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   800
-- used to check if we need to run through all hogs or just currenthedgehog
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   801
function isAStructureThatAppliesToMultipleGears(pID)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   802
	if 	strucType[pID] == loc("Healing Station") or
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   803
		strucType[pID] == loc("Reflector Shield") or
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   804
		strucType[pID] == loc("Weapon Filter") or
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   805
		strucType[pID] == loc("Bio-Filter")
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   806
	then
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   807
		return(true)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   808
	else
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   809
		return(false)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   810
	end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   811
end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   812
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   813
function HandleStructures()
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   814
11724
cf4d61123440 Construction Mode: Fix construction/support station
Wuzzy <almikes@aol.com>
parents: 11723
diff changeset
   815
	if GameTime % 100 == 0 then
cf4d61123440 Construction Mode: Fix construction/support station
Wuzzy <almikes@aol.com>
parents: 11723
diff changeset
   816
		for i = 1, #sProx do
cf4d61123440 Construction Mode: Fix construction/support station
Wuzzy <almikes@aol.com>
parents: 11723
diff changeset
   817
			sProx[i][2] = false
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   818
11724
cf4d61123440 Construction Mode: Fix construction/support station
Wuzzy <almikes@aol.com>
parents: 11723
diff changeset
   819
			if sProx[i][1] == loc("Structure Placement Mode") then
cf4d61123440 Construction Mode: Fix construction/support station
Wuzzy <almikes@aol.com>
parents: 11723
diff changeset
   820
				sProx[i][2] = true
cf4d61123440 Construction Mode: Fix construction/support station
Wuzzy <almikes@aol.com>
parents: 11723
diff changeset
   821
			end
cf4d61123440 Construction Mode: Fix construction/support station
Wuzzy <almikes@aol.com>
parents: 11723
diff changeset
   822
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   823
		end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   824
	end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   825
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   826
	for i = 1, #strucID do
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   827
11723
456f4e9f9dce Construction Mode: Update structure overlay each tick, thus falling smoothly
Wuzzy <almikes@aol.com>
parents: 11722
diff changeset
   828
		SetVisualGearValues(strucCirc[i], GetX(strucGear[i]), GetY(strucGear[i]), nil, nil, nil, nil, nil, strucCircRadius[i], nil, strucCircCol[i])
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   829
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   830
		tempID = i
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   831
11723
456f4e9f9dce Construction Mode: Update structure overlay each tick, thus falling smoothly
Wuzzy <almikes@aol.com>
parents: 11722
diff changeset
   832
		SetVisualGearValues(strucAltDisplay[i], GetX(strucGear[i]), GetY(strucGear[i]), 0, 0, nil, nil, 800000, sprTarget)
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   833
11723
456f4e9f9dce Construction Mode: Update structure overlay each tick, thus falling smoothly
Wuzzy <almikes@aol.com>
parents: 11722
diff changeset
   834
		if GameTime % 100 == 0 then
456f4e9f9dce Construction Mode: Update structure overlay each tick, thus falling smoothly
Wuzzy <almikes@aol.com>
parents: 11722
diff changeset
   835
			-- Check For proximity of stuff to our structures
456f4e9f9dce Construction Mode: Update structure overlay each tick, thus falling smoothly
Wuzzy <almikes@aol.com>
parents: 11722
diff changeset
   836
			if isAStructureThatAppliesToMultipleGears(i) then
456f4e9f9dce Construction Mode: Update structure overlay each tick, thus falling smoothly
Wuzzy <almikes@aol.com>
parents: 11722
diff changeset
   837
				runOnGears(CheckProximity)
456f4e9f9dce Construction Mode: Update structure overlay each tick, thus falling smoothly
Wuzzy <almikes@aol.com>
parents: 11722
diff changeset
   838
			else -- only check prox on CurrentHedgehog
456f4e9f9dce Construction Mode: Update structure overlay each tick, thus falling smoothly
Wuzzy <almikes@aol.com>
parents: 11722
diff changeset
   839
				if CurrentHedgehog ~= nil then
456f4e9f9dce Construction Mode: Update structure overlay each tick, thus falling smoothly
Wuzzy <almikes@aol.com>
parents: 11722
diff changeset
   840
					CheckProximity(CurrentHedgehog)
456f4e9f9dce Construction Mode: Update structure overlay each tick, thus falling smoothly
Wuzzy <almikes@aol.com>
parents: 11722
diff changeset
   841
				end
456f4e9f9dce Construction Mode: Update structure overlay each tick, thus falling smoothly
Wuzzy <almikes@aol.com>
parents: 11722
diff changeset
   842
			end
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   843
11723
456f4e9f9dce Construction Mode: Update structure overlay each tick, thus falling smoothly
Wuzzy <almikes@aol.com>
parents: 11722
diff changeset
   844
			if strucType[i] == loc("Generator") then
11732
e28b534188d3 update construction mode in-file version info
sheepluva
parents: 11730
diff changeset
   845
11723
456f4e9f9dce Construction Mode: Update structure overlay each tick, thus falling smoothly
Wuzzy <almikes@aol.com>
parents: 11722
diff changeset
   846
				for z = 0, ClansCount-1 do
456f4e9f9dce Construction Mode: Update structure overlay each tick, thus falling smoothly
Wuzzy <almikes@aol.com>
parents: 11722
diff changeset
   847
					if z == strucClan[i] then
456f4e9f9dce Construction Mode: Update structure overlay each tick, thus falling smoothly
Wuzzy <almikes@aol.com>
parents: 11722
diff changeset
   848
						increaseGearValue(strucGear[i],"power")
456f4e9f9dce Construction Mode: Update structure overlay each tick, thus falling smoothly
Wuzzy <almikes@aol.com>
parents: 11722
diff changeset
   849
						if getGearValue(strucGear[i],"power") == 10 then
456f4e9f9dce Construction Mode: Update structure overlay each tick, thus falling smoothly
Wuzzy <almikes@aol.com>
parents: 11722
diff changeset
   850
							setGearValue(strucGear[i],"power",0)
456f4e9f9dce Construction Mode: Update structure overlay each tick, thus falling smoothly
Wuzzy <almikes@aol.com>
parents: 11722
diff changeset
   851
							clanPower[z] = clanPower[z] + 1
11728
373150be0356 Construction Mode: Sanity-check numbers from script parameter
Wuzzy <almikes@aol.com>
parents: 11727
diff changeset
   852
							if conf_maxEnergy ~= "inf" and clanPower[z] > conf_maxEnergy then
11723
456f4e9f9dce Construction Mode: Update structure overlay each tick, thus falling smoothly
Wuzzy <almikes@aol.com>
parents: 11722
diff changeset
   853
								clanPower[z] = conf_maxEnergy
456f4e9f9dce Construction Mode: Update structure overlay each tick, thus falling smoothly
Wuzzy <almikes@aol.com>
parents: 11722
diff changeset
   854
							end
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   855
						end
11732
e28b534188d3 update construction mode in-file version info
sheepluva
parents: 11730
diff changeset
   856
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   857
					end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   858
				end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   859
			end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   860
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   861
		end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   862
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   863
	end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   864
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   865
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   866
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   867
	-- this is kinda messy and gross (even more than usual), fix it up at some point
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   868
	-- it just assumes that if you have access to girders, it works for rubbers
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   869
	-- as that is what the struc implemenation means due to construction station
11727
1c09b8d050ce Construction Mode: Fix timer issues
Wuzzy <almikes@aol.com>
parents: 11726
diff changeset
   870
	if GameTime % 100 == 0 and CurrentHedgehog ~= nil then
11724
cf4d61123440 Construction Mode: Fix construction/support station
Wuzzy <almikes@aol.com>
parents: 11723
diff changeset
   871
		anyUIProx = false
cf4d61123440 Construction Mode: Fix construction/support station
Wuzzy <almikes@aol.com>
parents: 11723
diff changeset
   872
		for i = 1, #sProx do
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   873
11724
cf4d61123440 Construction Mode: Fix construction/support station
Wuzzy <almikes@aol.com>
parents: 11723
diff changeset
   874
			if sProx[i][1] == loc("Girder Placement Mode") then
cf4d61123440 Construction Mode: Fix construction/support station
Wuzzy <almikes@aol.com>
parents: 11723
diff changeset
   875
				if sProx[i][2] == true then
cf4d61123440 Construction Mode: Fix construction/support station
Wuzzy <almikes@aol.com>
parents: 11723
diff changeset
   876
					AddAmmo(CurrentHedgehog, amGirder, 100)
cf4d61123440 Construction Mode: Fix construction/support station
Wuzzy <almikes@aol.com>
parents: 11723
diff changeset
   877
					AddAmmo(CurrentHedgehog, amRubber, 100)
12941
ffbd31afed96 HedgeEditor, Construction Mode: Refactor code by adding fake ammo type variables
Wuzzy <Wuzzy2@mail.ru>
parents: 12940
diff changeset
   878
					AddAmmo(CurrentHedgehog, amCMObjectPlacer, 100)
11724
cf4d61123440 Construction Mode: Fix construction/support station
Wuzzy <almikes@aol.com>
parents: 11723
diff changeset
   879
				else
cf4d61123440 Construction Mode: Fix construction/support station
Wuzzy <almikes@aol.com>
parents: 11723
diff changeset
   880
					AddAmmo(CurrentHedgehog, amGirder, 0)
cf4d61123440 Construction Mode: Fix construction/support station
Wuzzy <almikes@aol.com>
parents: 11723
diff changeset
   881
					AddAmmo(CurrentHedgehog, amRubber, 0)
12941
ffbd31afed96 HedgeEditor, Construction Mode: Refactor code by adding fake ammo type variables
Wuzzy <Wuzzy2@mail.ru>
parents: 12940
diff changeset
   882
					AddAmmo(CurrentHedgehog, amCMObjectPlacer, 0) -- new
11724
cf4d61123440 Construction Mode: Fix construction/support station
Wuzzy <almikes@aol.com>
parents: 11723
diff changeset
   883
				end
cf4d61123440 Construction Mode: Fix construction/support station
Wuzzy <almikes@aol.com>
parents: 11723
diff changeset
   884
			elseif sProx[i][1] == loc("Teleportation Mode") then
cf4d61123440 Construction Mode: Fix construction/support station
Wuzzy <almikes@aol.com>
parents: 11723
diff changeset
   885
				if sProx[i][2] == true then
cf4d61123440 Construction Mode: Fix construction/support station
Wuzzy <almikes@aol.com>
parents: 11723
diff changeset
   886
					AddAmmo(CurrentHedgehog, amTeleport, 100)
cf4d61123440 Construction Mode: Fix construction/support station
Wuzzy <almikes@aol.com>
parents: 11723
diff changeset
   887
				else
cf4d61123440 Construction Mode: Fix construction/support station
Wuzzy <almikes@aol.com>
parents: 11723
diff changeset
   888
					AddAmmo(CurrentHedgehog, amTeleport, 0)
cf4d61123440 Construction Mode: Fix construction/support station
Wuzzy <almikes@aol.com>
parents: 11723
diff changeset
   889
				end
cf4d61123440 Construction Mode: Fix construction/support station
Wuzzy <almikes@aol.com>
parents: 11723
diff changeset
   890
			elseif sProx[i][1] == loc("Weapon Crate Placement Mode") then
cf4d61123440 Construction Mode: Fix construction/support station
Wuzzy <almikes@aol.com>
parents: 11723
diff changeset
   891
				-- this is new stuff
cf4d61123440 Construction Mode: Fix construction/support station
Wuzzy <almikes@aol.com>
parents: 11723
diff changeset
   892
				if sProx[i][2] == true then
12941
ffbd31afed96 HedgeEditor, Construction Mode: Refactor code by adding fake ammo type variables
Wuzzy <Wuzzy2@mail.ru>
parents: 12940
diff changeset
   893
					AddAmmo(CurrentHedgehog, amCMCratePlacer, 100)
11724
cf4d61123440 Construction Mode: Fix construction/support station
Wuzzy <almikes@aol.com>
parents: 11723
diff changeset
   894
				else
12941
ffbd31afed96 HedgeEditor, Construction Mode: Refactor code by adding fake ammo type variables
Wuzzy <Wuzzy2@mail.ru>
parents: 12940
diff changeset
   895
					AddAmmo(CurrentHedgehog, amCMCratePlacer, 0)
11724
cf4d61123440 Construction Mode: Fix construction/support station
Wuzzy <almikes@aol.com>
parents: 11723
diff changeset
   896
				end
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   897
			end
11724
cf4d61123440 Construction Mode: Fix construction/support station
Wuzzy <almikes@aol.com>
parents: 11723
diff changeset
   898
cf4d61123440 Construction Mode: Fix construction/support station
Wuzzy <almikes@aol.com>
parents: 11723
diff changeset
   899
			if (sProx[i][2] == true) then
cf4d61123440 Construction Mode: Fix construction/support station
Wuzzy <almikes@aol.com>
parents: 11723
diff changeset
   900
				anyUIProx = true
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   901
			end
11724
cf4d61123440 Construction Mode: Fix construction/support station
Wuzzy <almikes@aol.com>
parents: 11723
diff changeset
   902
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   903
		end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   904
	end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   905
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   906
end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   907
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   908
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   909
function checkForSpecialWeapons()
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   910
12941
ffbd31afed96 HedgeEditor, Construction Mode: Refactor code by adding fake ammo type variables
Wuzzy <Wuzzy2@mail.ru>
parents: 12940
diff changeset
   911
	if (GetCurAmmoType() == amCMObjectPlacer) then
11942
abdb24f0c2d9 Change descriptions for special Construction Mode tools
Wuzzy <almikes@aol.com>
parents: 11881
diff changeset
   912
		AddCaption(loc("Object Placer"),GetClanColor(GetHogClan(CurrentHedgehog)),capgrpAmmoinfo)
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   913
	end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   914
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   915
	lastWep = GetCurAmmoType()
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   916
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   917
end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   918
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   919
----------------------------------------------------------
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   920
-- EXCERPTS OF ADAPTED HEDGE_EDITOR CODE FOLLOWS
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   921
----------------------------------------------------------
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   922
-- experimental crap
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   923
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   924
local landType = 0
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   925
-----------------------------------------
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   926
-- tracking vars for save slash load purposes
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   927
-----------------------------------------
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   928
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   929
local hhs = {}
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   930
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   931
---------------------------------
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   932
-- crates are made of this stuff
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   933
---------------------------------
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   934
placeholder = 20
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   935
 atkArray =
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   936
				{
11981
acae870a66b9 Use GetAmmoName in Construction Mode
Wuzzy <almikes@aol.com>
parents: 11942
diff changeset
   937
				{amBazooka, 	"amBazooka",		0, 2*placeholder},
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   938
				--{amBee, 		"amBee",			0, loc("Homing Bee"), 		4*placeholder},
11981
acae870a66b9 Use GetAmmoName in Construction Mode
Wuzzy <almikes@aol.com>
parents: 11942
diff changeset
   939
				{amMortar, 		"amMortar",			0, 1*placeholder},
acae870a66b9 Use GetAmmoName in Construction Mode
Wuzzy <almikes@aol.com>
parents: 11942
diff changeset
   940
				{amDrill, 		"amDrill",			0, 3*placeholder},
acae870a66b9 Use GetAmmoName in Construction Mode
Wuzzy <almikes@aol.com>
parents: 11942
diff changeset
   941
				{amSnowball, 	"amSnowball",		0, 3*placeholder},
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   942
11981
acae870a66b9 Use GetAmmoName in Construction Mode
Wuzzy <almikes@aol.com>
parents: 11942
diff changeset
   943
				{amGrenade,		"amGrenade",		0, 2*placeholder},
acae870a66b9 Use GetAmmoName in Construction Mode
Wuzzy <almikes@aol.com>
parents: 11942
diff changeset
   944
				{amClusterBomb,	"amClusterBomb",	0, 3*placeholder},
acae870a66b9 Use GetAmmoName in Construction Mode
Wuzzy <almikes@aol.com>
parents: 11942
diff changeset
   945
				{amWatermelon, 	"amWatermelon",		0, 25*placeholder},
acae870a66b9 Use GetAmmoName in Construction Mode
Wuzzy <almikes@aol.com>
parents: 11942
diff changeset
   946
				{amHellishBomb,	"amHellishBomb",	0, 25*placeholder},
acae870a66b9 Use GetAmmoName in Construction Mode
Wuzzy <almikes@aol.com>
parents: 11942
diff changeset
   947
				{amMolotov, 	"amMolotov",		0, 3*placeholder},
acae870a66b9 Use GetAmmoName in Construction Mode
Wuzzy <almikes@aol.com>
parents: 11942
diff changeset
   948
				{amGasBomb, 	"amGasBomb",		0, 3*placeholder},
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   949
11981
acae870a66b9 Use GetAmmoName in Construction Mode
Wuzzy <almikes@aol.com>
parents: 11942
diff changeset
   950
				{amShotgun,		"amShotgun",		0, 2*placeholder},
acae870a66b9 Use GetAmmoName in Construction Mode
Wuzzy <almikes@aol.com>
parents: 11942
diff changeset
   951
				{amDEagle,		"amDEagle",			0, 2*placeholder},
acae870a66b9 Use GetAmmoName in Construction Mode
Wuzzy <almikes@aol.com>
parents: 11942
diff changeset
   952
				{amSniperRifle,	"amSniperRifle",	0, 3*placeholder},
11709
cea5418c1af6 Construction Mode: Make weapon names match en.txt
Wuzzy <almikes@aol.com>
parents: 11708
diff changeset
   953
				--{amSineGun, 	"amSineGun",		0, loc("Sine Gun"), 			6*placeholder},
11981
acae870a66b9 Use GetAmmoName in Construction Mode
Wuzzy <almikes@aol.com>
parents: 11942
diff changeset
   954
				{amFlamethrower,"amFlamethrower",	0, 4*placeholder},
acae870a66b9 Use GetAmmoName in Construction Mode
Wuzzy <almikes@aol.com>
parents: 11942
diff changeset
   955
				{amIceGun, 		"amIceGun",			0, 15*placeholder},
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   956
11981
acae870a66b9 Use GetAmmoName in Construction Mode
Wuzzy <almikes@aol.com>
parents: 11942
diff changeset
   957
				{amFirePunch, 	"amFirePunch",		0, 3*placeholder},
acae870a66b9 Use GetAmmoName in Construction Mode
Wuzzy <almikes@aol.com>
parents: 11942
diff changeset
   958
				{amWhip,		"amWhip",			0, 1*placeholder},
acae870a66b9 Use GetAmmoName in Construction Mode
Wuzzy <almikes@aol.com>
parents: 11942
diff changeset
   959
				{amBaseballBat, "amBaseballBat",	0, 7*placeholder},
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   960
				--{amKamikaze, 	"amKamikaze",		0, loc("Kamikaze"),			1*placeholder},
11981
acae870a66b9 Use GetAmmoName in Construction Mode
Wuzzy <almikes@aol.com>
parents: 11942
diff changeset
   961
				{amSeduction, 	"amSeduction",		0, 1*placeholder},
acae870a66b9 Use GetAmmoName in Construction Mode
Wuzzy <almikes@aol.com>
parents: 11942
diff changeset
   962
				{amHammer,		"amHammer",			0, 1*placeholder},
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   963
11981
acae870a66b9 Use GetAmmoName in Construction Mode
Wuzzy <almikes@aol.com>
parents: 11942
diff changeset
   964
				{amMine, 		"amMine",			0, 1*placeholder},
acae870a66b9 Use GetAmmoName in Construction Mode
Wuzzy <almikes@aol.com>
parents: 11942
diff changeset
   965
				{amDynamite, 	"amDynamite",		0, 9*placeholder},
acae870a66b9 Use GetAmmoName in Construction Mode
Wuzzy <almikes@aol.com>
parents: 11942
diff changeset
   966
				{amCake, 		"amCake",			0, 25*placeholder},
acae870a66b9 Use GetAmmoName in Construction Mode
Wuzzy <almikes@aol.com>
parents: 11942
diff changeset
   967
				{amBallgun, 	"amBallgun",		0, 40*placeholder},
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   968
				--{amRCPlane,		"amRCPlane",		0, loc("RC Plane"), 	25*placeholder},
11981
acae870a66b9 Use GetAmmoName in Construction Mode
Wuzzy <almikes@aol.com>
parents: 11942
diff changeset
   969
				{amSMine,		"amSMine",			0, 5*placeholder},
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   970
12941
ffbd31afed96 HedgeEditor, Construction Mode: Refactor code by adding fake ammo type variables
Wuzzy <Wuzzy2@mail.ru>
parents: 12940
diff changeset
   971
				-- Careful! Some airborne attacks are overwritten by the special Construction Mode tools
ffbd31afed96 HedgeEditor, Construction Mode: Refactor code by adding fake ammo type variables
Wuzzy <Wuzzy2@mail.ru>
parents: 12940
diff changeset
   972
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   973
				--{amAirAttack,	"amAirAttack",		0, loc("Air Attack"), 		10*placeholder},
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   974
				--{amMineStrike,	"amMineStrike",		0, loc("Mine Strike"), 		15*placeholder},
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   975
				--{amNapalm, 		"amNapalm",			0, loc("Napalm"), 		15*placeholder},
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   976
				--{amPiano,		"amPiano",			0, loc("Piano Strike"), 	40*placeholder},
11759
1e2ec1be5041 Construction Mode: Reorder weapon and utility list to parrallel weapon menu order
Wuzzy <almikes@aol.com>
parents: 11758
diff changeset
   977
				--{amDrillStrike,	"amDrillStrike",	0, loc("Drill Strike"), 15*placeholder},
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   978
12397
414bcb4ca5ee Construction Mode: Move pick hammer and blow torch into weapon crates (game default)
Wuzzy <almikes@aol.com>
parents: 12336
diff changeset
   979
				{amPickHammer,		"amPickHammer",		0, 2*placeholder},
414bcb4ca5ee Construction Mode: Move pick hammer and blow torch into weapon crates (game default)
Wuzzy <almikes@aol.com>
parents: 12336
diff changeset
   980
				{amBlowTorch, 		"amBlowTorch",		0, 4*placeholder},
11981
acae870a66b9 Use GetAmmoName in Construction Mode
Wuzzy <almikes@aol.com>
parents: 11942
diff changeset
   981
				{amKnife,		"amKnife",			0, 2*placeholder},
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   982
12214
facbc3c6e166 Increase duck cost in Construction Mode to 40
Wuzzy <almikes@aol.com>
parents: 12207
diff changeset
   983
				{amBirdy,		"amBirdy",			0, 7*placeholder},
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   984
12214
facbc3c6e166 Increase duck cost in Construction Mode to 40
Wuzzy <almikes@aol.com>
parents: 12207
diff changeset
   985
				{amDuck,		"amDuck",			0, 2*placeholder}
12207
2de020695c20 Add rubber duck to (Balanced) Random Weapon, Construction Mode, HedgeEditor
Wuzzy <almikes@aol.com>
parents: 12093
diff changeset
   986
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   987
				}
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   988
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   989
 utilArray =
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   990
				{
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   991
				--{amGirder, 			"amGirder",			0, loc("Girder"), 		4*placeholder},
11981
acae870a66b9 Use GetAmmoName in Construction Mode
Wuzzy <almikes@aol.com>
parents: 11942
diff changeset
   992
				{amLandGun,		"amLandGun",		0, 5*placeholder},
11709
cea5418c1af6 Construction Mode: Make weapon names match en.txt
Wuzzy <almikes@aol.com>
parents: 11708
diff changeset
   993
				--{amRubber, 			"amRubber",			0, loc("Rubber"), 	5*placeholder},
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   994
11981
acae870a66b9 Use GetAmmoName in Construction Mode
Wuzzy <almikes@aol.com>
parents: 11942
diff changeset
   995
				{amRope, 			"amRope",	0, 7*placeholder},
acae870a66b9 Use GetAmmoName in Construction Mode
Wuzzy <almikes@aol.com>
parents: 11942
diff changeset
   996
				{amParachute, 		"amParachute",		0, 2*placeholder},
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
   997
				--{amTeleport,		"amTeleport",		0, loc("Teleport"), 		6*placeholder},
11981
acae870a66b9 Use GetAmmoName in Construction Mode
Wuzzy <almikes@aol.com>
parents: 11942
diff changeset
   998
				{amJetpack,			"amJetpack",	0, 8*placeholder},
acae870a66b9 Use GetAmmoName in Construction Mode
Wuzzy <almikes@aol.com>
parents: 11942
diff changeset
   999
				{amPortalGun,		"amPortalGun",		0, 15*placeholder},
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1000
11981
acae870a66b9 Use GetAmmoName in Construction Mode
Wuzzy <almikes@aol.com>
parents: 11942
diff changeset
  1001
				{amInvulnerable,	"amInvulnerable",	0, 5*placeholder},
acae870a66b9 Use GetAmmoName in Construction Mode
Wuzzy <almikes@aol.com>
parents: 11942
diff changeset
  1002
				{amLaserSight,		"amLaserSight",		0, 2*placeholder},
acae870a66b9 Use GetAmmoName in Construction Mode
Wuzzy <almikes@aol.com>
parents: 11942
diff changeset
  1003
				{amVampiric,		"amVampiric",		0, 6*placeholder},
11759
1e2ec1be5041 Construction Mode: Reorder weapon and utility list to parrallel weapon menu order
Wuzzy <almikes@aol.com>
parents: 11758
diff changeset
  1004
				--{amResurrector, 	"amResurrector",	0, loc("Resurrector"), 		8*placeholder},
1e2ec1be5041 Construction Mode: Reorder weapon and utility list to parrallel weapon menu order
Wuzzy <almikes@aol.com>
parents: 11758
diff changeset
  1005
				--{amTardis, 			"amTardis",			0, loc("Time Box"), 			2*placeholder},
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1006
11759
1e2ec1be5041 Construction Mode: Reorder weapon and utility list to parrallel weapon menu order
Wuzzy <almikes@aol.com>
parents: 11758
diff changeset
  1007
				--{amSwitch,			"amSwitch",			0, loc("Switch Hog"), 		4*placeholder}
11981
acae870a66b9 Use GetAmmoName in Construction Mode
Wuzzy <almikes@aol.com>
parents: 11942
diff changeset
  1008
				{amLowGravity, 		"amLowGravity",		0, 4*placeholder},
acae870a66b9 Use GetAmmoName in Construction Mode
Wuzzy <almikes@aol.com>
parents: 11942
diff changeset
  1009
				{amExtraDamage, 	"amExtraDamage",	0, 6*placeholder},
acae870a66b9 Use GetAmmoName in Construction Mode
Wuzzy <almikes@aol.com>
parents: 11942
diff changeset
  1010
				{amExtraTime,		"amExtraTime",		0, 8*placeholder}
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1011
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1012
				}
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1013
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1014
----------------------------
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1015
-- placement shite
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1016
----------------------------
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1017
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1018
local cGear = nil -- detects placement of girders and objects (using airattack)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1019
local curWep = amNothing
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1020
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1021
-- primary placement categories
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1022
local cIndex = 1 -- category index
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1023
local cat = 	{
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1024
				"Girder Placement Mode",
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1025
				"Rubber Placement Mode",
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1026
				"Mine Placement Mode",
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1027
				"Sticky Mine Placement Mode",
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1028
				"Barrel Placement Mode",
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1029
				"Weapon Crate Placement Mode",
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1030
				"Utility Crate Placement Mode",
11761
25c6188084c2 Construction Mode: Make weapon crate mode be initial selection in crate tool
Wuzzy <almikes@aol.com>
parents: 11760
diff changeset
  1031
				"Health Crate Placement Mode",
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1032
				"Structure Placement Mode"
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1033
				}
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1034
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1035
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1036
 sProx = 	{
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1037
				{loc("Girder Placement Mode"),false},
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1038
				{loc("Rubber Placement Mode"),false},
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1039
				{loc("Mine Placement Mode"),false},
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1040
				{loc("Sticky Mine Placement Mode"),false},
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1041
				{loc("Barrel Placement Mode"),false},
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1042
				{loc("Weapon Crate Placement Mode"),false},
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1043
				{loc("Utility Crate Placement Mode"),false},
11761
25c6188084c2 Construction Mode: Make weapon crate mode be initial selection in crate tool
Wuzzy <almikes@aol.com>
parents: 11760
diff changeset
  1044
				{loc("Health Crate Placement Mode"),false},
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1045
				{loc("Structure Placement Mode"),false},
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1046
				{loc("Teleportation Mode"),false}
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1047
				}
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1048
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1049
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1050
local pMode = {}	-- pMode contains custom subsets of the main categories
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1051
local pIndex = 1
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1052
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1053
local CGR = 1 -- current girder rotation, we actually need this as HW remembers what rotation you last used
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1054
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1055
local placedX = {}
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1056
local placedY = {}
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1057
local placedSpec = {}
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1058
local placedSuperSpec = {}
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1059
local placedType = {}
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1060
local placedCount = 0
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1061
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1062
local sCirc -- circle that appears around selected gears
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1063
local sGear = nil
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1064
local closestDist
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1065
local closestGear = nil
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1066
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1067
local tCirc = {} -- array of circles that appear around tagged gears
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1068
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1069
------------------------
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1070
-- SOME GENERAL METHODS
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1071
------------------------
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1072
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1073
function GetDistFromGearToXY(gear, g2X, g2Y)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1074
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1075
	g1X, g1Y = GetGearPosition(gear)
12682
b7fd7ab8ddf9 Construction Mode: Fix Lua error spam when using time box with filters on map
Wuzzy <almikes@aol.com>
parents: 12397
diff changeset
  1076
	if not g1X then
b7fd7ab8ddf9 Construction Mode: Fix Lua error spam when using time box with filters on map
Wuzzy <almikes@aol.com>
parents: 12397
diff changeset
  1077
		return nil
b7fd7ab8ddf9 Construction Mode: Fix Lua error spam when using time box with filters on map
Wuzzy <almikes@aol.com>
parents: 12397
diff changeset
  1078
	end
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1079
	q = g1X - g2X
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1080
	w = g1Y - g2Y
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1081
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1082
	return ( (q*q) + (w*w) )
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1083
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1084
end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1085
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1086
function GetDistFromXYtoXY(a, b, c, d)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1087
	q = a - c
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1088
	w = b - d
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1089
	return ( (q*q) + (w*w) )
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1090
end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1091
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1092
function SelectGear(gear)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1093
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1094
	d = GetDistFromGearToXY(gear, placedX[placedCount], placedY[placedCount])
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1095
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1096
	if d < closestDist then
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1097
		closestDist = d
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1098
		closestGear = gear
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1099
	end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1100
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1101
end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1102
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1103
-- essentially called when user clicks the mouse
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1104
-- with girders or an airattack
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1105
function PlaceObject(x,y)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1106
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1107
	placedX[placedCount] = x
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1108
	placedY[placedCount] = y
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1109
	placedType[placedCount] = cat[cIndex]
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1110
	placedSpec[placedCount] = pMode[pIndex]
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1111
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1112
	if (clanUsedExtraTime[GetHogClan(CurrentHedgehog)] == true) and (cat[cIndex] == "Utility Crate Placement Mode") and (utilArray[pIndex][1] == amExtraTime) then
12092
9fe7eb1f7df2 Construction Mode: Turn crate limit into a script parameter
Wuzzy <almikes@aol.com>
parents: 12091
diff changeset
  1113
		AddCaption(loc("You may only place 1 Extra Time crate per turn."),0xffba00ff,capgrpVolume)
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1114
		PlaySound(sndDenied)
12092
9fe7eb1f7df2 Construction Mode: Turn crate limit into a script parameter
Wuzzy <almikes@aol.com>
parents: 12091
diff changeset
  1115
	elseif (conf_cratesPerRound ~= "inf" and clanCratesSpawned[GetHogClan(CurrentHedgehog)] >= conf_cratesPerRound) and ( (cat[cIndex] == "Health Crate Placement Mode") or (cat[cIndex] == "Utility Crate Placement Mode") or (cat[cIndex] == "Weapon Crate Placement Mode")  )  then
9fe7eb1f7df2 Construction Mode: Turn crate limit into a script parameter
Wuzzy <almikes@aol.com>
parents: 12091
diff changeset
  1116
		AddCaption(string.format(loc("You may only place %d crates per round."), conf_cratesPerRound),0xffba00ff,capgrpVolume)
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1117
		PlaySound(sndDenied)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1118
	elseif (XYisInRect(x,y, clanBoundsSX[GetHogClan(CurrentHedgehog)],clanBoundsSY[GetHogClan(CurrentHedgehog)],clanBoundsEX[GetHogClan(CurrentHedgehog)],clanBoundsEY[GetHogClan(CurrentHedgehog)]) == true)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1119
	and (clanPower[GetHogClan(CurrentHedgehog)] >= placedExpense)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1120
	then
12091
db5e12d623cc Contruction Mode: Fix rubber being placable in land and invalid girder placement costing energy
Wuzzy <almikes@aol.com>
parents: 11982
diff changeset
  1121
		-- For checking if the actual placement succeeded
db5e12d623cc Contruction Mode: Fix rubber being placable in land and invalid girder placement costing energy
Wuzzy <almikes@aol.com>
parents: 11982
diff changeset
  1122
		local placed = false
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1123
		if cat[cIndex] == "Girder Placement Mode" then
12091
db5e12d623cc Contruction Mode: Fix rubber being placable in land and invalid girder placement costing energy
Wuzzy <almikes@aol.com>
parents: 11982
diff changeset
  1124
			placed = PlaceGirder(x, y, CGR)
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1125
			placedSpec[placedCount] = CGR
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1126
		elseif cat[cIndex] == "Rubber Placement Mode" then
12091
db5e12d623cc Contruction Mode: Fix rubber being placable in land and invalid girder placement costing energy
Wuzzy <almikes@aol.com>
parents: 11982
diff changeset
  1127
			placed = PlaceRubber(x, y, CGR)
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1128
			placedSpec[placedCount] = CGR
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1129
		elseif cat[cIndex] == "Health Crate Placement Mode" then
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1130
			gear = SpawnHealthCrate(x,y)
12091
db5e12d623cc Contruction Mode: Fix rubber being placable in land and invalid girder placement costing energy
Wuzzy <almikes@aol.com>
parents: 11982
diff changeset
  1131
			if gear ~= nil then
db5e12d623cc Contruction Mode: Fix rubber being placable in land and invalid girder placement costing energy
Wuzzy <almikes@aol.com>
parents: 11982
diff changeset
  1132
				placed = true
db5e12d623cc Contruction Mode: Fix rubber being placable in land and invalid girder placement costing energy
Wuzzy <almikes@aol.com>
parents: 11982
diff changeset
  1133
				SetHealth(gear, pMode[pIndex])
db5e12d623cc Contruction Mode: Fix rubber being placable in land and invalid girder placement costing energy
Wuzzy <almikes@aol.com>
parents: 11982
diff changeset
  1134
				setGearValue(gear,"caseType","med")
db5e12d623cc Contruction Mode: Fix rubber being placable in land and invalid girder placement costing energy
Wuzzy <almikes@aol.com>
parents: 11982
diff changeset
  1135
				clanCratesSpawned[GetHogClan(CurrentHedgehog)] = clanCratesSpawned[GetHogClan(CurrentHedgehog)] +1
db5e12d623cc Contruction Mode: Fix rubber being placable in land and invalid girder placement costing energy
Wuzzy <almikes@aol.com>
parents: 11982
diff changeset
  1136
			end
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1137
		elseif cat[cIndex] == "Weapon Crate Placement Mode" then
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1138
			gear = SpawnAmmoCrate(x, y, atkArray[pIndex][1])
12091
db5e12d623cc Contruction Mode: Fix rubber being placable in land and invalid girder placement costing energy
Wuzzy <almikes@aol.com>
parents: 11982
diff changeset
  1139
			if gear ~= nil then
db5e12d623cc Contruction Mode: Fix rubber being placable in land and invalid girder placement costing energy
Wuzzy <almikes@aol.com>
parents: 11982
diff changeset
  1140
				placed = true
db5e12d623cc Contruction Mode: Fix rubber being placable in land and invalid girder placement costing energy
Wuzzy <almikes@aol.com>
parents: 11982
diff changeset
  1141
				placedSpec[placedCount] = atkArray[pIndex][2]
db5e12d623cc Contruction Mode: Fix rubber being placable in land and invalid girder placement costing energy
Wuzzy <almikes@aol.com>
parents: 11982
diff changeset
  1142
				setGearValue(gear,"caseType","ammo")
db5e12d623cc Contruction Mode: Fix rubber being placable in land and invalid girder placement costing energy
Wuzzy <almikes@aol.com>
parents: 11982
diff changeset
  1143
				setGearValue(gear,"contents",atkArray[pIndex][2])
db5e12d623cc Contruction Mode: Fix rubber being placable in land and invalid girder placement costing energy
Wuzzy <almikes@aol.com>
parents: 11982
diff changeset
  1144
				clanCratesSpawned[GetHogClan(CurrentHedgehog)] = clanCratesSpawned[GetHogClan(CurrentHedgehog)] +1
db5e12d623cc Contruction Mode: Fix rubber being placable in land and invalid girder placement costing energy
Wuzzy <almikes@aol.com>
parents: 11982
diff changeset
  1145
			end
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1146
		elseif cat[cIndex] == "Utility Crate Placement Mode" then
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1147
			gear = SpawnUtilityCrate(x, y, utilArray[pIndex][1])
12091
db5e12d623cc Contruction Mode: Fix rubber being placable in land and invalid girder placement costing energy
Wuzzy <almikes@aol.com>
parents: 11982
diff changeset
  1148
			if gear ~= nil then
db5e12d623cc Contruction Mode: Fix rubber being placable in land and invalid girder placement costing energy
Wuzzy <almikes@aol.com>
parents: 11982
diff changeset
  1149
				placed = true
db5e12d623cc Contruction Mode: Fix rubber being placable in land and invalid girder placement costing energy
Wuzzy <almikes@aol.com>
parents: 11982
diff changeset
  1150
				placedSpec[placedCount] = utilArray[pIndex][2]
db5e12d623cc Contruction Mode: Fix rubber being placable in land and invalid girder placement costing energy
Wuzzy <almikes@aol.com>
parents: 11982
diff changeset
  1151
				setGearValue(gear,"caseType","util")
db5e12d623cc Contruction Mode: Fix rubber being placable in land and invalid girder placement costing energy
Wuzzy <almikes@aol.com>
parents: 11982
diff changeset
  1152
				setGearValue(gear,"contents",utilArray[pIndex][2])
db5e12d623cc Contruction Mode: Fix rubber being placable in land and invalid girder placement costing energy
Wuzzy <almikes@aol.com>
parents: 11982
diff changeset
  1153
				if utilArray[pIndex][1] == amExtraTime then
db5e12d623cc Contruction Mode: Fix rubber being placable in land and invalid girder placement costing energy
Wuzzy <almikes@aol.com>
parents: 11982
diff changeset
  1154
					clanUsedExtraTime[GetHogClan(CurrentHedgehog)] = true
db5e12d623cc Contruction Mode: Fix rubber being placable in land and invalid girder placement costing energy
Wuzzy <almikes@aol.com>
parents: 11982
diff changeset
  1155
				end
db5e12d623cc Contruction Mode: Fix rubber being placable in land and invalid girder placement costing energy
Wuzzy <almikes@aol.com>
parents: 11982
diff changeset
  1156
				clanCratesSpawned[GetHogClan(CurrentHedgehog)] = clanCratesSpawned[GetHogClan(CurrentHedgehog)] +1
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1157
			end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1158
		elseif cat[cIndex] == "Barrel Placement Mode" then
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1159
			gear = AddGear(x, y, gtExplosives, 0, 0, 0, 0)
12091
db5e12d623cc Contruction Mode: Fix rubber being placable in land and invalid girder placement costing energy
Wuzzy <almikes@aol.com>
parents: 11982
diff changeset
  1160
			if gear ~= nil then
db5e12d623cc Contruction Mode: Fix rubber being placable in land and invalid girder placement costing energy
Wuzzy <almikes@aol.com>
parents: 11982
diff changeset
  1161
				placed = true
db5e12d623cc Contruction Mode: Fix rubber being placable in land and invalid girder placement costing energy
Wuzzy <almikes@aol.com>
parents: 11982
diff changeset
  1162
				SetHealth(gear, pMode[pIndex])
db5e12d623cc Contruction Mode: Fix rubber being placable in land and invalid girder placement costing energy
Wuzzy <almikes@aol.com>
parents: 11982
diff changeset
  1163
			end
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1164
		elseif cat[cIndex] == "Mine Placement Mode" then
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1165
			gear = AddGear(x, y, gtMine, 0, 0, 0, 0)
12091
db5e12d623cc Contruction Mode: Fix rubber being placable in land and invalid girder placement costing energy
Wuzzy <almikes@aol.com>
parents: 11982
diff changeset
  1166
			if gear ~= nil then
db5e12d623cc Contruction Mode: Fix rubber being placable in land and invalid girder placement costing energy
Wuzzy <almikes@aol.com>
parents: 11982
diff changeset
  1167
				placed = true
db5e12d623cc Contruction Mode: Fix rubber being placable in land and invalid girder placement costing energy
Wuzzy <almikes@aol.com>
parents: 11982
diff changeset
  1168
				SetTimer(gear, pMode[pIndex])
db5e12d623cc Contruction Mode: Fix rubber being placable in land and invalid girder placement costing energy
Wuzzy <almikes@aol.com>
parents: 11982
diff changeset
  1169
			end
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1170
		elseif cat[cIndex] == "Sticky Mine Placement Mode" then
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1171
			gear = AddGear(x, y, gtSMine, 0, 0, 0, 0)
12091
db5e12d623cc Contruction Mode: Fix rubber being placable in land and invalid girder placement costing energy
Wuzzy <almikes@aol.com>
parents: 11982
diff changeset
  1172
			placed = gear ~= nil
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1173
		elseif cat[cIndex] == "Structure Placement Mode" then
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1174
			AddStruc(x,y, pMode[pIndex],GetHogClan(CurrentHedgehog))
12091
db5e12d623cc Contruction Mode: Fix rubber being placable in land and invalid girder placement costing energy
Wuzzy <almikes@aol.com>
parents: 11982
diff changeset
  1175
			placed = true
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1176
		end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1177
12091
db5e12d623cc Contruction Mode: Fix rubber being placable in land and invalid girder placement costing energy
Wuzzy <almikes@aol.com>
parents: 11982
diff changeset
  1178
		if placed then
db5e12d623cc Contruction Mode: Fix rubber being placable in land and invalid girder placement costing energy
Wuzzy <almikes@aol.com>
parents: 11982
diff changeset
  1179
			clanPower[GetHogClan(CurrentHedgehog)] = clanPower[GetHogClan(CurrentHedgehog)] - placedExpense
db5e12d623cc Contruction Mode: Fix rubber being placable in land and invalid girder placement costing energy
Wuzzy <almikes@aol.com>
parents: 11982
diff changeset
  1180
			placedCount = placedCount + 1
db5e12d623cc Contruction Mode: Fix rubber being placable in land and invalid girder placement costing energy
Wuzzy <almikes@aol.com>
parents: 11982
diff changeset
  1181
		else
db5e12d623cc Contruction Mode: Fix rubber being placable in land and invalid girder placement costing energy
Wuzzy <almikes@aol.com>
parents: 11982
diff changeset
  1182
			AddCaption(loc("Invalid Placement"),0xffba00ff,capgrpVolume)
db5e12d623cc Contruction Mode: Fix rubber being placable in land and invalid girder placement costing energy
Wuzzy <almikes@aol.com>
parents: 11982
diff changeset
  1183
			PlaySound(sndDenied)
db5e12d623cc Contruction Mode: Fix rubber being placable in land and invalid girder placement costing energy
Wuzzy <almikes@aol.com>
parents: 11982
diff changeset
  1184
		end
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1185
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1186
	else
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1187
	    if (clanPower[GetHogClan(CurrentHedgehog)] >= placedExpense) then
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1188
            AddCaption(loc("Invalid Placement"),0xffba00ff,capgrpVolume)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1189
        else
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1190
            AddCaption(loc("Insufficient Power"),0xffba00ff,capgrpVolume)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1191
        end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1192
		PlaySound(sndDenied)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1193
	end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1194
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1195
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1196
end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1197
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1198
-- called when user changes primary selection
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1199
-- either via up/down keys
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1200
-- or selecting girder/airattack
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1201
function RedefineSubset()
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1202
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1203
	pIndex = 1
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1204
	pMode = {}
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1205
	placedExpense = 1
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1206
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1207
	if cat[cIndex] == "Girder Placement Mode" then
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1208
		pIndex = CGR
11712
0a33c3172e6d Mark some forgotten Construction Mode strings for translation
Wuzzy <almikes@aol.com>
parents: 11711
diff changeset
  1209
		pMode = {loc("Girder")}
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1210
	elseif cat[cIndex] == "Rubber Placement Mode" then
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1211
		pIndex = CGR
11712
0a33c3172e6d Mark some forgotten Construction Mode strings for translation
Wuzzy <almikes@aol.com>
parents: 11711
diff changeset
  1212
		pMode = {loc("Rubber")}
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1213
		placedExpense = 3
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1214
	elseif cat[cIndex] == "Barrel Placement Mode" then
11713
106112bbacfa Tweak barrel and mine defaults in Construction Mode
Wuzzy <almikes@aol.com>
parents: 11712
diff changeset
  1215
		pMode = {60}
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1216
		placedExpense = 10
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1217
	elseif cat[cIndex] == "Health Crate Placement Mode" then
11726
4addfad422ab Construction Mode: Recognize health case amount from game scheme
Wuzzy <almikes@aol.com>
parents: 11725
diff changeset
  1218
		pMode = {HealthCaseAmount}
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1219
		placedExpense = 5
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1220
	elseif cat[cIndex] == "Weapon Crate Placement Mode" then
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1221
		for i = 1, #atkArray do
11981
acae870a66b9 Use GetAmmoName in Construction Mode
Wuzzy <almikes@aol.com>
parents: 11942
diff changeset
  1222
			pMode[i] = GetAmmoName(atkArray[i][1])
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1223
		end
11981
acae870a66b9 Use GetAmmoName in Construction Mode
Wuzzy <almikes@aol.com>
parents: 11942
diff changeset
  1224
		placedExpense = atkArray[pIndex][4]
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1225
	elseif cat[cIndex] == "Utility Crate Placement Mode" then
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1226
		for i = 1, #utilArray do
11981
acae870a66b9 Use GetAmmoName in Construction Mode
Wuzzy <almikes@aol.com>
parents: 11942
diff changeset
  1227
			pMode[i] = GetAmmoName(utilArray[i][1])
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1228
		end
11981
acae870a66b9 Use GetAmmoName in Construction Mode
Wuzzy <almikes@aol.com>
parents: 11942
diff changeset
  1229
		placedExpense = utilArray[pIndex][4]
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1230
	elseif cat[cIndex] == "Mine Placement Mode" then
11713
106112bbacfa Tweak barrel and mine defaults in Construction Mode
Wuzzy <almikes@aol.com>
parents: 11712
diff changeset
  1231
		pMode = {0,1000,2000,3000,4000,5000}
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1232
		placedExpense = 15
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1233
	elseif cat[cIndex] == "Sticky Mine Placement Mode" then
11712
0a33c3172e6d Mark some forgotten Construction Mode strings for translation
Wuzzy <almikes@aol.com>
parents: 11711
diff changeset
  1234
		pMode = {loc("Sticky Mine")}
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1235
		placedExpense = 20
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1236
	elseif cat[cIndex] == "Structure Placement Mode" then
12943
3feab46234dd Construction Mode: Sort structure types roughly by importance and convenience
Wuzzy <Wuzzy2@mail.ru>
parents: 12942
diff changeset
  1237
		pMode = {
3feab46234dd Construction Mode: Sort structure types roughly by importance and convenience
Wuzzy <Wuzzy2@mail.ru>
parents: 12942
diff changeset
  1238
			loc("Support Station"),
3feab46234dd Construction Mode: Sort structure types roughly by importance and convenience
Wuzzy <Wuzzy2@mail.ru>
parents: 12942
diff changeset
  1239
			loc("Construction Station"),
3feab46234dd Construction Mode: Sort structure types roughly by importance and convenience
Wuzzy <Wuzzy2@mail.ru>
parents: 12942
diff changeset
  1240
			loc("Healing Station"),
3feab46234dd Construction Mode: Sort structure types roughly by importance and convenience
Wuzzy <Wuzzy2@mail.ru>
parents: 12942
diff changeset
  1241
			loc("Teleportation Node"),
3feab46234dd Construction Mode: Sort structure types roughly by importance and convenience
Wuzzy <Wuzzy2@mail.ru>
parents: 12942
diff changeset
  1242
			loc("Weapon Filter"),
3feab46234dd Construction Mode: Sort structure types roughly by importance and convenience
Wuzzy <Wuzzy2@mail.ru>
parents: 12942
diff changeset
  1243
3feab46234dd Construction Mode: Sort structure types roughly by importance and convenience
Wuzzy <Wuzzy2@mail.ru>
parents: 12942
diff changeset
  1244
			loc("Bio-Filter"),
3feab46234dd Construction Mode: Sort structure types roughly by importance and convenience
Wuzzy <Wuzzy2@mail.ru>
parents: 12942
diff changeset
  1245
			loc("Reflector Shield"),
3feab46234dd Construction Mode: Sort structure types roughly by importance and convenience
Wuzzy <Wuzzy2@mail.ru>
parents: 12942
diff changeset
  1246
			loc("Respawner"),
3feab46234dd Construction Mode: Sort structure types roughly by importance and convenience
Wuzzy <Wuzzy2@mail.ru>
parents: 12942
diff changeset
  1247
			loc("Generator"),
3feab46234dd Construction Mode: Sort structure types roughly by importance and convenience
Wuzzy <Wuzzy2@mail.ru>
parents: 12942
diff changeset
  1248
		}
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1249
	end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1250
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1251
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1252
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1253
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1254
end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1255
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1256
-- called in onGameTick()
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1257
function HandleHedgeEditor()
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1258
11723
456f4e9f9dce Construction Mode: Update structure overlay each tick, thus falling smoothly
Wuzzy <almikes@aol.com>
parents: 11722
diff changeset
  1259
	HandleStructures()
456f4e9f9dce Construction Mode: Update structure overlay each tick, thus falling smoothly
Wuzzy <almikes@aol.com>
parents: 11722
diff changeset
  1260
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1261
	if CurrentHedgehog ~= nil then
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1262
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1263
		if wallsVisible == true then
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1264
			HandleBorderEffects()
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1265
		end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1266
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1267
		if (CurrentHedgehog ~= nil) and (TurnTimeLeft ~= TurnTime) then
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1268
			if (lastWep ~= GetCurAmmoType()) then
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1269
				checkForSpecialWeapons()
11717
f35139700d22 Construction Mode: Disable setting drill strike timer in object placement mode
Wuzzy <almikes@aol.com>
parents: 11716
diff changeset
  1270
			elseif checkForSpecialWeaponsIn == 0 then
f35139700d22 Construction Mode: Disable setting drill strike timer in object placement mode
Wuzzy <almikes@aol.com>
parents: 11716
diff changeset
  1271
				checkForSpecialWeapons()
f35139700d22 Construction Mode: Disable setting drill strike timer in object placement mode
Wuzzy <almikes@aol.com>
parents: 11716
diff changeset
  1272
				checkForSpecialWeaponsIn = -1
f35139700d22 Construction Mode: Disable setting drill strike timer in object placement mode
Wuzzy <almikes@aol.com>
parents: 11716
diff changeset
  1273
			else
f35139700d22 Construction Mode: Disable setting drill strike timer in object placement mode
Wuzzy <almikes@aol.com>
parents: 11716
diff changeset
  1274
				checkForSpecialWeaponsIn = checkForSpecialWeaponsIn - 1
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1275
			end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1276
		end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1277
11727
1c09b8d050ce Construction Mode: Fix timer issues
Wuzzy <almikes@aol.com>
parents: 11726
diff changeset
  1278
		if GameTime % 100 == 0 then
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1279
12836
8610462e3d33 Remove 2 unused number tags in Construction Mode GUI
Wuzzy <Wuzzy2@mail.ru>
parents: 12682
diff changeset
  1280
			DrawClanPowerTag()
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1281
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1282
			curWep = GetCurAmmoType()
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1283
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1284
			-- change to girder mode on weapon swap
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1285
			if (cIndex ~= 1) and (curWep == amGirder) then
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1286
				cIndex = 1
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1287
				RedefineSubset()
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1288
			elseif (cIndex ~=2) and (curWep == amRubber) then
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1289
				cIndex = 2
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1290
				RedefineSubset()
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1291
			-- change to generic mode if girder no longer selected
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1292
			elseif (cIndex == 1) and (curWep ~= amGirder) then
11718
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
  1293
				cIndex = 3
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1294
				RedefineSubset()
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1295
			elseif (cIndex == 2) and (curWep ~= amRubber) then
11718
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
  1296
				cIndex = 3
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1297
				RedefineSubset()
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1298
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1299
			end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1300
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1301
			-- update display selection criteria
12941
ffbd31afed96 HedgeEditor, Construction Mode: Refactor code by adding fake ammo type variables
Wuzzy <Wuzzy2@mail.ru>
parents: 12940
diff changeset
  1302
			if ((curWep == amGirder) or (curWep == amCMStructurePlacer) or (curWep == amCMCratePlacer) or (curWep == amCMObjectPlacer) or (curWep == amRubber))
11760
001994046892 Construction Mode: Don't update ticker for cursor keys when hedgehog is not under control anymore
Wuzzy <almikes@aol.com>
parents: 11759
diff changeset
  1303
				and (CurrentHedgehog ~= nil or band(GetState(CurrentHedgehog), gstHHDriven) ~= 0) then
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1304
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1305
				---------------hooolllllyyyy fucking shit this
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1306
				-- code is a broken mess now
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1307
				-- it was redesigned and compromised three times
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1308
				-- so now it is a mess trying to do what it was
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1309
				-- never designed to do
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1310
				-- needs to be rewritten badly sadface
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1311
				-- this bit here catches the new 3 types of weapons
12941
ffbd31afed96 HedgeEditor, Construction Mode: Refactor code by adding fake ammo type variables
Wuzzy <Wuzzy2@mail.ru>
parents: 12940
diff changeset
  1312
				if ((sProx[cIndex][1] == loc("Structure Placement Mode") and (curWep ~= amCMStructurePlacer))) then
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1313
					updatePlacementDisplay(1)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1314
				elseif (sProx[cIndex][1] == loc("Health Crate Placement Mode")) or
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1315
							(sProx[cIndex][1] == loc("Weapon Crate Placement Mode")) or
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1316
							(sProx[cIndex][1] == loc("Utility Crate Placement Mode")) then
12941
ffbd31afed96 HedgeEditor, Construction Mode: Refactor code by adding fake ammo type variables
Wuzzy <Wuzzy2@mail.ru>
parents: 12940
diff changeset
  1317
								if curWep ~= amCMCratePlacer then
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1318
									updatePlacementDisplay(1)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1319
								end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1320
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1321
				elseif (sProx[cIndex][1] == loc("Mine Placement Mode")) or
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1322
							(sProx[cIndex][1] == loc("Sticky Mine Placement Mode")) or
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1323
							(sProx[cIndex][1] == loc("Barrel Placement Mode")) then
12941
ffbd31afed96 HedgeEditor, Construction Mode: Refactor code by adding fake ammo type variables
Wuzzy <Wuzzy2@mail.ru>
parents: 12940
diff changeset
  1324
								if curWep ~= amCMObjectPlacer then
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1325
									updatePlacementDisplay(1)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1326
								end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1327
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1328
				end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1329
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1330
				--this is called when it happens that we have placement
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1331
				--mode selected and we are looking at something
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1332
				--we shouldn't be allowed to look at, as would be the case
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1333
				--when you WERE allowed to look at it, but then maybe
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1334
				--a bomb blows up the structure that was granting you
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1335
				--that ability
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1336
				if (sProx[cIndex][2] ~= true) then
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1337
					updatePlacementDisplay(1)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1338
				else
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1339
					updateCost()
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1340
				end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1341
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1342
11301
fa18940f290d - Rus localization for following game styles:
antonc27 <antonc27@mail.ru>
parents: 11015
diff changeset
  1343
				AddCaption(loc(cat[cIndex]),0xffba00ff,capgrpMessage)
11714
8575b8b76373 Construction Mode: Show mine timer in seconds
Wuzzy <almikes@aol.com>
parents: 11713
diff changeset
  1344
				showModeMessage()
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1345
				wallsVisible = true
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1346
			else
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1347
				wallsVisible = false
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1348
			end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1349
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1350
		end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1351
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1352
	end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1353
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1354
	-- some kind of target detected, tell me your story
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1355
	if cGear ~= nil then
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1356
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1357
		x,y = GetGearTarget(cGear)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1358
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1359
		if GetGearType(cGear) == gtAirAttack then
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1360
			DeleteGear(cGear)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1361
			PlaceObject(x, y)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1362
		elseif GetGearType(cGear) == gtTeleport then
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1363
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1364
				CheckTeleport(cGear, x, y)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1365
				cGear = nil
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1366
		elseif GetGearType(cGear) == gtGirder then
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1367
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1368
			CGR = GetState(cGear)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1369
11718
f699978eae19 Throw away old out-commented Construction Mode code
Wuzzy <almikes@aol.com>
parents: 11717
diff changeset
  1370
			PlaceObject(x, y)
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1371
		end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1372
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1373
	end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1374
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1375
end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1376
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1377
---------------------------------------------------------------
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1378
-- Cycle through selection subsets (by changing pIndex, pMode)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1379
-- i.e 	health of barrels, medikits,
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1380
--		timer of mines
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1381
--		contents of crates
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1382
--		gears to reposition etc.
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1383
---------------------------------------------------------------
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1384
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1385
function updateCost()
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1386
11760
001994046892 Construction Mode: Don't update ticker for cursor keys when hedgehog is not under control anymore
Wuzzy <almikes@aol.com>
parents: 11759
diff changeset
  1387
	if CurrentHedgehog == nil or band(GetState(CurrentHedgehog), gstHHDriven) == 0 then return end
001994046892 Construction Mode: Don't update ticker for cursor keys when hedgehog is not under control anymore
Wuzzy <almikes@aol.com>
parents: 11759
diff changeset
  1388
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1389
	if pMode[pIndex] == loc("Healing Station") then
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1390
		placedExpense = 50
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1391
	elseif pMode[pIndex] == loc("Weapon Filter") then
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1392
		placedExpense = 50
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1393
	elseif pMode[pIndex] == loc("Bio-Filter") then
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1394
		placedExpense = 100
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1395
	elseif pMode[pIndex] == loc("Respawner") then
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1396
		placedExpense = 300
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1397
	elseif pMode[pIndex] == loc("Teleportation Node") then
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1398
		placedExpense = 30
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1399
	elseif pMode[pIndex] == loc("Support Station") then
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1400
		placedExpense = 50
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1401
	elseif pMode[pIndex] == loc("Construction Station") then
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1402
		placedExpense = 50
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1403
	elseif pMode[pIndex] == loc("Generator") then
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1404
			placedExpense = 300
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1405
	elseif pMode[pIndex] == loc("Reflector Shield") then
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1406
			placedExpense = 200
11708
d5d798172875 Fix crate costs in Construction Mode being all the same (fixes #15)
Wuzzy <almikes@aol.com>
parents: 11301
diff changeset
  1407
	elseif cat[cIndex] == "Weapon Crate Placement Mode" then
11981
acae870a66b9 Use GetAmmoName in Construction Mode
Wuzzy <almikes@aol.com>
parents: 11942
diff changeset
  1408
		placedExpense = atkArray[pIndex][4]
11708
d5d798172875 Fix crate costs in Construction Mode being all the same (fixes #15)
Wuzzy <almikes@aol.com>
parents: 11301
diff changeset
  1409
	elseif cat[cIndex] == "Utility Crate Placement Mode" then
11981
acae870a66b9 Use GetAmmoName in Construction Mode
Wuzzy <almikes@aol.com>
parents: 11942
diff changeset
  1410
		placedExpense = utilArray[pIndex][4]
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1411
	end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1412
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1413
	AddCaption(loc("Cost") .. ": " .. placedExpense,0xffba00ff,capgrpAmmostate)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1414
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1415
end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1416
11717
f35139700d22 Construction Mode: Disable setting drill strike timer in object placement mode
Wuzzy <almikes@aol.com>
parents: 11716
diff changeset
  1417
function onTimer(key)
f35139700d22 Construction Mode: Disable setting drill strike timer in object placement mode
Wuzzy <almikes@aol.com>
parents: 11716
diff changeset
  1418
12942
ca23981ec219 Add a few key shortcuts in Costruction Mode
Wuzzy <Wuzzy2@mail.ru>
parents: 12941
diff changeset
  1419
	-- Hacky workaround for object placer: Since this is based on the drill strike, it
ca23981ec219 Add a few key shortcuts in Costruction Mode
Wuzzy <Wuzzy2@mail.ru>
parents: 12941
diff changeset
  1420
	-- allows the 5 timer keys to be pressed, causing the announcer to show up
ca23981ec219 Add a few key shortcuts in Costruction Mode
Wuzzy <Wuzzy2@mail.ru>
parents: 12941
diff changeset
  1421
	-- This triggers code in 1 tick to send other message to mask the earlier one.
11717
f35139700d22 Construction Mode: Disable setting drill strike timer in object placement mode
Wuzzy <almikes@aol.com>
parents: 11716
diff changeset
  1422
	checkForSpecialWeaponsIn = 1
f35139700d22 Construction Mode: Disable setting drill strike timer in object placement mode
Wuzzy <almikes@aol.com>
parents: 11716
diff changeset
  1423
12942
ca23981ec219 Add a few key shortcuts in Costruction Mode
Wuzzy <Wuzzy2@mail.ru>
parents: 12941
diff changeset
  1424
	if (curWep == amCMStructurePlacer) then
ca23981ec219 Add a few key shortcuts in Costruction Mode
Wuzzy <Wuzzy2@mail.ru>
parents: 12941
diff changeset
  1425
		-- Select structure directly in structure placer
ca23981ec219 Add a few key shortcuts in Costruction Mode
Wuzzy <Wuzzy2@mail.ru>
parents: 12941
diff changeset
  1426
		-- [Timer X] selects structures 1-5
ca23981ec219 Add a few key shortcuts in Costruction Mode
Wuzzy <Wuzzy2@mail.ru>
parents: 12941
diff changeset
  1427
		-- [Precise]+[Timer X] selects structures 6-10
ca23981ec219 Add a few key shortcuts in Costruction Mode
Wuzzy <Wuzzy2@mail.ru>
parents: 12941
diff changeset
  1428
ca23981ec219 Add a few key shortcuts in Costruction Mode
Wuzzy <Wuzzy2@mail.ru>
parents: 12941
diff changeset
  1429
		local structureID = key
ca23981ec219 Add a few key shortcuts in Costruction Mode
Wuzzy <Wuzzy2@mail.ru>
parents: 12941
diff changeset
  1430
		local precise = band(GetGearMessage(CurrentHedgehog), gmPrecise) ~= 0
ca23981ec219 Add a few key shortcuts in Costruction Mode
Wuzzy <Wuzzy2@mail.ru>
parents: 12941
diff changeset
  1431
		if precise then
ca23981ec219 Add a few key shortcuts in Costruction Mode
Wuzzy <Wuzzy2@mail.ru>
parents: 12941
diff changeset
  1432
			structureID = structureID + 5
ca23981ec219 Add a few key shortcuts in Costruction Mode
Wuzzy <Wuzzy2@mail.ru>
parents: 12941
diff changeset
  1433
		end
ca23981ec219 Add a few key shortcuts in Costruction Mode
Wuzzy <Wuzzy2@mail.ru>
parents: 12941
diff changeset
  1434
		-- Check for valid pIndex
ca23981ec219 Add a few key shortcuts in Costruction Mode
Wuzzy <Wuzzy2@mail.ru>
parents: 12941
diff changeset
  1435
		if structureID <= #pMode then
ca23981ec219 Add a few key shortcuts in Costruction Mode
Wuzzy <Wuzzy2@mail.ru>
parents: 12941
diff changeset
  1436
			pIndex = structureID
ca23981ec219 Add a few key shortcuts in Costruction Mode
Wuzzy <Wuzzy2@mail.ru>
parents: 12941
diff changeset
  1437
			showModeMessage()
ca23981ec219 Add a few key shortcuts in Costruction Mode
Wuzzy <Wuzzy2@mail.ru>
parents: 12941
diff changeset
  1438
			updateCost()
ca23981ec219 Add a few key shortcuts in Costruction Mode
Wuzzy <Wuzzy2@mail.ru>
parents: 12941
diff changeset
  1439
		end
ca23981ec219 Add a few key shortcuts in Costruction Mode
Wuzzy <Wuzzy2@mail.ru>
parents: 12941
diff changeset
  1440
	elseif (curWep == amCMObjectPlacer) then
ca23981ec219 Add a few key shortcuts in Costruction Mode
Wuzzy <Wuzzy2@mail.ru>
parents: 12941
diff changeset
  1441
		-- [Timer X]: Set mine time 1-5
ca23981ec219 Add a few key shortcuts in Costruction Mode
Wuzzy <Wuzzy2@mail.ru>
parents: 12941
diff changeset
  1442
		if cat[cIndex] == "Mine Placement Mode" then
ca23981ec219 Add a few key shortcuts in Costruction Mode
Wuzzy <Wuzzy2@mail.ru>
parents: 12941
diff changeset
  1443
			local index = key + 1
ca23981ec219 Add a few key shortcuts in Costruction Mode
Wuzzy <Wuzzy2@mail.ru>
parents: 12941
diff changeset
  1444
			if key <= #pMode then
ca23981ec219 Add a few key shortcuts in Costruction Mode
Wuzzy <Wuzzy2@mail.ru>
parents: 12941
diff changeset
  1445
				pIndex = index
ca23981ec219 Add a few key shortcuts in Costruction Mode
Wuzzy <Wuzzy2@mail.ru>
parents: 12941
diff changeset
  1446
				showModeMessage()
ca23981ec219 Add a few key shortcuts in Costruction Mode
Wuzzy <Wuzzy2@mail.ru>
parents: 12941
diff changeset
  1447
				updateCost()
ca23981ec219 Add a few key shortcuts in Costruction Mode
Wuzzy <Wuzzy2@mail.ru>
parents: 12941
diff changeset
  1448
			end
ca23981ec219 Add a few key shortcuts in Costruction Mode
Wuzzy <Wuzzy2@mail.ru>
parents: 12941
diff changeset
  1449
		end
ca23981ec219 Add a few key shortcuts in Costruction Mode
Wuzzy <Wuzzy2@mail.ru>
parents: 12941
diff changeset
  1450
	end
ca23981ec219 Add a few key shortcuts in Costruction Mode
Wuzzy <Wuzzy2@mail.ru>
parents: 12941
diff changeset
  1451
ca23981ec219 Add a few key shortcuts in Costruction Mode
Wuzzy <Wuzzy2@mail.ru>
parents: 12941
diff changeset
  1452
end
ca23981ec219 Add a few key shortcuts in Costruction Mode
Wuzzy <Wuzzy2@mail.ru>
parents: 12941
diff changeset
  1453
ca23981ec219 Add a few key shortcuts in Costruction Mode
Wuzzy <Wuzzy2@mail.ru>
parents: 12941
diff changeset
  1454
function onSwitch()
ca23981ec219 Add a few key shortcuts in Costruction Mode
Wuzzy <Wuzzy2@mail.ru>
parents: 12941
diff changeset
  1455
	if (curWep == amCMObjectPlacer) then
ca23981ec219 Add a few key shortcuts in Costruction Mode
Wuzzy <Wuzzy2@mail.ru>
parents: 12941
diff changeset
  1456
		-- [Switch]: Set mine time to 0
ca23981ec219 Add a few key shortcuts in Costruction Mode
Wuzzy <Wuzzy2@mail.ru>
parents: 12941
diff changeset
  1457
		pIndex = 1
ca23981ec219 Add a few key shortcuts in Costruction Mode
Wuzzy <Wuzzy2@mail.ru>
parents: 12941
diff changeset
  1458
		showModeMessage()
ca23981ec219 Add a few key shortcuts in Costruction Mode
Wuzzy <Wuzzy2@mail.ru>
parents: 12941
diff changeset
  1459
		updateCost()
ca23981ec219 Add a few key shortcuts in Costruction Mode
Wuzzy <Wuzzy2@mail.ru>
parents: 12941
diff changeset
  1460
	end
11717
f35139700d22 Construction Mode: Disable setting drill strike timer in object placement mode
Wuzzy <almikes@aol.com>
parents: 11716
diff changeset
  1461
end
f35139700d22 Construction Mode: Disable setting drill strike timer in object placement mode
Wuzzy <almikes@aol.com>
parents: 11716
diff changeset
  1462
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1463
function onLeft()
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1464
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1465
	pIndex = pIndex - 1
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1466
	if pIndex == 0 then
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1467
		pIndex = #pMode
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1468
	end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1469
12941
ffbd31afed96 HedgeEditor, Construction Mode: Refactor code by adding fake ammo type variables
Wuzzy <Wuzzy2@mail.ru>
parents: 12940
diff changeset
  1470
	if (curWep == amGirder) or (curWep == amCMStructurePlacer) or (curWep == amCMCratePlacer) or (curWep == amCMObjectPlacer) then
11714
8575b8b76373 Construction Mode: Show mine timer in seconds
Wuzzy <almikes@aol.com>
parents: 11713
diff changeset
  1471
		showModeMessage()
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1472
		updateCost()
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1473
	end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1474
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1475
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1476
end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1477
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1478
function onRight()
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1479
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1480
	pIndex = pIndex + 1
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1481
	if pIndex > #pMode then
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1482
		pIndex = 1
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1483
	end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1484
12941
ffbd31afed96 HedgeEditor, Construction Mode: Refactor code by adding fake ammo type variables
Wuzzy <Wuzzy2@mail.ru>
parents: 12940
diff changeset
  1485
	if (curWep == amGirder) or (curWep == amCMStructurePlacer) or (curWep == amCMCratePlacer) or (curWep == amCMObjectPlacer) then
11714
8575b8b76373 Construction Mode: Show mine timer in seconds
Wuzzy <almikes@aol.com>
parents: 11713
diff changeset
  1486
		showModeMessage()
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1487
		updateCost()
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1488
	end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1489
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1490
end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1491
11730
8cc9c8a43dcc Construction Mode: Fix Girder/Rubber mode sometimes show nil
Wuzzy <almikes@aol.com>
parents: 11729
diff changeset
  1492
function showModeMessage()
11760
001994046892 Construction Mode: Don't update ticker for cursor keys when hedgehog is not under control anymore
Wuzzy <almikes@aol.com>
parents: 11759
diff changeset
  1493
	if CurrentHedgehog == nil or band(GetState(CurrentHedgehog), gstHHDriven) == 0 then return end
11730
8cc9c8a43dcc Construction Mode: Fix Girder/Rubber mode sometimes show nil
Wuzzy <almikes@aol.com>
parents: 11729
diff changeset
  1494
	local val = pMode[pIndex]
8cc9c8a43dcc Construction Mode: Fix Girder/Rubber mode sometimes show nil
Wuzzy <almikes@aol.com>
parents: 11729
diff changeset
  1495
	local str
8cc9c8a43dcc Construction Mode: Fix Girder/Rubber mode sometimes show nil
Wuzzy <almikes@aol.com>
parents: 11729
diff changeset
  1496
	if cat[cIndex] == "Mine Placement Mode" then
8cc9c8a43dcc Construction Mode: Fix Girder/Rubber mode sometimes show nil
Wuzzy <almikes@aol.com>
parents: 11729
diff changeset
  1497
		-- timer in seconds
8cc9c8a43dcc Construction Mode: Fix Girder/Rubber mode sometimes show nil
Wuzzy <almikes@aol.com>
parents: 11729
diff changeset
  1498
		str = string.format(loc("%d sec"), div(val, 1000))
8cc9c8a43dcc Construction Mode: Fix Girder/Rubber mode sometimes show nil
Wuzzy <almikes@aol.com>
parents: 11729
diff changeset
  1499
	elseif cat[cIndex] == "Girder Placement Mode" then
8cc9c8a43dcc Construction Mode: Fix Girder/Rubber mode sometimes show nil
Wuzzy <almikes@aol.com>
parents: 11729
diff changeset
  1500
		str = loc("Girder")
8cc9c8a43dcc Construction Mode: Fix Girder/Rubber mode sometimes show nil
Wuzzy <almikes@aol.com>
parents: 11729
diff changeset
  1501
	elseif cat[cIndex] == "Rubber Placement Mode" then
8cc9c8a43dcc Construction Mode: Fix Girder/Rubber mode sometimes show nil
Wuzzy <almikes@aol.com>
parents: 11729
diff changeset
  1502
		str = loc("Rubber")
8cc9c8a43dcc Construction Mode: Fix Girder/Rubber mode sometimes show nil
Wuzzy <almikes@aol.com>
parents: 11729
diff changeset
  1503
	else
8cc9c8a43dcc Construction Mode: Fix Girder/Rubber mode sometimes show nil
Wuzzy <almikes@aol.com>
parents: 11729
diff changeset
  1504
		str = tostring(val)
8cc9c8a43dcc Construction Mode: Fix Girder/Rubber mode sometimes show nil
Wuzzy <almikes@aol.com>
parents: 11729
diff changeset
  1505
	end
8cc9c8a43dcc Construction Mode: Fix Girder/Rubber mode sometimes show nil
Wuzzy <almikes@aol.com>
parents: 11729
diff changeset
  1506
	AddCaption(str,0xffba00ff,capgrpMessage2)
8cc9c8a43dcc Construction Mode: Fix Girder/Rubber mode sometimes show nil
Wuzzy <almikes@aol.com>
parents: 11729
diff changeset
  1507
end
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1508
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1509
function updatePlacementDisplay(pDir)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1510
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1511
	foundMatch = false
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1512
	while(foundMatch == false) do
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1513
		cIndex = cIndex + pDir
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1514
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1515
		if (cIndex == 1) or (cIndex == 2) then --1	--we no longer hit girder by normal means
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1516
			cIndex = #cat
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1517
		elseif cIndex > #cat then
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1518
			cIndex = 3	 -- 2 ----we no longer hit girder by normal means
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1519
		end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1520
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1521
		if sProx[cIndex][2] == true then
12941
ffbd31afed96 HedgeEditor, Construction Mode: Refactor code by adding fake ammo type variables
Wuzzy <Wuzzy2@mail.ru>
parents: 12940
diff changeset
  1522
			if (GetCurAmmoType() == amCMCratePlacer) then
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1523
				if (sProx[cIndex][1] == loc("Health Crate Placement Mode")) or
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1524
					(sProx[cIndex][1] == loc("Weapon Crate Placement Mode")) or
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1525
					(sProx[cIndex][1] == loc("Utility Crate Placement Mode"))
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1526
					then
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1527
						foundMatch = true
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1528
					end
12941
ffbd31afed96 HedgeEditor, Construction Mode: Refactor code by adding fake ammo type variables
Wuzzy <Wuzzy2@mail.ru>
parents: 12940
diff changeset
  1529
			elseif (GetCurAmmoType() == amCMObjectPlacer) then
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1530
				if (sProx[cIndex][1] == loc("Mine Placement Mode")) or
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1531
					(sProx[cIndex][1] == loc("Sticky Mine Placement Mode")) or
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1532
					(sProx[cIndex][1] == loc("Barrel Placement Mode"))
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1533
					then
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1534
						foundMatch = true
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1535
					end
12941
ffbd31afed96 HedgeEditor, Construction Mode: Refactor code by adding fake ammo type variables
Wuzzy <Wuzzy2@mail.ru>
parents: 12940
diff changeset
  1536
			elseif (GetCurAmmoType() == amCMStructurePlacer) then
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1537
				if sProx[cIndex][1] == loc("Structure Placement Mode") then
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1538
					foundMatch = true
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1539
				end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1540
			end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1541
		end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1542
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1543
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1544
		if foundMatch == true then
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1545
			RedefineSubset()
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1546
			updateCost()
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1547
		end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1548
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1549
	end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1550
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1551
end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1552
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1553
---------------------------------------------------------
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1554
-- Cycle through primary categories (by changing cIndex)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1555
-- i.e 	mine, sticky mine, barrels
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1556
--		health/weapon/utility crate, placement of gears
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1557
---------------------------------------------------------
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1558
function onUp()
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1559
12941
ffbd31afed96 HedgeEditor, Construction Mode: Refactor code by adding fake ammo type variables
Wuzzy <Wuzzy2@mail.ru>
parents: 12940
diff changeset
  1560
	if ( (curWep == amCMCratePlacer) or (curWep == amCMObjectPlacer) ) then
11760
001994046892 Construction Mode: Don't update ticker for cursor keys when hedgehog is not under control anymore
Wuzzy <almikes@aol.com>
parents: 11759
diff changeset
  1561
		if CurrentHedgehog ~= nil or band(GetState(CurrentHedgehog), gstHHDriven) ~= 0 then
001994046892 Construction Mode: Don't update ticker for cursor keys when hedgehog is not under control anymore
Wuzzy <almikes@aol.com>
parents: 11759
diff changeset
  1562
			updatePlacementDisplay(-1)
001994046892 Construction Mode: Don't update ticker for cursor keys when hedgehog is not under control anymore
Wuzzy <almikes@aol.com>
parents: 11759
diff changeset
  1563
		end
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1564
	end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1565
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1566
end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1567
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1568
function onDown()
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1569
12941
ffbd31afed96 HedgeEditor, Construction Mode: Refactor code by adding fake ammo type variables
Wuzzy <Wuzzy2@mail.ru>
parents: 12940
diff changeset
  1570
	if ( (curWep == amCMCratePlacer) or (curWep == amCMObjectPlacer) ) then
11760
001994046892 Construction Mode: Don't update ticker for cursor keys when hedgehog is not under control anymore
Wuzzy <almikes@aol.com>
parents: 11759
diff changeset
  1571
		if CurrentHedgehog ~= nil or band(GetState(CurrentHedgehog), gstHHDriven) ~= 0 then
001994046892 Construction Mode: Don't update ticker for cursor keys when hedgehog is not under control anymore
Wuzzy <almikes@aol.com>
parents: 11759
diff changeset
  1572
			updatePlacementDisplay(1)
001994046892 Construction Mode: Don't update ticker for cursor keys when hedgehog is not under control anymore
Wuzzy <almikes@aol.com>
parents: 11759
diff changeset
  1573
		end
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1574
	end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1575
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1576
end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1577
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1578
----------------------------
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1579
-- standard event handlers
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1580
----------------------------
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1581
11720
5cb2f245ee2f Add script parameter support to Construction Mode
Wuzzy <almikes@aol.com>
parents: 11719
diff changeset
  1582
-- Parses a positive integer
12092
9fe7eb1f7df2 Construction Mode: Turn crate limit into a script parameter
Wuzzy <almikes@aol.com>
parents: 12091
diff changeset
  1583
function parseInt(str, default, infinityPermitted)
9fe7eb1f7df2 Construction Mode: Turn crate limit into a script parameter
Wuzzy <almikes@aol.com>
parents: 12091
diff changeset
  1584
	if str == "inf" and infinityPermitted then
9fe7eb1f7df2 Construction Mode: Turn crate limit into a script parameter
Wuzzy <almikes@aol.com>
parents: 12091
diff changeset
  1585
		return "inf"
9fe7eb1f7df2 Construction Mode: Turn crate limit into a script parameter
Wuzzy <almikes@aol.com>
parents: 12091
diff changeset
  1586
	end
11720
5cb2f245ee2f Add script parameter support to Construction Mode
Wuzzy <almikes@aol.com>
parents: 11719
diff changeset
  1587
	if str == nil then return default end
5cb2f245ee2f Add script parameter support to Construction Mode
Wuzzy <almikes@aol.com>
parents: 11719
diff changeset
  1588
	local s = string.match(str, "(%d*)")
5cb2f245ee2f Add script parameter support to Construction Mode
Wuzzy <almikes@aol.com>
parents: 11719
diff changeset
  1589
	if s ~= nil then
11728
373150be0356 Construction Mode: Sanity-check numbers from script parameter
Wuzzy <almikes@aol.com>
parents: 11727
diff changeset
  1590
		return math.min(4294967295, math.max(0, tonumber(s)))
11720
5cb2f245ee2f Add script parameter support to Construction Mode
Wuzzy <almikes@aol.com>
parents: 11719
diff changeset
  1591
	else
5cb2f245ee2f Add script parameter support to Construction Mode
Wuzzy <almikes@aol.com>
parents: 11719
diff changeset
  1592
		return nil
5cb2f245ee2f Add script parameter support to Construction Mode
Wuzzy <almikes@aol.com>
parents: 11719
diff changeset
  1593
	end
5cb2f245ee2f Add script parameter support to Construction Mode
Wuzzy <almikes@aol.com>
parents: 11719
diff changeset
  1594
end
5cb2f245ee2f Add script parameter support to Construction Mode
Wuzzy <almikes@aol.com>
parents: 11719
diff changeset
  1595
5cb2f245ee2f Add script parameter support to Construction Mode
Wuzzy <almikes@aol.com>
parents: 11719
diff changeset
  1596
-- Parse parameters
5cb2f245ee2f Add script parameter support to Construction Mode
Wuzzy <almikes@aol.com>
parents: 11719
diff changeset
  1597
function onParameters()
5cb2f245ee2f Add script parameter support to Construction Mode
Wuzzy <almikes@aol.com>
parents: 11719
diff changeset
  1598
	parseParams()
5cb2f245ee2f Add script parameter support to Construction Mode
Wuzzy <almikes@aol.com>
parents: 11719
diff changeset
  1599
	conf_initialEnergy = parseInt(params["initialenergy"], conf_initialEnergy)
5cb2f245ee2f Add script parameter support to Construction Mode
Wuzzy <almikes@aol.com>
parents: 11719
diff changeset
  1600
	conf_energyPerRound = parseInt(params["energyperround"], conf_energyPerRound)
12092
9fe7eb1f7df2 Construction Mode: Turn crate limit into a script parameter
Wuzzy <almikes@aol.com>
parents: 12091
diff changeset
  1601
	conf_maxEnergy = parseInt(params["maxenergy"], conf_maxEnergy, true)
9fe7eb1f7df2 Construction Mode: Turn crate limit into a script parameter
Wuzzy <almikes@aol.com>
parents: 12091
diff changeset
  1602
	conf_cratesPerRound = parseInt(params["cratesperround"], conf_cratesPerRound, true)
11720
5cb2f245ee2f Add script parameter support to Construction Mode
Wuzzy <almikes@aol.com>
parents: 11719
diff changeset
  1603
end
5cb2f245ee2f Add script parameter support to Construction Mode
Wuzzy <almikes@aol.com>
parents: 11719
diff changeset
  1604
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1605
function onGameInit()
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1606
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1607
	Explosives = 0
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1608
	MinesNum = 0
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1609
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1610
	EnableGameFlags(gfInfAttack)
12093
0d6e0ed36c9e Construction Mode: Fix free girder/rubber placement near hog
Wuzzy <almikes@aol.com>
parents: 12092
diff changeset
  1611
	-- This is a hack to make sure all girder/rubber placement is handled by Construction Mode to overwrite the default behaviour
0d6e0ed36c9e Construction Mode: Fix free girder/rubber placement near hog
Wuzzy <almikes@aol.com>
parents: 12092
diff changeset
  1612
	SetMaxBuildDistance(1)
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1613
11881
34ede05e4d4f Remove old Fort Mode from frontend
Wuzzy <almikes@aol.com>
parents: 11762
diff changeset
  1614
	fortMode = MapGen == mgForts
11733
67049c8dedd1 make construction mode work with fort mode without mixing up clans and forts
sheepluva
parents: 11732
diff changeset
  1615
67049c8dedd1 make construction mode work with fort mode without mixing up clans and forts
sheepluva
parents: 11732
diff changeset
  1616
	-- if there are forts, let engine place the hogs on them
67049c8dedd1 make construction mode work with fort mode without mixing up clans and forts
sheepluva
parents: 11732
diff changeset
  1617
	if fortMode then
67049c8dedd1 make construction mode work with fort mode without mixing up clans and forts
sheepluva
parents: 11732
diff changeset
  1618
		EnableGameFlags(gfDivideTeams)
67049c8dedd1 make construction mode work with fort mode without mixing up clans and forts
sheepluva
parents: 11732
diff changeset
  1619
	end
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1620
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1621
	RedefineSubset()
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1622
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1623
end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1624
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1625
function initialSetup(gear)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1626
11733
67049c8dedd1 make construction mode work with fort mode without mixing up clans and forts
sheepluva
parents: 11732
diff changeset
  1627
	-- engine already placed hogs in fort mode
67049c8dedd1 make construction mode work with fort mode without mixing up clans and forts
sheepluva
parents: 11732
diff changeset
  1628
	if not fortMode then
67049c8dedd1 make construction mode work with fort mode without mixing up clans and forts
sheepluva
parents: 11732
diff changeset
  1629
		FindPlace(gear, false, clanBoundsSX[GetHogClan(gear)], clanBoundsEX[GetHogClan(gear)],true)
67049c8dedd1 make construction mode work with fort mode without mixing up clans and forts
sheepluva
parents: 11732
diff changeset
  1630
	end
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1631
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1632
	-- for now, everyone should have this stuff
12941
ffbd31afed96 HedgeEditor, Construction Mode: Refactor code by adding fake ammo type variables
Wuzzy <Wuzzy2@mail.ru>
parents: 12940
diff changeset
  1633
	AddAmmo(gear, amCMStructurePlacer, 100)
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1634
	AddAmmo(gear, amSwitch, 100)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1635
	AddAmmo(gear, amSkip, 100)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1636
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1637
end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1638
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1639
function onGameStart()
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1640
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1641
	trackTeams()
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1642
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1643
	ShowMission	(
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1644
				loc("CONSTRUCTION MODE"),
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1645
				loc("a Hedgewars mini-game"),
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1646
				loc("Build a fortress and destroy your enemy.") .. "|" ..
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1647
				loc("There are a variety of structures available to aid you.") .. "|" ..
11942
abdb24f0c2d9 Change descriptions for special Construction Mode tools
Wuzzy <almikes@aol.com>
parents: 11881
diff changeset
  1648
				loc("Use the structure placer to place structures.")
11725
3444792e8ebe Construction Mode: Remove 2 useless blank lines in mission panel
Wuzzy <almikes@aol.com>
parents: 11724
diff changeset
  1649
				, 4, 5000
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1650
				)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1651
12941
ffbd31afed96 HedgeEditor, Construction Mode: Refactor code by adding fake ammo type variables
Wuzzy <Wuzzy2@mail.ru>
parents: 12940
diff changeset
  1652
	SetAmmoTexts(amCMStructurePlacer, loc("Structure Placer"), loc("Construction Mode tool"), loc("Build one of multiple different structures|to aid you in victory, at the cost of energy.") .. "| |" ..
12943
3feab46234dd Construction Mode: Sort structure types roughly by importance and convenience
Wuzzy <Wuzzy2@mail.ru>
parents: 12942
diff changeset
  1653
	loc("Support Station: Allows placement of crates.") .. "|"..
3feab46234dd Construction Mode: Sort structure types roughly by importance and convenience
Wuzzy <Wuzzy2@mail.ru>
parents: 12942
diff changeset
  1654
	loc("Construction Station: Allows placement of|    girders, rubber, mines, sticky mines|    and barrels.")  .. "|" ..
11942
abdb24f0c2d9 Change descriptions for special Construction Mode tools
Wuzzy <almikes@aol.com>
parents: 11881
diff changeset
  1655
	loc("Healing Station: Heals nearby hogs.")  .. "|" ..
12943
3feab46234dd Construction Mode: Sort structure types roughly by importance and convenience
Wuzzy <Wuzzy2@mail.ru>
parents: 12942
diff changeset
  1656
	loc("Teleportation Node: Allows teleportation|    between other nodes.")  .. "|" ..
3feab46234dd Construction Mode: Sort structure types roughly by importance and convenience
Wuzzy <Wuzzy2@mail.ru>
parents: 12942
diff changeset
  1657
	loc("Weapon Filter: Dematerializes all ammo|    carried by enemies entering it.")  .. "|" ..
11942
abdb24f0c2d9 Change descriptions for special Construction Mode tools
Wuzzy <almikes@aol.com>
parents: 11881
diff changeset
  1658
	loc("Bio-Filter: Aggressively removes enemies.")  .. "|" ..
abdb24f0c2d9 Change descriptions for special Construction Mode tools
Wuzzy <almikes@aol.com>
parents: 11881
diff changeset
  1659
	loc("Reflector Shield: Reflects enemy projectiles.")  .. "|" ..
abdb24f0c2d9 Change descriptions for special Construction Mode tools
Wuzzy <almikes@aol.com>
parents: 11881
diff changeset
  1660
	loc("Respawner: Resurrects dead hogs.")  .. "|" ..
12942
ca23981ec219 Add a few key shortcuts in Costruction Mode
Wuzzy <Wuzzy2@mail.ru>
parents: 12941
diff changeset
  1661
	loc("Generator: Generates energy.")  .. "|" ..
12943
3feab46234dd Construction Mode: Sort structure types roughly by importance and convenience
Wuzzy <Wuzzy2@mail.ru>
parents: 12942
diff changeset
  1662
	" |" ..
11942
abdb24f0c2d9 Change descriptions for special Construction Mode tools
Wuzzy <almikes@aol.com>
parents: 11881
diff changeset
  1663
12942
ca23981ec219 Add a few key shortcuts in Costruction Mode
Wuzzy <Wuzzy2@mail.ru>
parents: 12941
diff changeset
  1664
	loc("Left/right: Choose structure type").."|"..
ca23981ec219 Add a few key shortcuts in Costruction Mode
Wuzzy <Wuzzy2@mail.ru>
parents: 12941
diff changeset
  1665
	loc("1-5, Precise + 1-4: Choose structure type").."|"..
ca23981ec219 Add a few key shortcuts in Costruction Mode
Wuzzy <Wuzzy2@mail.ru>
parents: 12941
diff changeset
  1666
	loc("Cursor: Build structure"))
11942
abdb24f0c2d9 Change descriptions for special Construction Mode tools
Wuzzy <almikes@aol.com>
parents: 11881
diff changeset
  1667
12092
9fe7eb1f7df2 Construction Mode: Turn crate limit into a script parameter
Wuzzy <almikes@aol.com>
parents: 12091
diff changeset
  1668
	local txt_crateLimit = ""
9fe7eb1f7df2 Construction Mode: Turn crate limit into a script parameter
Wuzzy <almikes@aol.com>
parents: 12091
diff changeset
  1669
	if conf_cratesPerRound ~= "inf" then
9fe7eb1f7df2 Construction Mode: Turn crate limit into a script parameter
Wuzzy <almikes@aol.com>
parents: 12091
diff changeset
  1670
		txt_crateLimit = string.format(loc("You may only place %d crates per round."), conf_cratesPerRound) .. "|"
9fe7eb1f7df2 Construction Mode: Turn crate limit into a script parameter
Wuzzy <almikes@aol.com>
parents: 12091
diff changeset
  1671
	end
9fe7eb1f7df2 Construction Mode: Turn crate limit into a script parameter
Wuzzy <almikes@aol.com>
parents: 12091
diff changeset
  1672
12941
ffbd31afed96 HedgeEditor, Construction Mode: Refactor code by adding fake ammo type variables
Wuzzy <Wuzzy2@mail.ru>
parents: 12940
diff changeset
  1673
	SetAmmoTexts(amCMCratePlacer, loc("Crate Placer"), loc("Construction Mode tool"),
12092
9fe7eb1f7df2 Construction Mode: Turn crate limit into a script parameter
Wuzzy <almikes@aol.com>
parents: 12091
diff changeset
  1674
		loc("This allows you to create a crate anywhere|within your clan's area of influence,|at the cost of energy.") .. "|" ..
9fe7eb1f7df2 Construction Mode: Turn crate limit into a script parameter
Wuzzy <almikes@aol.com>
parents: 12091
diff changeset
  1675
		txt_crateLimit ..
12943
3feab46234dd Construction Mode: Sort structure types roughly by importance and convenience
Wuzzy <Wuzzy2@mail.ru>
parents: 12942
diff changeset
  1676
		loc("Up/down: Choose crate type") .. "|" ..
12092
9fe7eb1f7df2 Construction Mode: Turn crate limit into a script parameter
Wuzzy <almikes@aol.com>
parents: 12091
diff changeset
  1677
		loc("Left/right: Choose crate contents") .. "|" ..
9fe7eb1f7df2 Construction Mode: Turn crate limit into a script parameter
Wuzzy <almikes@aol.com>
parents: 12091
diff changeset
  1678
		loc("|Cursor: Place crate"))
12942
ca23981ec219 Add a few key shortcuts in Costruction Mode
Wuzzy <Wuzzy2@mail.ru>
parents: 12941
diff changeset
  1679
	SetAmmoTexts(amCMObjectPlacer, loc("Object Placer"), loc("Construction Mode tool"),
ca23981ec219 Add a few key shortcuts in Costruction Mode
Wuzzy <Wuzzy2@mail.ru>
parents: 12941
diff changeset
  1680
		loc("This allows you to create and place mines,|sticky mines and barrels anywhere within your|clan's area of influence at the cost of energy.").."|"..
ca23981ec219 Add a few key shortcuts in Costruction Mode
Wuzzy <Wuzzy2@mail.ru>
parents: 12941
diff changeset
  1681
		loc("Up/down: Choose object type|1-5/Switch/Left/Right: Choose mine timer|Cursor: Place object")
ca23981ec219 Add a few key shortcuts in Costruction Mode
Wuzzy <Wuzzy2@mail.ru>
parents: 12941
diff changeset
  1682
	)
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1683
12336
fbc268170015 Construction Mode: Mention teleportation restriction in tooltip
Wuzzy <almikes@aol.com>
parents: 12214
diff changeset
  1684
	SetAmmoDescriptionAppendix(amTeleport, loc("It only works in teleportation nodes of your own clan."))
fbc268170015 Construction Mode: Mention teleportation restriction in tooltip
Wuzzy <almikes@aol.com>
parents: 12214
diff changeset
  1685
	
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1686
	sCirc = AddVisualGear(0,0,vgtCircle,0,true)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1687
	SetVisualGearValues(sCirc, 0, 0, 100, 255, 1, 10, 0, 40, 3, 0x00000000)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1688
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1689
	for i = 0, ClansCount-1 do
11982
6f4b96669f9d Fix Construction Mode screwing up when initialenergy > maxenergy
Wuzzy <almikes@aol.com>
parents: 11981
diff changeset
  1690
		clanPower[i] = math.min(conf_initialEnergy, conf_maxEnergy)
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1691
		clanLWepIndex[i] = 1 -- for ease of use let's track this stuff
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1692
		clanLUtilIndex[i] = 1
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1693
		clanLGearIndex[i] = 1
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1694
		clanUsedExtraTime[i] = false
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1695
		clanCratesSpawned[i] = 0
11721
8c1a30d4cbc8 Construction Mode: Fix giving round energy boost at first round
Wuzzy <almikes@aol.com>
parents: 11720
diff changeset
  1696
		clanFirstTurn[i] = true
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1697
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1698
	end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1699
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1700
	tMapWidth = RightX - LeftX
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1701
	tMapHeight = WaterLine - TopY
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1702
	clanInterval = div(tMapWidth,ClansCount)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1703
11733
67049c8dedd1 make construction mode work with fort mode without mixing up clans and forts
sheepluva
parents: 11732
diff changeset
  1704
	-- define construction areas for each clan
67049c8dedd1 make construction mode work with fort mode without mixing up clans and forts
sheepluva
parents: 11732
diff changeset
  1705
	-- if there are forts-based spawn locations, adjust areas around them
67049c8dedd1 make construction mode work with fort mode without mixing up clans and forts
sheepluva
parents: 11732
diff changeset
  1706
	for i = 0, ClansCount-1 do
67049c8dedd1 make construction mode work with fort mode without mixing up clans and forts
sheepluva
parents: 11732
diff changeset
  1707
		local slot
67049c8dedd1 make construction mode work with fort mode without mixing up clans and forts
sheepluva
parents: 11732
diff changeset
  1708
		if fortMode then
67049c8dedd1 make construction mode work with fort mode without mixing up clans and forts
sheepluva
parents: 11732
diff changeset
  1709
			slot = div(GetX(getFirstHogOfClan(i))-LeftX,clanInterval)
67049c8dedd1 make construction mode work with fort mode without mixing up clans and forts
sheepluva
parents: 11732
diff changeset
  1710
		else
67049c8dedd1 make construction mode work with fort mode without mixing up clans and forts
sheepluva
parents: 11732
diff changeset
  1711
			slot = i
67049c8dedd1 make construction mode work with fort mode without mixing up clans and forts
sheepluva
parents: 11732
diff changeset
  1712
		end
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1713
11733
67049c8dedd1 make construction mode work with fort mode without mixing up clans and forts
sheepluva
parents: 11732
diff changeset
  1714
		local color = GetClanColor(i)
67049c8dedd1 make construction mode work with fort mode without mixing up clans and forts
sheepluva
parents: 11732
diff changeset
  1715
67049c8dedd1 make construction mode work with fort mode without mixing up clans and forts
sheepluva
parents: 11732
diff changeset
  1716
		clanBoundsSX[i] = LeftX+(clanInterval*slot)+20
67049c8dedd1 make construction mode work with fort mode without mixing up clans and forts
sheepluva
parents: 11732
diff changeset
  1717
		clanBoundsSY[i] = TopY
67049c8dedd1 make construction mode work with fort mode without mixing up clans and forts
sheepluva
parents: 11732
diff changeset
  1718
		clanBoundsEX[i] = LeftX+(clanInterval*slot)+clanInterval-20
67049c8dedd1 make construction mode work with fort mode without mixing up clans and forts
sheepluva
parents: 11732
diff changeset
  1719
		clanBoundsEY[i] = WaterLine
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1720
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1721
		--top and bottom
11733
67049c8dedd1 make construction mode work with fort mode without mixing up clans and forts
sheepluva
parents: 11732
diff changeset
  1722
		AddWall(LeftX+(clanInterval*slot),TopY,clanInterval,margin,color)
67049c8dedd1 make construction mode work with fort mode without mixing up clans and forts
sheepluva
parents: 11732
diff changeset
  1723
		AddWall(LeftX+(clanInterval*slot),WaterLine-25,clanInterval,margin,color)
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1724
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1725
		--add a wall to the left and right
11733
67049c8dedd1 make construction mode work with fort mode without mixing up clans and forts
sheepluva
parents: 11732
diff changeset
  1726
		AddWall(LeftX+(clanInterval*slot)+20,TopY,margin,WaterLine,color)
67049c8dedd1 make construction mode work with fort mode without mixing up clans and forts
sheepluva
parents: 11732
diff changeset
  1727
		AddWall(LeftX+(clanInterval*slot)+clanInterval-20,TopY,margin,WaterLine,color)
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1728
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1729
	end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1730
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1731
	runOnHogs(initialSetup)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1732
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1733
end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1734
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1735
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1736
function onNewTurn()
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1737
11720
5cb2f245ee2f Add script parameter support to Construction Mode
Wuzzy <almikes@aol.com>
parents: 11719
diff changeset
  1738
	local clan = GetHogClan(CurrentHedgehog)
11721
8c1a30d4cbc8 Construction Mode: Fix giving round energy boost at first round
Wuzzy <almikes@aol.com>
parents: 11720
diff changeset
  1739
	if clanFirstTurn[clan] then
8c1a30d4cbc8 Construction Mode: Fix giving round energy boost at first round
Wuzzy <almikes@aol.com>
parents: 11720
diff changeset
  1740
		clanFirstTurn[clan] = false
8c1a30d4cbc8 Construction Mode: Fix giving round energy boost at first round
Wuzzy <almikes@aol.com>
parents: 11720
diff changeset
  1741
	else
8c1a30d4cbc8 Construction Mode: Fix giving round energy boost at first round
Wuzzy <almikes@aol.com>
parents: 11720
diff changeset
  1742
		clanPower[clan] = clanPower[clan] + conf_energyPerRound
11728
373150be0356 Construction Mode: Sanity-check numbers from script parameter
Wuzzy <almikes@aol.com>
parents: 11727
diff changeset
  1743
		if conf_maxEnergy ~= "inf" and clanPower[clan] > conf_maxEnergy then
11721
8c1a30d4cbc8 Construction Mode: Fix giving round energy boost at first round
Wuzzy <almikes@aol.com>
parents: 11720
diff changeset
  1744
			clanPower[clan] = conf_maxEnergy
8c1a30d4cbc8 Construction Mode: Fix giving round energy boost at first round
Wuzzy <almikes@aol.com>
parents: 11720
diff changeset
  1745
		end
11720
5cb2f245ee2f Add script parameter support to Construction Mode
Wuzzy <almikes@aol.com>
parents: 11719
diff changeset
  1746
	end
5cb2f245ee2f Add script parameter support to Construction Mode
Wuzzy <almikes@aol.com>
parents: 11719
diff changeset
  1747
	clanUsedExtraTime[clan] = false
5cb2f245ee2f Add script parameter support to Construction Mode
Wuzzy <almikes@aol.com>
parents: 11719
diff changeset
  1748
	clanCratesSpawned[clan] = 0
11015
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1749
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1750
end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1751
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1752
function onGameTick()
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1753
	HandleHedgeEditor()
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1754
end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1755
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1756
function isATrackedGear(gear)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1757
	if 	(GetGearType(gear) == gtHedgehog) or
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1758
		(GetGearType(gear) == gtTarget) or
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1759
		(GetGearType(gear) == gtCase)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1760
	then
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1761
		return(true)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1762
	else
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1763
		return(false)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1764
	end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1765
end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1766
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1767
-- track hedgehogs and placement gears
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1768
function onGearAdd(gear)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1769
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1770
	if GetGearType(gear) == gtHedgehog then
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1771
	elseif (GetGearType(gear) == gtAirAttack) or (GetGearType(gear) == gtTeleport) or (GetGearType(gear) == gtGirder) then
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1772
		cGear = gear
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1773
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1774
	end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1775
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1776
	if isATrackedGear(gear) then
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1777
		trackGear(gear)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1778
	elseif gearCanBeDeflected(gear) then
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1779
		trackGear(gear)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1780
		setGearReflectionValues(gear)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1781
	end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1782
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1783
end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1784
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1785
function onGearDelete(gear)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1786
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1787
	if GetGearType(gear) == gtTarget then
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1788
		CheckGearForStructureLink(gear)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1789
	end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1790
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1791
	if (GetGearType(gear) == gtAirAttack) or (GetGearType(gear) == gtTeleport) or (GetGearType(gear) == gtGirder) then
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1792
		cGear = nil
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1793
	end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1794
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1795
	if (isATrackedGear(gear) or gearCanBeDeflected(gear)) then
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1796
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1797
		if getGearValue(gear, "tCirc") ~= nil then
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1798
			DeleteVisualGear(getGearValue(gear, "tCirc"))
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1799
		end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1800
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1801
		trackDeletion(gear)
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1802
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1803
	end
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1804
7a905f0070ce CRLF purge
nemo
parents: 10897
diff changeset
  1805
end