DeathMatch: Enable unlimited relaunches

alut-include-path
Fulgen301 2017-03-25 13:44:42 +01:00
parent 3a39ec9f94
commit b31355391b
1 changed files with 2 additions and 49 deletions

View File

@ -23,66 +23,19 @@ func Initialize()
}
maxkills = GameCall("WinKillCount");
if(maxkills == nil || maxkills < 1) maxkills = 4;
return _inherited(...);
}
protected func InitializePlayer(int plr)
{
// Join plr.
JoinPlayer(plr);
// Scenario script callback.
GameCall("OnPlayerRelaunch", plr, false);
return _inherited(plr, ...);
GetRelaunchRule()->SetDefaultRelaunches(nil);
return _inherited(...);
}
protected func RelaunchPlayer(int plr, int killer)
{
_inherited(plr, killer, ...);
var clonk = CreateObjectAbove(Clonk, 0, 0, plr);
clonk->MakeCrewMember(plr);
SetCursor(plr, clonk);
JoinPlayer(plr);
// Scenario script callback.
GameCall("OnPlayerRelaunch", plr, true);
// Show scoreboard for a while
DoScoreboardShow(1, plr + 1);
Schedule(this,Format("DoScoreboardShow(-1, %d)", plr + 1), 35 * ShowBoardTime);
NotifyHUD();
return;
}
protected func JoinPlayer(int plr)
{
var clonk = GetCrew(plr);
clonk->DoEnergy(100000);
var pos = FindRelaunchPos(plr);
clonk->SetPosition(pos[0], pos[1]);
return;
}
private func FindRelaunchPos(int plr)
{
var tx, ty; // Test position.
for (var i = 0; i < 500; i++)
{
tx = Random(LandscapeWidth());
ty = Random(LandscapeHeight());
if (GBackSemiSolid(AbsX(tx), AbsY(ty)))
continue;
if (GBackSemiSolid(AbsX(tx+5), AbsY(ty+10)))
continue;
if (GBackSemiSolid(AbsX(tx+5), AbsY(ty-10)))
continue;
if (GBackSemiSolid(AbsX(tx-5), AbsY(ty+10)))
continue;
if (GBackSemiSolid(AbsX(tx-5), AbsY(ty-10)))
continue;
// Succes.
return [tx, ty];
}
return nil;
}
public func IsFulfilled()
{
// Check whether someone has reached the limit.