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