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