relaunch rule: fix scoreboard updating and scenario overloading

stable-8
Maikel de Vries 2018-03-11 17:05:50 +01:00
parent 2c4676d63c
commit 68d901b61c
2 changed files with 8 additions and 5 deletions

View File

@ -41,7 +41,7 @@ protected func OnClonkDeath(object clonk, int killer)
return _inherited(clonk, killer, ...); return _inherited(clonk, killer, ...);
} }
protected func OnPlayerRelaunch(int plr) protected func OnPlayerRelaunchCountChanged(int plr)
{ {
if (GetRelaunchRule()->HasUnlimitedRelaunches()) return; if (GetRelaunchRule()->HasUnlimitedRelaunches()) return;
Scoreboard->SetPlayerData(plr, "relaunches", GetRelaunchRule()->GetPlayerRelaunchCount(plr)); Scoreboard->SetPlayerData(plr, "relaunches", GetRelaunchRule()->GetPlayerRelaunchCount(plr));

View File

@ -219,8 +219,9 @@ public func InitializePlayer(int plr)
// Check if relaunch is needed. // Check if relaunch is needed.
if (!initial_relaunch || !perform_restart) if (!initial_relaunch || !perform_restart)
return; return;
// Scenario script callback. // Scenario script and goals callbacks.
if (GameCallEx("OnPlayerRelaunch", plr, false)) GameCallEx("OnPlayerRelaunchCountChanged", plr);
if (GameCall("OnPlayerRelaunch", plr, false))
return; return;
return DoRelaunch(plr, nil, nil, true); return DoRelaunch(plr, nil, nil, true);
} }
@ -241,7 +242,9 @@ public func OnClonkDeath(object clonk, int killer)
return; return;
} }
} }
if (GameCallEx("OnPlayerRelaunch", plr, true)) // Scenario script and goals callbacks.
GameCallEx("OnPlayerRelaunchCountChanged", plr);
if (GameCall("OnPlayerRelaunch", plr, true))
return; return;
return DoRelaunch(plr, clonk, nil); return DoRelaunch(plr, clonk, nil);
} }
@ -358,7 +361,7 @@ public func DoRelaunch(int plr, object clonk, array position, bool no_creation)
if (!GetCursor(plr) || GetCursor(plr) == clonk) if (!GetCursor(plr) || GetCursor(plr) == clonk)
SetCursor(plr, new_clonk); SetCursor(plr, new_clonk);
new_clonk->DoEnergy(new_clonk.Energy ?? 100000); new_clonk->DoEnergy(new_clonk.MaxEnergy ?? 100000);
if (relaunch_time) if (relaunch_time)
{ {