forked from Mirrors/openclonk
fix scoreboard kills, deaths, etc.
This is better done through the clonk death callback such that all deaths and not just last clonk deaths are registered.install-platforms
parent
752f086a0c
commit
956108b415
|
@ -12,30 +12,30 @@
|
|||
|
||||
local maxkills;
|
||||
|
||||
local ShowBoardTime = 5; // Duration in seconds the scoreboard will be shown to a player on an event.static const ShowBoardTime = 5; // Duration in seconds the scoreboard will be shown to a player on an event.
|
||||
// Duration in seconds the scoreboard will be shown to a player on an event.
|
||||
local ShowBoardTime = 5;
|
||||
|
||||
func Initialize()
|
||||
{
|
||||
if(ObjectCount(Find_ID(GetID()), Find_Exclude(this)))
|
||||
{
|
||||
(FindObject(Find_ID(GetID()), Find_Exclude(this)).maxkills) += 2;
|
||||
return RemoveObject();
|
||||
}
|
||||
maxkills = GameCall("WinKillCount");
|
||||
if(maxkills == nil || maxkills < 1) maxkills = 4;
|
||||
if (maxkills == nil || maxkills < 1)
|
||||
maxkills = 4;
|
||||
// Assure relaunching is enabled and infinite.
|
||||
GetRelaunchRule()->SetDefaultRelaunchCount(nil);
|
||||
return _inherited(...);
|
||||
}
|
||||
|
||||
protected func RelaunchPlayer(int plr, int killer)
|
||||
protected func OnClonkDeath(object clonk, int killer)
|
||||
{
|
||||
_inherited(plr, killer, ...);
|
||||
var plr = clonk->GetOwner();
|
||||
_inherited(clonk, killer, ...);
|
||||
// Show scoreboard for a while
|
||||
DoScoreboardShow(1, plr + 1);
|
||||
Schedule(this,Format("DoScoreboardShow(-1, %d)", plr + 1), 35 * ShowBoardTime);
|
||||
NotifyHUD();
|
||||
return;
|
||||
}
|
||||
|
||||
public func IsFulfilled()
|
||||
{
|
||||
// Check whether someone has reached the limit.
|
||||
|
|
|
@ -44,6 +44,8 @@ func Initialize()
|
|||
Scoreboard->SetTitle("King of the Hill");
|
||||
//CalculatePosition();
|
||||
ScheduleCall(this, "PostInitialize", 3);
|
||||
// Assure relaunching is enabled and infinite.
|
||||
GetRelaunchRule()->SetDefaultRelaunchCount(nil);
|
||||
return _inherited(...);
|
||||
}
|
||||
|
||||
|
@ -136,6 +138,7 @@ public func IsFulfilled()
|
|||
|
||||
func OnClonkDeath(object clonk, int killer)
|
||||
{
|
||||
_inherited(clonk, killer, ...);
|
||||
if (clonk->GetAlive()) return;
|
||||
|
||||
if (GetPlayerName(clonk->GetOwner()))
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
// Include modular scoreboard columns, notice the reverse order.
|
||||
#include Scoreboard_KillStreak
|
||||
#include Scoreboard_Kill
|
||||
//#include Scoreboard_Death
|
||||
#include Scoreboard_Relaunch
|
||||
|
||||
// Some rule default values
|
||||
|
@ -45,9 +44,10 @@ protected func InitializePlayer(int plr)
|
|||
_inherited(plr, ...);
|
||||
}
|
||||
|
||||
protected func RelaunchPlayer(int plr, int killer)
|
||||
protected func OnClonkDeath(object clonk, int killer)
|
||||
{
|
||||
_inherited(plr, killer, ...);
|
||||
var plr = clonk->GetOwner();
|
||||
_inherited(clonk, killer, ...);
|
||||
// the kill logs rule cares about logging the respawn
|
||||
// ..
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
Make sure that the following functions return _inherited(...);
|
||||
* Initialize();
|
||||
* InitializePlayer(int plr);
|
||||
* RelaunchPlayer(int plr, int killer);
|
||||
* OnClonkDeath(object clonk, int killer);
|
||||
* RemovePlayer(int plr);
|
||||
--*/
|
||||
|
||||
|
@ -45,13 +45,14 @@ protected func InitializePlayer(int plr)
|
|||
return _inherited(plr, ...);
|
||||
}
|
||||
|
||||
protected func RelaunchPlayer(int plr, int killer)
|
||||
protected func OnClonkDeath(object clonk, int killer)
|
||||
{
|
||||
var plr = clonk->GetOwner();
|
||||
var plrid = GetPlayerID(plr);
|
||||
// Modify scoreboard death count entry for this player.
|
||||
score_death_list[plrid]++;
|
||||
Scoreboard->SetPlayerData(plr, "deaths", score_death_list[plrid]);
|
||||
return _inherited(plr, killer, ...);
|
||||
return _inherited(clonk, killer, ...);
|
||||
}
|
||||
|
||||
protected func RemovePlayer(int plr)
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
Make sure that the following functions return _inherited(...);
|
||||
* Initialize();
|
||||
* InitializePlayer(int plr);
|
||||
* RelaunchPlayer(int plr, int killer);
|
||||
* OnClonkDeath(object clonk, int killer);
|
||||
* RemovePlayer(int plr);
|
||||
--*/
|
||||
|
||||
|
@ -35,19 +35,20 @@ protected func InitializePlayer(int plr)
|
|||
return _inherited(plr, ...);
|
||||
}
|
||||
|
||||
protected func RelaunchPlayer(int plr, int killer)
|
||||
protected func OnClonkDeath(object clonk, int killer)
|
||||
{
|
||||
var plr = clonk->GetOwner();
|
||||
var plrid = GetPlayerID(killer);
|
||||
// Only if killer exists and has not committed suicide.
|
||||
if (killer == plr || killer == NO_OWNER)
|
||||
return _inherited(plr, killer, ...);
|
||||
return _inherited(clonk, killer, ...);
|
||||
// Only if killer and victim are on different teams.
|
||||
if (GetPlayerTeam(killer) && GetPlayerTeam(killer) == GetPlayerTeam(plr))
|
||||
return _inherited(plr, killer, ...);
|
||||
return _inherited(clonk, killer, ...);
|
||||
// Modify scoreboard kill count entry for killer.
|
||||
score_kill_list[plrid]++;
|
||||
Scoreboard->SetPlayerData(killer, "kills", score_kill_list[plrid]);
|
||||
return _inherited(plr, killer, ...);
|
||||
return _inherited(clonk, killer, ...);
|
||||
}
|
||||
|
||||
protected func RemovePlayer(int plr)
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
Make sure that the following functions return _inherited(...);
|
||||
* Initialize();
|
||||
* InitializePlayer(int plr);
|
||||
* RelaunchPlayer(int plr, int killer);
|
||||
* OnClonkDeath(object clonk, int killer);
|
||||
* RemovePlayer(int plr);
|
||||
--*/
|
||||
|
||||
|
@ -35,23 +35,24 @@ protected func InitializePlayer(int plr)
|
|||
return _inherited(plr, ...);
|
||||
}
|
||||
|
||||
protected func RelaunchPlayer(int plr, int killer)
|
||||
protected func OnClonkDeath(object clonk, int killer)
|
||||
{
|
||||
var plr = clonk->GetOwner();
|
||||
var plrid = GetPlayerID(plr);
|
||||
var killerid = GetPlayerID(killer);
|
||||
// reset scoreboard kill streak count entry for killed player.
|
||||
score_killstreak_list[plrid] = 0;
|
||||
Scoreboard->SetPlayerData(plr, "killstreaks", nil);
|
||||
// Only if killer exists and has not committed suicide.
|
||||
// Only if killer exists and has not committed suicide.
|
||||
if (plr == killer || !GetPlayerName(killer))
|
||||
return _inherited(plr, killer, ...);
|
||||
return _inherited(clonk, killer, ...);
|
||||
// Only if killer and victim are on different teams.
|
||||
if (GetPlayerTeam(killer) && GetPlayerTeam(killer) == GetPlayerTeam(plr))
|
||||
return _inherited(plr, killer, ...);
|
||||
return _inherited(clonk, killer, ...);
|
||||
// Modify scoreboard kill streak count entry for killer.
|
||||
score_killstreak_list[killerid]++;
|
||||
Scoreboard->SetPlayerData(killer, "killstreaks", score_killstreak_list[killerid]);
|
||||
return _inherited(plr, killer, ...);
|
||||
return _inherited(clonk, killer, ...);
|
||||
}
|
||||
|
||||
protected func RemovePlayer(int plr)
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
Make sure that the following functions return _inherited(...);
|
||||
* Initialize();
|
||||
* InitializePlayer(int plr);
|
||||
* RelaunchPlayer(int plr, int killer);
|
||||
* OnClonkDeath(object clonk, int killer);
|
||||
* RemovePlayer(int plr);
|
||||
--*/
|
||||
|
||||
|
@ -25,17 +25,20 @@ protected func Initialize()
|
|||
|
||||
protected func InitializePlayer(int plr)
|
||||
{
|
||||
if (GetRelaunchRule()->HasUnlimitedRelaunches()) return;
|
||||
if (GetRelaunchRule()->HasUnlimitedRelaunches())
|
||||
return;
|
||||
Scoreboard->NewPlayerEntry(plr);
|
||||
Scoreboard->SetPlayerData(plr, "relaunches", GetRelaunchRule()->GetPlayerRelaunchCount(plr));
|
||||
return _inherited(plr, ...);
|
||||
}
|
||||
|
||||
protected func RelaunchPlayer(int plr, int killer)
|
||||
protected func OnClonkDeath(object clonk, int killer)
|
||||
{
|
||||
if (GetRelaunchRule()->HasUnlimitedRelaunches()) return;
|
||||
var plr = clonk->GetOwner();
|
||||
if (GetRelaunchRule()->HasUnlimitedRelaunches())
|
||||
return;
|
||||
Scoreboard->SetPlayerData(plr, "relaunches", GetRelaunchRule()->GetPlayerRelaunchCount(plr));
|
||||
return _inherited(plr, killer, ...);
|
||||
return _inherited(clonk, killer, ...);
|
||||
}
|
||||
|
||||
protected func OnPlayerRelaunch(int plr)
|
||||
|
|
Loading…
Reference in New Issue