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