share/hedgewars/Data/Scripts/Multiplayer/Space_Invasion.lua
author Wuzzy <Wuzzy2@mail.ru>
Mon, 26 Nov 2018 01:13:10 +0100
changeset 14301 0855344f54a7
parent 13774 e874bfe563c7
child 14306 8fc6ac47f00a
permissions -rw-r--r--
Highlander: Fix hogs receiving air strikes in maps with border
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
     1
8043
da083f8d95e6 We need custom script loading function in lua now
unc0rr
parents: 7838
diff changeset
     2
HedgewarsScriptLoad("/Scripts/Locale.lua")
da083f8d95e6 We need custom script loading function in lua now
unc0rr
parents: 7838
diff changeset
     3
HedgewarsScriptLoad("/Scripts/Tracker.lua")
12059
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
     4
HedgewarsScriptLoad("/Scripts/Params.lua")
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
     5
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
     6
--[[
13584
ff7378430675 Space Invasion: Delete dead code and ancient outdated comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13454
diff changeset
     7
Space Invasion
12059
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
     8
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
     9
=== DOCUMENTATION ===
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
    10
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
    11
== SCRIPT CONFIGURATION ==
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
    12
You can configure this script a little bit, you only have to edit the game scheme.
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
    13
The script makes heavy use of the script parameters, but you can also use some,
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
    14
but not all, of the other settings in a game scheme.
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
    15
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
    16
You CAN use the following options:
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
    17
- disable girders (highly recommended!)
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
    18
- disable land objects
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
    19
- random order
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
    20
- solid land
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
    21
- low gravity (makes this game much easier, but this script is probably not optimized for it yet)
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
    22
- bottom border
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
    23
- fort mode (just changes the landscape)
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
    24
- teams start at opposite parts of land
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
    25
- wind affects almost everything
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
    26
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
    27
Those options are also possible, but have no real gameplay effect:
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
    28
- disable wind
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
    29
- tag team
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
    30
- king mode (here it only changes hats, so this is just for fun)
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
    31
- vampiric (has no real gameplay effect; just for the grapical effect)
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
    32
- full border (it’s techincally possible, but the script is currently not very well optimized for this mode)
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
    33
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
    34
You CANNOT use any other of the on/off options in the game scheme. Those settings are simply discarded by the script.
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
    35
12068
797d1236a56b Disable world edge in Space Invasion
Wuzzy <almikes@aol.com>
parents: 12067
diff changeset
    36
You also can change the following settings in the game scheme:
12059
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
    37
- time per round (very important)
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
    38
- script parameters, see below
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
    39
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
    40
The other settings are technically possible, but their effect is limited:
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
    41
- damage percentage
12068
797d1236a56b Disable world edge in Space Invasion
Wuzzy <almikes@aol.com>
parents: 12067
diff changeset
    42
- mines/air mines (they don’t harm the active hedgehog, however)
12059
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
    43
- number of barrels
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
    44
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
    45
All other variables are discarded, the script forces its own settings.
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
    46
There will be never Sudden Death, any crate drops, any mines and any
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
    47
barrels.
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
    48
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
    49
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
    50
== SCRIPT PARAMETERS ==
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
    51
This script can be configured mostly with the script parameters.
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
    52
The script parameters are specified in a key=value format each,
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
    53
and each pair is delimeted by a comma.
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
    54
All values must be integer of 0 or higher. All values are optional
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
    55
and have a default if unspecified
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
    56
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
    57
List of parameters:
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
    58
- rounds: Number of rounds (default: 3)
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
    59
- shield: Amount of shield you start with (default: 30)
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
    60
- barrels: Amount of ammo (barrels) you start with (default: 5)
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
    61
- pings: How many time you can use the radar per round (default: 2)
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
    62
- barrelbonus: How many barrels you get for collecting/destroning a green invader (default: 3)
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
    63
- shieldbonus: How much shield you get for collecting/destroying a purple invader (default: 30)
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
    64
- timebonus: How many seconds you get for killing a drone (red) (default: 4)
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
    65
- forcetheme: If set to false, the game will use your chosen theme instead of forcing EarthRise
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
    66
-             Please note that the game may not be able to be played in some themes if the sky
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
    67
               color is very bright (i.e. Bath)
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
    68
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
    69
Example input for the field “Script parameters”:
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
    70
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
    71
rounds=5
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
    72
>>> 5 rounds, everything else is default
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
    73
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
    74
forcetheme=false
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
    75
>>> Makes the game use whatever thme
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
    76
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
    77
shield=0, barrels=3, pings=0
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
    78
>>> no shield, no radar pings and only 3 barrels (could be some hard mode)
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
    79
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
    80
(empty string)
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
    81
>>> Use defaults for everything
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
    82
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
    83
]]
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
    84
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
    85
--------------------------
12059
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
    86
-- TODO list: notes for later
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
    87
--------------------------
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
    88
-- imitate winning animation at end instead of just ending the game
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
    89
12068
797d1236a56b Disable world edge in Space Invasion
Wuzzy <almikes@aol.com>
parents: 12067
diff changeset
    90
-- add support for other world edges (they are currently disabled)
797d1236a56b Disable world edge in Space Invasion
Wuzzy <almikes@aol.com>
parents: 12067
diff changeset
    91
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
    92
-- if more weapons are added, replace primshotsfired all over the place
6819
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
    93
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
    94
-- look for derp and let invaders shoot again
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
    95
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
    96
-- more weapons? flamer/machineballgun,
6819
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
    97
-- some kind of bomb that just drops straight down
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
    98
-- "fire and forget" missile
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
    99
-- shockwave
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
   100
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
   101
-- some kind of ability-meter that lets you do something awesome when you are
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
   102
-- doing really well in a given round.
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
   103
-- probably new kind of shield that pops any invaders who come near
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
   104
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
   105
-- new invader: golden snitch, doesn't show up on your radar
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
   106
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   107
-- maybe replace (48/100*SI.vCircRadius[i])/2 with something better
6819
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
   108
13585
dc4ce9f486b0 Refactor colors and caption type in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13584
diff changeset
   109
-------------------
dc4ce9f486b0 Refactor colors and caption type in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13584
diff changeset
   110
-- CAPTION TYPES --
dc4ce9f486b0 Refactor colors and caption type in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13584
diff changeset
   111
-------------------
dc4ce9f486b0 Refactor colors and caption type in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13584
diff changeset
   112
--[[
dc4ce9f486b0 Refactor colors and caption type in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13584
diff changeset
   113
The captions have been carefully assigned to avoid overlapping.
dc4ce9f486b0 Refactor colors and caption type in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13584
diff changeset
   114
dc4ce9f486b0 Refactor colors and caption type in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13584
diff changeset
   115
capgrpMessage: Basic bonuses for a simple action, rounds complete
dc4ce9f486b0 Refactor colors and caption type in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13584
diff changeset
   116
capgrpMessage2: Extended bonus, awarded for repeating a basic bonus
dc4ce9f486b0 Refactor colors and caption type in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13584
diff changeset
   117
capgrpVolume: X-Hit Combo
dc4ce9f486b0 Refactor colors and caption type in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13584
diff changeset
   118
capgrpGameState: End of turn information, kamikaze achievements
dc4ce9f486b0 Refactor colors and caption type in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13584
diff changeset
   119
capgrpAmmoinfo: Ammo type at start of turn; Multi-shot, Shield Miser
dc4ce9f486b0 Refactor colors and caption type in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13584
diff changeset
   120
capgrpAmmostate: Remaining ammo, depleted ammo; Accuracy Bonus, Sniper, They Call Me Bullseye, Point Blank Combo
dc4ce9f486b0 Refactor colors and caption type in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13584
diff changeset
   121
]]
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   122
12059
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   123
------- CODE FOLLOWS -------
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   124
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   125
----------------------------------
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   126
-- so I herd u liek wariables
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   127
----------------------------------
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   128
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   129
-- The table that holds the Space Invasion variables
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   130
local SI = {}
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   131
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   132
SI.fMod = 1000000 -- use this for dev and .16+ games
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   133
13454
57de4f050891 Space Invasion: Improve how round score is displayed
Wuzzy <Wuzzy2@mail.ru>
parents: 13453
diff changeset
   134
-- Tag IDs
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   135
SI.TAG_TIME = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   136
SI.TAG_BARRELS = 1
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   137
SI.TAG_SHIELD = 2
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   138
SI.TAG_ROUND_SCORE = 4
13454
57de4f050891 Space Invasion: Improve how round score is displayed
Wuzzy <Wuzzy2@mail.ru>
parents: 13453
diff changeset
   139
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   140
-- some console stuff
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   141
SI.shellID = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   142
SI.explosivesID = 0
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   143
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   144
-- gaudyRacer
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   145
SI.boosterOn = false
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   146
SI.preciseOn = false
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   147
SI.roundLimit = 3		-- can be overridden by script parameter "rounds"
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   148
SI.roundNumber = 0
13715
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   149
SI.lastRound = -1
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   150
SI.gameOver = false
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   151
SI.gameBegun = false
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   152
12059
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   153
-- for script parameters
13031
ca7fdb431b34 Construction Mode, Space Invasion: Add example script param in default schems to make editing more convenient
Wuzzy <Wuzzy2@mail.ru>
parents: 13024
diff changeset
   154
-- NOTE: If you change this, also change the default “Space Invasion” game scheme
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   155
SI.startBarrels = 5		-- "barrels"
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   156
SI.startShield = 30		-- "shield"
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   157
SI.startRadShots = 2		-- "pings"
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   158
SI.shieldBonus = 30		-- "shieldbonus"
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   159
SI.barrelBonus = 3		-- "barrelbonus"
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   160
SI.timeBonus = 4		-- "timebonus"
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   161
SI.forceTheme = true		-- "forcetheme"
12059
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   162
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   163
--------------------------
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   164
-- hog and team tracking variales
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   165
--------------------------
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   166
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   167
SI.numhhs = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   168
SI.hhs = {}
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   169
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   170
SI.teamNameArr = {}
13715
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   171
SI.teamNameArrReverse = {}
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   172
SI.teamClan = {}
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   173
SI.teamSize = {}
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   174
SI.teamIndex = {}
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   175
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   176
SI.teamScore = {}
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   177
SI.teamCircsKilled = {}
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   178
SI.teamSurfer = {}
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   179
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   180
-- stats variables
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   181
SI.roundKills = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   182
SI.roundScore = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   183
SI.RK = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   184
SI.GK = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   185
SI.BK = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   186
SI.OK = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   187
SI.SK = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   188
SI.shieldMiser = true
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   189
SI.fierceComp = false
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   190
SI.chainCounter = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   191
SI.chainLength = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   192
SI.shotsFired = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   193
SI.shotsHit = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   194
SI.sniperHits = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   195
SI.pointBlankHits = 0
12059
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   196
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   197
---------------------
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   198
-- awards (for stats section, just for fun)
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   199
---------------------
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   200
-- global awards
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   201
SI.awardTotalKills=0	-- overall killed invaders (min. 30)
12059
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   202
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   203
-- hog awards
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   204
SI.awardRoundScore = nil	-- hog with most score in 1 round (min. 50)
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   205
SI.awardRoundKills = nil	-- most kills in 1 round (min. 5)
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   206
SI.awardAccuracy = nil	-- awarded to hog who didn’t miss once in his round, with most kills (min. 5)
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   207
SI.awardCombo = nil	-- hog with longest combo (min. 5)
12059
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   208
13033
8b6d8418d580 Play a few more taunts in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13031
diff changeset
   209
8b6d8418d580 Play a few more taunts in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13031
diff changeset
   210
8b6d8418d580 Play a few more taunts in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13031
diff changeset
   211
-- Taunt trackers
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   212
SI.tauntTimer = -1
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   213
SI.tauntGear = nil
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   214
SI.tauntSound = nil
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   215
SI.tauntClanShots = 0 -- hogs of same clans shot in this turn
13033
8b6d8418d580 Play a few more taunts in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13031
diff changeset
   216
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   217
---------------------
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   218
-- tumbler goods
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   219
---------------------
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   220
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   221
SI.moveTimer = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   222
SI.leftOn = false
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   223
SI.rightOn = false
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   224
SI.upOn = false
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   225
SI.downOn = false
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   226
6819
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
   227
----------------
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
   228
-- TUMBLER
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   229
SI.wep = {}
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   230
SI.wepAmmo = {}
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   231
SI.wepIndex = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   232
SI.wepCount = 0
6819
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
   233
----------------
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
   234
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
   235
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
   236
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   237
SI.primShotsMax = 5
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   238
SI.primShotsLeft = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   239
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   240
SI.TimeLeftCounter = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   241
SI.TimeLeft = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   242
SI.stopMovement = false
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   243
SI.tumbleStarted = false
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   244
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   245
SI.beam = false
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   246
SI.pShield = nil
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   247
SI.shieldHealth = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   248
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   249
SI.timer100 = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   250
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   251
SI.vTag = {}
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   252
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   253
-----------------------------------------------
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   254
-- CIRCLY GOODIES
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   255
-----------------------------------------------
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   256
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   257
SI.circlesAreGo = false
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   258
SI.playerIsFine = true
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   259
SI.targetHit = false
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   260
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   261
SI.fadeAlpha = 0 -- used to fade the circles out gracefully when player dies
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   262
SI.pTimer = 0 -- tracking projectiles following player
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   263
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   264
SI.circAdjustTimer = 0		-- handle adjustment of circs direction
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   265
SI.m2Count = 0		-- handle speed of circs
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   266
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   267
SI.vCirc = {}
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   268
SI.vCCount = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   269
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   270
SI.rCirc = {}
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   271
SI.rCircX = {}
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   272
SI.rCircY = {}
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   273
SI.rAlpha = 255
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   274
SI.rPingTimer = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   275
SI.radShotsLeft = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   276
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   277
SI.vCircActive = {}
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   278
SI.vCircHealth = {}
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   279
SI.vType = {}
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   280
SI.vCounter = {}		-- how often this circ gets to "fire" etc
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   281
SI.vCounterLim = {} -- when SI.vCounter == SI.vCounterLim circle performs its special
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   282
SI.vCircScore = {} -- how many points killing this invader gives
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   283
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   284
SI.vCircRadMax = {}
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   285
SI.vCircRadMin = {}
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   286
SI.vCircRadDir = {}
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   287
SI.vCircRadCounter = {}
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   288
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   289
SI.vCircDX = {}
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   290
SI.vCircDY = {}
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   291
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   292
SI.vCircX = {}
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   293
SI.vCircY = {}
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   294
SI.vCircMinA = {}
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   295
SI.vCircMaxA = {}
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   296
SI.vCircType = {}
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   297
SI.vCircPulse = {}
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   298
SI.vCircFuckAll = {}
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   299
SI.vCircRadius = {}
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   300
SI.vCircWidth = {}
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   301
SI.vCircCol = {}
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   302
13585
dc4ce9f486b0 Refactor colors and caption type in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13584
diff changeset
   303
-- Colors
dc4ce9f486b0 Refactor colors and caption type in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13584
diff changeset
   304
-- Invaders
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   305
SI.colorDrone = 0xFF0000FF
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   306
SI.colorBoss = 0x0050FFFF
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   307
SI.colorBossParticle = SI.colorBoss
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   308
SI.colorAmmo = 0x00FF00FF
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   309
SI.colorShield = 0xA800FFFF
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   310
SI.colorShieldParticle = SI.colorShield
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   311
SI.colorDisabled = 0xFFFFFFFF -- disabled invader at end of turn
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   312
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   313
-- Other SI.colors
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   314
SI.colorMsgDepleted = 0xFF0000FF
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   315
SI.colorMsgBonus = 0xFFBA00FF
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   316
SI.colorTimer = 0xFFEE00FF
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   317
SI.colorScore = 0xFFFFFFFF
13585
dc4ce9f486b0 Refactor colors and caption type in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13584
diff changeset
   318
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   319
-------------------------------------------
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   320
-- some lazy copypasta/modified methods
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   321
-------------------------------------------
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   322
5629
c24d29a538af HUD for Space Invasion, minor bugfix
mikade
parents: 5334
diff changeset
   323
c24d29a538af HUD for Space Invasion, minor bugfix
mikade
parents: 5334
diff changeset
   324
13454
57de4f050891 Space Invasion: Improve how round score is displayed
Wuzzy <Wuzzy2@mail.ru>
parents: 13453
diff changeset
   325
function HideTag(i)
57de4f050891 Space Invasion: Improve how round score is displayed
Wuzzy <Wuzzy2@mail.ru>
parents: 13453
diff changeset
   326
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   327
	SetVisualGearValues(SI.vTag[i],0,0,0,0,0,1,0, 0, 240000, 0xFFFFFF00)
5629
c24d29a538af HUD for Space Invasion, minor bugfix
mikade
parents: 5334
diff changeset
   328
c24d29a538af HUD for Space Invasion, minor bugfix
mikade
parents: 5334
diff changeset
   329
end
c24d29a538af HUD for Space Invasion, minor bugfix
mikade
parents: 5334
diff changeset
   330
c24d29a538af HUD for Space Invasion, minor bugfix
mikade
parents: 5334
diff changeset
   331
function DrawTag(i)
5827
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5825
diff changeset
   332
12059
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   333
	local zoomL = 1.3
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   334
	local xOffset = 40
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   335
	local yOffset, tValue, tCol
5629
c24d29a538af HUD for Space Invasion, minor bugfix
mikade
parents: 5334
diff changeset
   336
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   337
	if i == SI.TAG_TIME then
5827
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5825
diff changeset
   338
		yOffset = 40
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   339
		tCol = SI.colorTimer
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   340
		tValue = SI.TimeLeft
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   341
	elseif i == SI.TAG_BARRELS then
5827
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5825
diff changeset
   342
		zoomL = 1.1
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5825
diff changeset
   343
		yOffset = 70
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   344
		tCol = SI.colorAmmo
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   345
		tValue = SI.wepAmmo[SI.wepIndex]
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   346
	elseif i == SI.TAG_SHIELD then
5827
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5825
diff changeset
   347
		zoomL = 1.1
5629
c24d29a538af HUD for Space Invasion, minor bugfix
mikade
parents: 5334
diff changeset
   348
		xOffset = 40 + 35
5827
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5825
diff changeset
   349
		yOffset = 70
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   350
		tCol = SI.colorShield
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   351
		tValue = SI.shieldHealth - 80
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   352
	elseif i == SI.TAG_ROUND_SCORE then
12059
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   353
		zoomL = 1.1
13454
57de4f050891 Space Invasion: Improve how round score is displayed
Wuzzy <Wuzzy2@mail.ru>
parents: 13453
diff changeset
   354
		xOffset = 40
57de4f050891 Space Invasion: Improve how round score is displayed
Wuzzy <Wuzzy2@mail.ru>
parents: 13453
diff changeset
   355
		yOffset = 100
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   356
		tCol = SI.colorScore
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   357
		tValue = SI.roundScore
5629
c24d29a538af HUD for Space Invasion, minor bugfix
mikade
parents: 5334
diff changeset
   358
	end
c24d29a538af HUD for Space Invasion, minor bugfix
mikade
parents: 5334
diff changeset
   359
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   360
	DeleteVisualGear(SI.vTag[i])
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   361
	SI.vTag[i] = AddVisualGear(0, 0, vgtHealthTag, 0, false)
5827
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5825
diff changeset
   362
	SetVisualGearValues	(
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   363
				SI.vTag[i], 		--id
13454
57de4f050891 Space Invasion: Improve how round score is displayed
Wuzzy <Wuzzy2@mail.ru>
parents: 13453
diff changeset
   364
				-(div(ScreenWidth, 2)) + xOffset,	--xoffset
5629
c24d29a538af HUD for Space Invasion, minor bugfix
mikade
parents: 5334
diff changeset
   365
				ScreenHeight - yOffset, --yoffset
c24d29a538af HUD for Space Invasion, minor bugfix
mikade
parents: 5334
diff changeset
   366
				0, 			--dx
c24d29a538af HUD for Space Invasion, minor bugfix
mikade
parents: 5334
diff changeset
   367
				0, 			--dy
c24d29a538af HUD for Space Invasion, minor bugfix
mikade
parents: 5334
diff changeset
   368
				zoomL, 			--zoom
c24d29a538af HUD for Space Invasion, minor bugfix
mikade
parents: 5334
diff changeset
   369
				1, 			--~= 0 means align to screen
13453
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13452
diff changeset
   370
				nil, 			--frameticks
5629
c24d29a538af HUD for Space Invasion, minor bugfix
mikade
parents: 5334
diff changeset
   371
				tValue, 		--value
c24d29a538af HUD for Space Invasion, minor bugfix
mikade
parents: 5334
diff changeset
   372
				240000, 		--timer
13584
ff7378430675 Space Invasion: Delete dead code and ancient outdated comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13454
diff changeset
   373
				tCol			--color
5629
c24d29a538af HUD for Space Invasion, minor bugfix
mikade
parents: 5334
diff changeset
   374
				)
c24d29a538af HUD for Space Invasion, minor bugfix
mikade
parents: 5334
diff changeset
   375
c24d29a538af HUD for Space Invasion, minor bugfix
mikade
parents: 5334
diff changeset
   376
end
c24d29a538af HUD for Space Invasion, minor bugfix
mikade
parents: 5334
diff changeset
   377
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   378
function RebuildTeamInfo()
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   379
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   380
	-- make a list of individual team names
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   381
	for i = 0, (TeamsCount-1) do
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   382
		SI.teamSize[i] = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   383
		SI.teamIndex[i] = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   384
		SI.teamScore[i] = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   385
		SI.teamCircsKilled[i] = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   386
		SI.teamSurfer[i] = false
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   387
	end
13715
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   388
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   389
	for i=0, TeamsCount-1 do
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   390
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   391
		local name = GetTeamName(i)
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   392
		SI.teamNameArr[i] = name
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   393
		SI.teamNameArrReverse[name] = i
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   394
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   395
	end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   396
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   397
	-- find out how many hogs per team, and the index of the first hog in SI.hhs
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   398
	for i = 0, (TeamsCount-1) do
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   399
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   400
		for z = 0, (SI.numhhs-1) do
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   401
			if GetHogTeamName(SI.hhs[z]) == SI.teamNameArr[i] then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   402
				SI.teamClan[i] = GetHogClan(SI.hhs[z])
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   403
				if SI.teamSize[i] == 0 then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   404
					SI.teamIndex[i] = z -- should give starting index
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   405
				end
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   406
				SI.teamSize[i] = SI.teamSize[i] + 1
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   407
				--add a pointer so this hog appears at i in SI.hhs
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   408
			end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   409
		end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   410
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   411
	end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   412
13024
880662cf41ee Add team score next to team bars for CTF_Blizard, Control, CTF, Mutant, Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 12431
diff changeset
   413
	for i=0, TeamsCount-1 do
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   414
		SetTeamLabel(SI.teamNameArr[i], SI.teamScore[i])
13024
880662cf41ee Add team score next to team bars for CTF_Blizard, Control, CTF, Mutant, Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 12431
diff changeset
   415
	end
880662cf41ee Add team score next to team bars for CTF_Blizard, Control, CTF, Mutant, Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 12431
diff changeset
   416
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   417
end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   418
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   419
-- control
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   420
function AwardPoints(p)
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   421
	SI.roundScore = SI.roundScore + p
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   422
	DrawTag(SI.TAG_ROUND_SCORE)
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   423
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   424
	for i = 0,(TeamsCount-1) do
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   425
		if SI.teamClan[i] == GetHogClan(CurrentHedgehog) then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   426
			SI.teamScore[i] = SI.teamScore[i] + p
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   427
			SetTeamLabel(SI.teamNameArr[i], SI.teamScore[i])
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   428
		end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   429
	end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   430
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   431
end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   432
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   433
function AwardKills(t)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   434
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   435
	SI.roundKills = SI.roundKills + 1
6253
d73317579ae4 Add "Surfer" achievement to Space Invasion.
mikade
parents: 5894
diff changeset
   436
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   437
	for i = 0,(TeamsCount-1) do
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   438
		if SI.teamClan[i] == GetHogClan(CurrentHedgehog) then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   439
			SI.teamCircsKilled[i] = SI.teamCircsKilled[i] + 1
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   440
			SI.awardTotalKills = SI.awardTotalKills + 1
12059
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   441
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   442
		end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   443
	end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   444
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   445
end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   446
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   447
-----------------
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   448
12059
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   449
function UpdateSimpleAward(oldAward, value, threshold)
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   450
	local awarded = false
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   451
	local newAward
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   452
	if oldAward == nil then
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   453
		if threshold == nil then
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   454
			awarded = true
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   455
		elseif value > threshold then
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   456
			awarded = true
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   457
		end
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   458
	elseif value > oldAward.value then
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   459
		if threshold == nil then
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   460
			awarded = true
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   461
		elseif value > threshold then
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   462
			awarded = true
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   463
		end
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   464
	end
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   465
	if awarded then
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   466
		newAward = {
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   467
			hogName = GetHogName(CurrentHedgehog),
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   468
			teamName = GetHogTeamName(CurrentHedgehog),
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   469
			value = value
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   470
		}
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   471
	else
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   472
		newAward = oldAward
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   473
	end
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   474
	return newAward
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   475
end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   476
13715
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   477
-- Update scoreboard and check victory state.
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   478
-- Returns 2 bools:
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   479
-- 1: true if game over
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   480
-- 2: true if game's not over but we're playing now in tie-breaking phase
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   481
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   482
function CommentOnScore()
12059
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   483
	local teamStats = {}
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   484
	for i = 0,(TeamsCount-1) do
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   485
		table.insert(teamStats, {score = SI.teamScore[i], kills = SI.teamCircsKilled[i], name = SI.teamNameArr[i]})
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   486
	end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   487
12059
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   488
	local scorecomp = function (v1, v2)
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   489
		if v1.score > v2.score then
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   490
			return true
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   491
		else
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   492
			return false
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   493
		end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   494
	end
12059
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   495
	table.sort(teamStats, scorecomp)
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   496
	local teamComment = {}
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   497
	for i = TeamsCount,1,-1 do
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   498
		local comment
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   499
		if teamStats[i].name ~= " " then
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   500
			local comment = teamStats[i].name .. " |" ..
12064
e8458438dcee More helpful Space Invasion description
Wuzzy <almikes@aol.com>
parents: 12063
diff changeset
   501
			string.format(loc("Score: %d"), teamStats[i].score) .. "|" ..
e8458438dcee More helpful Space Invasion description
Wuzzy <almikes@aol.com>
parents: 12063
diff changeset
   502
			string.format(loc("Kills: %d"), teamStats[i].kills)
13715
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   503
			if i < TeamsCount then
12064
e8458438dcee More helpful Space Invasion description
Wuzzy <almikes@aol.com>
parents: 12063
diff changeset
   504
				comment = comment .. "| |"
e8458438dcee More helpful Space Invasion description
Wuzzy <almikes@aol.com>
parents: 12063
diff changeset
   505
			end
12059
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   506
			table.insert(teamComment, comment)
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   507
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   508
			SendStat(siClanHealth, tostring(teamStats[i].score), teamStats[i].name)
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   509
		else
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   510
			comment = "|"
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   511
		end
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   512
		table.insert(teamComment, comment)
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   513
	end
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   514
13715
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   515
	local roundLimitHit = SI.roundNumber >= SI.roundLimit
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   516
	local tie = teamStats[1].score == teamStats[2].score
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   517
	local lGameOver = roundLimitHit and (not tie)
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   518
12059
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   519
	local entireC = ""
13715
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   520
12059
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   521
	for i = TeamsCount,1,-1 do
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   522
		entireC = entireC .. teamComment[i]
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   523
	end
13715
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   524
12059
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   525
	local statusText, scoreText
13715
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   526
	-- Game is over
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   527
	if lGameOver then
13024
880662cf41ee Add team score next to team bars for CTF_Blizard, Control, CTF, Mutant, Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 12431
diff changeset
   528
		statusText = loc("Game over!")
880662cf41ee Add team score next to team bars for CTF_Blizard, Control, CTF, Mutant, Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 12431
diff changeset
   529
		scoreText = loc("Final team scores:")
13715
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   530
	-- Round is over and game is not yet complete
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   531
	elseif not roundLimitHit then
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   532
		AddCaption(string.format(loc("Rounds complete: %d/%d"), SI.roundNumber, SI.roundLimit), capcolDefault, capgrpMessage)
13715
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   533
		return lGameOver, false
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   534
	-- Teams are tied for the lead at the end
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   535
	elseif roundLimitHit and tie then
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   536
		local tieBreakingRound = SI.roundNumber - SI.roundLimit + 1
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   537
		local msg
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   538
		if tieBreakingRound == 1 then
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   539
			msg = loc("Teams are tied! Continue playing rounds until we have a winner!")
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   540
		else
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   541
			msg = string.format(loc("Tie-breaking round %d"), tieBreakingRound)
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   542
		end
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   543
		AddCaption(msg, capcolDefault, capgrpMessage)
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   544
		return lGameOver, true
12059
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   545
	end
13715
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   546
12339
0bc8c5fcd08c Use the traditional winning sequence in Space Invasion again (killing off the losers)
Wuzzy <almikes@aol.com>
parents: 12292
diff changeset
   547
	local displayTime
13715
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   548
	if lGameOver then
12339
0bc8c5fcd08c Use the traditional winning sequence in Space Invasion again (killing off the losers)
Wuzzy <almikes@aol.com>
parents: 12292
diff changeset
   549
		displayTime = 20000
0bc8c5fcd08c Use the traditional winning sequence in Space Invasion again (killing off the losers)
Wuzzy <almikes@aol.com>
parents: 12292
diff changeset
   550
	else
0bc8c5fcd08c Use the traditional winning sequence in Space Invasion again (killing off the losers)
Wuzzy <almikes@aol.com>
parents: 12292
diff changeset
   551
		displayTime = 1
0bc8c5fcd08c Use the traditional winning sequence in Space Invasion again (killing off the losers)
Wuzzy <almikes@aol.com>
parents: 12292
diff changeset
   552
	end
12059
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   553
	ShowMission(	loc("Space Invasion"),
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   554
			statusText,
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   555
			string.format(loc("Rounds complete: %d/%d"), SI.roundNumber, SI.roundLimit) .. "| " .. "|" ..
12339
0bc8c5fcd08c Use the traditional winning sequence in Space Invasion again (killing off the losers)
Wuzzy <almikes@aol.com>
parents: 12292
diff changeset
   556
			scoreText .. " |" ..entireC, 4, displayTime)
12059
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   557
13715
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   558
	if lGameOver then
12059
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   559
		local winnerTeam = teamStats[1].name
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   560
		for i = 0, (SI.numhhs-1) do
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   561
			if GetHogTeamName(SI.hhs[i]) == winnerTeam then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   562
				SetState(SI.hhs[i], bor(GetState(SI.hhs[i]), gstWinner))
12059
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   563
			end
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   564
		end
13648
690cc84e9fd6 Use capcolDefault in Lua scripts
Wuzzy <Wuzzy2@mail.ru>
parents: 13585
diff changeset
   565
		AddCaption(string.format(loc("%s wins!"), winnerTeam), capcolDefault, capgrpGameState)
12429
b9cc405541c1 Fix various loc() syntax errors in scripts
Wuzzy <almikes@aol.com>
parents: 12339
diff changeset
   566
		SendStat(siGameResult, string.format(loc("%s wins!"), winnerTeam))
12059
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   567
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   568
		for i = 1, TeamsCount do
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   569
			SendStat(siPointType, loc("points"))
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   570
			SendStat(siPlayerKills, tostring(teamStats[i].score), teamStats[i].name)
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   571
		end
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   572
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   573
		local killscomp = function (v1, v2)
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   574
			if v1.kills > v2.kills then
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   575
				return true
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   576
			else
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   577
				return false
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   578
			end
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   579
		end
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   580
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   581
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   582
--[[ Award some awards (just for fun, its for the stats screen only
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   583
and has no effect on the score or game outcome. ]]
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   584
		local awardsGiven = 0
13715
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   585
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   586
		if SI.roundNumber == SI.roundLimit + 1 then
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   587
			SendStat(siCustomAchievement,
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   588
			loc("The teams were tied, so an additional round has been played to determine the winner."))
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   589
			awardsGiven = awardsGiven + 1
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   590
		elseif SI.roundNumber > SI.roundLimit then
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   591
			SendStat(siCustomAchievement,
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   592
			string.format(loc("The teams were tied, so %d additional rounds have been played to determine the winner."),
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   593
			SI.roundNumber - SI.roundLimit))
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   594
			awardsGiven = awardsGiven + 1
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   595
		end
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   596
		if SI.awardTotalKills >= 30 then
12059
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   597
			awardsGiven = awardsGiven + 1
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   598
			SendStat(siCustomAchievement,
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   599
				string.format(loc("%d invaders have been destroyed in this game."), SI.awardTotalKills))
12059
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   600
		end
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   601
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   602
		table.sort(teamStats, killscomp)
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   603
		local bestKills = teamStats[1].kills
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   604
		if bestKills > 10 then
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   605
			awardsGiven = awardsGiven + 1
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   606
			local text
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   607
			if bestKills >= 50 then
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   608
				text = loc("BOOM! BOOM! BOOM! %s are the masters of destruction with %d destroyed invaders.")
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   609
			elseif bestKills >= 25 then
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   610
				text = loc("BOOM! %s really didn't like the invaders, so they decided to destroy as much as %d of them.")
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   611
			else
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   612
				text = loc("Boom! %s has destroyed %d invaders.")
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   613
			end
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   614
			SendStat(siCustomAchievement,
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   615
			string.format(text,
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   616
	                teamStats[1].name, teamStats[1].kills))
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   617
		end
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   618
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   619
		if SI.awardRoundKills ~= nil then
12059
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   620
			awardsGiven = awardsGiven + 1
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   621
			local text
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   622
			if SI.awardRoundKills.value >= 33 then
12059
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   623
				text = loc("%s (%s) has been invited to join the Planetary Association of the Hedgehogs, it destroyed a staggering %d invaders in just one round!")
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   624
			elseif SI.awardRoundKills.value >= 22 then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   625
				if SI.awardRoundKills.hogName == "Rambo" then
12059
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   626
					text = loc("The hardships of the war turned %s (%s) into a killing machine: %d invaders destroyed in one round!")
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   627
				else
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   628
					text = loc("%s (%s) is Rambo in a hedgehog costume! He destroyed %d invaders in one round.")
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   629
				end
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   630
			elseif SI.awardRoundKills.value >= 11 then
12429
b9cc405541c1 Fix various loc() syntax errors in scripts
Wuzzy <almikes@aol.com>
parents: 12339
diff changeset
   631
				text = loc("%s (%s) is addicted to killing: %d invaders destroyed in one round.")
12059
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   632
			else
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   633
				text = loc("%s (%s) destroyed %d invaders in one round.")
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   634
			end
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   635
			SendStat(siCustomAchievement,
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   636
			string.format(text,
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   637
			SI.awardRoundKills.hogName, SI.awardRoundKills.teamName, SI.awardRoundKills.value))
12059
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   638
		end
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   639
		if SI.awardRoundScore ~= nil then
12059
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   640
			awardsGiven = awardsGiven + 1
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   641
			local text
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   642
			if SI.awardRoundScore.value >= 300 then
12059
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   643
				text = loc("%s (%s) was undoubtedly the very best professional tumbler in this game: %d points in one round!")
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   644
			elseif SI.awardRoundScore.value >= 250 then
12059
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   645
				text = loc("%s (%s) struck like a meteor: %d points in only one round!")
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   646
			elseif SI.awardRoundScore.value >= 200 then
12059
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   647
				text = loc("%s (%s) is good at this: %d points in only one round!")
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   648
			elseif SI.awardRoundScore.value >= 150 then
12059
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   649
				text = loc("%s (%s) tumbles like no other: %d points in one round.")
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   650
			elseif SI.awardRoundScore.value >= 100 then
12059
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   651
				text = loc("%s (%s) is a tumbleweed: %d points in one round.")
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   652
			else
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   653
				text = loc("%s (%s) was the best baby tumbler: %d points in one round.")
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   654
			end
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   655
			SendStat(siCustomAchievement,
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   656
			string.format(text,
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   657
			SI.awardRoundScore.hogName, SI.awardRoundScore.teamName, SI.awardRoundScore.value))
12059
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   658
		end
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   659
		if SI.awardAccuracy ~= nil then
12059
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   660
			awardsGiven = awardsGiven + 1
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   661
			local text
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   662
			if SI.awardAccuracy.value >= 20 then
12059
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   663
				text = loc("The Society of Perfectionists greets %s (%s): No misses and %d hits in its best round.")
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   664
			elseif SI.awardAccuracy.value >= 10 then
12059
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   665
				text = loc("%s (%s) is a hardened hunter: No misses and %d hits in its best round!")
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   666
			else
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   667
				text = loc("%s (%s) shot %d invaders and never missed in the best round!")
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   668
			end
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   669
			SendStat(siCustomAchievement,
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   670
			string.format(text,
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   671
			SI.awardAccuracy.hogName, SI.awardAccuracy.teamName, SI.awardAccuracy.value))
12059
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   672
		end
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   673
		if SI.awardCombo ~= nil then
12059
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   674
			awardsGiven = awardsGiven + 1
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   675
			local text
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   676
			if SI.awardCombo.value >= 11 then
12059
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   677
				text = loc("%s (%s) was lightning-fast! Longest combo of %d, absolutely insane!")
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   678
			elseif SI.awardCombo.value >= 8 then
12059
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   679
				text = loc("%s (%s) gave short shrift to the invaders: Longest combo of %d!")
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   680
			else
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   681
				text = loc("%s (%s) was on fire: Longest combo of %d.")
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   682
			end
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   683
			SendStat(siCustomAchievement,
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   684
			string.format(text,
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   685
			SI.awardCombo.hogName, SI.awardCombo.teamName, SI.awardCombo.value))
12059
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   686
		end
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   687
		if awardsGiven == 0 then
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   688
			local text
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   689
			local r = math.random(1,4)
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   690
			if r == 1 then text = loc("This game wasn’t really exciting.")
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   691
			elseif r == 2 then text = loc("Did I miss something?")
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   692
			elseif r == 3 then text = loc("Nothing of interest has happened.")
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   693
			elseif r == 4 then text = loc("There are no snarky comments this time.")
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   694
			end
13715
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   695
12059
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   696
			SendStat(siCustomAchievement, text)
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   697
		end
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   698
	end
13715
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   699
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   700
	return lGameOver, false
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   701
end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   702
6253
d73317579ae4 Add "Surfer" achievement to Space Invasion.
mikade
parents: 5894
diff changeset
   703
function onNewRound()
13715
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   704
	SI.lastRound = TotalRounds
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   705
	SI.roundNumber = SI.roundNumber + 1
6253
d73317579ae4 Add "Surfer" achievement to Space Invasion.
mikade
parents: 5894
diff changeset
   706
13715
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   707
	local lGameOver, lTied = CommentOnScore()
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   708
	local bestScore = 0
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   709
	local bestClan = -1
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   710
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   711
	-- Game has been determined to be over, so end it
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   712
	if lGameOver then
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   713
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   714
		-- Get winning score
6253
d73317579ae4 Add "Surfer" achievement to Space Invasion.
mikade
parents: 5894
diff changeset
   715
		for i = 0, (TeamsCount-1) do
13715
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   716
			if SI.teamScore[i] > bestScore then
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   717
				bestScore = SI.teamScore[i]
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   718
				bestClan = SI.teamClan[i]
6253
d73317579ae4 Add "Surfer" achievement to Space Invasion.
mikade
parents: 5894
diff changeset
   719
			end
d73317579ae4 Add "Surfer" achievement to Space Invasion.
mikade
parents: 5894
diff changeset
   720
		end
d73317579ae4 Add "Surfer" achievement to Space Invasion.
mikade
parents: 5894
diff changeset
   721
12339
0bc8c5fcd08c Use the traditional winning sequence in Space Invasion again (killing off the losers)
Wuzzy <almikes@aol.com>
parents: 12292
diff changeset
   722
		-- Kill off all the losers
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   723
		for i = 0, (SI.numhhs-1) do
13715
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   724
			if GetHogClan(SI.hhs[i]) ~= bestClan then
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   725
				SetEffect(SI.hhs[i], heResurrectable, 0)
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   726
				SetHealth(SI.hhs[i],0)
13716
d5f12b1d180d Space Invasion: Add hilarious loser face to losers
Wuzzy <Wuzzy2@mail.ru>
parents: 13715
diff changeset
   727
				-- hilarious loser face
d5f12b1d180d Space Invasion: Add hilarious loser face to losers
Wuzzy <Wuzzy2@mail.ru>
parents: 13715
diff changeset
   728
				SetState(SI.hhs[i], bor(GetState(SI.hhs[i]), gstLoser))
12339
0bc8c5fcd08c Use the traditional winning sequence in Space Invasion again (killing off the losers)
Wuzzy <almikes@aol.com>
parents: 12292
diff changeset
   729
			end
0bc8c5fcd08c Use the traditional winning sequence in Space Invasion again (killing off the losers)
Wuzzy <almikes@aol.com>
parents: 12292
diff changeset
   730
		end
0bc8c5fcd08c Use the traditional winning sequence in Space Invasion again (killing off the losers)
Wuzzy <almikes@aol.com>
parents: 12292
diff changeset
   731
0bc8c5fcd08c Use the traditional winning sequence in Space Invasion again (killing off the losers)
Wuzzy <almikes@aol.com>
parents: 12292
diff changeset
   732
		-- Game over
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   733
		SI.gameOver = true
12292
faf1b93422ba Use new EndTurn in a couple of scripts, esp. to fix timeout taunts in Racer
Wuzzy <almikes@aol.com>
parents: 12068
diff changeset
   734
		EndTurn(true)
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   735
		SI.TimeLeft = 0
12431
9f3387907e06 Fix even more bad/broken loc()'s in scripts (hopefully the last one)
Wuzzy <almikes@aol.com>
parents: 12429
diff changeset
   736
		SendStat(siGraphTitle, loc("Score graph"))
13715
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   737
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   738
	-- Round limit passed and teams are tied!
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   739
	elseif lTied then
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   740
		-- Enter (or continue) tie-breaking phase...
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   741
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   742
		-- Rules in case of a tie:
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   743
		-- 1) All teams that are not tied for the lead are killed (they can't play anymore, but they will keep their score and be ranked normally)
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   744
		-- 2) Another round is played with the remaining teams
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   745
		-- 3) After this round, scores are checked again to determine a winner. If there's a tie again, this procedure is repeated
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   746
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   747
		-- Get leading teams
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   748
		for i = 0, (TeamsCount-1) do
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   749
			if SI.teamScore[i] > bestScore then
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   750
				bestScore = SI.teamScore[i]
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   751
			end
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   752
		end
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   753
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   754
		local tiedForTheLead = {}
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   755
		for i = 0, (TeamsCount-1) do
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   756
			if SI.teamScore[i] == bestScore then
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   757
				tiedForTheLead[i] = true
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   758
			end
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   759
		end
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   760
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   761
		local wasCurrent = false
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   762
		-- Kill teams not in the top
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   763
		for i = 0, (SI.numhhs-1) do
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   764
			local hog = SI.hhs[i]
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   765
			if GetHealth(hog) then -- check if hog is still alive
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   766
				local team = SI.teamNameArrReverse[GetHogTeamName(hog)]
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   767
				if team and tiedForTheLead[team] ~= true then
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   768
					-- hilarious loser face
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   769
					SetState(hog, bor(GetState(hog), gstLoser))
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   770
					-- die!
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   771
					SetEffect(hog, heResurrectable, 0)
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   772
					SetHealth(hog, 0)
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   773
					-- Note the death might not trigger immediately since we
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   774
					-- zero the health at the beginning of a turn rather than
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   775
					-- the end of one.
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   776
					-- It's just a minor visual thing, not a big deal.
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   777
					if hog == CurrentHedgehog then
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   778
						wasCurrent = true
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   779
					end
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   780
				end
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   781
			end
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   782
		end
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   783
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   784
		-- if current hedgehog was among the loser, end the turn
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   785
		if wasCurrent then
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   786
			EndTurn(true)
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   787
		end
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   788
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   789
		-- From that point on, the game just continues normally ...
6253
d73317579ae4 Add "Surfer" achievement to Space Invasion.
mikade
parents: 5894
diff changeset
   790
	end
d73317579ae4 Add "Surfer" achievement to Space Invasion.
mikade
parents: 5894
diff changeset
   791
end
d73317579ae4 Add "Surfer" achievement to Space Invasion.
mikade
parents: 5894
diff changeset
   792
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   793
-- gaudy racer
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   794
function CheckForNewRound()
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   795
13715
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
   796
	if TotalRounds > 0 and TotalRounds > SI.lastRound then
6253
d73317579ae4 Add "Surfer" achievement to Space Invasion.
mikade
parents: 5894
diff changeset
   797
		onNewRound()
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   798
	end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   799
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   800
end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   801
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   802
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   803
----------------------------------------
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   804
-- some tumbler/space invaders methods
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   805
----------------------------------------
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   806
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   807
function isATrackedGear(gear)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   808
	if 	(GetGearType(gear) == gtExplosives) or
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   809
		(GetGearType(gear) == gtShell) or
12060
ddf0fee75449 Space Invasion: Dump most out-commented and unused code
Wuzzy <almikes@aol.com>
parents: 12059
diff changeset
   810
		(GetGearType(gear) == gtFlame) or
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   811
		(GetGearType(gear) == gtBall)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   812
	then
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   813
		return(true)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   814
	else
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   815
		return(false)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   816
	end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   817
end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   818
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   819
function setNewGearValues(gear)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   820
13453
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13452
diff changeset
   821
	local lfs
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   822
	if GetGearType(gear) == gtShell then
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   823
		lfs = 50	-- roughly 5 seconds
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   824
		SI.shellID = SI.shellID + 1
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   825
		setGearValue(gear,"ID",SI.shellID)
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   826
	elseif GetGearType(gear) == gtBall then
6819
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
   827
		lfs = 5 --70	-- 7s
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   828
	elseif GetGearType(gear) == gtExplosives then
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   829
		lfs = 15	-- 1.5s
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   830
		SI.explosivesID = SI.explosivesID + 1
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   831
		setGearValue(gear,"ID",SI.explosivesID)
6819
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
   832
		setGearValue(gear,"XP", GetX(gear))
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
   833
		setGearValue(gear,"YP", GetY(gear))
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   834
	elseif GetGearType(gear) == gtFlame then
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   835
		lfs = 5	-- 0.5s
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   836
	else
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   837
		lfs = 100
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   838
	end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   839
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   840
	setGearValue(gear,"lifespan",lfs)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   841
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   842
end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   843
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   844
function HandleLifeSpan(gear)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   845
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   846
	decreaseGearValue(gear,"lifespan")
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   847
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   848
	if getGearValue(gear,"lifespan") == 0 then
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   849
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   850
		if GetGearType(gear) == gtShell then
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   851
			AddVisualGear(GetX(gear), GetY(gear), vgtExplosion, 0, false)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   852
		elseif GetGearType(gear) == gtExplosives then
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   853
			AddVisualGear(GetX(gear), GetY(gear), vgtBigExplosion, 0, false)
12059
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   854
			PlaySound(sndExplosion)
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   855
		elseif GetGearType(gear) == gtFlame then
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   856
			AddVisualGear(GetX(gear), GetY(gear), vgtSmoke, 0, false)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   857
		end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   858
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   859
		DeleteGear(gear)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   860
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   861
	end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   862
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   863
end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   864
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   865
-- this prevents ugly barrel clipping sounds when a barrel flies off map limits
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   866
function DeleteFarFlungBarrel(gear)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   867
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   868
	if GetGearType(gear) == gtExplosives then
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   869
		if 	(GetX(gear) < -1900) or
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   870
			(GetX(gear) > 6200) or
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   871
			(GetY(gear) < -3400)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   872
		then
5827
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5825
diff changeset
   873
			AddVisualGear(GetX(gear), GetY(gear), vgtBigExplosion, 0, false)
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5825
diff changeset
   874
			DeleteGear(gear)
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   875
		end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   876
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   877
	end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   878
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   879
end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   880
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   881
-----------------------
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   882
--EVENT HANDLERS
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   883
-- action keys
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   884
-----------------------
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   885
6819
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
   886
function ChangeWeapon()
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
   887
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   888
	SI.wepIndex = SI.wepIndex + 1
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   889
	if SI.wepIndex == SI.wepCount then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   890
		SI.wepIndex = 0
6819
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
   891
	end
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   892
	AddCaption(SI.wep[SI.wepIndex], GetClanColor(GetHogClan(CurrentHedgehog)), capgrpAmmoinfo)
6819
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
   893
end
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
   894
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
   895
-- derp tumbler
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
   896
function onPrecise()
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
   897
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   898
	if (CurrentHedgehog ~= nil) and (SI.stopMovement == false) and (SI.tumbleStarted == true) and (SI.wepAmmo[SI.wepIndex] > 0) then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   899
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   900
		SI.wepAmmo[SI.wepIndex] = SI.wepAmmo[SI.wepIndex] - 1
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   901
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   902
		if SI.wep[SI.wepIndex] == loc("Barrel Launcher") then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   903
			SI.shotsFired = SI.shotsFired +1
6819
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
   904
13453
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13452
diff changeset
   905
			local morte = AddGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog), gtExplosives, 0, 0, 0, 1)
13584
ff7378430675 Space Invasion: Delete dead code and ancient outdated comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13454
diff changeset
   906
			CopyPV(CurrentHedgehog, morte)
13453
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13452
diff changeset
   907
			local x,y = GetGearVelocity(morte)
6819
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
   908
			x = x*2
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
   909
			y = y*2
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
   910
			SetGearVelocity(morte, x, y)
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
   911
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   912
			if SI.wepAmmo[SI.wepIndex] == 0 then
12059
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   913
				PlaySound(sndSuddenDeath)
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   914
				AddCaption(loc("Ammo depleted!"),SI.colorMsgDepleted,capgrpAmmostate)
6819
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
   915
			else
12059
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   916
				PlaySound(sndThrowRelease)
6819
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
   917
			end
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   918
			DrawTag(SI.TAG_BARRELS)
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   919
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   920
		elseif SI.wep[SI.wepIndex] == loc("Mine Deployer") then
13453
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13452
diff changeset
   921
			local morte = AddGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog), gtAirBomb, 0, 0, 0, 0)
6819
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
   922
			SetTimer(morte, 1000)
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   923
			DrawTag(SI.TAG_BARRELS)
6819
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
   924
		end
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
   925
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   926
	elseif (SI.wepAmmo[SI.wepIndex] == 0) and (CurrentHedgehog ~= nil) and (SI.stopMovement == false) and (SI.tumbleStarted == true) then
12059
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   927
		PlaySound(sndDenied)
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   928
		AddCaption(loc("Ammo depleted!"),SI.colorMsgDepleted,capgrpAmmostate)
6819
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
   929
	end
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
   930
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   931
	SI.preciseOn = true
6819
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
   932
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
   933
end
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
   934
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
   935
function onPreciseUp()
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   936
	SI.preciseOn = false
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   937
end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   938
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   939
function onLJump()
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   940
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   941
	if (CurrentHedgehog ~= nil) and (SI.stopMovement == false) and (SI.tumbleStarted == true) then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   942
		SI.shieldMiser = false
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   943
		if SI.shieldHealth == 80 then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   944
			AddCaption(loc("Shield depleted"),SI.colorMsgDepleted,capgrpAmmostate)
12059
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   945
			PlaySound(sndDenied)
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   946
		elseif (SI.beam == false) and (SI.shieldHealth > 80) then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   947
			SI.beam = true
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   948
			SetVisualGearValues(SI.pShield, GetX(CurrentHedgehog), GetY(CurrentHedgehog), 40, 255, 1, 10, 0, 300, 1, SI.colorShield)
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   949
			AddCaption( string.format(loc("Shield ON: %d power remaining"), SI.shieldHealth - 80), SI.colorShield, capgrpAmmostate)
13033
8b6d8418d580 Play a few more taunts in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13031
diff changeset
   950
			PlaySound(sndInvulnerable)
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   951
		else
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   952
			SI.beam = false
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   953
			SetVisualGearValues(SI.pShield, GetX(CurrentHedgehog), GetY(CurrentHedgehog), 0, 0, 1, 10, 0, 0, 0, SI.colorShield)
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   954
			AddCaption( string.format(loc("Shield OFF: %d power remaining"), SI.shieldHealth - 80), SI.colorShield, capgrpAmmostate)
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   955
		end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   956
	end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   957
end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   958
5894
86c59c34cdd5 Balanced shield miser, multi-shot, and boss kills in SI. Added radar ping.
mikade
parents: 5827
diff changeset
   959
function onHJump()
86c59c34cdd5 Balanced shield miser, multi-shot, and boss kills in SI. Added radar ping.
mikade
parents: 5827
diff changeset
   960
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   961
	if (CurrentHedgehog ~= nil) and (SI.stopMovement == false) and (SI.tumbleStarted == true) and
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   962
	(SI.rAlpha == 255) then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   963
		if SI.radShotsLeft > 0 then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   964
			SI.rPingTimer = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   965
			SI.rAlpha = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   966
			SI.radShotsLeft = SI.radShotsLeft -1
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   967
			AddCaption(string.format(loc("Pings left: %d"), SI.radShotsLeft),GetClanColor(GetHogClan(CurrentHedgehog)),capgrpAmmostate)
12059
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   968
			-- Play sonar sound
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   969
			PlaySound(sndJetpackLaunch)
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   970
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   971
		else
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   972
			AddCaption(loc("No radar pings left!"),SI.colorMsgDepleted,capgrpAmmostate)
12059
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   973
			PlaySound(sndDenied)
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   974
		end
5894
86c59c34cdd5 Balanced shield miser, multi-shot, and boss kills in SI. Added radar ping.
mikade
parents: 5827
diff changeset
   975
	end
86c59c34cdd5 Balanced shield miser, multi-shot, and boss kills in SI. Added radar ping.
mikade
parents: 5827
diff changeset
   976
86c59c34cdd5 Balanced shield miser, multi-shot, and boss kills in SI. Added radar ping.
mikade
parents: 5827
diff changeset
   977
end
86c59c34cdd5 Balanced shield miser, multi-shot, and boss kills in SI. Added radar ping.
mikade
parents: 5827
diff changeset
   978
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   979
-----------------
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   980
-- movement keys
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   981
-----------------
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   982
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   983
function onLeft()
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   984
	SI.leftOn = true
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   985
end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   986
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   987
function onRight()
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   988
	SI.rightOn = true
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   989
end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   990
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   991
function onUp()
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   992
	SI.upOn = true
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   993
end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   994
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   995
function onDown()
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
   996
	SI.downOn = true
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   997
end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   998
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   999
function onDownUp()
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1000
	SI.downOn = false
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1001
end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1002
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1003
function onUpUp()
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1004
	SI.upOn = false
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1005
end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1006
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1007
function onLeftUp()
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1008
	SI.leftOn = false
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1009
end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1010
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1011
function onRightUp()
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1012
	SI.rightOn = false
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1013
end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1014
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1015
--------------------------
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1016
-- other event handlers
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1017
--------------------------
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1018
12059
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1019
function onParameters()
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1020
	parseParams()
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1021
	if params["rounds"] ~= nil then
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1022
		SI.roundLimit = math.floor(tonumber(params["rounds"]))
12059
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1023
	end
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1024
	if params["barrels"] ~= nil then
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1025
		SI.startBarrels = math.floor(tonumber(params["barrels"]))
12059
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1026
	end
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1027
	if params["pings"] ~= nil then
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1028
		SI.startRadShots = math.floor(tonumber(params["pings"]))
12059
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1029
	end
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1030
	if params["shield"] ~= nil then
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1031
		SI.startShield = math.floor(tonumber(params["shield"]))
12059
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1032
	end
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1033
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1034
	if params["barrelbonus"] ~= nil then
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1035
		SI.barrelBonus = math.floor(tonumber(params["barrelbonus"]))
12059
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1036
	end
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1037
	if params["shieldbonus"] ~= nil then
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1038
		SI.shieldBonus = math.floor(tonumber(params["shieldbonus"]))
12059
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1039
	end
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1040
	if params["timebonus"] ~= nil then
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1041
		SI.timeBonus = math.floor(tonumber(params["timebonus"]))
12059
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1042
	end
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1043
	if params["forcetheme"] == "false" then
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1044
		SI.forceTheme = false
12059
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1045
	else
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1046
		SI.forceTheme = true
12059
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1047
	end
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1048
end
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1049
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1050
function onGameInit()
12059
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1051
	--[[ Only GameFlags which are listed here are allowed. All other game flags will be discarded.
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1052
	Nonetheless this allows for some configuration in the game scheme ]]
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1053
	local allowedFlags = 
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1054
		-- those flags are probably the most realistic one to use
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1055
		gfDisableGirders + gfRandomOrder +	-- highly recommended!
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1056
		gfDisableLandObjects + gfSolidLand + gfLowGravity +
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1057
		-- a bit unusual but may still be useful
13277
5984e8c6cbeb Add new game flag gfSwitchHog, enable hog switching at turn start
Wuzzy <Wuzzy2@mail.ru>
parents: 13033
diff changeset
  1058
		gfBottomBorder + gfDivideTeams +
12059
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1059
		gfDisableWind + gfMoreWind + gfTagTeam +
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1060
		-- very unusual flags, they don’t affect gameplay really, they are mostly for funny graphical effects
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1061
		gfKing + 	-- King Mode doesn’t work like expected, since hedgehogs never really die here in this mode
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1062
		gfVampiric +	-- just for the grapical effects
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1063
		gfBorder 	-- technically possible, but not very fun to play
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1064
		-- any other flag is FORBIDDEN and will be disabled when it is on anyways!
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1065
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1066
	GameFlags = band(GameFlags, allowedFlags)
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1067
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1068
	if SI.forceTheme then
12059
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1069
		Theme = "EarthRise"
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1070
	end
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1071
	CaseFreq = 0
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1072
	HealthCaseProb = 0
6819
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
  1073
	Delay = 1000
12059
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1074
	SuddenDeathTurns = 50
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1075
	WaterRise = 0
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1076
	HealthDecrease = 0
12068
797d1236a56b Disable world edge in Space Invasion
Wuzzy <almikes@aol.com>
parents: 12067
diff changeset
  1077
	WorldEdge = weNone
12059
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1078
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1079
	local tags = { SI.TAG_TIME, SI.TAG_BARRELS, SI.TAG_SHIELD, SI.TAG_ROUND_SCORE }
13692
a8b2a5e7e9db Clean up more visual gears stuff in scripts
Wuzzy <Wuzzy2@mail.ru>
parents: 13686
diff changeset
  1080
	for t=1, #tags do
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1081
		SI.vTag[tags[t]] = AddVisualGear(0, 0, vgtHealthTag, 0, false)
13692
a8b2a5e7e9db Clean up more visual gears stuff in scripts
Wuzzy <Wuzzy2@mail.ru>
parents: 13686
diff changeset
  1082
		HideTag(tags[t])
5629
c24d29a538af HUD for Space Invasion, minor bugfix
mikade
parents: 5334
diff changeset
  1083
	end
c24d29a538af HUD for Space Invasion, minor bugfix
mikade
parents: 5334
diff changeset
  1084
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1085
	SI.wep[0] = loc("Barrel Launcher")
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1086
	SI.wep[1] = loc("Mine Deployer")
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1087
	SI.wep[2] = loc("Flamer")
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1088
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1089
	SI.wepCount = 3
6819
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
  1090
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1091
end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1092
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1093
function onGameStart()
13774
e874bfe563c7 Make sure scripts don't break w/ only 1 clan
Wuzzy <Wuzzy2@mail.ru>
parents: 13716
diff changeset
  1094
	if ClansCount >= 2 then
e874bfe563c7 Make sure scripts don't break w/ only 1 clan
Wuzzy <Wuzzy2@mail.ru>
parents: 13716
diff changeset
  1095
		SendGameResultOff()
e874bfe563c7 Make sure scripts don't break w/ only 1 clan
Wuzzy <Wuzzy2@mail.ru>
parents: 13716
diff changeset
  1096
		SendRankingStatsOff()
e874bfe563c7 Make sure scripts don't break w/ only 1 clan
Wuzzy <Wuzzy2@mail.ru>
parents: 13716
diff changeset
  1097
		SendAchievementsStatsOff()
e874bfe563c7 Make sure scripts don't break w/ only 1 clan
Wuzzy <Wuzzy2@mail.ru>
parents: 13716
diff changeset
  1098
		SendHealthStatsOff()
e874bfe563c7 Make sure scripts don't break w/ only 1 clan
Wuzzy <Wuzzy2@mail.ru>
parents: 13716
diff changeset
  1099
	end
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1100
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1101
	ShowMission	(
12061
b68ec446a111 Space Invasion: Make all strings more translator-friendly
Wuzzy <almikes@aol.com>
parents: 12060
diff changeset
  1102
				loc("SPACE INVASION"),
b68ec446a111 Space Invasion: Make all strings more translator-friendly
Wuzzy <almikes@aol.com>
parents: 12060
diff changeset
  1103
				loc("A Hedgewars mini-game"),
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1104
12064
e8458438dcee More helpful Space Invasion description
Wuzzy <almikes@aol.com>
parents: 12063
diff changeset
  1105
				loc("Fly into space to fight off the invaders with barrels!") .."|"..
e8458438dcee More helpful Space Invasion description
Wuzzy <almikes@aol.com>
parents: 12063
diff changeset
  1106
				loc("Destroy invaders and collect bonuses to score points.") .. "|" ..
e8458438dcee More helpful Space Invasion description
Wuzzy <almikes@aol.com>
parents: 12063
diff changeset
  1107
				loc("Get the highest score to win.") .. "|" ..
e8458438dcee More helpful Space Invasion description
Wuzzy <almikes@aol.com>
parents: 12063
diff changeset
  1108
				" " .. "|" ..
e8458438dcee More helpful Space Invasion description
Wuzzy <almikes@aol.com>
parents: 12063
diff changeset
  1109
				loc("Avoid bazookas, red and blue invaders.") .. "|" ..
e8458438dcee More helpful Space Invasion description
Wuzzy <almikes@aol.com>
parents: 12063
diff changeset
  1110
				loc("Collect the green and purple invaders.") .. "|" ..
e8458438dcee More helpful Space Invasion description
Wuzzy <almikes@aol.com>
parents: 12063
diff changeset
  1111
				loc("Use the shield to protect yourself from bazookas.") .. "|" ..
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1112
				" " .. "|" ..
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1113
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1114
				string.format(loc("Round Limit: %d"), SI.roundLimit) .. "|" ..
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1115
				" " .. "|" ..
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1116
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1117
				loc("Movement: [Up], [Down], [Left], [Right]") .. "|" ..
12061
b68ec446a111 Space Invasion: Make all strings more translator-friendly
Wuzzy <almikes@aol.com>
parents: 12060
diff changeset
  1118
				loc("Fire: [Precise]") .. "|" ..
b68ec446a111 Space Invasion: Make all strings more translator-friendly
Wuzzy <almikes@aol.com>
parents: 12060
diff changeset
  1119
				loc("Toggle Shield: [Long jump]") .. "|" ..
b68ec446a111 Space Invasion: Make all strings more translator-friendly
Wuzzy <almikes@aol.com>
parents: 12060
diff changeset
  1120
				loc("Radar Ping: [High jump]") .. "|" ..
b68ec446a111 Space Invasion: Make all strings more translator-friendly
Wuzzy <almikes@aol.com>
parents: 12060
diff changeset
  1121
b68ec446a111 Space Invasion: Make all strings more translator-friendly
Wuzzy <almikes@aol.com>
parents: 12060
diff changeset
  1122
				"", 4, 5000
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1123
				)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1124
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1125
	CreateMeSomeCircles()
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1126
	RebuildTeamInfo() -- control
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1127
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1128
end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1129
5825
a6eab1b7c00d Scripting: Update screen dimensions on screen resize and introduce onScreenResize() event.
sheepluva
parents: 5629
diff changeset
  1130
function onScreenResize()
a6eab1b7c00d Scripting: Update screen dimensions on screen resize and introduce onScreenResize() event.
sheepluva
parents: 5629
diff changeset
  1131
a6eab1b7c00d Scripting: Update screen dimensions on screen resize and introduce onScreenResize() event.
sheepluva
parents: 5629
diff changeset
  1132
	-- redraw Tags so that their screen locations are updated
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1133
	if (SI.gameBegun == true) then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1134
		DrawTag(SI.TAG_ROUND_SCORE)
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1135
		if (SI.stopMovement == false) then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1136
			DrawTag(SI.TAG_BARRELS)
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1137
			DrawTag(SI.TAG_SHIELD)
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1138
			if (SI.tumbleStarted == true) then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1139
				DrawTag(SI.TAG_TIME)
13454
57de4f050891 Space Invasion: Improve how round score is displayed
Wuzzy <Wuzzy2@mail.ru>
parents: 13453
diff changeset
  1140
			end
57de4f050891 Space Invasion: Improve how round score is displayed
Wuzzy <Wuzzy2@mail.ru>
parents: 13453
diff changeset
  1141
		end
5825
a6eab1b7c00d Scripting: Update screen dimensions on screen resize and introduce onScreenResize() event.
sheepluva
parents: 5629
diff changeset
  1142
	end
a6eab1b7c00d Scripting: Update screen dimensions on screen resize and introduce onScreenResize() event.
sheepluva
parents: 5629
diff changeset
  1143
a6eab1b7c00d Scripting: Update screen dimensions on screen resize and introduce onScreenResize() event.
sheepluva
parents: 5629
diff changeset
  1144
end
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1145
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1146
function onNewTurn()
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1147
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1148
	SI.radShotsLeft = SI.startRadShots
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1149
	SI.stopMovement = false
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1150
	SI.tumbleStarted = false
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1151
	SI.boosterOn = false
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1152
	SI.beam = false
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1153
	SI.shieldHealth = SI.startShield + 80 -- 50 = 5 secs, roughly
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1154
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1155
	SI.RK = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1156
	SI.GK = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1157
	SI.BK = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1158
	SI.OK = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1159
	SI.SK = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1160
	SI.roundKills = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1161
	SI.roundScore = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1162
	SI.shieldMiser = true
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1163
	SI.fierceComp = false
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1164
	SI.shotsFired = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1165
	SI.shotsHit = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1166
	SI.sniperHits = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1167
	SI.pointBlankHits = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1168
	SI.chainLength = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1169
	SI.chainCounter = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1170
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1171
	SI.tauntClanShots = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1172
	SI.tauntTimer = -1
13033
8b6d8418d580 Play a few more taunts in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13031
diff changeset
  1173
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1174
	-------------------------
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1175
	-- gaudy racer
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1176
	-------------------------
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1177
	CheckForNewRound()
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1178
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1179
	-- Handle Starting Stage of Game
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1180
	if (SI.gameOver == false) and (SI.gameBegun == false) then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1181
		SI.gameBegun = true
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1182
		SI.roundNumber = 0 -- 0
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1183
	end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1184
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1185
	if SI.gameOver == true then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1186
		SI.stopMovement = true
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1187
		SI.tumbleStarted = false
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1188
		SetMyCircles(false)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1189
	end
5827
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5825
diff changeset
  1190
6819
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
  1191
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
  1192
	-------
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
  1193
	-- tumbler
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
  1194
	----
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
  1195
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1196
	SI.wepAmmo[0] = SI.startBarrels
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1197
	SI.wepAmmo[1] = SI.startRadShots
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1198
	SI.wepAmmo[2] = 5000
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1199
	SI.wepIndex = 2
6819
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
  1200
	ChangeWeapon()
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
  1201
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
  1202
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1203
	HideTag(SI.TAG_TIME)
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1204
	if not SI.gameOver then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1205
		DrawTag(SI.TAG_BARRELS)
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1206
		DrawTag(SI.TAG_SHIELD)
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1207
		DrawTag(SI.TAG_ROUND_SCORE)
13454
57de4f050891 Space Invasion: Improve how round score is displayed
Wuzzy <Wuzzy2@mail.ru>
parents: 13453
diff changeset
  1208
	else
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1209
		HideTag(SI.TAG_BARRELS)
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1210
		HideTag(SI.TAG_SHIELD)
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1211
		HideTag(SI.TAG_ROUND_SCORE)
13454
57de4f050891 Space Invasion: Improve how round score is displayed
Wuzzy <Wuzzy2@mail.ru>
parents: 13453
diff changeset
  1212
	end
5629
c24d29a538af HUD for Space Invasion, minor bugfix
mikade
parents: 5334
diff changeset
  1213
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1214
end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1215
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1216
function ThingsToBeRunOnGears(gear)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1217
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1218
	HandleLifeSpan(gear)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1219
	DeleteFarFlungBarrel(gear)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1220
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1221
	if SI.circlesAreGo == true then
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1222
		CheckVarious(gear)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1223
		ProjectileTrack(gear)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1224
	end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1225
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1226
end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1227
10670
638af9cb922b make use of onGearWaterSkip
mikade <redgrinner@gmail.com>
parents: 10036
diff changeset
  1228
function onGearWaterSkip(gear)
638af9cb922b make use of onGearWaterSkip
mikade <redgrinner@gmail.com>
parents: 10036
diff changeset
  1229
	if gear == CurrentHedgehog then
638af9cb922b make use of onGearWaterSkip
mikade <redgrinner@gmail.com>
parents: 10036
diff changeset
  1230
638af9cb922b make use of onGearWaterSkip
mikade <redgrinner@gmail.com>
parents: 10036
diff changeset
  1231
		for i = 0,(TeamsCount-1) do
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1232
			if SI.teamClan[i] == GetHogClan(CurrentHedgehog) and (SI.teamSurfer[i] == false) then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1233
				SI.teamSurfer[i] = true
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1234
				AddCaption(loc("Surfer! +15 points!"),SI.colorMsgBonus,capgrpMessage)
10670
638af9cb922b make use of onGearWaterSkip
mikade <redgrinner@gmail.com>
parents: 10036
diff changeset
  1235
				AwardPoints(15)
638af9cb922b make use of onGearWaterSkip
mikade <redgrinner@gmail.com>
parents: 10036
diff changeset
  1236
			end
638af9cb922b make use of onGearWaterSkip
mikade <redgrinner@gmail.com>
parents: 10036
diff changeset
  1237
		end
638af9cb922b make use of onGearWaterSkip
mikade <redgrinner@gmail.com>
parents: 10036
diff changeset
  1238
638af9cb922b make use of onGearWaterSkip
mikade <redgrinner@gmail.com>
parents: 10036
diff changeset
  1239
	end
638af9cb922b make use of onGearWaterSkip
mikade <redgrinner@gmail.com>
parents: 10036
diff changeset
  1240
end
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1241
7717
2684fdb9d874 revert since I didn't quite get this working smoothly enough. was close though. perhaps some other time. Shame because calling game tick less frequently can save a lot of CPU
nemo
parents: 7229
diff changeset
  1242
function onGameTick()
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1243
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1244
	HandleCircles()
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1245
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1246
	SI.timer100 = SI.timer100 + 1
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1247
	if SI.timer100 >= 100 then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1248
		SI.timer100 = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1249
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1250
		if SI.beam == true then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1251
			SI.shieldHealth = SI.shieldHealth - 1
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1252
			if SI.shieldHealth < 80 then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1253
				SI.shieldHealth = 80
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1254
				SI.beam = false
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1255
				AddCaption(loc("Shield depleted"),SI.colorMsgDepleted,capgrpAmmostate)
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1256
				PlaySound(sndMineTick)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1257
				PlaySound(sndSwitchHog)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1258
			end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1259
		end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1260
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1261
		if SI.tauntTimer > 0 then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1262
			SI.tauntTimer = SI.tauntTimer - 100
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1263
			if SI.tauntTimer <= 0 and SI.tumbleStarted and not SI.stopMovement then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1264
				PlaySound(SI.tauntSound, SI.tauntGear)
13033
8b6d8418d580 Play a few more taunts in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13031
diff changeset
  1265
			end
8b6d8418d580 Play a few more taunts in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13031
diff changeset
  1266
		end
6819
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
  1267
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1268
		runOnGears(ThingsToBeRunOnGears)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1269
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1270
		if SI.circlesAreGo == true then
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1271
			CheckDistances()
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1272
		end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1273
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1274
		-- white smoke trail as player falls from the sky
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1275
		if (SI.TimeLeft <= 0) and (SI.stopMovement == true) and (CurrentHedgehog ~= nil) then
13453
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13452
diff changeset
  1276
			local j,k = GetGearVelocity(CurrentHedgehog)
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1277
			if (j ~= 0) and (k ~= 0) then
13685
a2f0cb003d7d Make decorational visual gears in Space Invasion non-critical
Wuzzy <Wuzzy2@mail.ru>
parents: 13648
diff changeset
  1278
				AddVisualGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog), vgtSmoke, 0, false)
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1279
			end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1280
		end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1281
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1282
	end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1283
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1284
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1285
	-- start the player tumbling with a boom once their turn has actually begun
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1286
	if (SI.tumbleStarted == false) and (SI.gameOver == false) then
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1287
		if (TurnTimeLeft > 0) and (TurnTimeLeft ~= TurnTime) then
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1288
			SI.tumbleStarted = true
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1289
			SI.TimeLeft = (TurnTime/1000)
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1290
			SI.fadeAlpha = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1291
			SI.rAlpha = 255
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1292
			AddGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog), gtGrenade, 0, 0, 0, 1)
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1293
			DrawTag(SI.TAG_TIME)
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1294
			DrawTag(SI.TAG_BARRELS)
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1295
			DrawTag(SI.TAG_SHIELD)
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1296
			DrawTag(SI.TAG_ROUND_SCORE)
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1297
			SetMyCircles(true)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1298
		end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1299
	end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1300
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1301
	if (CurrentHedgehog ~= nil) and (SI.tumbleStarted == true) then
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1302
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1303
		-- Calculate and display turn time
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1304
		SI.TimeLeftCounter = SI.TimeLeftCounter + 1
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1305
		if SI.TimeLeftCounter == 1000 then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1306
			SI.TimeLeftCounter = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1307
			SI.TimeLeft = SI.TimeLeft - 1
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1308
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1309
			if SI.TimeLeft >= 0 then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1310
				DrawTag(SI.TAG_TIME)
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1311
			end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1312
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1313
		end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1314
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1315
		if (SI.TimeLeftCounter % 1000) == 0 then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1316
			if SI.TimeLeft == 5 then
12062
1ee28630d424 Space Invasion: Play countdown sounds
Wuzzy <almikes@aol.com>
parents: 12061
diff changeset
  1317
				PlaySound(sndHurry, CurrentHedgehog)
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1318
			elseif SI.TimeLeft <= 4 and SI.TimeLeft >= 1 then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1319
				PlaySound(_G["sndCountdown"..SI.TimeLeft])
12062
1ee28630d424 Space Invasion: Play countdown sounds
Wuzzy <almikes@aol.com>
parents: 12061
diff changeset
  1320
			end
12059
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1321
		end
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1322
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1323
		-------------------------------
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1324
		-- Player has run out of luck (out of time or hit by gtShell)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1325
		-------------------------------
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1326
		-- checks in FloatyThings
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1327
		if PlayerIsFine() == false then
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1328
			SI.TimeLeft = 0
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1329
		end
5827
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5825
diff changeset
  1330
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1331
		if (SI.TimeLeft == 0) then
13585
dc4ce9f486b0 Refactor colors and caption type in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13584
diff changeset
  1332
			if PlayerIsFine() then
13648
690cc84e9fd6 Use capcolDefault in Lua scripts
Wuzzy <Wuzzy2@mail.ru>
parents: 13585
diff changeset
  1333
				AddCaption(loc("Time's up!"), capcolDefault, capgrpGameState)
13585
dc4ce9f486b0 Refactor colors and caption type in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13584
diff changeset
  1334
			end
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1335
			if (SI.stopMovement == false) then	--time to stop the player
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1336
				SI.stopMovement = true
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1337
				SI.boosterOn = false
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1338
				SI.beam = false
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1339
				SI.upOn = false
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1340
				SI.downOn = false
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1341
				SI.leftOn = false
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1342
				SI.rightOn = false
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1343
				SetMyCircles(false)
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1344
				SI.rAlpha = 255
12066
5beaf30c1cef Turn invaders white in Space Invasion when round is over
Wuzzy <almikes@aol.com>
parents: 12064
diff changeset
  1345
				FailGraphics()
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1346
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1347
				if SI.shieldMiser == true then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1348
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1349
					local p = (SI.roundKills*3.5) - ((SI.roundKills*3.5)%1) + 2
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1350
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1351
					AddCaption(string.format(loc("Shield Miser! +%d points!"), p), SI.colorMsgBonus, capgrpAmmoinfo)
5894
86c59c34cdd5 Balanced shield miser, multi-shot, and boss kills in SI. Added radar ping.
mikade
parents: 5827
diff changeset
  1352
					AwardPoints(p)
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1353
				end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1354
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1355
				local accuracy = (SI.shotsHit / SI.shotsFired) * 100
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1356
				if (accuracy >= 80) and (SI.shotsFired > 4) then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1357
					AddCaption(loc("Accuracy Bonus! +15 points"),SI.colorMsgBonus,capgrpAmmostate)
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1358
					AwardPoints(15)
12059
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1359
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1360
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1361
					-- special award for no misses
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1362
					local award = false
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1363
					if SI.awardAccuracy == nil then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1364
						if (SI.shotsHit >= SI.shotsFired) then
12059
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1365
							award = true
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1366
						end
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1367
					elseif (SI.shotsHit == SI.shotsFired) and SI.shotsHit > SI.awardAccuracy.value then
12059
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1368
						award = true
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1369
					end
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1370
					if award then
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1371
						SI.awardAccuracy = {
12059
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1372
							hogName = GetHogName(CurrentHedgehog),
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1373
							teamName = GetHogTeamName(CurrentHedgehog),
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1374
							value = SI.shotsHit, 
12059
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1375
						}
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1376
					end
13715
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13714
diff changeset
  1377
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1378
				end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1379
12059
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1380
				-- other awards
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1381
				SI.awardRoundScore = UpdateSimpleAward(SI.awardRoundScore, SI.roundScore, 50)
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1382
				SI.awardRoundKills = UpdateSimpleAward(SI.awardRoundKills, SI.roundKills, 5)
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1383
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1384
				HideTag(SI.TAG_TIME)
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1385
				HideTag(SI.TAG_BARRELS)
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1386
				HideTag(SI.TAG_SHIELD)
12059
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1387
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1388
			end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1389
		else -- remove this if you want tumbler to fall slowly on death
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1390
		-------------------------------
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1391
		-- Player is still in luck
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1392
		-------------------------------
5827
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5825
diff changeset
  1393
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1394
			if SI.chainCounter > 0 then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1395
				SI.chainCounter = SI.chainCounter -1
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1396
				if SI.chainCounter == 0 then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1397
					SI.chainLength = 0
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1398
				end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1399
			end
5827
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5825
diff changeset
  1400
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1401
			-- handle movement based on IO
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1402
			SI.moveTimer = SI.moveTimer + 1
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1403
			if SI.moveTimer == 100 then -- 100
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1404
				SI.moveTimer = 0
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1405
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1406
				---------------
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1407
				-- new trail code
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1408
				---------------
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1409
				-- the trail lets you know you have 5s left to pilot, akin to birdy feathers
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1410
				if (SI.TimeLeft <= 5) and (SI.TimeLeft > 0) then							--vgtSmoke
13685
a2f0cb003d7d Make decorational visual gears in Space Invasion non-critical
Wuzzy <Wuzzy2@mail.ru>
parents: 13648
diff changeset
  1411
					local tempE = AddVisualGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog), vgtSmoke, 0, false)
13453
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13452
diff changeset
  1412
					SetVisualGearValues(tempE, nil, nil, nil, nil, nil, nil, nil, nil, nil, GetClanColor(GetHogClan(CurrentHedgehog)) )
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1413
				end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1414
				--------------
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1415
				--------------
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1416
13453
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13452
diff changeset
  1417
				local dx, dy = GetGearVelocity(CurrentHedgehog)
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1418
13453
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13452
diff changeset
  1419
				local dxlimit, dylimit
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1420
				if SI.boosterOn == true then
13453
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13452
diff changeset
  1421
					local tempE = AddVisualGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog), vgtDust, 0, false)
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13452
diff changeset
  1422
					SetVisualGearValues(tempE, nil, nil, nil, nil, nil, nil, nil, 1, nil, GetClanColor(GetHogClan(CurrentHedgehog)) )
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1423
					dxlimit = 0.8*SI.fMod
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1424
					dylimit = 0.8*SI.fMod
6819
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
  1425
				else
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1426
					dxlimit = 0.4*SI.fMod
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1427
					dylimit = 0.4*SI.fMod
6819
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
  1428
				end
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1429
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1430
				if dx > dxlimit then
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1431
					dx = dxlimit
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1432
				end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1433
				if dy > dylimit then
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1434
					dy = dylimit
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1435
				end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1436
				if dx < -dxlimit then
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1437
					dx = -dxlimit
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1438
				end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1439
				if dy < -dylimit then
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1440
					dy = -dylimit
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1441
				end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1442
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1443
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1444
				if SI.leftOn == true then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1445
					dx = dx - 0.1*SI.fMod
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1446
				end
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1447
				if SI.rightOn == true then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1448
					dx = dx + 0.1*SI.fMod
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1449
				end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1450
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1451
				if SI.upOn == true then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1452
					dy = dy - 0.1*SI.fMod
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1453
				end
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1454
				if SI.downOn == true then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1455
					dy = dy + 0.1*SI.fMod
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1456
				end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1457
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1458
				SetGearVelocity(CurrentHedgehog, dx, dy)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1459
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1460
			end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1461
6819
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
  1462
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1463
		end -- new end I put here to check if he's still alive or not
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1464
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1465
	end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1466
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1467
end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1468
6819
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
  1469
function onGearDamage(gear, damage)
13033
8b6d8418d580 Play a few more taunts in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13031
diff changeset
  1470
	if GetGearType(gear) == gtHedgehog and damage >= 60 then
8b6d8418d580 Play a few more taunts in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13031
diff changeset
  1471
		if GetHogClan(gear) ~= GetHogClan(CurrentHedgehog) then
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1472
			if (SI.fierceComp == false) then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1473
				SI.fierceComp = true
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1474
				AddCaption(loc("Fierce Competition! +8 points!"),SI.colorMsgBonus,capgrpMessage)
13033
8b6d8418d580 Play a few more taunts in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13031
diff changeset
  1475
				AwardPoints(8)
8b6d8418d580 Play a few more taunts in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13031
diff changeset
  1476
			end
8b6d8418d580 Play a few more taunts in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13031
diff changeset
  1477
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1478
			SI.tauntTimer = 500
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1479
			SI.tauntGear = gear
13033
8b6d8418d580 Play a few more taunts in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13031
diff changeset
  1480
			local r = math.random(1, 2)
8b6d8418d580 Play a few more taunts in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13031
diff changeset
  1481
			if r == 1 then
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1482
				SI.tauntSound = sndIllGetYou
13033
8b6d8418d580 Play a few more taunts in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13031
diff changeset
  1483
			else
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1484
				SI.tauntSound = sndJustYouWait
13033
8b6d8418d580 Play a few more taunts in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13031
diff changeset
  1485
			end
8b6d8418d580 Play a few more taunts in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13031
diff changeset
  1486
		elseif gear ~= CurrentHedgehog then
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1487
			SI.tauntTimer = 500
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1488
			SI.tauntGear = gear
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1489
			if SI.tauntClanShots == 0 then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1490
				SI.tauntSound = sndSameTeam
13033
8b6d8418d580 Play a few more taunts in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13031
diff changeset
  1491
			else
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1492
				SI.tauntSound = sndTraitor
13033
8b6d8418d580 Play a few more taunts in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13031
diff changeset
  1493
			end
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1494
			SI.tauntClanShots = SI.tauntClanShots + 1
6819
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
  1495
		end
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
  1496
	end
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
  1497
end
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
  1498
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1499
function onGearResurrect(gear)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1500
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1501
	-- did I fall into the water? well, that was a stupid thing to do
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1502
	if gear == CurrentHedgehog then
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1503
		SI.TimeLeft = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1504
		SI.playerIsFine = false
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1505
	end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1506
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1507
end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1508
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1509
function onGearAdd(gear)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1510
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1511
	if isATrackedGear(gear) then
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1512
		trackGear(gear)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1513
		setNewGearValues(gear)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1514
	end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1515
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1516
	if GetGearType(gear) == gtHedgehog then
7838
5c2337f8dbb2 Issue #443 - change in syntax for effects
nemo
parents: 7717
diff changeset
  1517
		SetEffect(gear, heResurrectable, 1)
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1518
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1519
		-----------
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1520
		-- control
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1521
		SI.hhs[SI.numhhs] = gear
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1522
		SI.numhhs = SI.numhhs + 1
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1523
		-----------
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1524
	end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1525
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1526
end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1527
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1528
function onGearDelete(gear)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1529
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1530
	if isATrackedGear(gear) then
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1531
		trackDeletion(gear)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1532
	end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1533
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1534
	if CurrentHedgehog ~= nil then
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1535
		FollowGear(CurrentHedgehog)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1536
	end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1537
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1538
end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1539
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1540
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1541
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1542
------------------------------------------------------------
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1543
------------------------------------------------------------
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1544
------------------------------------------------------------
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1545
------------------------------------------------------------
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1546
-- FLOATY THINGS
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1547
-- "I'll make this into a generic library and code properly
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1548
-- when I have more time and feel less lazy"
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1549
------------------------------------------------------------
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1550
------------------------------------------------------------
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1551
------------------------------------------------------------
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1552
------------------------------------------------------------
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1553
5894
86c59c34cdd5 Balanced shield miser, multi-shot, and boss kills in SI. Added radar ping.
mikade
parents: 5827
diff changeset
  1554
function DoHorribleThings(cUID)
86c59c34cdd5 Balanced shield miser, multi-shot, and boss kills in SI. Added radar ping.
mikade
parents: 5827
diff changeset
  1555
6253
d73317579ae4 Add "Surfer" achievement to Space Invasion.
mikade
parents: 5894
diff changeset
  1556
	-- work out the distance to the target
13453
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13452
diff changeset
  1557
	local g1X, g1Y = GetGearPosition(CurrentHedgehog)
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1558
	local g2X, g2Y = SI.vCircX[cUID], SI.vCircY[cUID]
13453
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13452
diff changeset
  1559
	local q = g1X - g2X
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13452
diff changeset
  1560
	local w = g1Y - g2Y
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13452
diff changeset
  1561
	local r = math.sqrt( (q*q) + (w*w) )	--alternate
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13452
diff changeset
  1562
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13452
diff changeset
  1563
	local opp = w
5894
86c59c34cdd5 Balanced shield miser, multi-shot, and boss kills in SI. Added radar ping.
mikade
parents: 5827
diff changeset
  1564
	if opp < 0 then
86c59c34cdd5 Balanced shield miser, multi-shot, and boss kills in SI. Added radar ping.
mikade
parents: 5827
diff changeset
  1565
		opp = opp*-1
86c59c34cdd5 Balanced shield miser, multi-shot, and boss kills in SI. Added radar ping.
mikade
parents: 5827
diff changeset
  1566
	end
86c59c34cdd5 Balanced shield miser, multi-shot, and boss kills in SI. Added radar ping.
mikade
parents: 5827
diff changeset
  1567
86c59c34cdd5 Balanced shield miser, multi-shot, and boss kills in SI. Added radar ping.
mikade
parents: 5827
diff changeset
  1568
	-- work out the angle (theta) to the target
13453
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13452
diff changeset
  1569
	local t = math.deg ( math.asin(opp / r) )
6253
d73317579ae4 Add "Surfer" achievement to Space Invasion.
mikade
parents: 5894
diff changeset
  1570
d73317579ae4 Add "Surfer" achievement to Space Invasion.
mikade
parents: 5894
diff changeset
  1571
	-- based on the radius of the radar, calculate what x/y displacement should be
13453
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13452
diff changeset
  1572
	local NR = 150 -- radius at which to draw circs
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13452
diff changeset
  1573
	local NX = math.cos( math.rad(t) ) * NR
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13452
diff changeset
  1574
	local NY = math.sin( math.rad(t) ) * NR
6253
d73317579ae4 Add "Surfer" achievement to Space Invasion.
mikade
parents: 5894
diff changeset
  1575
5894
86c59c34cdd5 Balanced shield miser, multi-shot, and boss kills in SI. Added radar ping.
mikade
parents: 5827
diff changeset
  1576
	-- displace xy based on where this thing actually is
6819
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
  1577
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
  1578
	if r < NR then
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1579
		SI.rCircX[cUID] = g2X
6819
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
  1580
	elseif q > 0 then
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1581
		SI.rCircX[cUID] = g1X - NX
5894
86c59c34cdd5 Balanced shield miser, multi-shot, and boss kills in SI. Added radar ping.
mikade
parents: 5827
diff changeset
  1582
	else
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1583
		SI.rCircX[cUID] = g1X + NX
5894
86c59c34cdd5 Balanced shield miser, multi-shot, and boss kills in SI. Added radar ping.
mikade
parents: 5827
diff changeset
  1584
	end
86c59c34cdd5 Balanced shield miser, multi-shot, and boss kills in SI. Added radar ping.
mikade
parents: 5827
diff changeset
  1585
6819
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
  1586
	if r < NR then
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1587
		SI.rCircY[cUID] = g2Y
6819
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
  1588
	elseif w > 0 then
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1589
		SI.rCircY[cUID] = g1Y - NY
5894
86c59c34cdd5 Balanced shield miser, multi-shot, and boss kills in SI. Added radar ping.
mikade
parents: 5827
diff changeset
  1590
	else
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1591
		SI.rCircY[cUID] = g1Y + NY
5894
86c59c34cdd5 Balanced shield miser, multi-shot, and boss kills in SI. Added radar ping.
mikade
parents: 5827
diff changeset
  1592
	end
6253
d73317579ae4 Add "Surfer" achievement to Space Invasion.
mikade
parents: 5894
diff changeset
  1593
5894
86c59c34cdd5 Balanced shield miser, multi-shot, and boss kills in SI. Added radar ping.
mikade
parents: 5827
diff changeset
  1594
end
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1595
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1596
function PlayerIsFine()
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1597
	return (SI.playerIsFine)
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1598
end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1599
6819
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
  1600
function GetDistFromXYtoXY(a, b, c, d)
13453
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13452
diff changeset
  1601
	local q = a - c
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13452
diff changeset
  1602
	local w = b - d
6819
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
  1603
	return ( (q*q) + (w*w) )
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
  1604
end
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
  1605
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1606
function GetDistFromGearToGear(gear, gear2)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1607
13453
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13452
diff changeset
  1608
	local g1X, g1Y = GetGearPosition(gear)
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13452
diff changeset
  1609
	local g2X, g2Y = GetGearPosition(gear2)
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13452
diff changeset
  1610
	local q = g1X - g2X
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13452
diff changeset
  1611
	local w = g1Y - g2Y
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1612
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1613
	return ( (q*q) + (w*w) )
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1614
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1615
end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1616
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1617
function GetDistFromGearToXY(gear, g2X, g2Y)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1618
13453
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13452
diff changeset
  1619
	local g1X, g1Y = GetGearPosition(gear)
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13452
diff changeset
  1620
	local q = g1X - g2X
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13452
diff changeset
  1621
	local w = g1Y - g2Y
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1622
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1623
	return ( (q*q) + (w*w) )
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1624
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1625
end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1626
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1627
function CreateMeSomeCircles()
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1628
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1629
	for i = 0, 7 do
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1630
		SI.vCCount = SI.vCCount +1
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1631
		SI.vCirc[i] = AddVisualGear(0,0,vgtCircle,0,true)
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1632
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1633
		SI.rCirc[i] = AddVisualGear(0,0,vgtCircle,0,true)
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1634
		SI.rCircX[i] = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1635
		SI.rCircY[i] = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1636
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1637
		SI.vCircDX[i] = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1638
		SI.vCircDY[i] = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1639
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1640
		SI.vType[i] = "generic"
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1641
		SI.vCounter[i] = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1642
		SI.vCounterLim[i] = 3000
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1643
		SI.vCircScore[i] = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1644
		SI.vCircHealth[i] = 1
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1645
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1646
		SI.vCircMinA[i] = 80
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1647
		SI.vCircMaxA[i] = 255
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1648
		SI.vCircType[i] = 1
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1649
		SI.vCircPulse[i] = 10
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1650
		SI.vCircFuckAll[i] = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1651
		SI.vCircRadius[i] = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1652
		SI.vCircWidth[i] = 3
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1653
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1654
		SI.vCircRadMax[i] = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1655
		SI.vCircRadMin[i] = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1656
		SI.vCircRadDir[i] = -1
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1657
		SI.vCircRadCounter[i] = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1658
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1659
		SI.vCircX[i], SI.vCircY[i] = 0,0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1660
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1661
		SI.vCircCol[i] = 0xFF00FFFF
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1662
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1663
		SetVisualGearValues(SI.vCirc[i], SI.vCircX[i], SI.vCircY[i], SI.vCircMinA[i], SI.vCircMaxA[i], SI.vCircType[i], SI.vCircPulse[i], SI.vCircFuckAll[i], SI.vCircRadius[i], SI.vCircWidth[i], SI.vCircCol[i])
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1664
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1665
		SetVisualGearValues(SI.rCirc[i], 0, 0, 100, 255, 1, 10, 0, 40, 3, SI.vCircCol[i])
5894
86c59c34cdd5 Balanced shield miser, multi-shot, and boss kills in SI. Added radar ping.
mikade
parents: 5827
diff changeset
  1666
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1667
	end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1668
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1669
	SI.pShield = AddVisualGear(0,0,vgtCircle,0,true)
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1670
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1671
end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1672
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1673
function IGotMeASafeXYValue(i)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1674
13453
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13452
diff changeset
  1675
	local acceptibleDistance = 800
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1676
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1677
	SI.vCircX[i] = GetRandom(5000)
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1678
	SI.vCircY[i] = GetRandom(2000)
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1679
	local dist = GetDistFromGearToXY(CurrentHedgehog, SI.vCircX[i], SI.vCircY[i])
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1680
	if dist > acceptibleDistance*acceptibleDistance then
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1681
		return(true)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1682
	else
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1683
		return(false)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1684
	end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1685
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1686
end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1687
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1688
function CircleDamaged(i)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1689
13453
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13452
diff changeset
  1690
	local res = ""
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1691
	SI.vCircHealth[i] = SI.vCircHealth[i] -1
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1692
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1693
	if SI.vCircHealth[i] <= 0 then
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1694
	-- circle is dead, do death effects/consequences
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1695
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1696
		SI.vCircActive[i] = false
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1697
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1698
		if (SI.vType[i] == "drone") then
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1699
			PlaySound(sndHellishImpact4)
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1700
			SI.TimeLeft = SI.TimeLeft + SI.timeBonus
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1701
			AddCaption(string.format(loc("Time extended! +%dsec"), SI.timeBonus), SI.colorDrone, capgrpMessage )
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1702
			DrawTag(SI.TAG_TIME)
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1703
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1704
			local morte = AddGear(SI.vCircX[i], SI.vCircY[i], gtExplosives, 0, 0, 0, 1)
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1705
			SetHealth(morte, 0)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1706
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1707
			SI.RK = SI.RK + 1
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1708
			if SI.RK == 5 then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1709
				SI.RK = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1710
				AddCaption(loc("Drone Hunter! +10 points!"),SI.colorMsgBonus,capgrpMessage2)
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1711
				AwardPoints(10)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1712
			end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1713
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1714
		elseif (SI.vType[i] == "ammo") then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1715
			AddVisualGear(SI.vCircX[i], SI.vCircY[i], vgtExplosion, 0, false)
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1716
			PlaySound(sndExplosion)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1717
			PlaySound(sndShotgunReload)
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1718
			SI.wepAmmo[0] = SI.wepAmmo[0] + SI.barrelBonus
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1719
			AddCaption(string.format(loc("+%d Ammo"), SI.barrelBonus), SI.colorAmmo,capgrpMessage)
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1720
			DrawTag(SI.TAG_BARRELS)
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1721
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1722
			SI.GK = SI.GK + 1
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1723
			if SI.GK == 3 then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1724
				SI.GK = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1725
				AddCaption(loc("Ammo Maniac! +5 points!"),SI.colorMsgBonus,capgrpMessage2)
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1726
				AwardPoints(5)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1727
			end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1728
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1729
		elseif (SI.vType[i] == "bonus") then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1730
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1731
			AddVisualGear(SI.vCircX[i], SI.vCircY[i], vgtExplosion, 0, false)
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1732
			PlaySound(sndExplosion)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1733
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1734
			AddVisualGear(SI.vCircX[i], SI.vCircY[i], vgtFire, 0, false)
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1735
			AddVisualGear(SI.vCircX[i], SI.vCircY[i], vgtFire, 0, false)
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1736
			AddVisualGear(SI.vCircX[i], SI.vCircY[i], vgtFire, 0, false)
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1737
			AddVisualGear(SI.vCircX[i], SI.vCircY[i], vgtFire, 0, false)
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1738
			AddVisualGear(SI.vCircX[i], SI.vCircY[i], vgtFire, 0, false)
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1739
			AddVisualGear(SI.vCircX[i], SI.vCircY[i], vgtSmoke, 0, false)
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1740
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1741
			PlaySound(sndVaporize)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1742
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1743
			SI.shieldHealth = SI.shieldHealth + SI.shieldBonus
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1744
			if SI.shieldHealth >= 250 then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1745
				SI.shieldHealth = 250
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1746
				AddCaption(loc("Shield is fully recharged!"),SI.colorShield,capgrpMessage)
13585
dc4ce9f486b0 Refactor colors and caption type in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13584
diff changeset
  1747
			else
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1748
				AddCaption(string.format(loc("Shield boosted! +%d power"),SI.shieldBonus), SI.colorShield,capgrpMessage)
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1749
			end
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1750
			DrawTag(SI.TAG_SHIELD)
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1751
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1752
			SI.OK = SI.OK + 1
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1753
			if SI.OK == 3 then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1754
				SI.OK = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1755
				AddCaption(loc("Shield Seeker! +10 points!"),SI.colorShield,capgrpMessage2)
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1756
				AwardPoints(10)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1757
			end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1758
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1759
		elseif (SI.vType[i] == "blueboss") then
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1760
			PlaySound(sndHellishImpact3)
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1761
			SI.tauntTimer = 300
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1762
			SI.tauntSound = sndEnemyDown
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1763
			SI.tauntGear = CurrentHedgehog
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1764
			AddCaption(loc("Boss defeated! +30 points!"), SI.colorBoss,capgrpMessage)
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1765
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1766
			local morte = AddGear(SI.vCircX[i], SI.vCircY[i], gtExplosives, 0, 0, 0, 1)
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1767
			SetHealth(morte, 0)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1768
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1769
			SI.BK = SI.BK + 1
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1770
			if SI.BK == 2 then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1771
				SI.BK = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1772
				AddCaption(loc("Boss Slayer! +25 points!"),SI.colorMsgBonus,capgrpMessage2)
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1773
				AwardPoints(25)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1774
			end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1775
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1776
		end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1777
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1778
		AwardPoints(SI.vCircScore[i])
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1779
		AwardKills()
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1780
		SetUpCircle(i)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1781
		res = "fatal"
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1782
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1783
		SI.chainCounter = 3000
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1784
		SI.chainLength = SI.chainLength + 1
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1785
		if SI.chainLength > 1 then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1786
			AddCaption( string.format(loc("%d-Hit Combo! +%d points!"), SI.chainLength, SI.chainLength*2),SI.colorMsgBonus,capgrpVolume)
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1787
			AwardPoints(SI.chainLength*2)
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1788
		end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1789
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1790
		SI.awardCombo = UpdateSimpleAward(SI.awardCombo, SI.chainLength, 5)
12059
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1791
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1792
	else
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1793
	-- circle is merely damaged
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1794
	-- do damage effects/sounds
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1795
		AddVisualGear(SI.vCircX[i], SI.vCircY[i], vgtSteam, 0, false)
13453
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13452
diff changeset
  1796
		local r = math.random(1,4)
12059
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1797
		PlaySound(_G["sndHellishImpact" .. tostring(r)])
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1798
		res = "non-fatal"
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1799
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1800
	end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1801
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1802
	return(res)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1803
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1804
end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1805
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1806
function SetUpCircle(i)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1807
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1808
13453
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13452
diff changeset
  1809
	local r = GetRandom(10)
13585
dc4ce9f486b0 Refactor colors and caption type in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13584
diff changeset
  1810
	-- 80% of spawning either drone/ammo
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1811
	if r <= 7 then
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1812
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1813
		r = GetRandom(2)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1814
		if r == 0 then
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1815
			SI.vCircCol[i] = SI.colorDrone
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1816
			SI.vType[i] = "drone"
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1817
			SI.vCircRadMin[i] = 50	*5
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1818
			SI.vCircRadMax[i] = 90	*5
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1819
			SI.vCounterLim[i] = 3000
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1820
			SI.vCircScore[i] = 10
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1821
			SI.vCircHealth[i] = 1
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1822
		elseif r == 1 then
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1823
			SI.vCircCol[i] = SI.colorAmmo
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1824
			SI.vType[i] = "ammo"
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1825
			SI.vCircRadMin[i] = 25	*7
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1826
			SI.vCircRadMax[i] = 30	*7
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1827
			SI.vCircScore[i] = 3
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1828
			SI.vCircHealth[i] = 1
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1829
		end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1830
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1831
	-- 20% chance of spawning boss or bonus
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1832
	else
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1833
		r = GetRandom(5)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1834
		if r <= 1 then
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1835
			SI.vCircCol[i] = SI.colorBoss
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1836
			SI.vType[i] = "blueboss"
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1837
			SI.vCircRadMin[i] = 100*5
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1838
			SI.vCircRadMax[i] = 180*5
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1839
			SI.vCircWidth[i] = 1
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1840
			SI.vCounterLim[i] = 2000
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1841
			SI.vCircScore[i] = 30
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1842
			SI.vCircHealth[i] = 3
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1843
		else
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1844
			SI.vCircCol[i] = SI.colorShield
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1845
			SI.vType[i] = "bonus"
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1846
			SI.vCircRadMin[i] = 20 *7
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1847
			SI.vCircRadMax[i] = 40 *7
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1848
			SI.vCircScore[i] = 5
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1849
			SI.vCircHealth[i] = 1
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1850
		end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1851
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1852
	end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1853
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1854
	-- regenerate circle xy if too close to player or until sanity limit kicks in
13453
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13452
diff changeset
  1855
	local reN = 0
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1856
	while (reN < 10) do
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1857
		if IGotMeASafeXYValue(i) == false then
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1858
			reN = reN + 1
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1859
		else
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1860
			reN = 15
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1861
		end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1862
	end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1863
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1864
	SI.vCircRadius[i] = SI.vCircRadMax[i] - GetRandom(SI.vCircRadMin[i])
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1865
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1866
	SetVisualGearValues(SI.vCirc[i], SI.vCircX[i], SI.vCircY[i], nil, nil, nil, nil, nil, SI.vCircRadius[i], SI.vCircWidth[i], SI.vCircCol[i]-0x000000FF)
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1867
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1868
	SetVisualGearValues(SI.rCirc[i], 0, 0, nil, nil, nil, nil, nil, nil, nil, SI.vCircCol[i]-0x000000FF)
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1869
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1870
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1871
	SI.vCircActive[i] = true
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1872
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1873
end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1874
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1875
function SetMyCircles(s)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1876
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1877
	SI.circlesAreGo = s
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1878
	SI.playerIsFine = s
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1879
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1880
	for i = 0,(SI.vCCount-1) do
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1881
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1882
		if s == false then
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1883
			SI.vCircActive[i] = false
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1884
		elseif s == true then
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1885
			SetUpCircle(i)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1886
		end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1887
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1888
	end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1889
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1890
end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1891
13033
8b6d8418d580 Play a few more taunts in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13031
diff changeset
  1892
function WellHeAintGonnaJumpNoMore(x,y,explode,kamikaze)
12059
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1893
	if explode==true then
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1894
		AddVisualGear(x, y, vgtBigExplosion, 0, false)
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1895
		PlaySound(sndExplosion)
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1896
		local r = math.random(1,3)
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1897
		PlaySound(_G["sndOoff"..r], CurrentHedgehog)
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1898
	end
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1899
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1900
	SI.playerIsFine = false
12066
5beaf30c1cef Turn invaders white in Space Invasion when round is over
Wuzzy <almikes@aol.com>
parents: 12064
diff changeset
  1901
	FailGraphics()
13033
8b6d8418d580 Play a few more taunts in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13031
diff changeset
  1902
8b6d8418d580 Play a few more taunts in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13031
diff changeset
  1903
	if not kamikaze then
13648
690cc84e9fd6 Use capcolDefault in Lua scripts
Wuzzy <Wuzzy2@mail.ru>
parents: 13585
diff changeset
  1904
		AddCaption(loc("GOTCHA!"), capcolDefault, capgrpGameState)
13033
8b6d8418d580 Play a few more taunts in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13031
diff changeset
  1905
		PlaySound(sndHellish)
8b6d8418d580 Play a few more taunts in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13031
diff changeset
  1906
	end
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1907
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1908
	SI.targetHit = true
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1909
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1910
end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1911
12066
5beaf30c1cef Turn invaders white in Space Invasion when round is over
Wuzzy <almikes@aol.com>
parents: 12064
diff changeset
  1912
-- Turn all circles white to indicate they can't be hit anymore
5beaf30c1cef Turn invaders white in Space Invasion when round is over
Wuzzy <almikes@aol.com>
parents: 12064
diff changeset
  1913
function FailGraphics()
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1914
	for i = 0,(SI.vCCount-1) do
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1915
		SI.vCircCol[i] = SI.colorDisabled
12066
5beaf30c1cef Turn invaders white in Space Invasion when round is over
Wuzzy <almikes@aol.com>
parents: 12064
diff changeset
  1916
	end
5beaf30c1cef Turn invaders white in Space Invasion when round is over
Wuzzy <almikes@aol.com>
parents: 12064
diff changeset
  1917
end
5beaf30c1cef Turn invaders white in Space Invasion when round is over
Wuzzy <almikes@aol.com>
parents: 12064
diff changeset
  1918
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1919
--- collision detection for weapons fire
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1920
function CheckVarious(gear)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1921
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1922
	SI.targetHit = false
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1923
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1924
	-- if circle is hit by player fire
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1925
	if (GetGearType(gear) == gtExplosives) then
13453
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13452
diff changeset
  1926
		local circsHit = 0
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1927
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1928
		for i = 0,(SI.vCCount-1) do
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1929
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1930
			local dist = GetDistFromGearToXY(gear, SI.vCircX[i], SI.vCircY[i])
12060
ddf0fee75449 Space Invasion: Dump most out-commented and unused code
Wuzzy <almikes@aol.com>
parents: 12059
diff changeset
  1931
ddf0fee75449 Space Invasion: Dump most out-commented and unused code
Wuzzy <almikes@aol.com>
parents: 12059
diff changeset
  1932
			-- calculate my real radius if I am an aura
13453
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13452
diff changeset
  1933
			local NR
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1934
			if SI.vCircType[i] == 0 then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1935
				NR = SI.vCircRadius[i]
12060
ddf0fee75449 Space Invasion: Dump most out-commented and unused code
Wuzzy <almikes@aol.com>
parents: 12059
diff changeset
  1936
			else
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1937
				NR = (48/100*SI.vCircRadius[i])/2
12060
ddf0fee75449 Space Invasion: Dump most out-commented and unused code
Wuzzy <almikes@aol.com>
parents: 12059
diff changeset
  1938
			end
ddf0fee75449 Space Invasion: Dump most out-commented and unused code
Wuzzy <almikes@aol.com>
parents: 12059
diff changeset
  1939
ddf0fee75449 Space Invasion: Dump most out-commented and unused code
Wuzzy <almikes@aol.com>
parents: 12059
diff changeset
  1940
			if dist <= NR*NR then
ddf0fee75449 Space Invasion: Dump most out-commented and unused code
Wuzzy <almikes@aol.com>
parents: 12059
diff changeset
  1941
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1942
				dist = (GetDistFromXYtoXY(SI.vCircX[i], SI.vCircY[i], getGearValue(gear,"XP"), getGearValue(gear,"YP")) - (NR*NR))
12060
ddf0fee75449 Space Invasion: Dump most out-commented and unused code
Wuzzy <almikes@aol.com>
parents: 12059
diff changeset
  1943
				if dist >= 1000000 then
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1944
					SI.sniperHits = SI.sniperHits +1
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1945
					AddCaption(loc("Sniper! +8 points!"),SI.colorMsgBonus,capgrpAmmostate)
12060
ddf0fee75449 Space Invasion: Dump most out-commented and unused code
Wuzzy <almikes@aol.com>
parents: 12059
diff changeset
  1946
					AwardPoints(8)
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1947
					if SI.sniperHits == 3 then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1948
						SI.sniperHits = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1949
						AddCaption(loc("They Call Me Bullseye! +16 points!"),SI.colorMsgBonus,capgrpAmmostate)
12060
ddf0fee75449 Space Invasion: Dump most out-commented and unused code
Wuzzy <almikes@aol.com>
parents: 12059
diff changeset
  1950
						AwardPoints(16)
ddf0fee75449 Space Invasion: Dump most out-commented and unused code
Wuzzy <almikes@aol.com>
parents: 12059
diff changeset
  1951
					end
ddf0fee75449 Space Invasion: Dump most out-commented and unused code
Wuzzy <almikes@aol.com>
parents: 12059
diff changeset
  1952
				elseif dist <= 6000 then
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1953
					SI.pointBlankHits = SI.pointBlankHits +1
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1954
					if SI.pointBlankHits == 3 then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1955
						SI.pointBlankHits = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1956
						AddCaption(loc("Point Blank Combo! +5 points!"),SI.colorMsgBonus,capgrpAmmostate)
12060
ddf0fee75449 Space Invasion: Dump most out-commented and unused code
Wuzzy <almikes@aol.com>
parents: 12059
diff changeset
  1957
						AwardPoints(5)
ddf0fee75449 Space Invasion: Dump most out-commented and unused code
Wuzzy <almikes@aol.com>
parents: 12059
diff changeset
  1958
					end
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1959
				end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1960
12060
ddf0fee75449 Space Invasion: Dump most out-commented and unused code
Wuzzy <almikes@aol.com>
parents: 12059
diff changeset
  1961
				AddVisualGear(GetX(gear), GetY(gear), vgtBigExplosion, 0, false)
ddf0fee75449 Space Invasion: Dump most out-commented and unused code
Wuzzy <almikes@aol.com>
parents: 12059
diff changeset
  1962
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1963
				SI.targetHit = true
12060
ddf0fee75449 Space Invasion: Dump most out-commented and unused code
Wuzzy <almikes@aol.com>
parents: 12059
diff changeset
  1964
				CircleDamaged(i)
ddf0fee75449 Space Invasion: Dump most out-commented and unused code
Wuzzy <almikes@aol.com>
parents: 12059
diff changeset
  1965
ddf0fee75449 Space Invasion: Dump most out-commented and unused code
Wuzzy <almikes@aol.com>
parents: 12059
diff changeset
  1966
				circsHit = circsHit + 1
ddf0fee75449 Space Invasion: Dump most out-commented and unused code
Wuzzy <almikes@aol.com>
parents: 12059
diff changeset
  1967
				if circsHit > 1 then
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1968
					AddCaption(loc("Multi-shot! +15 points!"),SI.colorMsgBonus,capgrpAmmoinfo)
12060
ddf0fee75449 Space Invasion: Dump most out-commented and unused code
Wuzzy <almikes@aol.com>
parents: 12059
diff changeset
  1969
					AwardPoints(15)
5894
86c59c34cdd5 Balanced shield miser, multi-shot, and boss kills in SI. Added radar ping.
mikade
parents: 5827
diff changeset
  1970
						circsHit = 0
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1971
				end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1972
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1973
				SI.shotsHit = SI.shotsHit + 1
12060
ddf0fee75449 Space Invasion: Dump most out-commented and unused code
Wuzzy <almikes@aol.com>
parents: 12059
diff changeset
  1974
ddf0fee75449 Space Invasion: Dump most out-commented and unused code
Wuzzy <almikes@aol.com>
parents: 12059
diff changeset
  1975
			end
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1976
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1977
		end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1978
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1979
	-- if player is hit by circle bazooka
13452
93ba1826b8c2 Fix rare Lua error message spam in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13277
diff changeset
  1980
	elseif (GetGearType(gear) == gtShell) and (CurrentHedgehog ~= nil) then
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1981
13453
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13452
diff changeset
  1982
		local dist = GetDistFromGearToGear(gear, CurrentHedgehog)
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1983
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1984
		if SI.beam == true then
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1985
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1986
			if dist < 3000 then
13685
a2f0cb003d7d Make decorational visual gears in Space Invasion non-critical
Wuzzy <Wuzzy2@mail.ru>
parents: 13648
diff changeset
  1987
				local tempE = AddVisualGear(GetX(gear), GetY(gear), vgtSmoke, 0, false)
13585
dc4ce9f486b0 Refactor colors and caption type in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13584
diff changeset
  1988
				SetVisualGearValues(tempE, nil, nil, nil, nil, nil, nil, nil, nil, nil, 0xFF00FFFF)
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1989
				PlaySound(sndVaporize)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1990
				DeleteGear(gear)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1991
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1992
				SI.SK = SI.SK + 1
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1993
				if SI.SK == 5 then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1994
					SI.SK = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  1995
					AddCaption(loc("Shield Master! +10 points!"),SI.colorMsgBonus,capgrpMessage)
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1996
					AwardPoints(10)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1997
				end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1998
			end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1999
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2000
		elseif dist < 1600 then
12059
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  2001
			WellHeAintGonnaJumpNoMore(GetX(gear), GetY(gear), true)
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2002
		end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2003
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2004
	end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2005
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2006
	if SI.targetHit == true then
13584
ff7378430675 Space Invasion: Delete dead code and ancient outdated comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13454
diff changeset
  2007
		DeleteGear(gear)
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2008
	end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2009
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2010
end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2011
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2012
-- collision detection for player entering a circle
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2013
function CheckDistances()
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2014
13452
93ba1826b8c2 Fix rare Lua error message spam in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13277
diff changeset
  2015
	if not CurrentHedgehog then
93ba1826b8c2 Fix rare Lua error message spam in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13277
diff changeset
  2016
		return
93ba1826b8c2 Fix rare Lua error message spam in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13277
diff changeset
  2017
	end
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2018
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2019
	for i = 0,(SI.vCCount-1) do
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2020
13453
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13452
diff changeset
  2021
		local g1X, g1Y = GetGearPosition(CurrentHedgehog)
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2022
		local g2X, g2Y = SI.vCircX[i], SI.vCircY[i]
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2023
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2024
		g1X = g1X - g2X
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2025
		g1Y = g1Y - g2Y
13453
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13452
diff changeset
  2026
		local dist = (g1X*g1X) + (g1Y*g1Y)
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2027
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2028
		-- calculate my real radius if I am an aura
13453
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13452
diff changeset
  2029
		local NR
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2030
		if SI.vCircType[i] == 0 then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2031
			NR = SI.vCircRadius[i]
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2032
		else
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2033
			NR = (48/100*SI.vCircRadius[i])/2
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2034
		end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2035
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2036
		if dist <= NR*NR then
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2037
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2038
			if 	(SI.vCircActive[i] == true) and
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2039
				((SI.vType[i] == "ammo") or (SI.vType[i] == "bonus") )
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2040
			then
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2041
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2042
				CircleDamaged(i)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2043
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2044
			elseif (SI.vCircActive[i] == true) and
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2045
					( (SI.vType[i] == "drone") or (SI.vType[i] == "blueboss") )
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2046
			then
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2047
13453
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13452
diff changeset
  2048
				local ss = CircleDamaged(i)
12059
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  2049
				local explosion
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2050
				if SI.vType[i] == "blueboss" then explosion = true else explosion = false end
13033
8b6d8418d580 Play a few more taunts in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13031
diff changeset
  2051
8b6d8418d580 Play a few more taunts in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13031
diff changeset
  2052
				local kamikaze = false
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2053
				if ss == "fatal" then
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2054
					if (SI.wepAmmo[0] == 0) and (SI.TimeLeft <= 9) then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2055
						AddCaption(loc("Kamikaze Expert! +15 points!"),SI.colorMsgBonus,capgrpGameState)
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2056
						AwardPoints(15)
12059
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  2057
						PlaySound(sndKamikaze, CurrentHedgehog)
13033
8b6d8418d580 Play a few more taunts in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13031
diff changeset
  2058
						kamikaze = true
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2059
					elseif (SI.wepAmmo[0] == 0) then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2060
						AddCaption(loc("Depleted Kamikaze! +5 points!"),SI.colorMsgBonus,capgrpGameState)
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2061
						AwardPoints(5)
12059
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  2062
						PlaySound(sndKamikaze, CurrentHedgehog)
13033
8b6d8418d580 Play a few more taunts in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13031
diff changeset
  2063
						kamikaze = true
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2064
					elseif SI.TimeLeft <= 9 then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2065
						AddCaption(loc("Timed Kamikaze! +10 points!"),SI.colorMsgBonus,capgrpGameState)
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2066
						AwardPoints(10)
12059
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  2067
						PlaySound(sndKamikaze, CurrentHedgehog)
13033
8b6d8418d580 Play a few more taunts in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13031
diff changeset
  2068
						kamikaze = true
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2069
					end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2070
				end
13033
8b6d8418d580 Play a few more taunts in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13031
diff changeset
  2071
				WellHeAintGonnaJumpNoMore(GetX(CurrentHedgehog),GetY(CurrentHedgehog),explosion,kamikaze)
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2072
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2073
			end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2074
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2075
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2076
		end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2077
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2078
	end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2079
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2080
end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2081
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2082
function HandleCircles()
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2083
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2084
	if SI.rAlpha ~= 255 then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2085
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2086
		SI.rPingTimer = SI.rPingTimer + 1
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2087
		if SI.rPingTimer == 100 then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2088
			SI.rPingTimer = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2089
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2090
			SI.rAlpha = SI.rAlpha + 5
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2091
			if SI.rAlpha >= 255 then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2092
				SI.rAlpha = 255
6253
d73317579ae4 Add "Surfer" achievement to Space Invasion.
mikade
parents: 5894
diff changeset
  2093
			end
5894
86c59c34cdd5 Balanced shield miser, multi-shot, and boss kills in SI. Added radar ping.
mikade
parents: 5827
diff changeset
  2094
		end
6253
d73317579ae4 Add "Surfer" achievement to Space Invasion.
mikade
parents: 5894
diff changeset
  2095
5894
86c59c34cdd5 Balanced shield miser, multi-shot, and boss kills in SI. Added radar ping.
mikade
parents: 5827
diff changeset
  2096
	end
86c59c34cdd5 Balanced shield miser, multi-shot, and boss kills in SI. Added radar ping.
mikade
parents: 5827
diff changeset
  2097
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2098
	for i = 0,(SI.vCCount-1) do
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2099
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2100
		SetVisualGearValues(SI.rCirc[i], SI.rCircX[i], SI.rCircY[i], 100, 255, 1, 10, 0, 40, 3, SI.vCircCol[i]-SI.rAlpha)
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2101
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2102
		SI.vCounter[i] = SI.vCounter[i] + 1
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2103
		if SI.vCounter[i] >= SI.vCounterLim[i] then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2104
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2105
			SI.vCounter[i] = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2106
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2107
			if 	((SI.vType[i] == "drone") or (SI.vType[i] == "blueboss") ) and
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2108
				(SI.vCircActive[i] == true) then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2109
				AddGear(SI.vCircX[i], SI.vCircY[i], gtShell, 0, 0, 0, 1)
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2110
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2111
			end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2112
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2113
		end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2114
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2115
		if (SI.vCircActive[i] == true) then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2116
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2117
			SI.vCircRadCounter[i] = SI.vCircRadCounter[i] + 1
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2118
			if SI.vCircRadCounter[i] == 100 then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2119
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2120
				SI.vCircRadCounter[i] = 0
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2121
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2122
				-- make my radius increase/decrease faster if I am an aura
13453
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13452
diff changeset
  2123
				local M
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2124
				if SI.vCircType[i] == 0 then
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2125
					M = 1
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2126
				else
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2127
					M = 10
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2128
				end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2129
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2130
				SI.vCircRadius[i] = SI.vCircRadius[i] + SI.vCircRadDir[i]
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2131
				if SI.vCircRadius[i] > SI.vCircRadMax[i] then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2132
					SI.vCircRadDir[i] = -M
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2133
				elseif SI.vCircRadius[i] < SI.vCircRadMin[i] then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2134
					SI.vCircRadDir[i] = M
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2135
				end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2136
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2137
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2138
				-- random effect test
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2139
				-- maybe use this to tell the difference between circs
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2140
				-- you can kill by shooting or not
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2141
				--vgtSmoke vgtSmokeWhite
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2142
				--vgtSteam -- nice long trail
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2143
				--vgtDust -- short trail on earthrise
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2144
				--vgtSmokeTrace
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2145
				if SI.vType[i] == "ammo" then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2146
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2147
					local tempE = AddVisualGear(SI.vCircX[i], SI.vCircY[i], vgtSmoke, 0, false)
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2148
					SetVisualGearValues(tempE, SI.vCircX[i], SI.vCircY[i], nil, nil, nil, nil, nil, nil, nil, SI.vCircCol[i] )
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2149
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2150
				elseif SI.vType[i] == "bonus" then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2151
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2152
					local tempE = AddVisualGear(SI.vCircX[i], SI.vCircY[i], vgtDust, 0, false)
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2153
					SetVisualGearValues(tempE, SI.vCircX[i], SI.vCircY[i], nil, nil, nil, nil, nil, 1, nil, SI.colorShieldParticle)
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2154
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2155
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2156
				elseif SI.vType[i] == "blueboss" then
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2157
13453
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13452
diff changeset
  2158
					local k = 25
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13452
diff changeset
  2159
					local g = vgtSteam
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2160
					local trailColour = SI.colorBossParticle
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2161
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2162
					local tempE = AddVisualGear(SI.vCircX[i], SI.vCircY[i], g, 0, false)
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2163
					SetVisualGearValues(tempE, SI.vCircX[i], SI.vCircY[i]+k, nil, nil, nil, nil, nil, nil, nil, trailColour-75 )
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2164
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2165
					tempE = AddVisualGear(SI.vCircX[i], SI.vCircY[i], g, 0, false)
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2166
					SetVisualGearValues(tempE, SI.vCircX[i]+k, SI.vCircY[i]-k, nil, nil, nil, nil, nil, nil, nil, trailColour-75 )
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2167
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2168
					tempE = AddVisualGear(SI.vCircX[i], SI.vCircY[i], g, 0, false)
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2169
					SetVisualGearValues(tempE, SI.vCircX[i]-k, SI.vCircY[i]-k, nil, nil, nil, nil, nil, nil, nil, trailColour-75 )
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2170
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2171
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2172
				end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2173
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2174
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2175
			end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2176
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2177
		end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2178
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2179
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2180
	end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2181
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2182
	-- alter the circles velocities
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2183
	SI.circAdjustTimer = SI.circAdjustTimer + 1
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2184
	if SI.circAdjustTimer == 2000 then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2185
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2186
		SI.circAdjustTimer = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2187
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2188
		for i = 0,(SI.vCCount-1) do
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2189
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2190
			-- bounce the circles off the edges if they go too far
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2191
			-- or make them move in random directions
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2192
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2193
			if SI.vCircX[i] > 5500 then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2194
				SI.vCircDX[i] = -5	--5 circmovchange
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2195
			elseif SI.vCircX[i] < -1500 then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2196
				SI.vCircDX[i] = 5	--5 circmovchange
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2197
			else
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2198
13453
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13452
diff changeset
  2199
				local z = GetRandom(2)
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2200
				if z == 1 then
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2201
					z = 1
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2202
				else
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2203
					z = -1
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2204
				end
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2205
				SI.vCircDX[i] = SI.vCircDX[i] + GetRandom(3)*z	--3 circmovchange
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2206
			end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2207
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2208
			if SI.vCircY[i] > 1500 then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2209
				SI.vCircDY[i] = -5	--5 circmovchange
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2210
			elseif SI.vCircY[i] < -2900 then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2211
				SI.vCircDY[i] = 5	--5 circmovchange
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2212
			else
13453
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13452
diff changeset
  2213
				local z = GetRandom(2)
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2214
				if z == 1 then
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2215
					z = 1
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2216
				else
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2217
					z = -1
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2218
				end
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2219
				SI.vCircDY[i] = SI.vCircDY[i] + GetRandom(3)*z	--3 circmovchange
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2220
			end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2221
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2222
		end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2223
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2224
	end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2225
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2226
	-- move the circles according to their current velocities
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2227
	SI.m2Count = SI.m2Count + 1
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2228
	if SI.m2Count == 25 then	--25 circmovchange
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2229
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2230
		SI.m2Count = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2231
		for i = 0,(SI.vCCount-1) do
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2232
			SI.vCircX[i] = SI.vCircX[i] + SI.vCircDX[i]
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2233
			SI.vCircY[i] = SI.vCircY[i] + SI.vCircDY[i]
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2234
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2235
			if (CurrentHedgehog ~= nil) and (SI.rAlpha ~= 255) then
12060
ddf0fee75449 Space Invasion: Dump most out-commented and unused code
Wuzzy <almikes@aol.com>
parents: 12059
diff changeset
  2236
				DoHorribleThings(i)
5894
86c59c34cdd5 Balanced shield miser, multi-shot, and boss kills in SI. Added radar ping.
mikade
parents: 5827
diff changeset
  2237
			end
86c59c34cdd5 Balanced shield miser, multi-shot, and boss kills in SI. Added radar ping.
mikade
parents: 5827
diff changeset
  2238
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2239
		end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2240
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2241
		if (SI.TimeLeft == 0) and (SI.tumbleStarted == true) then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2242
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2243
			SI.fadeAlpha = SI.fadeAlpha + 1
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2244
			if SI.fadeAlpha >= 255 then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2245
				SI.fadeAlpha = 255
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2246
			end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2247
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2248
		end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2249
7717
2684fdb9d874 revert since I didn't quite get this working smoothly enough. was close though. perhaps some other time. Shame because calling game tick less frequently can save a lot of CPU
nemo
parents: 7229
diff changeset
  2250
	end
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2251
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2252
	for i = 0,(SI.vCCount-1) do
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2253
		SetVisualGearValues(SI.vCirc[i], SI.vCircX[i], SI.vCircY[i], nil, nil, nil, nil, nil, SI.vCircRadius[i])
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2254
	end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2255
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2256
	if 	(SI.TimeLeft == 0) or
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2257
		((SI.tumbleStarted == false)) then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2258
		for i = 0,(SI.vCCount-1) do
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2259
			SetVisualGearValues(SI.vCirc[i], SI.vCircX[i], SI.vCircY[i], nil, nil, nil, nil, nil, SI.vCircRadius[i], nil, (SI.vCircCol[i]-SI.fadeAlpha))
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2260
		end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2261
	end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2262
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2263
6819
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
  2264
	if (CurrentHedgehog ~= nil) then
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2265
		if SI.beam == true then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2266
			SetVisualGearValues(SI.pShield, GetX(CurrentHedgehog), GetY(CurrentHedgehog), nil, nil, nil, nil, nil, 200, nil, SI.colorShield-0x000000FF - -SI.shieldHealth )
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2267
			DrawTag(SI.TAG_SHIELD)
6819
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
  2268
		else
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2269
			SetVisualGearValues(SI.pShield, GetX(CurrentHedgehog), GetY(CurrentHedgehog), nil, nil, nil, nil, nil, 0)
6819
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
  2270
		end
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
  2271
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2272
	end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2273
6819
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
  2274
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2275
end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2276
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2277
function ProjectileTrack(gear)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2278
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2279
	if (GetGearType(gear) == gtShell) then
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2280
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2281
		local turningSpeed = 0.1*SI.fMod
13453
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13452
diff changeset
  2282
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13452
diff changeset
  2283
		local dx, dy = GetGearVelocity(gear)
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2284
7717
2684fdb9d874 revert since I didn't quite get this working smoothly enough. was close though. perhaps some other time. Shame because calling game tick less frequently can save a lot of CPU
nemo
parents: 7229
diff changeset
  2285
		if GetX(gear) > GetX(CurrentHedgehog) then
12060
ddf0fee75449 Space Invasion: Dump most out-commented and unused code
Wuzzy <almikes@aol.com>
parents: 12059
diff changeset
  2286
			dx = dx - turningSpeed
7717
2684fdb9d874 revert since I didn't quite get this working smoothly enough. was close though. perhaps some other time. Shame because calling game tick less frequently can save a lot of CPU
nemo
parents: 7229
diff changeset
  2287
		else
12060
ddf0fee75449 Space Invasion: Dump most out-commented and unused code
Wuzzy <almikes@aol.com>
parents: 12059
diff changeset
  2288
			dx = dx + turningSpeed
7717
2684fdb9d874 revert since I didn't quite get this working smoothly enough. was close though. perhaps some other time. Shame because calling game tick less frequently can save a lot of CPU
nemo
parents: 7229
diff changeset
  2289
		end
2684fdb9d874 revert since I didn't quite get this working smoothly enough. was close though. perhaps some other time. Shame because calling game tick less frequently can save a lot of CPU
nemo
parents: 7229
diff changeset
  2290
2684fdb9d874 revert since I didn't quite get this working smoothly enough. was close though. perhaps some other time. Shame because calling game tick less frequently can save a lot of CPU
nemo
parents: 7229
diff changeset
  2291
		if GetY(gear) > GetY(CurrentHedgehog) then
12060
ddf0fee75449 Space Invasion: Dump most out-commented and unused code
Wuzzy <almikes@aol.com>
parents: 12059
diff changeset
  2292
			dy = dy - turningSpeed
7717
2684fdb9d874 revert since I didn't quite get this working smoothly enough. was close though. perhaps some other time. Shame because calling game tick less frequently can save a lot of CPU
nemo
parents: 7229
diff changeset
  2293
		else
12060
ddf0fee75449 Space Invasion: Dump most out-commented and unused code
Wuzzy <almikes@aol.com>
parents: 12059
diff changeset
  2294
			dy = dy + turningSpeed
7717
2684fdb9d874 revert since I didn't quite get this working smoothly enough. was close though. perhaps some other time. Shame because calling game tick less frequently can save a lot of CPU
nemo
parents: 7229
diff changeset
  2295
		end
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2296
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2297
13714
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2298
		local dxlimit = 0.4*SI.fMod
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13692
diff changeset
  2299
		local dylimit = 0.4*SI.fMod
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2300
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2301
		if dx > dxlimit then
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2302
			dx = dxlimit
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2303
		end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2304
		if dy > dylimit then
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2305
			dy = dylimit
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2306
		end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2307
		if dx < -dxlimit then
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2308
			dx = -dxlimit
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2309
		end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2310
		if dy < -dylimit then
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2311
			dy = -dylimit
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2312
		end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2313
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2314
		SetGearVelocity(gear, dx, dy)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2315
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2316
	end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2317
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2318
end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2319