share/hedgewars/Data/Scripts/Multiplayer/Space_Invasion.lua
author Wuzzy <Wuzzy2@mail.ru>
Tue, 28 May 2019 01:28:59 +0200
changeset 15090 e16f906224fd
parent 14974 6c17ef373079
child 15810 acf70c44065b
permissions -rw-r--r--
Change mission panel icons for a couple of game styles
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")
12054
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
--[[
13579
ff7378430675 Space Invasion: Delete dead code and ancient outdated comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13451
diff changeset
     7
Space Invasion
12054
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
12063
797d1236a56b Disable world edge in Space Invasion
Wuzzy <almikes@aol.com>
parents: 12062
diff changeset
    36
You also can change the following settings in the game scheme:
12054
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
12063
797d1236a56b Disable world edge in Space Invasion
Wuzzy <almikes@aol.com>
parents: 12062
diff changeset
    42
- mines/air mines (they don’t harm the active hedgehog, however)
12054
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
--------------------------
12054
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
12063
797d1236a56b Disable world edge in Space Invasion
Wuzzy <almikes@aol.com>
parents: 12062
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: 12062
diff changeset
    91
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
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
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
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
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
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
13580
dc4ce9f486b0 Refactor colors and caption type in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13579
diff changeset
   109
-------------------
dc4ce9f486b0 Refactor colors and caption type in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13579
diff changeset
   110
-- CAPTION TYPES --
dc4ce9f486b0 Refactor colors and caption type in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13579
diff changeset
   111
-------------------
dc4ce9f486b0 Refactor colors and caption type in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13579
diff changeset
   112
--[[
dc4ce9f486b0 Refactor colors and caption type in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13579
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: 13579
diff changeset
   114
dc4ce9f486b0 Refactor colors and caption type in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13579
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: 13579
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: 13579
diff changeset
   117
capgrpVolume: X-Hit Combo
dc4ce9f486b0 Refactor colors and caption type in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13579
diff changeset
   118
capgrpGameState: End of turn information, kamikaze achievements
dc4ce9f486b0 Refactor colors and caption type in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13579
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: 13579
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: 13579
diff changeset
   121
]]
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   122
12054
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
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
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: 13687
diff changeset
   130
local SI = {}
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   131
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
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
13451
57de4f050891 Space Invasion: Improve how round score is displayed
Wuzzy <Wuzzy2@mail.ru>
parents: 13449
diff changeset
   134
-- Tag IDs
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   135
SI.TAG_TIME = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   136
SI.TAG_BARRELS = 1
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   137
SI.TAG_SHIELD = 2
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   138
SI.TAG_ROUND_SCORE = 4
13451
57de4f050891 Space Invasion: Improve how round score is displayed
Wuzzy <Wuzzy2@mail.ru>
parents: 13449
diff changeset
   139
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   140
-- some console stuff
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   141
SI.shellID = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
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
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   145
SI.boosterOn = false
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   146
SI.preciseOn = false
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
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: 13687
diff changeset
   148
SI.roundNumber = 0
13711
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13710
diff changeset
   149
SI.lastRound = -1
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   150
SI.gameOver = false
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   151
SI.gameBegun = false
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   152
12054
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
13026
ca7fdb431b34 Construction Mode, Space Invasion: Add example script param in default schems to make editing more convenient
Wuzzy <Wuzzy2@mail.ru>
parents: 13019
diff changeset
   154
-- NOTE: If you change this, also change the default “Space Invasion” game scheme
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   155
SI.startBarrels = 5		-- "barrels"
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   156
SI.startShield = 30		-- "shield"
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   157
SI.startRadShots = 2		-- "pings"
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   158
SI.shieldBonus = 30		-- "shieldbonus"
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   159
SI.barrelBonus = 3		-- "barrelbonus"
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   160
SI.timeBonus = 4		-- "timebonus"
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   161
SI.forceTheme = true		-- "forcetheme"
12054
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
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   167
SI.numhhs = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   168
SI.hhs = {}
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   169
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   170
SI.teamNameArr = {}
13711
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13710
diff changeset
   171
SI.teamNameArrReverse = {}
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   172
SI.teamClan = {}
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   173
SI.teamSize = {}
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   174
SI.teamIndex = {}
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   175
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   176
SI.teamScore = {}
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   177
SI.teamCircsKilled = {}
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
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
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   181
SI.roundKills = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   182
SI.roundScore = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   183
SI.RK = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   184
SI.GK = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   185
SI.BK = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   186
SI.OK = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   187
SI.SK = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   188
SI.shieldMiser = true
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   189
SI.fierceComp = false
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   190
SI.chainCounter = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   191
SI.chainLength = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   192
SI.shotsFired = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   193
SI.shotsHit = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   194
SI.sniperHits = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   195
SI.pointBlankHits = 0
12054
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
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   201
SI.awardTotalKills=0	-- overall killed invaders (min. 30)
12054
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
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
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: 13687
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: 13687
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: 13687
diff changeset
   207
SI.awardCombo = nil	-- hog with longest combo (min. 5)
12054
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   208
13028
8b6d8418d580 Play a few more taunts in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13026
diff changeset
   209
8b6d8418d580 Play a few more taunts in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13026
diff changeset
   210
8b6d8418d580 Play a few more taunts in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13026
diff changeset
   211
-- Taunt trackers
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   212
SI.tauntTimer = -1
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   213
SI.tauntGear = nil
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   214
SI.tauntSound = nil
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   215
SI.tauntClanShots = 0 -- hogs of same clans shot in this turn
13028
8b6d8418d580 Play a few more taunts in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13026
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
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   221
SI.moveTimer = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   222
SI.leftOn = false
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   223
SI.rightOn = false
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   224
SI.upOn = false
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
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
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   229
SI.wep = {}
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   230
SI.wepAmmo = {}
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   231
SI.wepIndex = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
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
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   237
SI.primShotsMax = 5
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   238
SI.primShotsLeft = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   239
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   240
SI.TimeLeftCounter = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   241
SI.TimeLeft = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   242
SI.stopMovement = false
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   243
SI.tumbleStarted = false
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   244
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   245
SI.beam = false
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   246
SI.pShield = nil
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   247
SI.shieldHealth = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   248
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   249
SI.timer100 = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   250
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
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
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   257
SI.circlesAreGo = false
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   258
SI.playerIsFine = true
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   259
SI.targetHit = false
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   260
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
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: 13687
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: 13687
diff changeset
   263
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
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: 13687
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: 13687
diff changeset
   266
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   267
SI.vCirc = {}
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   268
SI.vCCount = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   269
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   270
SI.rCirc = {}
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   271
SI.rCircX = {}
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   272
SI.rCircY = {}
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   273
SI.rAlpha = 255
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   274
SI.rPingTimer = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   275
SI.radShotsLeft = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   276
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   277
SI.vCircActive = {}
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   278
SI.vCircHealth = {}
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   279
SI.vType = {}
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
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: 13687
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: 13687
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: 13687
diff changeset
   283
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   284
SI.vCircRadMax = {}
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   285
SI.vCircRadMin = {}
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   286
SI.vCircRadDir = {}
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   287
SI.vCircRadCounter = {}
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   288
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   289
SI.vCircDX = {}
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   290
SI.vCircDY = {}
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   291
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   292
SI.vCircX = {}
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   293
SI.vCircY = {}
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   294
SI.vCircMinA = {}
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   295
SI.vCircMaxA = {}
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   296
SI.vCircType = {}
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   297
SI.vCircPulse = {}
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   298
SI.vCircFuckAll = {}
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   299
SI.vCircRadius = {}
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   300
SI.vCircWidth = {}
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   301
SI.vCircCol = {}
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   302
13580
dc4ce9f486b0 Refactor colors and caption type in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13579
diff changeset
   303
-- Colors
dc4ce9f486b0 Refactor colors and caption type in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13579
diff changeset
   304
-- Invaders
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   305
SI.colorDrone = 0xFF0000FF
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   306
SI.colorBoss = 0x0050FFFF
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   307
SI.colorBossParticle = SI.colorBoss
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   308
SI.colorAmmo = 0x00FF00FF
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   309
SI.colorShield = 0xA800FFFF
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   310
SI.colorShieldParticle = SI.colorShield
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
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: 13687
diff changeset
   312
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   313
-- Other SI.colors
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   314
SI.colorMsgDepleted = 0xFF0000FF
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   315
SI.colorMsgBonus = 0xFFBA00FF
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   316
SI.colorTimer = 0xFFEE00FF
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   317
SI.colorScore = 0xFFFFFFFF
13580
dc4ce9f486b0 Refactor colors and caption type in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13579
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
13451
57de4f050891 Space Invasion: Improve how round score is displayed
Wuzzy <Wuzzy2@mail.ru>
parents: 13449
diff changeset
   325
function HideTag(i)
57de4f050891 Space Invasion: Improve how round score is displayed
Wuzzy <Wuzzy2@mail.ru>
parents: 13449
diff changeset
   326
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
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
12054
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
14322
8fc6ac47f00a Tweak Construction Mode, HedgeEditor, Space Invasion and Tumbler to support touch interface
Wuzzy <Wuzzy2@mail.ru>
parents: 13798
diff changeset
   334
	local xOffset, yOffset, tValue, tCol
5629
c24d29a538af HUD for Space Invasion, minor bugfix
mikade
parents: 5334
diff changeset
   335
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   336
	if i == SI.TAG_TIME then
14322
8fc6ac47f00a Tweak Construction Mode, HedgeEditor, Space Invasion and Tumbler to support touch interface
Wuzzy <Wuzzy2@mail.ru>
parents: 13798
diff changeset
   337
		if INTERFACE == "touch" then
8fc6ac47f00a Tweak Construction Mode, HedgeEditor, Space Invasion and Tumbler to support touch interface
Wuzzy <Wuzzy2@mail.ru>
parents: 13798
diff changeset
   338
			xOffset = 60
8fc6ac47f00a Tweak Construction Mode, HedgeEditor, Space Invasion and Tumbler to support touch interface
Wuzzy <Wuzzy2@mail.ru>
parents: 13798
diff changeset
   339
			yOffset = ScreenHeight - 35
8fc6ac47f00a Tweak Construction Mode, HedgeEditor, Space Invasion and Tumbler to support touch interface
Wuzzy <Wuzzy2@mail.ru>
parents: 13798
diff changeset
   340
		else
8fc6ac47f00a Tweak Construction Mode, HedgeEditor, Space Invasion and Tumbler to support touch interface
Wuzzy <Wuzzy2@mail.ru>
parents: 13798
diff changeset
   341
			xOffset = 40
8fc6ac47f00a Tweak Construction Mode, HedgeEditor, Space Invasion and Tumbler to support touch interface
Wuzzy <Wuzzy2@mail.ru>
parents: 13798
diff changeset
   342
			yOffset = 40
8fc6ac47f00a Tweak Construction Mode, HedgeEditor, Space Invasion and Tumbler to support touch interface
Wuzzy <Wuzzy2@mail.ru>
parents: 13798
diff changeset
   343
		end
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   344
		tCol = SI.colorTimer
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   345
		tValue = SI.TimeLeft
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   346
	elseif i == SI.TAG_BARRELS then
5827
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5825
diff changeset
   347
		zoomL = 1.1
14322
8fc6ac47f00a Tweak Construction Mode, HedgeEditor, Space Invasion and Tumbler to support touch interface
Wuzzy <Wuzzy2@mail.ru>
parents: 13798
diff changeset
   348
		if INTERFACE == "touch" then
8fc6ac47f00a Tweak Construction Mode, HedgeEditor, Space Invasion and Tumbler to support touch interface
Wuzzy <Wuzzy2@mail.ru>
parents: 13798
diff changeset
   349
			xOffset = 126
8fc6ac47f00a Tweak Construction Mode, HedgeEditor, Space Invasion and Tumbler to support touch interface
Wuzzy <Wuzzy2@mail.ru>
parents: 13798
diff changeset
   350
			yOffset = ScreenHeight - 37
8fc6ac47f00a Tweak Construction Mode, HedgeEditor, Space Invasion and Tumbler to support touch interface
Wuzzy <Wuzzy2@mail.ru>
parents: 13798
diff changeset
   351
		else
8fc6ac47f00a Tweak Construction Mode, HedgeEditor, Space Invasion and Tumbler to support touch interface
Wuzzy <Wuzzy2@mail.ru>
parents: 13798
diff changeset
   352
			xOffset = 40
8fc6ac47f00a Tweak Construction Mode, HedgeEditor, Space Invasion and Tumbler to support touch interface
Wuzzy <Wuzzy2@mail.ru>
parents: 13798
diff changeset
   353
			yOffset = 70
8fc6ac47f00a Tweak Construction Mode, HedgeEditor, Space Invasion and Tumbler to support touch interface
Wuzzy <Wuzzy2@mail.ru>
parents: 13798
diff changeset
   354
		end
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   355
		tCol = SI.colorAmmo
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   356
		tValue = SI.wepAmmo[SI.wepIndex]
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   357
	elseif i == SI.TAG_SHIELD then
5827
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5825
diff changeset
   358
		zoomL = 1.1
14322
8fc6ac47f00a Tweak Construction Mode, HedgeEditor, Space Invasion and Tumbler to support touch interface
Wuzzy <Wuzzy2@mail.ru>
parents: 13798
diff changeset
   359
		if INTERFACE == "touch" then
8fc6ac47f00a Tweak Construction Mode, HedgeEditor, Space Invasion and Tumbler to support touch interface
Wuzzy <Wuzzy2@mail.ru>
parents: 13798
diff changeset
   360
			xOffset = 126 + 35
8fc6ac47f00a Tweak Construction Mode, HedgeEditor, Space Invasion and Tumbler to support touch interface
Wuzzy <Wuzzy2@mail.ru>
parents: 13798
diff changeset
   361
			yOffset = ScreenHeight - 37
8fc6ac47f00a Tweak Construction Mode, HedgeEditor, Space Invasion and Tumbler to support touch interface
Wuzzy <Wuzzy2@mail.ru>
parents: 13798
diff changeset
   362
		else
8fc6ac47f00a Tweak Construction Mode, HedgeEditor, Space Invasion and Tumbler to support touch interface
Wuzzy <Wuzzy2@mail.ru>
parents: 13798
diff changeset
   363
			xOffset = 40 + 35
8fc6ac47f00a Tweak Construction Mode, HedgeEditor, Space Invasion and Tumbler to support touch interface
Wuzzy <Wuzzy2@mail.ru>
parents: 13798
diff changeset
   364
			yOffset = 70
8fc6ac47f00a Tweak Construction Mode, HedgeEditor, Space Invasion and Tumbler to support touch interface
Wuzzy <Wuzzy2@mail.ru>
parents: 13798
diff changeset
   365
		end
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   366
		tCol = SI.colorShield
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   367
		tValue = SI.shieldHealth - 80
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   368
	elseif i == SI.TAG_ROUND_SCORE then
12054
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   369
		zoomL = 1.1
14322
8fc6ac47f00a Tweak Construction Mode, HedgeEditor, Space Invasion and Tumbler to support touch interface
Wuzzy <Wuzzy2@mail.ru>
parents: 13798
diff changeset
   370
		if INTERFACE == "touch" then
8fc6ac47f00a Tweak Construction Mode, HedgeEditor, Space Invasion and Tumbler to support touch interface
Wuzzy <Wuzzy2@mail.ru>
parents: 13798
diff changeset
   371
			xOffset = 126 + 70
8fc6ac47f00a Tweak Construction Mode, HedgeEditor, Space Invasion and Tumbler to support touch interface
Wuzzy <Wuzzy2@mail.ru>
parents: 13798
diff changeset
   372
			yOffset = ScreenHeight - 37
8fc6ac47f00a Tweak Construction Mode, HedgeEditor, Space Invasion and Tumbler to support touch interface
Wuzzy <Wuzzy2@mail.ru>
parents: 13798
diff changeset
   373
		else
8fc6ac47f00a Tweak Construction Mode, HedgeEditor, Space Invasion and Tumbler to support touch interface
Wuzzy <Wuzzy2@mail.ru>
parents: 13798
diff changeset
   374
			xOffset = 40
8fc6ac47f00a Tweak Construction Mode, HedgeEditor, Space Invasion and Tumbler to support touch interface
Wuzzy <Wuzzy2@mail.ru>
parents: 13798
diff changeset
   375
			yOffset = 100
8fc6ac47f00a Tweak Construction Mode, HedgeEditor, Space Invasion and Tumbler to support touch interface
Wuzzy <Wuzzy2@mail.ru>
parents: 13798
diff changeset
   376
		end
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   377
		tCol = SI.colorScore
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   378
		tValue = SI.roundScore
5629
c24d29a538af HUD for Space Invasion, minor bugfix
mikade
parents: 5334
diff changeset
   379
	end
c24d29a538af HUD for Space Invasion, minor bugfix
mikade
parents: 5334
diff changeset
   380
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   381
	DeleteVisualGear(SI.vTag[i])
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   382
	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
   383
	SetVisualGearValues	(
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   384
				SI.vTag[i], 		--id
13451
57de4f050891 Space Invasion: Improve how round score is displayed
Wuzzy <Wuzzy2@mail.ru>
parents: 13449
diff changeset
   385
				-(div(ScreenWidth, 2)) + xOffset,	--xoffset
5629
c24d29a538af HUD for Space Invasion, minor bugfix
mikade
parents: 5334
diff changeset
   386
				ScreenHeight - yOffset, --yoffset
c24d29a538af HUD for Space Invasion, minor bugfix
mikade
parents: 5334
diff changeset
   387
				0, 			--dx
c24d29a538af HUD for Space Invasion, minor bugfix
mikade
parents: 5334
diff changeset
   388
				0, 			--dy
c24d29a538af HUD for Space Invasion, minor bugfix
mikade
parents: 5334
diff changeset
   389
				zoomL, 			--zoom
c24d29a538af HUD for Space Invasion, minor bugfix
mikade
parents: 5334
diff changeset
   390
				1, 			--~= 0 means align to screen
13449
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13448
diff changeset
   391
				nil, 			--frameticks
5629
c24d29a538af HUD for Space Invasion, minor bugfix
mikade
parents: 5334
diff changeset
   392
				tValue, 		--value
c24d29a538af HUD for Space Invasion, minor bugfix
mikade
parents: 5334
diff changeset
   393
				240000, 		--timer
13579
ff7378430675 Space Invasion: Delete dead code and ancient outdated comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13451
diff changeset
   394
				tCol			--color
5629
c24d29a538af HUD for Space Invasion, minor bugfix
mikade
parents: 5334
diff changeset
   395
				)
c24d29a538af HUD for Space Invasion, minor bugfix
mikade
parents: 5334
diff changeset
   396
c24d29a538af HUD for Space Invasion, minor bugfix
mikade
parents: 5334
diff changeset
   397
end
c24d29a538af HUD for Space Invasion, minor bugfix
mikade
parents: 5334
diff changeset
   398
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   399
function RebuildTeamInfo()
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   400
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   401
	-- make a list of individual team names
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   402
	for i = 0, (TeamsCount-1) do
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   403
		SI.teamSize[i] = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   404
		SI.teamIndex[i] = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   405
		SI.teamScore[i] = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   406
		SI.teamCircsKilled[i] = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   407
		SI.teamSurfer[i] = false
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   408
	end
13711
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13710
diff changeset
   409
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13710
diff changeset
   410
	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: 13710
diff changeset
   411
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13710
diff changeset
   412
		local name = GetTeamName(i)
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13710
diff changeset
   413
		SI.teamNameArr[i] = name
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13710
diff changeset
   414
		SI.teamNameArrReverse[name] = i
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   415
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   416
	end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   417
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   418
	-- 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
   419
	for i = 0, (TeamsCount-1) do
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   420
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   421
		for z = 0, (SI.numhhs-1) do
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   422
			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: 13687
diff changeset
   423
				SI.teamClan[i] = GetHogClan(SI.hhs[z])
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   424
				if SI.teamSize[i] == 0 then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   425
					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
   426
				end
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   427
				SI.teamSize[i] = SI.teamSize[i] + 1
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   428
				--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
   429
			end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   430
		end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   431
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   432
	end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   433
13019
880662cf41ee Add team score next to team bars for CTF_Blizard, Control, CTF, Mutant, Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 12426
diff changeset
   434
	for i=0, TeamsCount-1 do
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   435
		SetTeamLabel(SI.teamNameArr[i], SI.teamScore[i])
13019
880662cf41ee Add team score next to team bars for CTF_Blizard, Control, CTF, Mutant, Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 12426
diff changeset
   436
	end
880662cf41ee Add team score next to team bars for CTF_Blizard, Control, CTF, Mutant, Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 12426
diff changeset
   437
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   438
end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   439
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   440
-- control
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   441
function AwardPoints(p)
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   442
	SI.roundScore = SI.roundScore + p
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   443
	DrawTag(SI.TAG_ROUND_SCORE)
5245
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
	for i = 0,(TeamsCount-1) do
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   446
		if SI.teamClan[i] == GetHogClan(CurrentHedgehog) then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   447
			SI.teamScore[i] = SI.teamScore[i] + p
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   448
			SetTeamLabel(SI.teamNameArr[i], SI.teamScore[i])
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   449
		end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   450
	end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   451
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   452
end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   453
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   454
function AwardKills(t)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   455
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   456
	SI.roundKills = SI.roundKills + 1
6253
d73317579ae4 Add "Surfer" achievement to Space Invasion.
mikade
parents: 5894
diff changeset
   457
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   458
	for i = 0,(TeamsCount-1) do
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   459
		if SI.teamClan[i] == GetHogClan(CurrentHedgehog) then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   460
			SI.teamCircsKilled[i] = SI.teamCircsKilled[i] + 1
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   461
			SI.awardTotalKills = SI.awardTotalKills + 1
12054
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   462
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   463
		end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   464
	end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   465
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   466
end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   467
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   468
-----------------
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   469
12054
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   470
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
   471
	local awarded = false
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   472
	local newAward
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   473
	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
   474
		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
   475
			awarded = true
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   476
		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
   477
			awarded = true
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   478
		end
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   479
	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
   480
		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
   481
			awarded = true
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   482
		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
   483
			awarded = true
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   484
		end
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   485
	end
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   486
	if awarded then
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   487
		newAward = {
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   488
			hogName = GetHogName(CurrentHedgehog),
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   489
			teamName = GetHogTeamName(CurrentHedgehog),
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   490
			value = value
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   491
		}
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   492
	else
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   493
		newAward = oldAward
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   494
	end
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   495
	return newAward
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   496
end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   497
13711
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13710
diff changeset
   498
-- 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: 13710
diff changeset
   499
-- Returns 2 bools:
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13710
diff changeset
   500
-- 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: 13710
diff changeset
   501
-- 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: 13710
diff changeset
   502
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   503
function CommentOnScore()
12054
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   504
	local teamStats = {}
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   505
	for i = 0,(TeamsCount-1) do
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   506
		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
   507
	end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   508
12054
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   509
	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
   510
		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
   511
			return true
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   512
		else
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   513
			return false
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   514
		end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   515
	end
12054
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   516
	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
   517
	local teamComment = {}
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   518
	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
   519
		local comment
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   520
		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
   521
			local comment = teamStats[i].name .. " |" ..
12059
e8458438dcee More helpful Space Invasion description
Wuzzy <almikes@aol.com>
parents: 12058
diff changeset
   522
			string.format(loc("Score: %d"), teamStats[i].score) .. "|" ..
e8458438dcee More helpful Space Invasion description
Wuzzy <almikes@aol.com>
parents: 12058
diff changeset
   523
			string.format(loc("Kills: %d"), teamStats[i].kills)
13711
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13710
diff changeset
   524
			if i < TeamsCount then
12059
e8458438dcee More helpful Space Invasion description
Wuzzy <almikes@aol.com>
parents: 12058
diff changeset
   525
				comment = comment .. "| |"
e8458438dcee More helpful Space Invasion description
Wuzzy <almikes@aol.com>
parents: 12058
diff changeset
   526
			end
12054
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   527
			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
   528
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   529
			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
   530
		else
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   531
			comment = "|"
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   532
		end
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   533
		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
   534
	end
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   535
13711
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13710
diff changeset
   536
	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: 13710
diff changeset
   537
	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: 13710
diff changeset
   538
	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: 13710
diff changeset
   539
12054
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   540
	local entireC = ""
13711
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13710
diff changeset
   541
12054
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   542
	for i = TeamsCount,1,-1 do
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   543
		entireC = entireC .. teamComment[i]
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   544
	end
13711
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13710
diff changeset
   545
12054
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   546
	local statusText, scoreText
13711
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13710
diff changeset
   547
	-- Game is over
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13710
diff changeset
   548
	if lGameOver then
13019
880662cf41ee Add team score next to team bars for CTF_Blizard, Control, CTF, Mutant, Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 12426
diff changeset
   549
		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: 12426
diff changeset
   550
		scoreText = loc("Final team scores:")
13711
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13710
diff changeset
   551
	-- 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: 13710
diff changeset
   552
	elseif not roundLimitHit then
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   553
		AddCaption(string.format(loc("Rounds complete: %d/%d"), SI.roundNumber, SI.roundLimit), capcolDefault, capgrpMessage)
13711
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13710
diff changeset
   554
		return lGameOver, false
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13710
diff changeset
   555
	-- 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: 13710
diff changeset
   556
	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: 13710
diff changeset
   557
		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: 13710
diff changeset
   558
		local msg
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13710
diff changeset
   559
		if tieBreakingRound == 1 then
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13710
diff changeset
   560
			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: 13710
diff changeset
   561
		else
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13710
diff changeset
   562
			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: 13710
diff changeset
   563
		end
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13710
diff changeset
   564
		AddCaption(msg, capcolDefault, capgrpMessage)
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13710
diff changeset
   565
		return lGameOver, true
12054
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   566
	end
13711
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13710
diff changeset
   567
12334
0bc8c5fcd08c Use the traditional winning sequence in Space Invasion again (killing off the losers)
Wuzzy <almikes@aol.com>
parents: 12287
diff changeset
   568
	local displayTime
13711
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13710
diff changeset
   569
	if lGameOver then
12334
0bc8c5fcd08c Use the traditional winning sequence in Space Invasion again (killing off the losers)
Wuzzy <almikes@aol.com>
parents: 12287
diff changeset
   570
		displayTime = 20000
0bc8c5fcd08c Use the traditional winning sequence in Space Invasion again (killing off the losers)
Wuzzy <almikes@aol.com>
parents: 12287
diff changeset
   571
	else
0bc8c5fcd08c Use the traditional winning sequence in Space Invasion again (killing off the losers)
Wuzzy <almikes@aol.com>
parents: 12287
diff changeset
   572
		displayTime = 1
0bc8c5fcd08c Use the traditional winning sequence in Space Invasion again (killing off the losers)
Wuzzy <almikes@aol.com>
parents: 12287
diff changeset
   573
	end
15090
e16f906224fd Change mission panel icons for a couple of game styles
Wuzzy <Wuzzy2@mail.ru>
parents: 14974
diff changeset
   574
	local icon
e16f906224fd Change mission panel icons for a couple of game styles
Wuzzy <Wuzzy2@mail.ru>
parents: 14974
diff changeset
   575
	if lGameOver then
e16f906224fd Change mission panel icons for a couple of game styles
Wuzzy <Wuzzy2@mail.ru>
parents: 14974
diff changeset
   576
		icon = 4
e16f906224fd Change mission panel icons for a couple of game styles
Wuzzy <Wuzzy2@mail.ru>
parents: 14974
diff changeset
   577
	else
e16f906224fd Change mission panel icons for a couple of game styles
Wuzzy <Wuzzy2@mail.ru>
parents: 14974
diff changeset
   578
		icon = 2
e16f906224fd Change mission panel icons for a couple of game styles
Wuzzy <Wuzzy2@mail.ru>
parents: 14974
diff changeset
   579
	end
12054
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   580
	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
   581
			statusText,
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   582
			string.format(loc("Rounds complete: %d/%d"), SI.roundNumber, SI.roundLimit) .. "| " .. "|" ..
15090
e16f906224fd Change mission panel icons for a couple of game styles
Wuzzy <Wuzzy2@mail.ru>
parents: 14974
diff changeset
   583
			scoreText .. " |" ..entireC, icon, displayTime)
12054
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   584
13711
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13710
diff changeset
   585
	if lGameOver then
12054
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   586
		local winnerTeam = teamStats[1].name
13643
690cc84e9fd6 Use capcolDefault in Lua scripts
Wuzzy <Wuzzy2@mail.ru>
parents: 13580
diff changeset
   587
		AddCaption(string.format(loc("%s wins!"), winnerTeam), capcolDefault, capgrpGameState)
12424
b9cc405541c1 Fix various loc() syntax errors in scripts
Wuzzy <almikes@aol.com>
parents: 12334
diff changeset
   588
		SendStat(siGameResult, string.format(loc("%s wins!"), winnerTeam))
12054
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   589
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   590
		for i = 1, TeamsCount do
14599
50f511588635 Outsource commonly used words in siPointType to QTfrontend
Wuzzy <Wuzzy2@mail.ru>
parents: 14422
diff changeset
   591
			SendStat(siPointType, "!POINTS")
12054
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   592
			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
   593
		end
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   594
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   595
		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
   596
			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
   597
				return true
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   598
			else
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   599
				return false
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
		end
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   602
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   603
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   604
--[[ 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
   605
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
   606
		local awardsGiven = 0
13711
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13710
diff changeset
   607
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13710
diff changeset
   608
		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: 13710
diff changeset
   609
			SendStat(siCustomAchievement,
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13710
diff changeset
   610
			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: 13710
diff changeset
   611
			awardsGiven = awardsGiven + 1
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13710
diff changeset
   612
		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: 13710
diff changeset
   613
			SendStat(siCustomAchievement,
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13710
diff changeset
   614
			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: 13710
diff changeset
   615
			SI.roundNumber - SI.roundLimit))
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13710
diff changeset
   616
			awardsGiven = awardsGiven + 1
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13710
diff changeset
   617
		end
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   618
		if SI.awardTotalKills >= 30 then
12054
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   619
			awardsGiven = awardsGiven + 1
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   620
			SendStat(siCustomAchievement,
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   621
				string.format(loc("%d invaders have been destroyed in this game."), SI.awardTotalKills))
12054
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   622
		end
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   623
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   624
		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
   625
		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
   626
		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
   627
			awardsGiven = awardsGiven + 1
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   628
			local text
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   629
			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
   630
				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
   631
			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
   632
				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
   633
			else
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   634
				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
   635
			end
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   636
			SendStat(siCustomAchievement,
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   637
			string.format(text,
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   638
	                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
   639
		end
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   640
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   641
		if SI.awardRoundKills ~= nil then
12054
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   642
			awardsGiven = awardsGiven + 1
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   643
			local text
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   644
			if SI.awardRoundKills.value >= 33 then
12054
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) has been invited to join the Planetary Association of the Hedgehogs, it destroyed a staggering %d invaders in just one round!")
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   646
			elseif SI.awardRoundKills.value >= 22 then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   647
				if SI.awardRoundKills.hogName == "Rambo" then
12054
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   648
					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
   649
				else
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   650
					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
   651
				end
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   652
			elseif SI.awardRoundKills.value >= 11 then
12424
b9cc405541c1 Fix various loc() syntax errors in scripts
Wuzzy <almikes@aol.com>
parents: 12334
diff changeset
   653
				text = loc("%s (%s) is addicted to killing: %d invaders destroyed in one round.")
12054
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   654
			else
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   655
				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
   656
			end
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   657
			SendStat(siCustomAchievement,
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   658
			string.format(text,
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   659
			SI.awardRoundKills.hogName, SI.awardRoundKills.teamName, SI.awardRoundKills.value))
12054
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   660
		end
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   661
		if SI.awardRoundScore ~= nil then
12054
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   662
			awardsGiven = awardsGiven + 1
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   663
			local text
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   664
			if SI.awardRoundScore.value >= 300 then
12054
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) was undoubtedly the very best professional tumbler in this game: %d points in one round!")
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   666
			elseif SI.awardRoundScore.value >= 250 then
12054
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) struck like a meteor: %d points in only one round!")
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   668
			elseif SI.awardRoundScore.value >= 200 then
12054
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   669
				text = loc("%s (%s) is good at this: %d points in only one round!")
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   670
			elseif SI.awardRoundScore.value >= 150 then
12054
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   671
				text = loc("%s (%s) tumbles like no other: %d points in one round.")
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   672
			elseif SI.awardRoundScore.value >= 100 then
12054
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   673
				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
   674
			else
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   675
				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
   676
			end
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   677
			SendStat(siCustomAchievement,
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   678
			string.format(text,
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   679
			SI.awardRoundScore.hogName, SI.awardRoundScore.teamName, SI.awardRoundScore.value))
12054
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   680
		end
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   681
		if SI.awardAccuracy ~= nil then
12054
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   682
			awardsGiven = awardsGiven + 1
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   683
			local text
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   684
			if SI.awardAccuracy.value >= 20 then
12054
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   685
				text = loc("The Society of Perfectionists greets %s (%s): No misses and %d hits in its best round.")
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   686
			elseif SI.awardAccuracy.value >= 10 then
12054
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   687
				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
   688
			else
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   689
				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
   690
			end
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   691
			SendStat(siCustomAchievement,
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   692
			string.format(text,
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   693
			SI.awardAccuracy.hogName, SI.awardAccuracy.teamName, SI.awardAccuracy.value))
12054
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   694
		end
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   695
		if SI.awardCombo ~= nil then
12054
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   696
			awardsGiven = awardsGiven + 1
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   697
			local text
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   698
			if SI.awardCombo.value >= 11 then
12054
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   699
				text = loc("%s (%s) was lightning-fast! Longest combo of %d, absolutely insane!")
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   700
			elseif SI.awardCombo.value >= 8 then
12054
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   701
				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
   702
			else
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   703
				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
   704
			end
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   705
			SendStat(siCustomAchievement,
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   706
			string.format(text,
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   707
			SI.awardCombo.hogName, SI.awardCombo.teamName, SI.awardCombo.value))
12054
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   708
		end
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   709
		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
   710
			local text
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   711
			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
   712
			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
   713
			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
   714
			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
   715
			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
   716
			end
13711
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13710
diff changeset
   717
12054
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   718
			SendStat(siCustomAchievement, text)
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   719
		end
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   720
	end
13711
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13710
diff changeset
   721
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13710
diff changeset
   722
	return lGameOver, false
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   723
end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   724
6253
d73317579ae4 Add "Surfer" achievement to Space Invasion.
mikade
parents: 5894
diff changeset
   725
function onNewRound()
13711
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13710
diff changeset
   726
	SI.lastRound = TotalRounds
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   727
	SI.roundNumber = SI.roundNumber + 1
6253
d73317579ae4 Add "Surfer" achievement to Space Invasion.
mikade
parents: 5894
diff changeset
   728
13711
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13710
diff changeset
   729
	local lGameOver, lTied = CommentOnScore()
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13710
diff changeset
   730
	local bestScore = 0
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13710
diff changeset
   731
	local bestClan = -1
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13710
diff changeset
   732
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13710
diff changeset
   733
	-- 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: 13710
diff changeset
   734
	if lGameOver then
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13710
diff changeset
   735
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13710
diff changeset
   736
		-- Get winning score
6253
d73317579ae4 Add "Surfer" achievement to Space Invasion.
mikade
parents: 5894
diff changeset
   737
		for i = 0, (TeamsCount-1) do
13711
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13710
diff changeset
   738
			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: 13710
diff changeset
   739
				bestScore = SI.teamScore[i]
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13710
diff changeset
   740
				bestClan = SI.teamClan[i]
6253
d73317579ae4 Add "Surfer" achievement to Space Invasion.
mikade
parents: 5894
diff changeset
   741
			end
d73317579ae4 Add "Surfer" achievement to Space Invasion.
mikade
parents: 5894
diff changeset
   742
		end
d73317579ae4 Add "Surfer" achievement to Space Invasion.
mikade
parents: 5894
diff changeset
   743
12334
0bc8c5fcd08c Use the traditional winning sequence in Space Invasion again (killing off the losers)
Wuzzy <almikes@aol.com>
parents: 12287
diff changeset
   744
		-- Kill off all the losers
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   745
		for i = 0, (SI.numhhs-1) do
13711
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13710
diff changeset
   746
			if GetHogClan(SI.hhs[i]) ~= bestClan then
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   747
				SetEffect(SI.hhs[i], heResurrectable, 0)
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   748
				SetHealth(SI.hhs[i],0)
13712
d5f12b1d180d Space Invasion: Add hilarious loser face to losers
Wuzzy <Wuzzy2@mail.ru>
parents: 13711
diff changeset
   749
				-- hilarious loser face
d5f12b1d180d Space Invasion: Add hilarious loser face to losers
Wuzzy <Wuzzy2@mail.ru>
parents: 13711
diff changeset
   750
				SetState(SI.hhs[i], bor(GetState(SI.hhs[i]), gstLoser))
12334
0bc8c5fcd08c Use the traditional winning sequence in Space Invasion again (killing off the losers)
Wuzzy <almikes@aol.com>
parents: 12287
diff changeset
   751
			end
0bc8c5fcd08c Use the traditional winning sequence in Space Invasion again (killing off the losers)
Wuzzy <almikes@aol.com>
parents: 12287
diff changeset
   752
		end
0bc8c5fcd08c Use the traditional winning sequence in Space Invasion again (killing off the losers)
Wuzzy <almikes@aol.com>
parents: 12287
diff changeset
   753
0bc8c5fcd08c Use the traditional winning sequence in Space Invasion again (killing off the losers)
Wuzzy <almikes@aol.com>
parents: 12287
diff changeset
   754
		-- Game over
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   755
		SI.gameOver = true
12287
faf1b93422ba Use new EndTurn in a couple of scripts, esp. to fix timeout taunts in Racer
Wuzzy <almikes@aol.com>
parents: 12063
diff changeset
   756
		EndTurn(true)
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   757
		SI.TimeLeft = 0
12426
9f3387907e06 Fix even more bad/broken loc()'s in scripts (hopefully the last one)
Wuzzy <almikes@aol.com>
parents: 12424
diff changeset
   758
		SendStat(siGraphTitle, loc("Score graph"))
13711
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13710
diff changeset
   759
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13710
diff changeset
   760
	-- 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: 13710
diff changeset
   761
	elseif lTied then
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13710
diff changeset
   762
		-- 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: 13710
diff changeset
   763
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13710
diff changeset
   764
		-- 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: 13710
diff changeset
   765
		-- 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: 13710
diff changeset
   766
		-- 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: 13710
diff changeset
   767
		-- 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: 13710
diff changeset
   768
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13710
diff changeset
   769
		-- Get leading teams
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13710
diff changeset
   770
		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: 13710
diff changeset
   771
			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: 13710
diff changeset
   772
				bestScore = SI.teamScore[i]
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13710
diff changeset
   773
			end
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13710
diff changeset
   774
		end
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13710
diff changeset
   775
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13710
diff changeset
   776
		local tiedForTheLead = {}
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13710
diff changeset
   777
		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: 13710
diff changeset
   778
			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: 13710
diff changeset
   779
				tiedForTheLead[i] = true
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13710
diff changeset
   780
			end
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13710
diff changeset
   781
		end
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13710
diff changeset
   782
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13710
diff changeset
   783
		local wasCurrent = false
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13710
diff changeset
   784
		-- 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: 13710
diff changeset
   785
		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: 13710
diff changeset
   786
			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: 13710
diff changeset
   787
			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: 13710
diff changeset
   788
				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: 13710
diff changeset
   789
				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: 13710
diff changeset
   790
					-- hilarious loser face
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13710
diff changeset
   791
					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: 13710
diff changeset
   792
					-- die!
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13710
diff changeset
   793
					SetEffect(hog, heResurrectable, 0)
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13710
diff changeset
   794
					SetHealth(hog, 0)
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13710
diff changeset
   795
					-- 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: 13710
diff changeset
   796
					-- 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: 13710
diff changeset
   797
					-- the end of one.
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13710
diff changeset
   798
					-- 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: 13710
diff changeset
   799
					if hog == CurrentHedgehog then
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13710
diff changeset
   800
						wasCurrent = true
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13710
diff changeset
   801
					end
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13710
diff changeset
   802
				end
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13710
diff changeset
   803
			end
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13710
diff changeset
   804
		end
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13710
diff changeset
   805
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13710
diff changeset
   806
		-- 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: 13710
diff changeset
   807
		if wasCurrent then
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13710
diff changeset
   808
			EndTurn(true)
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13710
diff changeset
   809
		end
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13710
diff changeset
   810
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13710
diff changeset
   811
		-- From that point on, the game just continues normally ...
6253
d73317579ae4 Add "Surfer" achievement to Space Invasion.
mikade
parents: 5894
diff changeset
   812
	end
d73317579ae4 Add "Surfer" achievement to Space Invasion.
mikade
parents: 5894
diff changeset
   813
end
d73317579ae4 Add "Surfer" achievement to Space Invasion.
mikade
parents: 5894
diff changeset
   814
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   815
-- gaudy racer
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   816
function CheckForNewRound()
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   817
13711
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13710
diff changeset
   818
	if TotalRounds > 0 and TotalRounds > SI.lastRound then
6253
d73317579ae4 Add "Surfer" achievement to Space Invasion.
mikade
parents: 5894
diff changeset
   819
		onNewRound()
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   820
	end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   821
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   822
end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   823
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   824
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   825
----------------------------------------
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   826
-- some tumbler/space invaders methods
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   827
----------------------------------------
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   828
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   829
function isATrackedGear(gear)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   830
	if 	(GetGearType(gear) == gtExplosives) or
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   831
		(GetGearType(gear) == gtShell) or
12055
ddf0fee75449 Space Invasion: Dump most out-commented and unused code
Wuzzy <almikes@aol.com>
parents: 12054
diff changeset
   832
		(GetGearType(gear) == gtFlame) or
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   833
		(GetGearType(gear) == gtBall)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   834
	then
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   835
		return(true)
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
		return(false)
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
end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   840
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   841
function setNewGearValues(gear)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   842
13449
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13448
diff changeset
   843
	local lfs
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   844
	if GetGearType(gear) == gtShell then
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   845
		lfs = 50	-- roughly 5 seconds
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   846
		SI.shellID = SI.shellID + 1
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   847
		setGearValue(gear,"ID",SI.shellID)
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   848
	elseif GetGearType(gear) == gtBall then
6819
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
   849
		lfs = 5 --70	-- 7s
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   850
	elseif GetGearType(gear) == gtExplosives then
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   851
		lfs = 15	-- 1.5s
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   852
		SI.explosivesID = SI.explosivesID + 1
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   853
		setGearValue(gear,"ID",SI.explosivesID)
6819
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
   854
		setGearValue(gear,"XP", GetX(gear))
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
   855
		setGearValue(gear,"YP", GetY(gear))
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   856
	elseif GetGearType(gear) == gtFlame then
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   857
		lfs = 5	-- 0.5s
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   858
	else
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   859
		lfs = 100
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   860
	end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   861
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   862
	setGearValue(gear,"lifespan",lfs)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   863
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   864
end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   865
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   866
function HandleLifeSpan(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
	decreaseGearValue(gear,"lifespan")
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   869
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   870
	if getGearValue(gear,"lifespan") == 0 then
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   871
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   872
		if GetGearType(gear) == gtShell then
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   873
			AddVisualGear(GetX(gear), GetY(gear), vgtExplosion, 0, false)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   874
		elseif GetGearType(gear) == gtExplosives then
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   875
			AddVisualGear(GetX(gear), GetY(gear), vgtBigExplosion, 0, false)
12054
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   876
			PlaySound(sndExplosion)
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   877
		elseif GetGearType(gear) == gtFlame then
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   878
			AddVisualGear(GetX(gear), GetY(gear), vgtSmoke, 0, false)
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
		DeleteGear(gear)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   882
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   883
	end
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
end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   886
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   887
-- 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
   888
function DeleteFarFlungBarrel(gear)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   889
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   890
	if GetGearType(gear) == gtExplosives then
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   891
		if 	(GetX(gear) < -1900) or
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   892
			(GetX(gear) > 6200) or
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   893
			(GetY(gear) < -3400)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   894
		then
5827
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5825
diff changeset
   895
			AddVisualGear(GetX(gear), GetY(gear), vgtBigExplosion, 0, false)
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5825
diff changeset
   896
			DeleteGear(gear)
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   897
		end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   898
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   899
	end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   900
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   901
end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   902
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   903
-----------------------
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   904
--EVENT HANDLERS
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   905
-- action keys
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   906
-----------------------
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   907
6819
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
   908
function ChangeWeapon()
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
   909
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   910
	SI.wepIndex = SI.wepIndex + 1
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   911
	if SI.wepIndex == SI.wepCount then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   912
		SI.wepIndex = 0
6819
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
   913
	end
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   914
	AddCaption(SI.wep[SI.wepIndex], GetClanColor(GetHogClan(CurrentHedgehog)), capgrpAmmoinfo)
6819
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
   915
end
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
   916
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
   917
-- derp tumbler
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
   918
function onPrecise()
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
   919
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   920
	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: 13687
diff changeset
   921
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   922
		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: 13687
diff changeset
   923
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   924
		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: 13687
diff changeset
   925
			SI.shotsFired = SI.shotsFired +1
6819
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
   926
13449
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13448
diff changeset
   927
			local morte = AddGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog), gtExplosives, 0, 0, 0, 1)
13579
ff7378430675 Space Invasion: Delete dead code and ancient outdated comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13451
diff changeset
   928
			CopyPV(CurrentHedgehog, morte)
13449
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13448
diff changeset
   929
			local x,y = GetGearVelocity(morte)
6819
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
   930
			x = x*2
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
   931
			y = y*2
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
   932
			SetGearVelocity(morte, x, y)
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
   933
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   934
			if SI.wepAmmo[SI.wepIndex] == 0 then
12054
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   935
				PlaySound(sndSuddenDeath)
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   936
				AddCaption(loc("Ammo depleted!"),SI.colorMsgDepleted,capgrpAmmostate)
6819
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
   937
			else
12054
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   938
				PlaySound(sndThrowRelease)
6819
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
   939
			end
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   940
			DrawTag(SI.TAG_BARRELS)
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   941
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   942
		elseif SI.wep[SI.wepIndex] == loc("Mine Deployer") then
13449
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13448
diff changeset
   943
			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
   944
			SetTimer(morte, 1000)
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   945
			DrawTag(SI.TAG_BARRELS)
6819
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
   946
		end
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
   947
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   948
	elseif (SI.wepAmmo[SI.wepIndex] == 0) and (CurrentHedgehog ~= nil) and (SI.stopMovement == false) and (SI.tumbleStarted == true) then
12054
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   949
		PlaySound(sndDenied)
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   950
		AddCaption(loc("Ammo depleted!"),SI.colorMsgDepleted,capgrpAmmostate)
6819
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
   951
	end
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
   952
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   953
	SI.preciseOn = true
6819
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
   954
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
   955
end
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
   956
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
   957
function onPreciseUp()
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   958
	SI.preciseOn = false
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   959
end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   960
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   961
function onLJump()
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   962
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   963
	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: 13687
diff changeset
   964
		SI.shieldMiser = false
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   965
		if SI.shieldHealth == 80 then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   966
			AddCaption(loc("Shield depleted"),SI.colorMsgDepleted,capgrpAmmostate)
12054
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   967
			PlaySound(sndDenied)
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   968
		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: 13687
diff changeset
   969
			SI.beam = true
14846
cb5ffe17fdf9 Space Invasion: Fix missing arg in math.min
Wuzzy <Wuzzy2@mail.ru>
parents: 14845
diff changeset
   970
			SetVisualGearValues(SI.pShield, GetX(CurrentHedgehog), GetY(CurrentHedgehog), 40, 255, 1, 10, 0, nil, 1, SI.colorShield-0x000000FF - -math.min(SI.shieldHealth, 255))
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   971
			AddCaption( string.format(loc("Shield ON: %d power remaining"), SI.shieldHealth - 80), SI.colorShield, capgrpAmmostate)
13028
8b6d8418d580 Play a few more taunts in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13026
diff changeset
   972
			PlaySound(sndInvulnerable)
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   973
		else
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   974
			SI.beam = false
14844
358d81e29a88 Space Invasion: Fix minor visual glitches of shield
Wuzzy <Wuzzy2@mail.ru>
parents: 14832
diff changeset
   975
			SetVisualGearValues(SI.pShield, GetX(CurrentHedgehog), GetY(CurrentHedgehog), nil, nil, nil, nil, nil, nil, nil, 0x0)
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   976
			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
   977
		end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   978
	end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   979
end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
   980
5894
86c59c34cdd5 Balanced shield miser, multi-shot, and boss kills in SI. Added radar ping.
mikade
parents: 5827
diff changeset
   981
function onHJump()
86c59c34cdd5 Balanced shield miser, multi-shot, and boss kills in SI. Added radar ping.
mikade
parents: 5827
diff changeset
   982
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   983
	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: 13687
diff changeset
   984
	(SI.rAlpha == 255) then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   985
		if SI.radShotsLeft > 0 then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   986
			SI.rPingTimer = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   987
			SI.rAlpha = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   988
			SI.radShotsLeft = SI.radShotsLeft -1
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   989
			AddCaption(string.format(loc("Pings left: %d"), SI.radShotsLeft),GetClanColor(GetHogClan(CurrentHedgehog)),capgrpAmmostate)
12054
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   990
			-- Play sonar sound
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   991
			PlaySound(sndJetpackLaunch)
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   992
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   993
		else
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
   994
			AddCaption(loc("No radar pings left!"),SI.colorMsgDepleted,capgrpAmmostate)
12054
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   995
			PlaySound(sndDenied)
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
   996
		end
5894
86c59c34cdd5 Balanced shield miser, multi-shot, and boss kills in SI. Added radar ping.
mikade
parents: 5827
diff changeset
   997
	end
86c59c34cdd5 Balanced shield miser, multi-shot, and boss kills in SI. Added radar ping.
mikade
parents: 5827
diff changeset
   998
86c59c34cdd5 Balanced shield miser, multi-shot, and boss kills in SI. Added radar ping.
mikade
parents: 5827
diff changeset
   999
end
86c59c34cdd5 Balanced shield miser, multi-shot, and boss kills in SI. Added radar ping.
mikade
parents: 5827
diff changeset
  1000
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1001
-----------------
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1002
-- movement keys
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1003
-----------------
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1004
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1005
function onLeft()
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1006
	SI.leftOn = true
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1007
end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1008
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1009
function onRight()
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1010
	SI.rightOn = true
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1011
end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1012
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1013
function onUp()
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1014
	SI.upOn = true
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1015
end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1016
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1017
function onDown()
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1018
	SI.downOn = true
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1019
end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1020
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1021
function onDownUp()
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1022
	SI.downOn = false
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1023
end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1024
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1025
function onUpUp()
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1026
	SI.upOn = false
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1027
end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1028
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1029
function onLeftUp()
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1030
	SI.leftOn = false
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1031
end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1032
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1033
function onRightUp()
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1034
	SI.rightOn = false
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1035
end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1036
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1037
--------------------------
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1038
-- other event handlers
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1039
--------------------------
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1040
12054
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1041
function onParameters()
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1042
	parseParams()
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1043
	if params["rounds"] ~= nil then
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1044
		SI.roundLimit = math.floor(tonumber(params["rounds"]))
12054
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1045
	end
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1046
	if params["barrels"] ~= nil then
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1047
		SI.startBarrels = math.floor(tonumber(params["barrels"]))
12054
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
	if params["pings"] ~= nil then
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1050
		SI.startRadShots = math.floor(tonumber(params["pings"]))
12054
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1051
	end
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1052
	if params["shield"] ~= nil then
14845
f16868b40f2d Space Invasion: Fix possibility to go over shield limit with param
Wuzzy <Wuzzy2@mail.ru>
parents: 14844
diff changeset
  1053
		SI.startShield = math.min(250-80, math.floor(tonumber(params["shield"])))
12054
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1054
	end
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1055
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1056
	if params["barrelbonus"] ~= nil then
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1057
		SI.barrelBonus = math.floor(tonumber(params["barrelbonus"]))
12054
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1058
	end
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1059
	if params["shieldbonus"] ~= nil then
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1060
		SI.shieldBonus = math.floor(tonumber(params["shieldbonus"]))
12054
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1061
	end
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1062
	if params["timebonus"] ~= nil then
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1063
		SI.timeBonus = math.floor(tonumber(params["timebonus"]))
12054
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1064
	end
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1065
	if params["forcetheme"] == "false" then
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1066
		SI.forceTheme = false
12054
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1067
	else
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1068
		SI.forceTheme = true
12054
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1069
	end
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1070
end
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1071
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1072
function onGameInit()
12054
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1073
	--[[ 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
  1074
	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
  1075
	local allowedFlags = 
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1076
		-- 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
  1077
		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
  1078
		gfDisableLandObjects + gfSolidLand + gfLowGravity +
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1079
		-- a bit unusual but may still be useful
13272
5984e8c6cbeb Add new game flag gfSwitchHog, enable hog switching at turn start
Wuzzy <Wuzzy2@mail.ru>
parents: 13028
diff changeset
  1080
		gfBottomBorder + gfDivideTeams +
12054
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1081
		gfDisableWind + gfMoreWind + gfTagTeam +
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1082
		-- 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
  1083
		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
  1084
		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
  1085
		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
  1086
		-- 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
  1087
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1088
	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
  1089
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1090
	if SI.forceTheme then
12054
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1091
		Theme = "EarthRise"
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1092
	end
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1093
	CaseFreq = 0
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1094
	HealthCaseProb = 0
12054
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1095
	SuddenDeathTurns = 50
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1096
	WaterRise = 0
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1097
	HealthDecrease = 0
12063
797d1236a56b Disable world edge in Space Invasion
Wuzzy <almikes@aol.com>
parents: 12062
diff changeset
  1098
	WorldEdge = weNone
12054
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1099
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1100
	local tags = { SI.TAG_TIME, SI.TAG_BARRELS, SI.TAG_SHIELD, SI.TAG_ROUND_SCORE }
13687
a8b2a5e7e9db Clean up more visual gears stuff in scripts
Wuzzy <Wuzzy2@mail.ru>
parents: 13681
diff changeset
  1101
	for t=1, #tags do
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1102
		SI.vTag[tags[t]] = AddVisualGear(0, 0, vgtHealthTag, 0, false)
13687
a8b2a5e7e9db Clean up more visual gears stuff in scripts
Wuzzy <Wuzzy2@mail.ru>
parents: 13681
diff changeset
  1103
		HideTag(tags[t])
5629
c24d29a538af HUD for Space Invasion, minor bugfix
mikade
parents: 5334
diff changeset
  1104
	end
c24d29a538af HUD for Space Invasion, minor bugfix
mikade
parents: 5334
diff changeset
  1105
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1106
	SI.wep[0] = loc("Barrel Launcher")
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1107
	SI.wep[1] = loc("Mine Deployer")
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1108
	SI.wep[2] = loc("Flamer")
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1109
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1110
	SI.wepCount = 3
6819
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
  1111
14974
6c17ef373079 Mask sndFlyAway in Space Invasion and Tumbler
Wuzzy <Wuzzy2@mail.ru>
parents: 14950
diff changeset
  1112
	SetSoundMask(sndFlyAway, true)
6c17ef373079 Mask sndFlyAway in Space Invasion and Tumbler
Wuzzy <Wuzzy2@mail.ru>
parents: 14950
diff changeset
  1113
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1114
end
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
function onGameStart()
13798
e874bfe563c7 Make sure scripts don't break w/ only 1 clan
Wuzzy <Wuzzy2@mail.ru>
parents: 13712
diff changeset
  1117
	if ClansCount >= 2 then
e874bfe563c7 Make sure scripts don't break w/ only 1 clan
Wuzzy <Wuzzy2@mail.ru>
parents: 13712
diff changeset
  1118
		SendGameResultOff()
e874bfe563c7 Make sure scripts don't break w/ only 1 clan
Wuzzy <Wuzzy2@mail.ru>
parents: 13712
diff changeset
  1119
		SendRankingStatsOff()
e874bfe563c7 Make sure scripts don't break w/ only 1 clan
Wuzzy <Wuzzy2@mail.ru>
parents: 13712
diff changeset
  1120
		SendAchievementsStatsOff()
e874bfe563c7 Make sure scripts don't break w/ only 1 clan
Wuzzy <Wuzzy2@mail.ru>
parents: 13712
diff changeset
  1121
		SendHealthStatsOff()
e874bfe563c7 Make sure scripts don't break w/ only 1 clan
Wuzzy <Wuzzy2@mail.ru>
parents: 13712
diff changeset
  1122
	end
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
	ShowMission	(
12056
b68ec446a111 Space Invasion: Make all strings more translator-friendly
Wuzzy <almikes@aol.com>
parents: 12055
diff changeset
  1125
				loc("SPACE INVASION"),
b68ec446a111 Space Invasion: Make all strings more translator-friendly
Wuzzy <almikes@aol.com>
parents: 12055
diff changeset
  1126
				loc("A Hedgewars mini-game"),
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1127
12059
e8458438dcee More helpful Space Invasion description
Wuzzy <almikes@aol.com>
parents: 12058
diff changeset
  1128
				loc("Fly into space to fight off the invaders with barrels!") .."|"..
e8458438dcee More helpful Space Invasion description
Wuzzy <almikes@aol.com>
parents: 12058
diff changeset
  1129
				loc("Destroy invaders and collect bonuses to score points.") .. "|" ..
e8458438dcee More helpful Space Invasion description
Wuzzy <almikes@aol.com>
parents: 12058
diff changeset
  1130
				loc("Get the highest score to win.") .. "|" ..
e8458438dcee More helpful Space Invasion description
Wuzzy <almikes@aol.com>
parents: 12058
diff changeset
  1131
				" " .. "|" ..
e8458438dcee More helpful Space Invasion description
Wuzzy <almikes@aol.com>
parents: 12058
diff changeset
  1132
				loc("Avoid bazookas, red and blue invaders.") .. "|" ..
e8458438dcee More helpful Space Invasion description
Wuzzy <almikes@aol.com>
parents: 12058
diff changeset
  1133
				loc("Collect the green and purple invaders.") .. "|" ..
e8458438dcee More helpful Space Invasion description
Wuzzy <almikes@aol.com>
parents: 12058
diff changeset
  1134
				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
  1135
				" " .. "|" ..
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1136
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1137
				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
  1138
				" " .. "|" ..
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1139
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1140
				loc("Movement: [Up], [Down], [Left], [Right]") .. "|" ..
12056
b68ec446a111 Space Invasion: Make all strings more translator-friendly
Wuzzy <almikes@aol.com>
parents: 12055
diff changeset
  1141
				loc("Fire: [Precise]") .. "|" ..
b68ec446a111 Space Invasion: Make all strings more translator-friendly
Wuzzy <almikes@aol.com>
parents: 12055
diff changeset
  1142
				loc("Toggle Shield: [Long jump]") .. "|" ..
b68ec446a111 Space Invasion: Make all strings more translator-friendly
Wuzzy <almikes@aol.com>
parents: 12055
diff changeset
  1143
				loc("Radar Ping: [High jump]") .. "|" ..
b68ec446a111 Space Invasion: Make all strings more translator-friendly
Wuzzy <almikes@aol.com>
parents: 12055
diff changeset
  1144
15090
e16f906224fd Change mission panel icons for a couple of game styles
Wuzzy <Wuzzy2@mail.ru>
parents: 14974
diff changeset
  1145
				"", 8, 5000
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1146
				)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1147
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1148
	CreateMeSomeCircles()
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1149
	RebuildTeamInfo() -- control
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1150
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1151
end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1152
5825
a6eab1b7c00d Scripting: Update screen dimensions on screen resize and introduce onScreenResize() event.
sheepluva
parents: 5629
diff changeset
  1153
function onScreenResize()
a6eab1b7c00d Scripting: Update screen dimensions on screen resize and introduce onScreenResize() event.
sheepluva
parents: 5629
diff changeset
  1154
a6eab1b7c00d Scripting: Update screen dimensions on screen resize and introduce onScreenResize() event.
sheepluva
parents: 5629
diff changeset
  1155
	-- redraw Tags so that their screen locations are updated
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1156
	if (SI.gameBegun == true) then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1157
		DrawTag(SI.TAG_ROUND_SCORE)
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1158
		if (SI.stopMovement == false) then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1159
			DrawTag(SI.TAG_BARRELS)
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1160
			DrawTag(SI.TAG_SHIELD)
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1161
			if (SI.tumbleStarted == true) then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1162
				DrawTag(SI.TAG_TIME)
13451
57de4f050891 Space Invasion: Improve how round score is displayed
Wuzzy <Wuzzy2@mail.ru>
parents: 13449
diff changeset
  1163
			end
57de4f050891 Space Invasion: Improve how round score is displayed
Wuzzy <Wuzzy2@mail.ru>
parents: 13449
diff changeset
  1164
		end
5825
a6eab1b7c00d Scripting: Update screen dimensions on screen resize and introduce onScreenResize() event.
sheepluva
parents: 5629
diff changeset
  1165
	end
a6eab1b7c00d Scripting: Update screen dimensions on screen resize and introduce onScreenResize() event.
sheepluva
parents: 5629
diff changeset
  1166
a6eab1b7c00d Scripting: Update screen dimensions on screen resize and introduce onScreenResize() event.
sheepluva
parents: 5629
diff changeset
  1167
end
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1168
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1169
function onNewTurn()
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1170
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1171
	SI.radShotsLeft = SI.startRadShots
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1172
	SI.stopMovement = false
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1173
	SI.tumbleStarted = false
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1174
	SI.boosterOn = false
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1175
	SI.beam = false
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1176
	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: 13687
diff changeset
  1177
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1178
	SI.RK = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1179
	SI.GK = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1180
	SI.BK = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1181
	SI.OK = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1182
	SI.SK = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1183
	SI.roundKills = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1184
	SI.roundScore = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1185
	SI.shieldMiser = true
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1186
	SI.fierceComp = false
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1187
	SI.shotsFired = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1188
	SI.shotsHit = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1189
	SI.sniperHits = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1190
	SI.pointBlankHits = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1191
	SI.chainLength = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1192
	SI.chainCounter = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1193
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1194
	SI.tauntClanShots = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1195
	SI.tauntTimer = -1
13028
8b6d8418d580 Play a few more taunts in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13026
diff changeset
  1196
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1197
	-------------------------
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1198
	-- gaudy racer
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1199
	-------------------------
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1200
	CheckForNewRound()
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1201
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1202
	-- Handle Starting Stage of Game
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1203
	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: 13687
diff changeset
  1204
		SI.gameBegun = true
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1205
		SI.roundNumber = 0 -- 0
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1206
	end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1207
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1208
	if SI.gameOver == true then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1209
		SI.stopMovement = true
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1210
		SI.tumbleStarted = false
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1211
		SetMyCircles(false)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1212
	end
5827
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5825
diff changeset
  1213
6819
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
  1214
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
  1215
	-------
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
  1216
	-- tumbler
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
  1217
	----
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
  1218
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1219
	SI.wepAmmo[0] = SI.startBarrels
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1220
	SI.wepAmmo[1] = SI.startRadShots
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1221
	SI.wepAmmo[2] = 5000
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1222
	SI.wepIndex = 2
6819
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
  1223
	ChangeWeapon()
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
  1224
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
  1225
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1226
	HideTag(SI.TAG_TIME)
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1227
	if not SI.gameOver then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1228
		DrawTag(SI.TAG_BARRELS)
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1229
		DrawTag(SI.TAG_SHIELD)
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1230
		DrawTag(SI.TAG_ROUND_SCORE)
13451
57de4f050891 Space Invasion: Improve how round score is displayed
Wuzzy <Wuzzy2@mail.ru>
parents: 13449
diff changeset
  1231
	else
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1232
		HideTag(SI.TAG_BARRELS)
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1233
		HideTag(SI.TAG_SHIELD)
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1234
		HideTag(SI.TAG_ROUND_SCORE)
13451
57de4f050891 Space Invasion: Improve how round score is displayed
Wuzzy <Wuzzy2@mail.ru>
parents: 13449
diff changeset
  1235
	end
5629
c24d29a538af HUD for Space Invasion, minor bugfix
mikade
parents: 5334
diff changeset
  1236
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1237
end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1238
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1239
function ThingsToBeRunOnGears(gear)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1240
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1241
	HandleLifeSpan(gear)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1242
	DeleteFarFlungBarrel(gear)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1243
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1244
	if SI.circlesAreGo == true then
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1245
		CheckVarious(gear)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1246
		ProjectileTrack(gear)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1247
	end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1248
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1249
end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1250
10670
638af9cb922b make use of onGearWaterSkip
mikade <redgrinner@gmail.com>
parents: 10036
diff changeset
  1251
function onGearWaterSkip(gear)
638af9cb922b make use of onGearWaterSkip
mikade <redgrinner@gmail.com>
parents: 10036
diff changeset
  1252
	if gear == CurrentHedgehog then
638af9cb922b make use of onGearWaterSkip
mikade <redgrinner@gmail.com>
parents: 10036
diff changeset
  1253
638af9cb922b make use of onGearWaterSkip
mikade <redgrinner@gmail.com>
parents: 10036
diff changeset
  1254
		for i = 0,(TeamsCount-1) do
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1255
			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: 13687
diff changeset
  1256
				SI.teamSurfer[i] = true
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1257
				AddCaption(loc("Surfer! +15 points!"),SI.colorMsgBonus,capgrpMessage)
10670
638af9cb922b make use of onGearWaterSkip
mikade <redgrinner@gmail.com>
parents: 10036
diff changeset
  1258
				AwardPoints(15)
638af9cb922b make use of onGearWaterSkip
mikade <redgrinner@gmail.com>
parents: 10036
diff changeset
  1259
			end
638af9cb922b make use of onGearWaterSkip
mikade <redgrinner@gmail.com>
parents: 10036
diff changeset
  1260
		end
638af9cb922b make use of onGearWaterSkip
mikade <redgrinner@gmail.com>
parents: 10036
diff changeset
  1261
638af9cb922b make use of onGearWaterSkip
mikade <redgrinner@gmail.com>
parents: 10036
diff changeset
  1262
	end
638af9cb922b make use of onGearWaterSkip
mikade <redgrinner@gmail.com>
parents: 10036
diff changeset
  1263
end
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1264
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
  1265
function onGameTick()
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1266
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1267
	HandleCircles()
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1268
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1269
	SI.timer100 = SI.timer100 + 1
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1270
	if SI.timer100 >= 100 then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1271
		SI.timer100 = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1272
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1273
		if SI.beam == true then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1274
			SI.shieldHealth = SI.shieldHealth - 1
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1275
			if SI.shieldHealth < 80 then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1276
				SI.shieldHealth = 80
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1277
				SI.beam = false
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1278
				AddCaption(loc("Shield depleted"),SI.colorMsgDepleted,capgrpAmmostate)
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1279
				PlaySound(sndMineTick)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1280
				PlaySound(sndSwitchHog)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1281
			end
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
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1284
		if SI.tauntTimer > 0 then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1285
			SI.tauntTimer = SI.tauntTimer - 100
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1286
			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: 13687
diff changeset
  1287
				PlaySound(SI.tauntSound, SI.tauntGear)
13028
8b6d8418d580 Play a few more taunts in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13026
diff changeset
  1288
			end
8b6d8418d580 Play a few more taunts in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13026
diff changeset
  1289
		end
6819
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
  1290
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1291
		runOnGears(ThingsToBeRunOnGears)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1292
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1293
		if SI.circlesAreGo == true then
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1294
			CheckDistances()
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1295
		end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1296
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1297
		-- white smoke trail as player falls from the sky
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1298
		if (SI.TimeLeft <= 0) and (SI.stopMovement == true) and (CurrentHedgehog ~= nil) then
13449
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13448
diff changeset
  1299
			local j,k = GetGearVelocity(CurrentHedgehog)
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1300
			if (j ~= 0) and (k ~= 0) then
13680
a2f0cb003d7d Make decorational visual gears in Space Invasion non-critical
Wuzzy <Wuzzy2@mail.ru>
parents: 13643
diff changeset
  1301
				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
  1302
			end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1303
		end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1304
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1305
	end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1306
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1307
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1308
	-- start the player tumbling with a boom once their turn has actually begun
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1309
	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
  1310
		if (TurnTimeLeft > 0) and (TurnTimeLeft ~= TurnTime) then
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1311
			SI.tumbleStarted = true
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1312
			SI.TimeLeft = (TurnTime/1000)
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1313
			SI.fadeAlpha = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1314
			SI.rAlpha = 255
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1315
			AddGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog), gtGrenade, 0, 0, 0, 1)
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1316
			DrawTag(SI.TAG_TIME)
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1317
			DrawTag(SI.TAG_BARRELS)
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1318
			DrawTag(SI.TAG_SHIELD)
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1319
			DrawTag(SI.TAG_ROUND_SCORE)
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1320
			SetMyCircles(true)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1321
		end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1322
	end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1323
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1324
	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
  1325
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1326
		-- Calculate and display turn time
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1327
		SI.TimeLeftCounter = SI.TimeLeftCounter + 1
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1328
		if SI.TimeLeftCounter == 1000 then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1329
			SI.TimeLeftCounter = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1330
			SI.TimeLeft = SI.TimeLeft - 1
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1331
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1332
			if SI.TimeLeft >= 0 then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1333
				DrawTag(SI.TAG_TIME)
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1334
			end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1335
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1336
		end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1337
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1338
		if (SI.TimeLeftCounter % 1000) == 0 then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1339
			if SI.TimeLeft == 5 then
12057
1ee28630d424 Space Invasion: Play countdown sounds
Wuzzy <almikes@aol.com>
parents: 12056
diff changeset
  1340
				PlaySound(sndHurry, CurrentHedgehog)
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1341
			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: 13687
diff changeset
  1342
				PlaySound(_G["sndCountdown"..SI.TimeLeft])
12057
1ee28630d424 Space Invasion: Play countdown sounds
Wuzzy <almikes@aol.com>
parents: 12056
diff changeset
  1343
			end
12054
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1344
		end
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1345
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1346
		-------------------------------
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1347
		-- 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
  1348
		-------------------------------
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1349
		-- checks in FloatyThings
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1350
		if PlayerIsFine() == false then
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1351
			SI.TimeLeft = 0
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1352
		end
5827
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5825
diff changeset
  1353
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1354
		if (SI.TimeLeft == 0) then
13580
dc4ce9f486b0 Refactor colors and caption type in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13579
diff changeset
  1355
			if PlayerIsFine() then
13643
690cc84e9fd6 Use capcolDefault in Lua scripts
Wuzzy <Wuzzy2@mail.ru>
parents: 13580
diff changeset
  1356
				AddCaption(loc("Time's up!"), capcolDefault, capgrpGameState)
13580
dc4ce9f486b0 Refactor colors and caption type in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13579
diff changeset
  1357
			end
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1358
			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: 13687
diff changeset
  1359
				SI.stopMovement = true
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1360
				SI.boosterOn = false
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1361
				SI.beam = false
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1362
				SI.upOn = false
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1363
				SI.downOn = false
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1364
				SI.leftOn = false
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1365
				SI.rightOn = false
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1366
				SetMyCircles(false)
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1367
				SI.rAlpha = 255
12061
5beaf30c1cef Turn invaders white in Space Invasion when round is over
Wuzzy <almikes@aol.com>
parents: 12059
diff changeset
  1368
				FailGraphics()
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1369
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1370
				if SI.shieldMiser == true then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1371
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1372
					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: 13687
diff changeset
  1373
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1374
					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
  1375
					AwardPoints(p)
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1376
				end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1377
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1378
				local accuracy = (SI.shotsHit / SI.shotsFired) * 100
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1379
				if (accuracy >= 80) and (SI.shotsFired > 4) then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1380
					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
  1381
					AwardPoints(15)
12054
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1382
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1383
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1384
					-- 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
  1385
					local award = false
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1386
					if SI.awardAccuracy == nil then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1387
						if (SI.shotsHit >= SI.shotsFired) then
12054
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1388
							award = true
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1389
						end
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1390
					elseif (SI.shotsHit == SI.shotsFired) and SI.shotsHit > SI.awardAccuracy.value then
12054
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1391
						award = true
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1392
					end
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1393
					if award then
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1394
						SI.awardAccuracy = {
12054
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1395
							hogName = GetHogName(CurrentHedgehog),
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1396
							teamName = GetHogTeamName(CurrentHedgehog),
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1397
							value = SI.shotsHit, 
12054
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1398
						}
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1399
					end
13711
0da36902e5b6 Space Invasion: Continue playing rounds in case the teams are tied at the end
Wuzzy <Wuzzy2@mail.ru>
parents: 13710
diff changeset
  1400
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1401
				end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1402
12054
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1403
				-- other awards
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1404
				SI.awardRoundScore = UpdateSimpleAward(SI.awardRoundScore, SI.roundScore, 50)
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1405
				SI.awardRoundKills = UpdateSimpleAward(SI.awardRoundKills, SI.roundKills, 5)
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1406
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1407
				HideTag(SI.TAG_TIME)
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1408
				HideTag(SI.TAG_BARRELS)
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1409
				HideTag(SI.TAG_SHIELD)
12054
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1410
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1411
			end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1412
		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
  1413
		-------------------------------
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1414
		-- Player is still in luck
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1415
		-------------------------------
5827
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5825
diff changeset
  1416
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1417
			if SI.chainCounter > 0 then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1418
				SI.chainCounter = SI.chainCounter -1
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1419
				if SI.chainCounter == 0 then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1420
					SI.chainLength = 0
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1421
				end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1422
			end
5827
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5825
diff changeset
  1423
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1424
			-- handle movement based on IO
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1425
			SI.moveTimer = SI.moveTimer + 1
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1426
			if SI.moveTimer == 100 then -- 100
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1427
				SI.moveTimer = 0
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1428
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
				-- new trail code
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1431
				---------------
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1432
				-- the trail lets you know you have 5s left to pilot, akin to birdy feathers
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1433
				if (SI.TimeLeft <= 5) and (SI.TimeLeft > 0) then							--vgtSmoke
13680
a2f0cb003d7d Make decorational visual gears in Space Invasion non-critical
Wuzzy <Wuzzy2@mail.ru>
parents: 13643
diff changeset
  1434
					local tempE = AddVisualGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog), vgtSmoke, 0, false)
13449
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13448
diff changeset
  1435
					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
  1436
				end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1437
				--------------
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1438
				--------------
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1439
13449
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13448
diff changeset
  1440
				local dx, dy = GetGearVelocity(CurrentHedgehog)
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1441
13449
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13448
diff changeset
  1442
				local dxlimit, dylimit
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1443
				if SI.boosterOn == true then
13449
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13448
diff changeset
  1444
					local tempE = AddVisualGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog), vgtDust, 0, false)
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13448
diff changeset
  1445
					SetVisualGearValues(tempE, nil, nil, nil, nil, nil, nil, nil, 1, nil, GetClanColor(GetHogClan(CurrentHedgehog)) )
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1446
					dxlimit = 0.8*SI.fMod
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1447
					dylimit = 0.8*SI.fMod
6819
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
  1448
				else
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1449
					dxlimit = 0.4*SI.fMod
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1450
					dylimit = 0.4*SI.fMod
6819
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
  1451
				end
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1452
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1453
				if dx > dxlimit then
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1454
					dx = dxlimit
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1455
				end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1456
				if dy > dylimit then
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1457
					dy = dylimit
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1458
				end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1459
				if dx < -dxlimit then
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1460
					dx = -dxlimit
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1461
				end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1462
				if dy < -dylimit then
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1463
					dy = -dylimit
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1464
				end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1465
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1466
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1467
				if SI.leftOn == true then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1468
					dx = dx - 0.1*SI.fMod
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1469
				end
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1470
				if SI.rightOn == true then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1471
					dx = dx + 0.1*SI.fMod
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1472
				end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1473
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1474
				if SI.upOn == true then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1475
					dy = dy - 0.1*SI.fMod
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1476
				end
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1477
				if SI.downOn == true then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1478
					dy = dy + 0.1*SI.fMod
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1479
				end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1480
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1481
				SetGearVelocity(CurrentHedgehog, dx, dy)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1482
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1483
			end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1484
6819
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
  1485
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1486
		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
  1487
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1488
	end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1489
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1490
end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1491
6819
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
  1492
function onGearDamage(gear, damage)
13028
8b6d8418d580 Play a few more taunts in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13026
diff changeset
  1493
	if GetGearType(gear) == gtHedgehog and damage >= 60 then
8b6d8418d580 Play a few more taunts in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13026
diff changeset
  1494
		if GetHogClan(gear) ~= GetHogClan(CurrentHedgehog) then
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1495
			if (SI.fierceComp == false) then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1496
				SI.fierceComp = true
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1497
				AddCaption(loc("Fierce Competition! +8 points!"),SI.colorMsgBonus,capgrpMessage)
13028
8b6d8418d580 Play a few more taunts in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13026
diff changeset
  1498
				AwardPoints(8)
8b6d8418d580 Play a few more taunts in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13026
diff changeset
  1499
			end
8b6d8418d580 Play a few more taunts in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13026
diff changeset
  1500
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1501
			SI.tauntTimer = 500
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1502
			SI.tauntGear = gear
13028
8b6d8418d580 Play a few more taunts in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13026
diff changeset
  1503
			local r = math.random(1, 2)
8b6d8418d580 Play a few more taunts in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13026
diff changeset
  1504
			if r == 1 then
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1505
				SI.tauntSound = sndIllGetYou
13028
8b6d8418d580 Play a few more taunts in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13026
diff changeset
  1506
			else
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1507
				SI.tauntSound = sndJustYouWait
13028
8b6d8418d580 Play a few more taunts in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13026
diff changeset
  1508
			end
8b6d8418d580 Play a few more taunts in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13026
diff changeset
  1509
		elseif gear ~= CurrentHedgehog then
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1510
			SI.tauntTimer = 500
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1511
			SI.tauntGear = gear
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1512
			if SI.tauntClanShots == 0 then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1513
				SI.tauntSound = sndSameTeam
13028
8b6d8418d580 Play a few more taunts in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13026
diff changeset
  1514
			else
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1515
				SI.tauntSound = sndTraitor
13028
8b6d8418d580 Play a few more taunts in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13026
diff changeset
  1516
			end
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1517
			SI.tauntClanShots = SI.tauntClanShots + 1
6819
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
  1518
		end
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
  1519
	end
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
  1520
end
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
  1521
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1522
function onGearResurrect(gear)
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
	-- 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
  1525
	if gear == CurrentHedgehog then
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1526
		SI.TimeLeft = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1527
		SI.playerIsFine = false
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1528
	end
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
end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1531
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1532
function onGearAdd(gear)
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 isATrackedGear(gear) then
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1535
		trackGear(gear)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1536
		setNewGearValues(gear)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1537
	end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1538
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1539
	if GetGearType(gear) == gtHedgehog then
7838
5c2337f8dbb2 Issue #443 - change in syntax for effects
nemo
parents: 7717
diff changeset
  1540
		SetEffect(gear, heResurrectable, 1)
5245
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
		-- control
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1544
		SI.hhs[SI.numhhs] = gear
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1545
		SI.numhhs = SI.numhhs + 1
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1546
		-----------
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1547
	end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1548
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1549
end
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
function onGearDelete(gear)
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
	if isATrackedGear(gear) then
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1554
		trackDeletion(gear)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1555
	end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1556
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1557
	if CurrentHedgehog ~= nil then
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1558
		FollowGear(CurrentHedgehog)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1559
	end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1560
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1561
end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1562
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1563
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1564
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1565
------------------------------------------------------------
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1566
------------------------------------------------------------
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1567
------------------------------------------------------------
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1568
------------------------------------------------------------
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1569
-- FLOATY THINGS
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1570
-- "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
  1571
-- 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
  1572
------------------------------------------------------------
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1573
------------------------------------------------------------
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1574
------------------------------------------------------------
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1575
------------------------------------------------------------
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1576
14832
d65e25e211d4 Add integerSqrt and integerHypotenuse to Utils lib
Wuzzy <Wuzzy2@mail.ru>
parents: 14599
diff changeset
  1577
function HandleRadarBlip(cUID)
5894
86c59c34cdd5 Balanced shield miser, multi-shot, and boss kills in SI. Added radar ping.
mikade
parents: 5827
diff changeset
  1578
6253
d73317579ae4 Add "Surfer" achievement to Space Invasion.
mikade
parents: 5894
diff changeset
  1579
	-- work out the distance to the target
13449
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13448
diff changeset
  1580
	local g1X, g1Y = GetGearPosition(CurrentHedgehog)
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1581
	local g2X, g2Y = SI.vCircX[cUID], SI.vCircY[cUID]
13449
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13448
diff changeset
  1582
	local q = g1X - g2X
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13448
diff changeset
  1583
	local w = g1Y - g2Y
14832
d65e25e211d4 Add integerSqrt and integerHypotenuse to Utils lib
Wuzzy <Wuzzy2@mail.ru>
parents: 14599
diff changeset
  1584
	-- Floating point operations are safe, it's only for visuals
13449
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13448
diff changeset
  1585
	local r = math.sqrt( (q*q) + (w*w) )	--alternate
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13448
diff changeset
  1586
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13448
diff changeset
  1587
	local opp = w
5894
86c59c34cdd5 Balanced shield miser, multi-shot, and boss kills in SI. Added radar ping.
mikade
parents: 5827
diff changeset
  1588
	if opp < 0 then
86c59c34cdd5 Balanced shield miser, multi-shot, and boss kills in SI. Added radar ping.
mikade
parents: 5827
diff changeset
  1589
		opp = opp*-1
86c59c34cdd5 Balanced shield miser, multi-shot, and boss kills in SI. Added radar ping.
mikade
parents: 5827
diff changeset
  1590
	end
86c59c34cdd5 Balanced shield miser, multi-shot, and boss kills in SI. Added radar ping.
mikade
parents: 5827
diff changeset
  1591
86c59c34cdd5 Balanced shield miser, multi-shot, and boss kills in SI. Added radar ping.
mikade
parents: 5827
diff changeset
  1592
	-- work out the angle (theta) to the target
13449
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13448
diff changeset
  1593
	local t = math.deg ( math.asin(opp / r) )
6253
d73317579ae4 Add "Surfer" achievement to Space Invasion.
mikade
parents: 5894
diff changeset
  1594
d73317579ae4 Add "Surfer" achievement to Space Invasion.
mikade
parents: 5894
diff changeset
  1595
	-- based on the radius of the radar, calculate what x/y displacement should be
13449
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13448
diff changeset
  1596
	local NR = 150 -- radius at which to draw circs
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13448
diff changeset
  1597
	local NX = math.cos( math.rad(t) ) * NR
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13448
diff changeset
  1598
	local NY = math.sin( math.rad(t) ) * NR
6253
d73317579ae4 Add "Surfer" achievement to Space Invasion.
mikade
parents: 5894
diff changeset
  1599
5894
86c59c34cdd5 Balanced shield miser, multi-shot, and boss kills in SI. Added radar ping.
mikade
parents: 5827
diff changeset
  1600
	-- displace xy based on where this thing actually is
6819
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
  1601
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
  1602
	if r < NR then
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1603
		SI.rCircX[cUID] = g2X
6819
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
  1604
	elseif q > 0 then
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1605
		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
  1606
	else
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1607
		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
  1608
	end
86c59c34cdd5 Balanced shield miser, multi-shot, and boss kills in SI. Added radar ping.
mikade
parents: 5827
diff changeset
  1609
6819
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
  1610
	if r < NR then
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1611
		SI.rCircY[cUID] = g2Y
6819
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
  1612
	elseif w > 0 then
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1613
		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
  1614
	else
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1615
		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
  1616
	end
6253
d73317579ae4 Add "Surfer" achievement to Space Invasion.
mikade
parents: 5894
diff changeset
  1617
5894
86c59c34cdd5 Balanced shield miser, multi-shot, and boss kills in SI. Added radar ping.
mikade
parents: 5827
diff changeset
  1618
end
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1619
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1620
function PlayerIsFine()
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1621
	return (SI.playerIsFine)
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1622
end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1623
6819
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
  1624
function GetDistFromXYtoXY(a, b, c, d)
13449
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13448
diff changeset
  1625
	local q = a - c
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13448
diff changeset
  1626
	local w = b - d
6819
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
  1627
	return ( (q*q) + (w*w) )
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
  1628
end
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
  1629
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1630
function GetDistFromGearToGear(gear, gear2)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1631
13449
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13448
diff changeset
  1632
	local g1X, g1Y = GetGearPosition(gear)
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13448
diff changeset
  1633
	local g2X, g2Y = GetGearPosition(gear2)
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13448
diff changeset
  1634
	local q = g1X - g2X
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13448
diff changeset
  1635
	local w = g1Y - g2Y
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1636
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1637
	return ( (q*q) + (w*w) )
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1638
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1639
end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1640
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1641
function GetDistFromGearToXY(gear, g2X, g2Y)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1642
13449
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13448
diff changeset
  1643
	local g1X, g1Y = GetGearPosition(gear)
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13448
diff changeset
  1644
	local q = g1X - g2X
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13448
diff changeset
  1645
	local w = g1Y - g2Y
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1646
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1647
	return ( (q*q) + (w*w) )
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1648
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1649
end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1650
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1651
function CreateMeSomeCircles()
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1652
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1653
	for i = 0, 7 do
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1654
		SI.vCCount = SI.vCCount +1
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1655
		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: 13687
diff changeset
  1656
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1657
		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: 13687
diff changeset
  1658
		SI.rCircX[i] = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1659
		SI.rCircY[i] = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1660
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1661
		SI.vCircDX[i] = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1662
		SI.vCircDY[i] = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1663
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1664
		SI.vType[i] = "generic"
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1665
		SI.vCounter[i] = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1666
		SI.vCounterLim[i] = 3000
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1667
		SI.vCircScore[i] = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1668
		SI.vCircHealth[i] = 1
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1669
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1670
		SI.vCircMinA[i] = 80
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1671
		SI.vCircMaxA[i] = 255
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1672
		SI.vCircType[i] = 1
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1673
		SI.vCircPulse[i] = 10
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1674
		SI.vCircFuckAll[i] = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1675
		SI.vCircRadius[i] = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1676
		SI.vCircWidth[i] = 3
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1677
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1678
		SI.vCircRadMax[i] = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1679
		SI.vCircRadMin[i] = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1680
		SI.vCircRadDir[i] = -1
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1681
		SI.vCircRadCounter[i] = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1682
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1683
		SI.vCircX[i], SI.vCircY[i] = 0,0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1684
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1685
		SI.vCircCol[i] = 0xFF00FFFF
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1686
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1687
		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: 13687
diff changeset
  1688
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1689
		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
  1690
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1691
	end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1692
14844
358d81e29a88 Space Invasion: Fix minor visual glitches of shield
Wuzzy <Wuzzy2@mail.ru>
parents: 14832
diff changeset
  1693
	SI.pShield = AddVisualGear(0,0,vgtCircle,200,true)
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1694
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1695
end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1696
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1697
function IGotMeASafeXYValue(i)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1698
13449
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13448
diff changeset
  1699
	local acceptibleDistance = 800
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1700
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1701
	SI.vCircX[i] = GetRandom(5000)
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1702
	SI.vCircY[i] = GetRandom(2000)
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1703
	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
  1704
	if dist > acceptibleDistance*acceptibleDistance then
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1705
		return(true)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1706
	else
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1707
		return(false)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1708
	end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1709
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1710
end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1711
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1712
function CircleDamaged(i)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1713
13449
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13448
diff changeset
  1714
	local res = ""
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1715
	SI.vCircHealth[i] = SI.vCircHealth[i] -1
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1716
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1717
	if SI.vCircHealth[i] <= 0 then
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1718
	-- circle is dead, do death effects/consequences
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1719
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1720
		SI.vCircActive[i] = false
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1721
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1722
		if (SI.vType[i] == "drone") then
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1723
			PlaySound(sndHellishImpact4)
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1724
			SI.TimeLeft = SI.TimeLeft + SI.timeBonus
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1725
			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: 13687
diff changeset
  1726
			DrawTag(SI.TAG_TIME)
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1727
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1728
			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
  1729
			SetHealth(morte, 0)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1730
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1731
			SI.RK = SI.RK + 1
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1732
			if SI.RK == 5 then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1733
				SI.RK = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1734
				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
  1735
				AwardPoints(10)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1736
			end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1737
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1738
		elseif (SI.vType[i] == "ammo") then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1739
			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
  1740
			PlaySound(sndExplosion)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1741
			PlaySound(sndShotgunReload)
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1742
			SI.wepAmmo[0] = SI.wepAmmo[0] + SI.barrelBonus
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1743
			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: 13687
diff changeset
  1744
			DrawTag(SI.TAG_BARRELS)
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1745
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1746
			SI.GK = SI.GK + 1
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1747
			if SI.GK == 3 then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1748
				SI.GK = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1749
				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
  1750
				AwardPoints(5)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1751
			end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1752
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1753
		elseif (SI.vType[i] == "bonus") then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1754
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1755
			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
  1756
			PlaySound(sndExplosion)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1757
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1758
			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: 13687
diff changeset
  1759
			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: 13687
diff changeset
  1760
			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: 13687
diff changeset
  1761
			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: 13687
diff changeset
  1762
			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: 13687
diff changeset
  1763
			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
  1764
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1765
			PlaySound(sndVaporize)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1766
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1767
			SI.shieldHealth = SI.shieldHealth + SI.shieldBonus
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1768
			if SI.shieldHealth >= 250 then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1769
				SI.shieldHealth = 250
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1770
				AddCaption(loc("Shield is fully recharged!"),SI.colorShield,capgrpMessage)
13580
dc4ce9f486b0 Refactor colors and caption type in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13579
diff changeset
  1771
			else
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1772
				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
  1773
			end
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1774
			DrawTag(SI.TAG_SHIELD)
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1775
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1776
			SI.OK = SI.OK + 1
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1777
			if SI.OK == 3 then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1778
				SI.OK = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1779
				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
  1780
				AwardPoints(10)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1781
			end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1782
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1783
		elseif (SI.vType[i] == "blueboss") then
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1784
			PlaySound(sndHellishImpact3)
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1785
			SI.tauntTimer = 300
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1786
			SI.tauntSound = sndEnemyDown
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1787
			SI.tauntGear = CurrentHedgehog
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1788
			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: 13687
diff changeset
  1789
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1790
			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
  1791
			SetHealth(morte, 0)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1792
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1793
			SI.BK = SI.BK + 1
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1794
			if SI.BK == 2 then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1795
				SI.BK = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1796
				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
  1797
				AwardPoints(25)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1798
			end
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
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1802
		AwardPoints(SI.vCircScore[i])
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1803
		AwardKills()
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1804
		SetUpCircle(i)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1805
		res = "fatal"
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1806
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1807
		SI.chainCounter = 3000
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1808
		SI.chainLength = SI.chainLength + 1
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1809
		if SI.chainLength > 1 then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1810
			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: 13687
diff changeset
  1811
			AwardPoints(SI.chainLength*2)
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1812
		end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1813
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1814
		SI.awardCombo = UpdateSimpleAward(SI.awardCombo, SI.chainLength, 5)
12054
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1815
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1816
	else
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1817
	-- circle is merely damaged
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1818
	-- do damage effects/sounds
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1819
		AddVisualGear(SI.vCircX[i], SI.vCircY[i], vgtSteam, 0, false)
13449
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13448
diff changeset
  1820
		local r = math.random(1,4)
12054
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1821
		PlaySound(_G["sndHellishImpact" .. tostring(r)])
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1822
		res = "non-fatal"
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1823
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1824
	end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1825
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1826
	return(res)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1827
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1828
end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1829
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1830
function SetUpCircle(i)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1831
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1832
13449
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13448
diff changeset
  1833
	local r = GetRandom(10)
13580
dc4ce9f486b0 Refactor colors and caption type in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13579
diff changeset
  1834
	-- 80% of spawning either drone/ammo
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1835
	if r <= 7 then
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1836
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1837
		r = GetRandom(2)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1838
		if r == 0 then
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1839
			SI.vCircCol[i] = SI.colorDrone
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1840
			SI.vType[i] = "drone"
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1841
			SI.vCircRadMin[i] = 50	*5
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1842
			SI.vCircRadMax[i] = 90	*5
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1843
			SI.vCounterLim[i] = 3000
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1844
			SI.vCircScore[i] = 10
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1845
			SI.vCircHealth[i] = 1
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1846
		elseif r == 1 then
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1847
			SI.vCircCol[i] = SI.colorAmmo
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1848
			SI.vType[i] = "ammo"
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1849
			SI.vCircRadMin[i] = 25	*7
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1850
			SI.vCircRadMax[i] = 30	*7
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1851
			SI.vCircScore[i] = 3
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1852
			SI.vCircHealth[i] = 1
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1853
		end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1854
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1855
	-- 20% chance of spawning boss or bonus
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1856
	else
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1857
		r = GetRandom(5)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1858
		if r <= 1 then
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1859
			SI.vCircCol[i] = SI.colorBoss
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1860
			SI.vType[i] = "blueboss"
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1861
			SI.vCircRadMin[i] = 100*5
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1862
			SI.vCircRadMax[i] = 180*5
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1863
			SI.vCircWidth[i] = 1
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1864
			SI.vCounterLim[i] = 2000
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1865
			SI.vCircScore[i] = 30
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1866
			SI.vCircHealth[i] = 3
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1867
		else
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1868
			SI.vCircCol[i] = SI.colorShield
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1869
			SI.vType[i] = "bonus"
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1870
			SI.vCircRadMin[i] = 20 *7
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1871
			SI.vCircRadMax[i] = 40 *7
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1872
			SI.vCircScore[i] = 5
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1873
			SI.vCircHealth[i] = 1
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1874
		end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1875
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1876
	end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1877
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1878
	-- regenerate circle xy if too close to player or until sanity limit kicks in
13449
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13448
diff changeset
  1879
	local reN = 0
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1880
	while (reN < 10) do
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1881
		if IGotMeASafeXYValue(i) == false then
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1882
			reN = reN + 1
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1883
		else
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1884
			reN = 15
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1885
		end
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
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1888
	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: 13687
diff changeset
  1889
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1890
	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: 13687
diff changeset
  1891
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1892
	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: 13687
diff changeset
  1893
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1894
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1895
	SI.vCircActive[i] = true
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1896
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1897
end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1898
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1899
function SetMyCircles(s)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1900
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1901
	SI.circlesAreGo = s
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1902
	SI.playerIsFine = s
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1903
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1904
	for i = 0,(SI.vCCount-1) do
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1905
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1906
		if s == false then
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1907
			SI.vCircActive[i] = false
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1908
		elseif s == true then
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1909
			SetUpCircle(i)
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
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1912
	end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1913
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1914
end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1915
13028
8b6d8418d580 Play a few more taunts in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13026
diff changeset
  1916
function WellHeAintGonnaJumpNoMore(x,y,explode,kamikaze)
12054
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1917
	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
  1918
		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
  1919
		PlaySound(sndExplosion)
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1920
		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
  1921
		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
  1922
	end
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  1923
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1924
	SI.playerIsFine = false
12061
5beaf30c1cef Turn invaders white in Space Invasion when round is over
Wuzzy <almikes@aol.com>
parents: 12059
diff changeset
  1925
	FailGraphics()
13028
8b6d8418d580 Play a few more taunts in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13026
diff changeset
  1926
8b6d8418d580 Play a few more taunts in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13026
diff changeset
  1927
	if not kamikaze then
13643
690cc84e9fd6 Use capcolDefault in Lua scripts
Wuzzy <Wuzzy2@mail.ru>
parents: 13580
diff changeset
  1928
		AddCaption(loc("GOTCHA!"), capcolDefault, capgrpGameState)
13028
8b6d8418d580 Play a few more taunts in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13026
diff changeset
  1929
		PlaySound(sndHellish)
8b6d8418d580 Play a few more taunts in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13026
diff changeset
  1930
	end
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1931
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1932
	SI.targetHit = true
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1933
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1934
end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1935
12061
5beaf30c1cef Turn invaders white in Space Invasion when round is over
Wuzzy <almikes@aol.com>
parents: 12059
diff changeset
  1936
-- 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: 12059
diff changeset
  1937
function FailGraphics()
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1938
	for i = 0,(SI.vCCount-1) do
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1939
		SI.vCircCol[i] = SI.colorDisabled
12061
5beaf30c1cef Turn invaders white in Space Invasion when round is over
Wuzzy <almikes@aol.com>
parents: 12059
diff changeset
  1940
	end
5beaf30c1cef Turn invaders white in Space Invasion when round is over
Wuzzy <almikes@aol.com>
parents: 12059
diff changeset
  1941
end
5beaf30c1cef Turn invaders white in Space Invasion when round is over
Wuzzy <almikes@aol.com>
parents: 12059
diff changeset
  1942
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1943
--- collision detection for weapons fire
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1944
function CheckVarious(gear)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1945
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1946
	SI.targetHit = false
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1947
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1948
	-- if circle is hit by player fire
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1949
	if (GetGearType(gear) == gtExplosives) then
13449
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13448
diff changeset
  1950
		local circsHit = 0
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1951
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1952
		for i = 0,(SI.vCCount-1) do
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1953
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1954
			local dist = GetDistFromGearToXY(gear, SI.vCircX[i], SI.vCircY[i])
12055
ddf0fee75449 Space Invasion: Dump most out-commented and unused code
Wuzzy <almikes@aol.com>
parents: 12054
diff changeset
  1955
ddf0fee75449 Space Invasion: Dump most out-commented and unused code
Wuzzy <almikes@aol.com>
parents: 12054
diff changeset
  1956
			-- calculate my real radius if I am an aura
13449
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13448
diff changeset
  1957
			local NR
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1958
			if SI.vCircType[i] == 0 then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1959
				NR = SI.vCircRadius[i]
12055
ddf0fee75449 Space Invasion: Dump most out-commented and unused code
Wuzzy <almikes@aol.com>
parents: 12054
diff changeset
  1960
			else
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1961
				NR = (48/100*SI.vCircRadius[i])/2
12055
ddf0fee75449 Space Invasion: Dump most out-commented and unused code
Wuzzy <almikes@aol.com>
parents: 12054
diff changeset
  1962
			end
ddf0fee75449 Space Invasion: Dump most out-commented and unused code
Wuzzy <almikes@aol.com>
parents: 12054
diff changeset
  1963
ddf0fee75449 Space Invasion: Dump most out-commented and unused code
Wuzzy <almikes@aol.com>
parents: 12054
diff changeset
  1964
			if dist <= NR*NR then
ddf0fee75449 Space Invasion: Dump most out-commented and unused code
Wuzzy <almikes@aol.com>
parents: 12054
diff changeset
  1965
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1966
				dist = (GetDistFromXYtoXY(SI.vCircX[i], SI.vCircY[i], getGearValue(gear,"XP"), getGearValue(gear,"YP")) - (NR*NR))
12055
ddf0fee75449 Space Invasion: Dump most out-commented and unused code
Wuzzy <almikes@aol.com>
parents: 12054
diff changeset
  1967
				if dist >= 1000000 then
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1968
					SI.sniperHits = SI.sniperHits +1
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1969
					AddCaption(loc("Sniper! +8 points!"),SI.colorMsgBonus,capgrpAmmostate)
12055
ddf0fee75449 Space Invasion: Dump most out-commented and unused code
Wuzzy <almikes@aol.com>
parents: 12054
diff changeset
  1970
					AwardPoints(8)
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1971
					if SI.sniperHits == 3 then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1972
						SI.sniperHits = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1973
						AddCaption(loc("They Call Me Bullseye! +16 points!"),SI.colorMsgBonus,capgrpAmmostate)
12055
ddf0fee75449 Space Invasion: Dump most out-commented and unused code
Wuzzy <almikes@aol.com>
parents: 12054
diff changeset
  1974
						AwardPoints(16)
ddf0fee75449 Space Invasion: Dump most out-commented and unused code
Wuzzy <almikes@aol.com>
parents: 12054
diff changeset
  1975
					end
ddf0fee75449 Space Invasion: Dump most out-commented and unused code
Wuzzy <almikes@aol.com>
parents: 12054
diff changeset
  1976
				elseif dist <= 6000 then
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1977
					SI.pointBlankHits = SI.pointBlankHits +1
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1978
					if SI.pointBlankHits == 3 then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1979
						SI.pointBlankHits = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1980
						AddCaption(loc("Point Blank Combo! +5 points!"),SI.colorMsgBonus,capgrpAmmostate)
12055
ddf0fee75449 Space Invasion: Dump most out-commented and unused code
Wuzzy <almikes@aol.com>
parents: 12054
diff changeset
  1981
						AwardPoints(5)
ddf0fee75449 Space Invasion: Dump most out-commented and unused code
Wuzzy <almikes@aol.com>
parents: 12054
diff changeset
  1982
					end
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1983
				end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1984
12055
ddf0fee75449 Space Invasion: Dump most out-commented and unused code
Wuzzy <almikes@aol.com>
parents: 12054
diff changeset
  1985
				AddVisualGear(GetX(gear), GetY(gear), vgtBigExplosion, 0, false)
ddf0fee75449 Space Invasion: Dump most out-commented and unused code
Wuzzy <almikes@aol.com>
parents: 12054
diff changeset
  1986
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1987
				SI.targetHit = true
12055
ddf0fee75449 Space Invasion: Dump most out-commented and unused code
Wuzzy <almikes@aol.com>
parents: 12054
diff changeset
  1988
				CircleDamaged(i)
ddf0fee75449 Space Invasion: Dump most out-commented and unused code
Wuzzy <almikes@aol.com>
parents: 12054
diff changeset
  1989
ddf0fee75449 Space Invasion: Dump most out-commented and unused code
Wuzzy <almikes@aol.com>
parents: 12054
diff changeset
  1990
				circsHit = circsHit + 1
ddf0fee75449 Space Invasion: Dump most out-commented and unused code
Wuzzy <almikes@aol.com>
parents: 12054
diff changeset
  1991
				if circsHit > 1 then
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1992
					AddCaption(loc("Multi-shot! +15 points!"),SI.colorMsgBonus,capgrpAmmoinfo)
12055
ddf0fee75449 Space Invasion: Dump most out-commented and unused code
Wuzzy <almikes@aol.com>
parents: 12054
diff changeset
  1993
					AwardPoints(15)
5894
86c59c34cdd5 Balanced shield miser, multi-shot, and boss kills in SI. Added radar ping.
mikade
parents: 5827
diff changeset
  1994
						circsHit = 0
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1995
				end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  1996
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  1997
				SI.shotsHit = SI.shotsHit + 1
12055
ddf0fee75449 Space Invasion: Dump most out-commented and unused code
Wuzzy <almikes@aol.com>
parents: 12054
diff changeset
  1998
ddf0fee75449 Space Invasion: Dump most out-commented and unused code
Wuzzy <almikes@aol.com>
parents: 12054
diff changeset
  1999
			end
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2000
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2001
		end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2002
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2003
	-- if player is hit by circle bazooka
13448
93ba1826b8c2 Fix rare Lua error message spam in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13272
diff changeset
  2004
	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
  2005
13449
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13448
diff changeset
  2006
		local dist = GetDistFromGearToGear(gear, CurrentHedgehog)
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2007
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2008
		if SI.beam == true then
5245
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
			if dist < 3000 then
13680
a2f0cb003d7d Make decorational visual gears in Space Invasion non-critical
Wuzzy <Wuzzy2@mail.ru>
parents: 13643
diff changeset
  2011
				local tempE = AddVisualGear(GetX(gear), GetY(gear), vgtSmoke, 0, false)
13580
dc4ce9f486b0 Refactor colors and caption type in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13579
diff changeset
  2012
				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
  2013
				PlaySound(sndVaporize)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2014
				DeleteGear(gear)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2015
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2016
				SI.SK = SI.SK + 1
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2017
				if SI.SK == 5 then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2018
					SI.SK = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2019
					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
  2020
					AwardPoints(10)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2021
				end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2022
			end
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
		elseif dist < 1600 then
12054
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  2025
			WellHeAintGonnaJumpNoMore(GetX(gear), GetY(gear), true)
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2026
		end
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
	end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2029
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2030
	if SI.targetHit == true then
13579
ff7378430675 Space Invasion: Delete dead code and ancient outdated comments
Wuzzy <Wuzzy2@mail.ru>
parents: 13451
diff changeset
  2031
		DeleteGear(gear)
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2032
	end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2033
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
-- collision detection for player entering a circle
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2037
function CheckDistances()
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2038
13448
93ba1826b8c2 Fix rare Lua error message spam in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13272
diff changeset
  2039
	if not CurrentHedgehog then
93ba1826b8c2 Fix rare Lua error message spam in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13272
diff changeset
  2040
		return
93ba1826b8c2 Fix rare Lua error message spam in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13272
diff changeset
  2041
	end
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2042
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2043
	for i = 0,(SI.vCCount-1) do
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2044
13449
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13448
diff changeset
  2045
		local g1X, g1Y = GetGearPosition(CurrentHedgehog)
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2046
		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
  2047
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2048
		g1X = g1X - g2X
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2049
		g1Y = g1Y - g2Y
13449
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13448
diff changeset
  2050
		local dist = (g1X*g1X) + (g1Y*g1Y)
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2051
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2052
		-- calculate my real radius if I am an aura
13449
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13448
diff changeset
  2053
		local NR
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2054
		if SI.vCircType[i] == 0 then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2055
			NR = SI.vCircRadius[i]
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2056
		else
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2057
			NR = (48/100*SI.vCircRadius[i])/2
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2058
		end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2059
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2060
		if dist <= NR*NR then
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2061
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2062
			if 	(SI.vCircActive[i] == true) and
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2063
				((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
  2064
			then
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2065
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2066
				CircleDamaged(i)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2067
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2068
			elseif (SI.vCircActive[i] == true) and
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2069
					( (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
  2070
			then
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2071
13449
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13448
diff changeset
  2072
				local ss = CircleDamaged(i)
12054
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  2073
				local explosion
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2074
				if SI.vType[i] == "blueboss" then explosion = true else explosion = false end
13028
8b6d8418d580 Play a few more taunts in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13026
diff changeset
  2075
8b6d8418d580 Play a few more taunts in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13026
diff changeset
  2076
				local kamikaze = false
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2077
				if ss == "fatal" then
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2078
					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: 13687
diff changeset
  2079
						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
  2080
						AwardPoints(15)
12054
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  2081
						PlaySound(sndKamikaze, CurrentHedgehog)
13028
8b6d8418d580 Play a few more taunts in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13026
diff changeset
  2082
						kamikaze = true
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2083
					elseif (SI.wepAmmo[0] == 0) then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2084
						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
  2085
						AwardPoints(5)
12054
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  2086
						PlaySound(sndKamikaze, CurrentHedgehog)
13028
8b6d8418d580 Play a few more taunts in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13026
diff changeset
  2087
						kamikaze = true
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2088
					elseif SI.TimeLeft <= 9 then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2089
						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
  2090
						AwardPoints(10)
12054
0e6f044daeac Space Invasion: Better HUD, messages, stats screen, sounds. Add script param support
Wuzzy <almikes@aol.com>
parents: 10670
diff changeset
  2091
						PlaySound(sndKamikaze, CurrentHedgehog)
13028
8b6d8418d580 Play a few more taunts in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13026
diff changeset
  2092
						kamikaze = true
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2093
					end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2094
				end
13028
8b6d8418d580 Play a few more taunts in Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 13026
diff changeset
  2095
				WellHeAintGonnaJumpNoMore(GetX(CurrentHedgehog),GetY(CurrentHedgehog),explosion,kamikaze)
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2096
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2097
			end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2098
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2099
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2100
		end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2101
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2102
	end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2103
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2104
end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2105
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2106
function HandleCircles()
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2107
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2108
	if SI.rAlpha ~= 255 then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2109
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2110
		SI.rPingTimer = SI.rPingTimer + 1
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2111
		if SI.rPingTimer == 100 then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2112
			SI.rPingTimer = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2113
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2114
			SI.rAlpha = SI.rAlpha + 5
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2115
			if SI.rAlpha >= 255 then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2116
				SI.rAlpha = 255
6253
d73317579ae4 Add "Surfer" achievement to Space Invasion.
mikade
parents: 5894
diff changeset
  2117
			end
5894
86c59c34cdd5 Balanced shield miser, multi-shot, and boss kills in SI. Added radar ping.
mikade
parents: 5827
diff changeset
  2118
		end
6253
d73317579ae4 Add "Surfer" achievement to Space Invasion.
mikade
parents: 5894
diff changeset
  2119
5894
86c59c34cdd5 Balanced shield miser, multi-shot, and boss kills in SI. Added radar ping.
mikade
parents: 5827
diff changeset
  2120
	end
86c59c34cdd5 Balanced shield miser, multi-shot, and boss kills in SI. Added radar ping.
mikade
parents: 5827
diff changeset
  2121
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2122
	for i = 0,(SI.vCCount-1) do
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2123
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2124
		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: 13687
diff changeset
  2125
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2126
		SI.vCounter[i] = SI.vCounter[i] + 1
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2127
		if SI.vCounter[i] >= SI.vCounterLim[i] then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2128
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2129
			SI.vCounter[i] = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2130
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2131
			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: 13687
diff changeset
  2132
				(SI.vCircActive[i] == true) then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2133
				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
  2134
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
		end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2138
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2139
		if (SI.vCircActive[i] == true) then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2140
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2141
			SI.vCircRadCounter[i] = SI.vCircRadCounter[i] + 1
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2142
			if SI.vCircRadCounter[i] == 100 then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2143
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2144
				SI.vCircRadCounter[i] = 0
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2145
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2146
				-- make my radius increase/decrease faster if I am an aura
13449
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13448
diff changeset
  2147
				local M
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2148
				if SI.vCircType[i] == 0 then
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2149
					M = 1
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2150
				else
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2151
					M = 10
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2152
				end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2153
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2154
				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: 13687
diff changeset
  2155
				if SI.vCircRadius[i] > SI.vCircRadMax[i] then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2156
					SI.vCircRadDir[i] = -M
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2157
				elseif SI.vCircRadius[i] < SI.vCircRadMin[i] then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2158
					SI.vCircRadDir[i] = M
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2159
				end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2160
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2161
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2162
				-- random effect test
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2163
				-- 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
  2164
				-- you can kill by shooting or not
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2165
				--vgtSmoke vgtSmokeWhite
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2166
				--vgtSteam -- nice long trail
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2167
				--vgtDust -- short trail on earthrise
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2168
				--vgtSmokeTrace
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2169
				if SI.vType[i] == "ammo" then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2170
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2171
					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: 13687
diff changeset
  2172
					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: 13687
diff changeset
  2173
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2174
				elseif SI.vType[i] == "bonus" then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2175
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2176
					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: 13687
diff changeset
  2177
					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: 13687
diff changeset
  2178
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2179
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2180
				elseif SI.vType[i] == "blueboss" then
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2181
13449
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13448
diff changeset
  2182
					local k = 25
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13448
diff changeset
  2183
					local g = vgtSteam
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2184
					local trailColour = SI.colorBossParticle
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2185
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2186
					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: 13687
diff changeset
  2187
					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: 13687
diff changeset
  2188
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2189
					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: 13687
diff changeset
  2190
					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: 13687
diff changeset
  2191
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2192
					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: 13687
diff changeset
  2193
					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
  2194
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2195
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2196
				end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2197
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2198
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2199
			end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2200
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2201
		end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2202
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2203
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2204
	end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2205
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2206
	-- alter the circles velocities
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2207
	SI.circAdjustTimer = SI.circAdjustTimer + 1
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2208
	if SI.circAdjustTimer == 2000 then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2209
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2210
		SI.circAdjustTimer = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2211
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2212
		for i = 0,(SI.vCCount-1) do
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2213
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2214
			-- 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
  2215
			-- or make them move in random directions
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2216
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2217
			if SI.vCircX[i] > 5500 then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2218
				SI.vCircDX[i] = -5	--5 circmovchange
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2219
			elseif SI.vCircX[i] < -1500 then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2220
				SI.vCircDX[i] = 5	--5 circmovchange
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2221
			else
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2222
13449
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13448
diff changeset
  2223
				local z = GetRandom(2)
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2224
				if z == 1 then
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2225
					z = 1
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2226
				else
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2227
					z = -1
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2228
				end
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2229
				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
  2230
			end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2231
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2232
			if SI.vCircY[i] > 1500 then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2233
				SI.vCircDY[i] = -5	--5 circmovchange
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2234
			elseif SI.vCircY[i] < -2900 then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2235
				SI.vCircDY[i] = 5	--5 circmovchange
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2236
			else
13449
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13448
diff changeset
  2237
				local z = GetRandom(2)
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2238
				if z == 1 then
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2239
					z = 1
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2240
				else
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2241
					z = -1
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2242
				end
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2243
				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
  2244
			end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2245
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
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2250
	-- move the circles according to their current velocities
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2251
	SI.m2Count = SI.m2Count + 1
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2252
	if SI.m2Count == 25 then	--25 circmovchange
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2253
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2254
		SI.m2Count = 0
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2255
		for i = 0,(SI.vCCount-1) do
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2256
			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: 13687
diff changeset
  2257
			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: 13687
diff changeset
  2258
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2259
			if (CurrentHedgehog ~= nil) and (SI.rAlpha ~= 255) then
14832
d65e25e211d4 Add integerSqrt and integerHypotenuse to Utils lib
Wuzzy <Wuzzy2@mail.ru>
parents: 14599
diff changeset
  2260
				HandleRadarBlip(i)
5894
86c59c34cdd5 Balanced shield miser, multi-shot, and boss kills in SI. Added radar ping.
mikade
parents: 5827
diff changeset
  2261
			end
86c59c34cdd5 Balanced shield miser, multi-shot, and boss kills in SI. Added radar ping.
mikade
parents: 5827
diff changeset
  2262
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2263
		end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2264
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2265
		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: 13687
diff changeset
  2266
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2267
			SI.fadeAlpha = SI.fadeAlpha + 1
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2268
			if SI.fadeAlpha >= 255 then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2269
				SI.fadeAlpha = 255
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2270
			end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2271
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
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
  2274
	end
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2275
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2276
	for i = 0,(SI.vCCount-1) do
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2277
		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
  2278
	end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2279
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2280
	if 	(SI.TimeLeft == 0) or
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2281
		((SI.tumbleStarted == false)) then
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2282
		for i = 0,(SI.vCCount-1) do
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2283
			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
  2284
		end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2285
	end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2286
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2287
6819
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
  2288
	if (CurrentHedgehog ~= nil) then
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2289
		if SI.beam == true then
14844
358d81e29a88 Space Invasion: Fix minor visual glitches of shield
Wuzzy <Wuzzy2@mail.ru>
parents: 14832
diff changeset
  2290
			SetVisualGearValues(SI.pShield, GetX(CurrentHedgehog), GetY(CurrentHedgehog), nil, nil, nil, nil, nil, nil, nil, SI.colorShield-0x000000FF - -math.min(SI.shieldHealth, 255))
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2291
			DrawTag(SI.TAG_SHIELD)
6819
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
  2292
		else
14844
358d81e29a88 Space Invasion: Fix minor visual glitches of shield
Wuzzy <Wuzzy2@mail.ru>
parents: 14832
diff changeset
  2293
			SetVisualGearValues(SI.pShield, GetX(CurrentHedgehog), GetY(CurrentHedgehog), nil, nil, nil, nil, nil, nil, nil, 0x0)
6819
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
  2294
		end
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
  2295
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2296
	end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2297
6819
07e8de67c3c2 Added a missing loc
mikade <redgrinner@gmail.com>
parents: 6253
diff changeset
  2298
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2299
end
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
function ProjectileTrack(gear)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2302
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2303
	if (GetGearType(gear) == gtShell) then
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2304
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2305
		local turningSpeed = 0.1*SI.fMod
13449
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13448
diff changeset
  2306
6aca4f45ab0a Space Invasion: Localize most global variables
Wuzzy <Wuzzy2@mail.ru>
parents: 13448
diff changeset
  2307
		local dx, dy = GetGearVelocity(gear)
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2308
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
  2309
		if GetX(gear) > GetX(CurrentHedgehog) then
12055
ddf0fee75449 Space Invasion: Dump most out-commented and unused code
Wuzzy <almikes@aol.com>
parents: 12054
diff changeset
  2310
			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
  2311
		else
12055
ddf0fee75449 Space Invasion: Dump most out-commented and unused code
Wuzzy <almikes@aol.com>
parents: 12054
diff changeset
  2312
			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
  2313
		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
  2314
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
  2315
		if GetY(gear) > GetY(CurrentHedgehog) then
12055
ddf0fee75449 Space Invasion: Dump most out-commented and unused code
Wuzzy <almikes@aol.com>
parents: 12054
diff changeset
  2316
			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
  2317
		else
12055
ddf0fee75449 Space Invasion: Dump most out-commented and unused code
Wuzzy <almikes@aol.com>
parents: 12054
diff changeset
  2318
			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
  2319
		end
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2320
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2321
13710
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2322
		local dxlimit = 0.4*SI.fMod
e2b1abb4fba5 Space Invasion: refactor variables into a large table for everything
Wuzzy <Wuzzy2@mail.ru>
parents: 13687
diff changeset
  2323
		local dylimit = 0.4*SI.fMod
5245
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2324
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2325
		if dx > dxlimit then
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2326
			dx = dxlimit
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2327
		end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2328
		if dy > dylimit then
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2329
			dy = dylimit
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2330
		end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2331
		if dx < -dxlimit then
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2332
			dx = -dxlimit
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2333
		end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2334
		if dy < -dylimit then
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2335
			dy = -dylimit
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2336
		end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2337
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2338
		SetGearVelocity(gear, dx, dy)
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2339
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2340
	end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2341
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2342
end
ce407084728f Fully playable version of Space Invasion (fingers crossed). No bugs known.
mikade
parents:
diff changeset
  2343