forked from Mirrors/openclonk
prevent kill logs rule from creating the relaunch rule
parent
9e9e664581
commit
0ed4d484fc
|
@ -179,13 +179,13 @@ func OnClonkDeath(object clonk, int killer)
|
|||
return;
|
||||
}
|
||||
|
||||
func GetAdditionalPlayerRelaunchString(object clonk, int plr, int killed_by)
|
||||
public func GetAdditionalPlayerRelaunchString(object clonk, int plr, int killed_by)
|
||||
{
|
||||
if(!Hostile(killed_by, plr)) return;
|
||||
if(!location->GetKing()) return;
|
||||
if(location->GetKing()->GetOwner() != killed_by) return;
|
||||
if(!GetEffect("NewKing", GetCursor(killed_by))) return;
|
||||
var msg=Format("$IsNowKing$", GetTaggedPlayerName(killed_by));
|
||||
if (!Hostile(killed_by, plr)) return;
|
||||
if (!location->GetKing()) return;
|
||||
if (location->GetKing()->GetOwner() != killed_by) return;
|
||||
if (!GetEffect("NewKing", GetCursor(killed_by))) return;
|
||||
var msg = Format("$IsNowKing$", GetTaggedPlayerName(killed_by));
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
|
|
@ -26,62 +26,64 @@ func OnClonkDeath(object clonk, int killed_by)
|
|||
// parameters: clonk, owner, killed_by
|
||||
global func GetAdditionalPlayerRelaunchString(){return _inherited(...);} // dummy
|
||||
|
||||
func OnClonkDeathEx(object clonk, int plr, int killed_by)
|
||||
public func OnClonkDeathEx(object clonk, int plr, int killed_by)
|
||||
{
|
||||
if(!GetPlayerName(plr)) return;
|
||||
var name="Clonk";
|
||||
if(clonk) name=clonk.Prototype->GetName();
|
||||
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="";
|
||||
var log = "";
|
||||
if (!GetPlayerName(killed_by))
|
||||
log=Format(Translate(Format("KilledByGaia%d", which_one)), GetTaggedPlayerName(plr), name);
|
||||
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);
|
||||
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));
|
||||
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));
|
||||
|
||||
var relaunches = GetRelaunchRule()->GetPlayerRelaunchCount(plr);
|
||||
if(relaunches != nil)
|
||||
if (IsActiveRelaunchRule())
|
||||
{
|
||||
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);GameCallEx("GetAdditionalPlayerRelaunchString", clonk, plr, killed_by);
|
||||
if(other)
|
||||
var relaunches = GetRelaunchRule()->GetPlayerRelaunchCount(plr);
|
||||
if (relaunches != nil)
|
||||
{
|
||||
log=Format("%s %s", log, other);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
// get additional stuff from scenario
|
||||
var other=GameCall("GetAdditionalPlayerRelaunchString", clonk, plr, killed_by);
|
||||
if(other)
|
||||
// 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))))
|
||||
{
|
||||
log=Format("%s %s", log, other);
|
||||
var other = goal->~GetAdditionalPlayerRelaunchString(clonk, plr, killed_by);
|
||||
if (other)
|
||||
log = Format("%s %s", log, other);
|
||||
}
|
||||
|
||||
// also allow global callback function to add to death messages
|
||||
// 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)
|
||||
if (other)
|
||||
log = Format("%s, %s", log, other);
|
||||
|
||||
Log(log);
|
||||
return;
|
||||
}
|
||||
|
||||
local Name = "$Name$";
|
||||
|
|
|
@ -403,6 +403,11 @@ global func GetRelaunchRule()
|
|||
return FindObject(Find_ID(Rule_Relaunch)) || CreateObject(Rule_Relaunch);
|
||||
}
|
||||
|
||||
global func IsActiveRelaunchRule()
|
||||
{
|
||||
return !!FindObject(Find_ID(Rule_Relaunch));
|
||||
}
|
||||
|
||||
|
||||
/*-- Player Relaunches --*/
|
||||
|
||||
|
|
Loading…
Reference in New Issue