1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
|
/*-- Kill logs --*/
func Initialize()
{
// Only one at a time.
if (ObjectCount(Find_ID(GetID())) > 1)
return RemoveObject();
}
public func Activate(int by_plr)
{
MessageWindow(this.Description, by_plr);
return true;
}
func OnClonkDeath(object clonk, int killed_by)
{
var plr = clonk->GetOwner();
// Only log for existing players and clonks.
if (plr == NO_OWNER || !GetPlayerName(plr) || !clonk)
return;
ScheduleCall(this, "OnClonkDeathEx", 1, 0, clonk, plr, killed_by);
return _inherited(clonk, killed_by, ...);
}
// parameters: clonk, owner, killed_by
global func GetAdditionalPlayerRelaunchString(){return _inherited(...);} // dummy
public func OnClonkDeathEx(object clonk, int plr, int killed_by)
{
if (!GetPlayerName(plr))
return;
var name = "Clonk";
if (clonk)
name = clonk.Prototype->GetName();
// Assert there are three StringTbl entries for each.
var which_one = Random(3) + 1;
var log = "";
if (!GetPlayerName(killed_by))
log = Format(Translate(Format("KilledByGaia%d", which_one)), GetTaggedPlayerName(plr), name);
else if (plr == killed_by)
log = Format(Translate(Format("Selfkill%d", which_one)), GetTaggedPlayerName(plr), name);
else if (!Hostile(plr,killed_by))
log = Format(Translate(Format("Teamkill%d", which_one)), GetTaggedPlayerName(plr), name, GetTaggedPlayerName(killed_by));
else
log = Format(Translate(Format("KilledByPlayer%d", which_one)), GetTaggedPlayerName(plr), name, GetTaggedPlayerName(killed_by));
if (IsActiveRelaunchRule())
{
var relaunches = GetRelaunchRule()->GetPlayerRelaunchCount(plr);
if (relaunches != nil)
{
var msg = "";
if (relaunches < 0) // Player eliminated.
msg = Format("$MsgFail$", GetTaggedPlayerName(plr));
else if (relaunches == 0) // Last relaunch.
msg = Format("$MsgRelaunch0$", GetTaggedPlayerName(plr));
else if (relaunches == 1) // One relaunch remaining.
msg = Format("$MsgRelaunch1$", GetTaggedPlayerName(plr));
else // Multiple relaunches remaining.
msg = Format("$MsgRelaunchX$", GetTaggedPlayerName(plr), relaunches);
log = Format("%s %s", log, msg);
}
}
// This is also not a global function, but that is okay. So..
// get additional strings from goals/rules ("%s is now king!!")
for (var goal in FindObjects(Find_Or(Find_Category(C4D_Goal), Find_Category(C4D_Rule))))
{
var other = goal->~GetAdditionalPlayerRelaunchString(clonk, plr, killed_by);
if (other)
log = Format("%s %s", log, other);
}
// Get additional stuff from scenario.
var other = GameCall("GetAdditionalPlayerRelaunchString", clonk, plr, killed_by);
if (other)
log = Format("%s %s", log, other);
// Also allow global callback function to add to death messages.
other = GetAdditionalPlayerRelaunchString(clonk, plr, killed_by);
if (other)
log = Format("%s, %s", log, other);
Log(log);
return;
}
local Name = "$Name$";
local Description = "$Description$";
local Visibility = VIS_Editor;
local EditorPlacementLimit = 1; // Rules are to be placed only once
|