DarkMine: Fix relaunch handling

alut-include-path
Fulgen301 2017-04-17 17:12:14 +02:00
parent 6030299201
commit 85cfbc4065
1 changed files with 17 additions and 36 deletions

View File

@ -19,18 +19,30 @@ protected func Initialize()
{
// Goals and rules.
if (SCENPAR_GameMode == GAMEMODE_Deathmatch)
{
CreateObject(Goal_DeathMatch);
GetRelaunchRule()->SetDefaultRelaunches(Max(SCENPAR_NrRelaunchesKills, 0));
}
else if (SCENPAR_GameMode == GAMEMODE_LastManStanding)
{
CreateObject(Goal_LastManStanding);
GetRelaunchRule()->SetDefaultRelaunches(Max(SCENPAR_NrRelaunchesKills, 0));
}
else if (SCENPAR_GameMode == GAMEMODE_KingOfTheHill)
{
var goal = CreateObject(Goal_KingOfTheHill, LandscapeWidth() / 2, LandscapeHeight() / 2);
goal->SetRadius(72);
goal->SetPointLimit(Max(SCENPAR_NrRelaunchesKills, 1));
GetRelaunchRule()->SetDefaultRelaunches(nil);
}
CreateObject(Rule_KillLogs);
CreateObject(Rule_Gravestones);
GetRelaunchRule()
->SetLastWeaponUse(false)
->SetFreeCrew(true);
// Rescale cave coordinates with map zoom and shuffle them.
var mapzoom = GetScenarioVal("MapZoom", "Landscape");
for (var cave in cave_list)
@ -53,13 +65,6 @@ protected func Initialize()
return;
}
// Callback from the last man standing goal.
protected func RelaunchCount()
{
// Relaunch count depends on scenario setting.
return Max(SCENPAR_NrRelaunchesKills, 0);
}
// Callback from the last man standing goal.
protected func KillsToRelaunch()
{
@ -73,46 +78,22 @@ public func WinKillCount()
return Max(SCENPAR_NrRelaunchesKills, 1);
}
// Forward callbacks to OnPlayerRelaunch for KotH goal.
protected func InitializePlayer(int plr)
public func RelaunchPosition(int plr)
{
if (SCENPAR_GameMode == GAMEMODE_KingOfTheHill)
GameCall("OnPlayerRelaunch", plr, false);
return _inherited(plr, ...);
return FindStartCave(plr, GetRelaunchCount(plr) != SCENPAR_NrRelaunchesKills);
}
// Forward callbacks to OnPlayerRelaunch for KotH goal.
protected func RelaunchPlayer(int plr, int killer)
public func OnClonkLeftRelaunch(object clonk, int plr)
{
if (SCENPAR_GameMode == GAMEMODE_KingOfTheHill)
{
var clonk = CreateObjectAbove(Clonk, 0, 0, plr);
clonk->MakeCrewMember(plr);
SetCursor(plr, clonk);
clonk->DoEnergy(100000);
GameCall("OnPlayerRelaunch", plr, true);
}
return _inherited(plr, killer);
}
// Callback from the last man standing and deathmatch goal.
// Takes over the role of initializing the player.
protected func OnPlayerRelaunch(int plr, bool is_relaunch)
{
// Get the only clonk of the player.
var clonk = GetCrew(plr);
// Players start in a random small cave, the cave depends on whether it is a relaunch.
var cave = FindStartCave(plr, is_relaunch);
clonk->SetPosition(cave[0], cave[1]);
// Ensure spawn position is free
var cave = [clonk->GetX(), clonk->GetY()];
for (var i=0; i<4; ++i) BlastFree(cave[0], cave[1], 13);
// Players start with a shovel, a pickaxe and two firestones.
clonk->CreateContents(Shovel);
clonk->CreateContents(Pickaxe);
// Better weapons after relaunching.
if (!is_relaunch)
if (GetRelaunchCount(plr) != SCENPAR_NrRelaunchesKills)
{
clonk->CreateContents(Torch);
clonk->CreateContents(Firestone, 2);