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