Added GetDescription to all goals

This will be used by the new HUD on the controls branch.
Controls
Maikel de Vries 2014-02-17 19:16:27 +01:00
parent 4346da8e4e
commit 9a862835bb
23 changed files with 271 additions and 3 deletions

View File

@ -38,6 +38,11 @@ public func IsFulfilled()
return false;
}
public func GetDescription(int plr)
{
return this.Description;
}
public func Activate(int byplr)
{
MessageWindow(this.Description, byplr);

View File

@ -26,6 +26,16 @@ public func IsFulfilled()
return GetMaterial(basin_x, basin_y) == Material("Acid");
}
public func GetDescription(int plr)
{
var message;
if (IsFulfilled())
message = "$MsgGoalFulfilled$";
else
message = "$MsgGoalUnfulfilled$";
return message;
}
// Shows or hides a message window with information.
public func Activate(int plr)
{

View File

@ -27,6 +27,16 @@ public func IsFulfilled()
return false;
}
public func GetDescription(int plr)
{
var message;
if (IsFulfilled())
message = "$MsgGoalFulfilled$";
else
message = "$MsgGoalUnFulfilled$";
return message;
}
public func Activate(int byplr)
{
if (IsFulfilled())

View File

@ -29,6 +29,16 @@ public func IsFulfilled()
return !victim->GetAlive();
}
public func GetDescription(int plr)
{
var message;
if (IsFulfilled())
message = "$MsgGoalFulfilled$";
else
message = "$MsgGoalUnFulfilled$";
return message;
}
public func Activate(int byplr)
{
if (IsFulfilled())

View File

@ -25,6 +25,16 @@ public func IsFulfilled()
return statue && !statue->IsBroken();
}
public func GetDescription(int plr)
{
var message;
if (IsFulfilled())
message = "$MsgGoalFulfilled$";
else
message = "$MsgGoalUnfulfilled$";
return message;
}
// Shows or hides a message window with information.
public func Activate(int plr)
{

View File

@ -28,6 +28,16 @@ public func IsFulfilled()
return target->IsPowerAvailable(target->GetNeededPower());
}
public func GetDescription(int plr)
{
var message;
if (IsFulfilled())
message = "$MsgGoalFulfilled$";
else
message = "$MsgGoalUnFulfilled$";
return message;
}
// Shows or hides a message window with information.
public func Activate(int plr)
{

View File

@ -32,6 +32,16 @@ public func IsFulfilled()
return true;
}
public func GetDescription(int plr)
{
var message;
if (IsFulfilled())
message = "$MsgGoalFulfilled$";
else
message = "$MsgGoalUnFulfilled$";
return message;
}
public func Activate(int byplr)
{
if (IsFulfilled())

View File

@ -18,6 +18,16 @@ public func IsFulfilled()
return ObjectCount(Find_ID(Plane));
}
public func GetDescription(int plr)
{
var message;
if (IsFulfilled())
message = "$MsgGoalFulfilled$";
else
message = "$MsgGoalUnFulfilled$";
return message;
}
public func Activate(int byplr)
{
if (IsFulfilled())

View File

@ -146,6 +146,21 @@ public func IsFulfilled()
return false;
}
public func GetDescription(int plr)
{
var flags = GetScoreGoal() - score_list[GetPlayerTeam(plr)];
if (IsFulfilled())
return "$MsgGoalFulfilled$";
else
{
var msg = "$MsgGoalCaptureTheFlag$";
if (flags == 1)
return Format("%s %s", msg, "$MsgGoalUnfulfilled1$");
else
return Format("%s %s", msg, Format("$MsgGoalUnfulfilledX$", flags));
}
}
public func Activate(int byplr)
{
var flags = GetScoreGoal() - score_list[GetPlayerTeam(byplr)];

View File

@ -105,6 +105,27 @@ public func IsFulfilled()
return true;
}
public func GetDescription(int plr)
{
if(IsFulfilled())
{
if (GetKillCount(plr) >= maxkills)
return "$MsgVictory$";
}
else
{
var score = GetRelativeScore(plr);
if (score.kills > 0)
return Format("$MsgAhead$", score.kills, GetPlayerName(score.best));
else if (score.kills < 0)
return Format("$MsgBehind$", -score.kills, GetPlayerName(score.best));
else if (score.best == plr)
return Format("$MsgYouAreBest$", score.kills);
else
return Format("$MsgEqual$", GetPlayerName(score.best));
}
}
public func Activate(int byplr)
{
if(IsFulfilled())

View File

@ -109,6 +109,17 @@ private func CoveredByFlag(int x, int y)
return false;
}
// Return the description of this goal.
public func GetDescription(int plr)
{
var message;
if (GetExpansionArea() >= GetExpansionGoal() || GetExpansionGoal() == 0)
message = Format("$MsgGoalFulfilled$");
else
message = Format("$MsgGoalUnFulfilled$", 100 * GetExpansionArea() / GetExpansionGoal());
return message;
}
// Shows or hides a message window with information.
public func Activate(int plr)
{
@ -122,7 +133,7 @@ public func Activate(int plr)
// Otherwise open a new message.
AddEffect("GoalMessage", this, 100, 0, this);
var message;
if (GetExpansionArea() >= GetExpansionGoal())
if (GetExpansionArea() >= GetExpansionGoal() || GetExpansionGoal() == 0)
message = Format("@$MsgGoalFulfilled$");
else
message = Format("@$MsgGoalUnFulfilled$", 100 * GetExpansionArea() / GetExpansionGoal());
@ -136,7 +147,9 @@ protected func FxGoalMessageStart() {}
public func GetShortDescription(int plr)
{
// Show expansion percentage.
var perc = Min(100, 100 * GetExpansionArea() / GetExpansionGoal());
var perc = 0;
if (GetExpansionGoal())
perc = Min(100, 100 * GetExpansionArea() / GetExpansionGoal());
var clr = RGB(255, 0, 0);
if (perc >= 100)
clr = RGB(0, 255, 0);

View File

@ -211,6 +211,21 @@ private func CheckForWinner()
return;
}
public func GetDescription(int plr)
{
var teams=GetTeamPoints();
var lines=[];
for(var i=0;i<GetLength(teams);++i)
{
lines[GetLength(lines)]=Format("%s: %d", teams[i]["player_names"], teams[i]["points"] );
}
var msg=Format("$MsgGoalDesc$", GetPointLimit());
for(var i=0;i<GetLength(lines);++i)
msg=Format("%s|%s", msg, lines[i]);
return msg;
}
public func Activate(int byplr)
{

View File

@ -55,6 +55,29 @@ public func IsFulfilled()
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.

View File

@ -210,6 +210,33 @@ public func IsFulfilled()
return finished;
}
public func GetDescription(int plr)
{
var team = GetPlayerTeam(plr);
var msg;
if (finished)
{
if (team)
{
if (IsWinner(plr))
msg = "$MsgParkourWonTeam$";
else
msg = "$MsgParkourLostTeam$";
}
else
{
if (IsWinner(plr))
msg = "$MsgParkourWon$";
else
msg = "$MsgParkourLost$";
}
}
else
msg = Format("$MsgParkour$", cp_count);
return msg;
}
public func Activate(int plr)
{
var team = GetPlayerTeam(plr);

View File

@ -67,6 +67,32 @@ public func IsFulfilled()
return true;
}
// Shows or hides a message window with information.
public func GetDescription(int plr)
{
var message;
if (IsFulfilled())
{
message = "$MsgGoalFulfilled$";
}
else
{
message = "$MsgGoalExtraction$";
for (var i = 0; i < GetLength(resource_list); i++)
{
var mat = resource_list[i];
var tol = tolerance_list[i];
var mat_cnt = GetMaterialCount(Material(mat));
var res_id = GetMaterialVal("Blast2Object", "Material", Material(mat));
var res_cnt = ObjectCount(Find_ID(res_id));
var blast_ratio = GetMaterialVal("Blast2ObjectRatio", "Material", Material(mat));
var add_msg = Format("$MsgGoalResource$", res_id, Max(0, (mat_cnt - (2*tol+1) * blast_ratio / 2) / blast_ratio), res_cnt);
message = Format("%s%s", message, add_msg);
}
}
return message;
}
// Shows or hides a message window with information.
public func Activate(int plr)
{

View File

@ -65,6 +65,19 @@ public func IsFulfilled()
return true;
}
// Shows or hides a message window with information.
public func GetDescription(int plr)
{
var message;
if (IsFulfilled())
message = "$MsgGoalFulfilled$";
else
message = "$MsgGoalUnfulfilled$";
return message;
}
// Shows or hides a message window with information.
public func Activate(int plr)
{

View File

@ -27,6 +27,11 @@ public func Fulfill()
return;
}
public func GetDescription(int plr)
{
return this.Description;
}
/*-- Proplist --*/
local Name = "$Name$";
local Description = "$Description$";

View File

@ -1,2 +1,2 @@
Name=Scriptziel
Description=Script goal description: please change me

View File

@ -1 +1,2 @@
Name=Script goal
Description=Script goal description: please change me

View File

@ -48,6 +48,17 @@ public func IsFulfilled()
return (gems_to_sell<=0);
}
public func GetDescription(int plr)
{
var message;
if (IsFulfilled())
message = "$MsgGoalFulfilled$";
else
message = Format("$MsgGoalUnfulfilled$", gems_to_sell);
return message;
}
// Shows or hides a message window with information.
public func Activate(int plr)
{

View File

@ -57,6 +57,17 @@ public func IsFulfilled()
return true;
}
public func GetDescription(int plr)
{
var message;
if (IsFulfilled())
message = Format("$MsgGoalFulfilled$", GetWealthGoal());
else
message = Format("$MsgGoalUnfulfilled$", GetWealth(plr), GetWealthGoal());
return message;
}
// Shows or hides a message window with information.
public func Activate(int plr)
{

View File

@ -122,8 +122,15 @@ public func SetMissionAccess(string str_password)
// Base implementations to be overloaded by goal objects
// Overload: return whether the goal has been fulfilled.
public func IsFulfilled() { return true; }
// Overload: return the current description for this goal.
public func GetDescription(int plr)
{
return "WARNING: GetDescription(int plr) not overloaded by goal";
}
protected func Activate(plr)
{
if (IsFulfilled())

View File

@ -26,6 +26,11 @@ public func IsFulfilled()
return false;
}
public func GetDescription(int plr)
{
return this.Description;
}
public func CreateGoalFlag(int x, int y)
{
flag = CreateObject(TutorialFlag, 0, 0, NO_OWNER);