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 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
|
/*-- Melee --*/
#include Library_Goal
func MakeHostileToAll(int newplr, int team)
{
// If the player is in a team, don't change hostility.
if (team) return;
// Otherwise, make all other players enemies.
for (var i = 0; i < GetPlayerCount(); i++)
{
var plr = GetPlayerByIndex(i);
if (plr == newplr) continue;
SetHostility(newplr, plr, true, true);
SetHostility(plr, newplr, true, true);
}
}
protected func InitializePlayer(int newplr, int x, int y, object base, int team)
{
MakeHostileToAll(newplr, team);
return inherited(newplr, x, y, base, team, ...);
}
private func CheckTeamHostile(int plr1, int plr2)
{
var team1 = GetPlayerTeam(plr1);
if (team1 != GetPlayerTeam(plr2))
return true;
if (team1)
return false;
return Hostile(plr1, plr2);
}
public func IsFulfilled()
{
// If Teams.txt-Teams still need to be chosen, the goal cannot be fulfilled.
if (GetPlayerTeam(GetPlayerByIndex()) == -1) return;
for (var i = 0; i < GetPlayerCount(); i++)
{
var plr = GetPlayerByIndex(i);
// Compare with other players.
for (var j = i + 1; j < GetPlayerCount(); j++)
{
var plr2cmp = GetPlayerByIndex(j);
// Still enemy players out there?
if (CheckTeamHostile(plr, plr2cmp) ) return false;
}
}
// No enemy players, goal fulfilled.
return true;
}
public func GetDescription(int plr)
{
// Count enemy players.
var hostile_count;
for (var i = 0; i < GetPlayerCount(); i++)
{
var byplr = GetPlayerByIndex(i);
if (byplr == plr)
continue;
if (Hostile(byplr, plr) )
hostile_count++;
}
var message;
// Output
if (!hostile_count)
message = "$MsgGoalFulfilled$";
else
message = Format("$MsgGoalUnfulfilled$", hostile_count);
return message;
}
public func Activate(int byplr)
{
// Count enemy players.
var hostile_count;
for (var i = 0; i < GetPlayerCount(); i++)
{
var plr = GetPlayerByIndex(i);
if (plr == byplr)
continue;
if (Hostile(plr, byplr) )
hostile_count++;
}
// Output
if (!hostile_count)
MessageWindow("$MsgGoalFulfilled$", byplr);
else
MessageWindow(Format("$MsgGoalUnfulfilled$", hostile_count), byplr);
return;
}
public func GetShortDescription(int plr)
{
return ""; // TODO
}
local Name = "$Name$";
|