2010-01-25 15:30:25 +00:00
|
|
|
/*-- Melee --*/
|
|
|
|
|
2010-03-02 16:24:51 +00:00
|
|
|
#include Library_Goal
|
2010-01-25 15:30:25 +00:00
|
|
|
|
2012-04-29 14:27:26 +00:00
|
|
|
func MakeHostileToAll(int newplr, int team)
|
2010-01-25 15:30:25 +00:00
|
|
|
{
|
|
|
|
// 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);
|
2010-04-12 11:21:00 +00:00
|
|
|
if (plr == newplr) continue;
|
2010-03-30 16:48:38 +00:00
|
|
|
|
2010-01-25 15:30:25 +00:00
|
|
|
SetHostility(newplr, plr, true, true);
|
|
|
|
SetHostility(plr, newplr, true, true);
|
|
|
|
}
|
2012-04-29 14:27:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
protected func InitializePlayer(int newplr, int x, int y, object base, int team)
|
|
|
|
{
|
|
|
|
MakeHostileToAll(newplr, team);
|
2010-04-12 11:21:00 +00:00
|
|
|
return inherited(newplr, x, y, base, team, ...);
|
2010-01-25 15:30:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private func CheckTeamHostile(int plr1, int plr2)
|
|
|
|
{
|
|
|
|
var team1 = GetPlayerTeam(plr1);
|
2010-09-13 15:27:48 +00:00
|
|
|
if (team1 != GetPlayerTeam(plr2))
|
2010-01-25 15:30:25 +00:00
|
|
|
return true;
|
2010-09-13 15:27:48 +00:00
|
|
|
if (team1)
|
2010-01-25 15:30:25 +00:00
|
|
|
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;
|
|
|
|
|
2010-04-12 11:21:00 +00:00
|
|
|
for (var i = 0; i < GetPlayerCount(); i++)
|
2010-01-25 15:30:25 +00:00
|
|
|
{
|
|
|
|
var plr = GetPlayerByIndex(i);
|
|
|
|
// Compare with other players.
|
2010-04-12 11:21:00 +00:00
|
|
|
for (var j = i + 1; j < GetPlayerCount(); j++)
|
2010-01-25 15:30:25 +00:00
|
|
|
{
|
2010-09-13 15:27:48 +00:00
|
|
|
var plr2cmp = GetPlayerByIndex(j);
|
2010-01-25 15:30:25 +00:00
|
|
|
// Still enemy players out there?
|
2010-04-12 11:21:00 +00:00
|
|
|
if (CheckTeamHostile(plr, plr2cmp) ) return false;
|
2010-01-25 15:30:25 +00:00
|
|
|
}
|
|
|
|
}
|
2010-03-30 16:48:38 +00:00
|
|
|
|
2010-01-25 15:30:25 +00:00
|
|
|
// No enemy players, goal fulfilled.
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-02-17 18:16:27 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2010-01-31 20:31:04 +00:00
|
|
|
public func Activate(int byplr)
|
2010-01-25 15:30:25 +00:00
|
|
|
{
|
|
|
|
// Count enemy players.
|
|
|
|
var hostile_count;
|
2010-04-12 11:21:00 +00:00
|
|
|
for (var i = 0; i < GetPlayerCount(); i++)
|
2010-01-25 15:30:25 +00:00
|
|
|
{
|
|
|
|
var plr = GetPlayerByIndex(i);
|
2010-04-12 11:21:00 +00:00
|
|
|
if (plr == byplr)
|
2010-03-30 16:48:38 +00:00
|
|
|
continue;
|
2010-09-13 15:27:48 +00:00
|
|
|
if (Hostile(plr, byplr) )
|
2010-01-25 15:30:25 +00:00
|
|
|
hostile_count++;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Output
|
2010-04-12 11:21:00 +00:00
|
|
|
if (!hostile_count)
|
2010-01-25 15:30:25 +00:00
|
|
|
MessageWindow("$MsgGoalFulfilled$", byplr);
|
|
|
|
else
|
|
|
|
MessageWindow(Format("$MsgGoalUnfulfilled$", hostile_count), byplr);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-01-31 20:31:04 +00:00
|
|
|
public func GetShortDescription(int plr)
|
|
|
|
{
|
|
|
|
return ""; // TODO
|
|
|
|
}
|
|
|
|
|
2010-09-09 21:29:11 +00:00
|
|
|
local Name = "$Name$";
|