tests/lua/drillrockets_boom.lua
author nemo
Mon, 20 Jan 2014 21:16:17 -0500
changeset 10032 db65298717da
parent 10028 9e742fc72696
child 10421 87e47843018e
permissions -rw-r--r--
This adds idle hog tinting. Active hog tinting still needed.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10028
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
     1
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
     2
 -- taken from http://code.google.com/p/hedgewars/wiki/LuaDrawing
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
     3
 PointsBuffer = ''  -- A string to accumulate points in
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
     4
 function AddPoint(x, y, width, erase)
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
     5
     PointsBuffer = PointsBuffer .. string.char(band(x,0xff00) / 256 , band(x,0xff) , band(y,0xff00) / 256 , band(y,0xff))
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
     6
     if width then
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
     7
         width = bor(width,0x80)
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
     8
         if erase then
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
     9
             width = bor(width,0x40)
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
    10
         end
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
    11
         PointsBuffer = PointsBuffer .. string.char(width)
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
    12
     else
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
    13
         PointsBuffer = PointsBuffer .. string.char(0)
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
    14
     end
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
    15
     if #PointsBuffer > 245 then
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
    16
         ParseCommand('draw '..PointsBuffer)
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
    17
         PointsBuffer = ''
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
    18
     end
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
    19
 end
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
    20
 function FlushPoints()
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
    21
     if #PointsBuffer > 0 then
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
    22
         ParseCommand('draw '..PointsBuffer)
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
    23
         PointsBuffer = ''
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
    24
     end
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
    25
 end
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
    26
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
    27
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
    28
local ta_pointsize = 63
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
    29
local ta_radius = (ta_pointsize * 10 + 6) / 2
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
    30
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
    31
local sqrttwo = math.sqrt(2)
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
    32
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
    33
-- creates round test area
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
    34
function AddTestArea(testarea)
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
    35
	step = 100
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
    36
	xstep = step * testarea["xdir"]
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
    37
	ystep = step * testarea["ydir"]
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
    38
	x = testarea["x"]
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
    39
	y = testarea["y"]
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
    40
	if xstep * ystep ~= 0 then
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
    41
		xstep = math.floor(xstep / sqrttwo)
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
    42
		ystep = math.floor(ystep / sqrttwo)
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
    43
	end
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
    44
	AddPoint(x, y, ta_pointsize);
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
    45
	AddPoint(x + xstep, y + ystep, ta_pointsize, true);
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
    46
end
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
    47
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
    48
-- vertical test areas
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
    49
local taa_v1 = {x= 350, y= 400, xdir= 0, ydir= 1}
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
    50
local taa_v2 = {x= 350, y=1500, xdir= 0, ydir=-1}
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
    51
-- horizontal test areas
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
    52
local taa_h1 = {x=1150, y= 400, xdir= 1, ydir= 0}
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
    53
local taa_h2 = {x=1200, y=1100, xdir=-1, ydir= 0}
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
    54
-- diagonal test areas
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
    55
local taa_d1 = {x=2200, y= 400, xdir= 1, ydir= 1}
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
    56
local taa_d2 = {x=2000, y=1500, xdir= 1, ydir=-1}
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
    57
local taa_d3 = {x=3300, y= 400, xdir=-1, ydir= 1}
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
    58
local taa_d4 = {x=3300, y=1500, xdir=-1, ydir=-1}
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
    59
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
    60
-- fail counter
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
    61
local nfailed = 0
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
    62
local nspawned = 0
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
    63
local ndied = 0
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
    64
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
    65
function onGameInit()
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
    66
	-- At first we have to overwrite/set some global variables
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
    67
	-- that define the map, the game has to load, as well as
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
    68
	-- other things such as the game rules to use, etc.
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
    69
	-- Things we don't modify here will use their default values.
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
    70
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
    71
	-- The base number for the random number generator
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
    72
	Seed = 1
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
    73
	-- The map to be played
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
    74
	MapGen = 2
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
    75
	-- The theme to be used
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
    76
	Theme = "Bamboo"
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
    77
	-- Game settings and rules
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
    78
	EnableGameFlags(gfOneClanMode, gfDisableWind, gfDisableLandObjects, gfDisableGirders, gfSolidLand)
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
    79
	CaseFreq = 0
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
    80
	MinesNum = 0
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
    81
	Explosives = 0
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
    82
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
    83
	-- No damage please
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
    84
	DamagePercent = 1
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
    85
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
    86
	-- Draw Map
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
    87
	AddPoint(10,30,0) -- hog spawn platform
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
    88
	-- test areas
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
    89
	AddTestArea(taa_v1)
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
    90
	AddTestArea(taa_v2)
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
    91
	AddTestArea(taa_h1)
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
    92
	AddTestArea(taa_h2)
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
    93
	AddTestArea(taa_d1)
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
    94
	AddTestArea(taa_d2)
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
    95
	AddTestArea(taa_d3)
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
    96
	AddTestArea(taa_d4)
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
    97
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
    98
	FlushPoints()
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
    99
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
   100
	-- Create the player team
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
   101
	AddTeam("'Zooka Team", 14483456, "Simple", "Island", "Default")
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
   102
	-- And add a hog to it
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
   103
	player = AddHog("Hunter", 0, 1, "NoHat")
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
   104
	-- place it on how spawn platform
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
   105
	SetGearPosition(player, 10, 10)
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
   106
end
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
   107
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
   108
-- xdir/ydir is direction in which to fire the drills
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
   109
function SpawnDrillRocketArray(testarea)
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
   110
	xdir = testarea["xdir"]
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
   111
	ydir = testarea["ydir"]
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
   112
	centerx = testarea["x"]
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
   113
	centery = testarea["y"]
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
   114
	distance = 23
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
   115
	d = distance
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
   116
	radius = ta_radius
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
   117
	speed = 900000;
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
   118
	local xmin, xmax, ymin, ymax
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
   119
	if (xdir ~= 0) and (ydir ~= 0) then
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
   120
		d = d / sqrttwo
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
   121
		radius = radius / sqrttwo
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
   122
		speed = math.floor(speed / sqrttwo)
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
   123
	end
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
   124
	centerx = centerx - (xdir * (radius + 20))
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
   125
	centery = centery - (ydir * (radius + 20))
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
   126
	radius = radius - 6
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
   127
	xn = ydir
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
   128
	yn = -xdir
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
   129
	startx = centerx - (radius * xn)
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
   130
	starty = centery - (radius * yn)
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
   131
	endx = centerx + (radius * xn)
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
   132
	endy = centery + (radius * yn)
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
   133
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
   134
	-- spawn loop
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
   135
	x = startx
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
   136
	y = starty
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
   137
	xd = d * xn
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
   138
	yd = d * yn
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
   139
	if (xd < 0) and (startx < endx) then x = endx end
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
   140
	if (yd < 0) and (starty < endy) then y = endy end
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
   141
	nsteps = math.floor(math.max(math.abs(startx - endx),math.abs(starty - endy)) / d)
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
   142
	for i = 1, nsteps, 1 do
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
   143
		AddGear(math.floor(x), math.floor(y), gtDrill, gsttmpFlag * (i % 2), speed * xdir, speed * ydir, 0)
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
   144
		nspawned = nspawned + 1
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
   145
		x = x + xd
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
   146
		y = y + yd
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
   147
	end
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
   148
end
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
   149
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
   150
function onGearDelete(gear)
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
   151
	if GetGearType(gear) == gtDrill then
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
   152
		-- the way to check state will change in API at some point
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
   153
		if band(GetState(gear), gsttmpFlag) == 0 then
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
   154
			-- regular drill rocket
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
   155
			if (GetTimer(gear) < 2000) or (GetTimer(gear) > 3000) then
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
   156
				nfailed = nfailed + 1
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
   157
			end
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
   158
		else
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
   159
			-- airstrike drill rocket
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
   160
			if GetTimer(gear) > 0 then
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
   161
				nfailed = nfailed + 1
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
   162
			end
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
   163
		end
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
   164
		ndied = ndied + 1
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
   165
		if ndied == nspawned then
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
   166
			WriteLnToConsole('TESTRESULT: ' .. nfailed .. ' of ' .. nspawned .. ' drill rockets did not explode as expected')
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
   167
			if (nfailed > 0) then
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
   168
				EndLuaTest(TEST_FAILED)
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
   169
			else
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
   170
				EndLuaTest(TEST_SUCCESSFUL)
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
   171
			end
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
   172
		end
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
   173
	end
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
   174
end
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
   175
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
   176
function onGameStart()
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
   177
	SetGravity(1)
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
   178
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
   179
	SpawnDrillRocketArray(taa_h1)
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
   180
	SpawnDrillRocketArray(taa_h2)
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
   181
	SpawnDrillRocketArray(taa_v1)
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
   182
	SpawnDrillRocketArray(taa_v2)
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
   183
	SpawnDrillRocketArray(taa_d1)
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
   184
	SpawnDrillRocketArray(taa_d2)
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
   185
	SpawnDrillRocketArray(taa_d3)
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
   186
	SpawnDrillRocketArray(taa_d4)
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
   187
end
9e742fc72696 add a test based on unC0Rr's suggestion. still a lot of mess and redundancy involved, sry :P
sheepluva
parents:
diff changeset
   188