tests/lua/hellfire_burns.lua
author sheepluva
Tue, 02 Dec 2014 22:11:22 +0100
changeset 10609 15f2908113a1
parent 10421 87e47843018e
child 10611 58cad46782ff
permissions -rw-r--r--
make tests use Draw.lua for now too
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10380
07ae8fd1d7d4 add test I used for bisecting
sheepluva
parents:
diff changeset
     1
10609
15f2908113a1 make tests use Draw.lua for now too
sheepluva
parents: 10421
diff changeset
     2
HedgewarsScriptLoad("/Scripts/Draw.lua")
10380
07ae8fd1d7d4 add test I used for bisecting
sheepluva
parents:
diff changeset
     3
07ae8fd1d7d4 add test I used for bisecting
sheepluva
parents:
diff changeset
     4
local ta_pointsize = 63
07ae8fd1d7d4 add test I used for bisecting
sheepluva
parents:
diff changeset
     5
local ta_radius = (ta_pointsize * 10 + 6) / 2
07ae8fd1d7d4 add test I used for bisecting
sheepluva
parents:
diff changeset
     6
07ae8fd1d7d4 add test I used for bisecting
sheepluva
parents:
diff changeset
     7
local sqrttwo = math.sqrt(2)
07ae8fd1d7d4 add test I used for bisecting
sheepluva
parents:
diff changeset
     8
07ae8fd1d7d4 add test I used for bisecting
sheepluva
parents:
diff changeset
     9
-- creates round test area
07ae8fd1d7d4 add test I used for bisecting
sheepluva
parents:
diff changeset
    10
function AddTestArea(testarea)
07ae8fd1d7d4 add test I used for bisecting
sheepluva
parents:
diff changeset
    11
	step = 100
07ae8fd1d7d4 add test I used for bisecting
sheepluva
parents:
diff changeset
    12
	xstep = step * testarea["xdir"]
07ae8fd1d7d4 add test I used for bisecting
sheepluva
parents:
diff changeset
    13
	ystep = step * testarea["ydir"]
07ae8fd1d7d4 add test I used for bisecting
sheepluva
parents:
diff changeset
    14
	x = testarea["x"]
07ae8fd1d7d4 add test I used for bisecting
sheepluva
parents:
diff changeset
    15
	y = testarea["y"]
07ae8fd1d7d4 add test I used for bisecting
sheepluva
parents:
diff changeset
    16
	if xstep * ystep ~= 0 then
07ae8fd1d7d4 add test I used for bisecting
sheepluva
parents:
diff changeset
    17
		xstep = math.floor(xstep / sqrttwo)
07ae8fd1d7d4 add test I used for bisecting
sheepluva
parents:
diff changeset
    18
		ystep = math.floor(ystep / sqrttwo)
07ae8fd1d7d4 add test I used for bisecting
sheepluva
parents:
diff changeset
    19
	end
07ae8fd1d7d4 add test I used for bisecting
sheepluva
parents:
diff changeset
    20
	AddPoint(x, y, ta_pointsize);
07ae8fd1d7d4 add test I used for bisecting
sheepluva
parents:
diff changeset
    21
	AddPoint(x + xstep, y + ystep, ta_pointsize, true);
07ae8fd1d7d4 add test I used for bisecting
sheepluva
parents:
diff changeset
    22
end
07ae8fd1d7d4 add test I used for bisecting
sheepluva
parents:
diff changeset
    23
07ae8fd1d7d4 add test I used for bisecting
sheepluva
parents:
diff changeset
    24
-- vertical test area
07ae8fd1d7d4 add test I used for bisecting
sheepluva
parents:
diff changeset
    25
local taa_v2 = {x= 350, y=1500, xdir= 0, ydir=-1}
07ae8fd1d7d4 add test I used for bisecting
sheepluva
parents:
diff changeset
    26
07ae8fd1d7d4 add test I used for bisecting
sheepluva
parents:
diff changeset
    27
-- fail counter
07ae8fd1d7d4 add test I used for bisecting
sheepluva
parents:
diff changeset
    28
local nfailed = 0
07ae8fd1d7d4 add test I used for bisecting
sheepluva
parents:
diff changeset
    29
local nspawned = 0
07ae8fd1d7d4 add test I used for bisecting
sheepluva
parents:
diff changeset
    30
local ndied = 0
07ae8fd1d7d4 add test I used for bisecting
sheepluva
parents:
diff changeset
    31
07ae8fd1d7d4 add test I used for bisecting
sheepluva
parents:
diff changeset
    32
function onGameInit()
07ae8fd1d7d4 add test I used for bisecting
sheepluva
parents:
diff changeset
    33
	-- At first we have to overwrite/set some global variables
07ae8fd1d7d4 add test I used for bisecting
sheepluva
parents:
diff changeset
    34
	-- that define the map, the game has to load, as well as
07ae8fd1d7d4 add test I used for bisecting
sheepluva
parents:
diff changeset
    35
	-- other things such as the game rules to use, etc.
07ae8fd1d7d4 add test I used for bisecting
sheepluva
parents:
diff changeset
    36
	-- Things we don't modify here will use their default values.
07ae8fd1d7d4 add test I used for bisecting
sheepluva
parents:
diff changeset
    37
07ae8fd1d7d4 add test I used for bisecting
sheepluva
parents:
diff changeset
    38
	-- The base number for the random number generator
07ae8fd1d7d4 add test I used for bisecting
sheepluva
parents:
diff changeset
    39
	Seed = 1
07ae8fd1d7d4 add test I used for bisecting
sheepluva
parents:
diff changeset
    40
	-- The map to be played
10421
87e47843018e use constants for mapgen, expose those to lua
sheepluva
parents: 10381
diff changeset
    41
	MapGen = mgDrawn
10380
07ae8fd1d7d4 add test I used for bisecting
sheepluva
parents:
diff changeset
    42
	-- The theme to be used
07ae8fd1d7d4 add test I used for bisecting
sheepluva
parents:
diff changeset
    43
	Theme = "Bamboo"
07ae8fd1d7d4 add test I used for bisecting
sheepluva
parents:
diff changeset
    44
	-- Game settings and rules
07ae8fd1d7d4 add test I used for bisecting
sheepluva
parents:
diff changeset
    45
	EnableGameFlags(gfOneClanMode, gfDisableWind, gfDisableLandObjects, gfDisableGirders)
07ae8fd1d7d4 add test I used for bisecting
sheepluva
parents:
diff changeset
    46
	CaseFreq = 0
07ae8fd1d7d4 add test I used for bisecting
sheepluva
parents:
diff changeset
    47
	MinesNum = 0
07ae8fd1d7d4 add test I used for bisecting
sheepluva
parents:
diff changeset
    48
	Explosives = 0
07ae8fd1d7d4 add test I used for bisecting
sheepluva
parents:
diff changeset
    49
07ae8fd1d7d4 add test I used for bisecting
sheepluva
parents:
diff changeset
    50
	-- No damage please
07ae8fd1d7d4 add test I used for bisecting
sheepluva
parents:
diff changeset
    51
	DamagePercent = 1
07ae8fd1d7d4 add test I used for bisecting
sheepluva
parents:
diff changeset
    52
07ae8fd1d7d4 add test I used for bisecting
sheepluva
parents:
diff changeset
    53
	-- Draw Map
07ae8fd1d7d4 add test I used for bisecting
sheepluva
parents:
diff changeset
    54
	AddPoint(10,30,0) -- hog spawn platform
07ae8fd1d7d4 add test I used for bisecting
sheepluva
parents:
diff changeset
    55
	-- test areas
07ae8fd1d7d4 add test I used for bisecting
sheepluva
parents:
diff changeset
    56
	AddTestArea(taa_v2)
07ae8fd1d7d4 add test I used for bisecting
sheepluva
parents:
diff changeset
    57
07ae8fd1d7d4 add test I used for bisecting
sheepluva
parents:
diff changeset
    58
	FlushPoints()
07ae8fd1d7d4 add test I used for bisecting
sheepluva
parents:
diff changeset
    59
07ae8fd1d7d4 add test I used for bisecting
sheepluva
parents:
diff changeset
    60
	-- Create the player team
07ae8fd1d7d4 add test I used for bisecting
sheepluva
parents:
diff changeset
    61
	AddTeam("'Zooka Team", 14483456, "Simple", "Island", "Default")
07ae8fd1d7d4 add test I used for bisecting
sheepluva
parents:
diff changeset
    62
	-- And add a hog to it
07ae8fd1d7d4 add test I used for bisecting
sheepluva
parents:
diff changeset
    63
	player = AddHog("Hunter", 0, 1, "NoHat")
07ae8fd1d7d4 add test I used for bisecting
sheepluva
parents:
diff changeset
    64
	-- place it on how spawn platform
07ae8fd1d7d4 add test I used for bisecting
sheepluva
parents:
diff changeset
    65
	SetGearPosition(player, 10, 10)
07ae8fd1d7d4 add test I used for bisecting
sheepluva
parents:
diff changeset
    66
end
07ae8fd1d7d4 add test I used for bisecting
sheepluva
parents:
diff changeset
    67
10381
d263e0abcd7c tweak test
sheepluva
parents: 10380
diff changeset
    68
function onNewTurn()
10380
07ae8fd1d7d4 add test I used for bisecting
sheepluva
parents:
diff changeset
    69
	if not TestRectForObstacle(300, 1500, 400, 1900, true) then
07ae8fd1d7d4 add test I used for bisecting
sheepluva
parents:
diff changeset
    70
		WriteLnToConsole('HOLE DETECTED')
07ae8fd1d7d4 add test I used for bisecting
sheepluva
parents:
diff changeset
    71
		EndLuaTest(TEST_SUCCESSFUL)
10381
d263e0abcd7c tweak test
sheepluva
parents: 10380
diff changeset
    72
	else
d263e0abcd7c tweak test
sheepluva
parents: 10380
diff changeset
    73
		WriteLnToConsole('FIRE DID NOT BURN THROUGH!')
d263e0abcd7c tweak test
sheepluva
parents: 10380
diff changeset
    74
		EndLuaTest(TEST_FAILED)
10380
07ae8fd1d7d4 add test I used for bisecting
sheepluva
parents:
diff changeset
    75
	end
07ae8fd1d7d4 add test I used for bisecting
sheepluva
parents:
diff changeset
    76
end
07ae8fd1d7d4 add test I used for bisecting
sheepluva
parents:
diff changeset
    77
07ae8fd1d7d4 add test I used for bisecting
sheepluva
parents:
diff changeset
    78
07ae8fd1d7d4 add test I used for bisecting
sheepluva
parents:
diff changeset
    79
function onGameStart()
07ae8fd1d7d4 add test I used for bisecting
sheepluva
parents:
diff changeset
    80
	AddGear(350, 1500, gtHellishBomb, 0, 0, 0, 0)
07ae8fd1d7d4 add test I used for bisecting
sheepluva
parents:
diff changeset
    81
end
07ae8fd1d7d4 add test I used for bisecting
sheepluva
parents:
diff changeset
    82