forked from Mirrors/openclonk
fixed King of the Hill
parent
b0806668d9
commit
aa235b8836
|
@ -8,9 +8,9 @@
|
||||||
protected func Initialize()
|
protected func Initialize()
|
||||||
{
|
{
|
||||||
// Goal settings.
|
// Goal settings.
|
||||||
CreateObject(Goal_KingOfTheHill, 625, 170, NO_OWNER);
|
var goal = CreateObject(Goal_KingOfTheHill, 625, 170, NO_OWNER);
|
||||||
Goal_KingOfTheHill->SetRadius(120);
|
goal->SetRadius(120);
|
||||||
Goal_KingOfTheHill->SetPointLimit(6);
|
goal->SetPointLimit(6);
|
||||||
|
|
||||||
// Weapon chests.
|
// Weapon chests.
|
||||||
CreateObject(Chest, 690, 210, NO_OWNER);
|
CreateObject(Chest, 690, 210, NO_OWNER);
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
id=KingOfTheHill_Marker
|
id=KingOfTheHill_Marker
|
||||||
Version=4,9,5
|
Version=4,9,5
|
||||||
#Category=C4D_StaticBack | C4D_Foreground | C4D_IgnoreFoW
|
#Category=C4D_StaticBack | C4D_Foreground | C4D_IgnoreFoW
|
||||||
Category=C4D_StaticBack | C4D_Foreground
|
Category=C4D_StaticBack | C4D_IgnoreFoW
|
||||||
Width=15
|
Width=15
|
||||||
Height=15
|
Height=15
|
||||||
Offset=-7,-7
|
Offset=-7,-7
|
||||||
|
|
|
@ -1,16 +1,27 @@
|
||||||
/*
|
/*
|
||||||
Marker for King of the Hill
|
Marker for King of the Hill
|
||||||
Author: Zapper
|
Author: Zapper
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
local origin;
|
||||||
|
|
||||||
func Initialize()
|
func Initialize()
|
||||||
{
|
{
|
||||||
AddEffect("Timer", this, 10, 1, this);
|
AddEffect("Timer", this, 10, 1, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func SetOrigin(object o)
|
||||||
|
{
|
||||||
|
origin = o;
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetOrigin()
|
||||||
|
{
|
||||||
|
return origin;
|
||||||
|
}
|
||||||
|
|
||||||
func FxTimerTimer()
|
func FxTimerTimer()
|
||||||
{
|
{
|
||||||
var origin=this["origin"];
|
|
||||||
if(!origin) return RemoveObject();
|
if(!origin) return RemoveObject();
|
||||||
|
|
||||||
var x, y;
|
var x, y;
|
||||||
|
|
|
@ -8,7 +8,7 @@ local number;
|
||||||
|
|
||||||
func Init(o, n)
|
func Init(o, n)
|
||||||
{
|
{
|
||||||
this->SetObjectBlitMode(GFX_BLIT_Mod2);
|
SetObjectBlitMode(GFX_BLIT_Mod2);
|
||||||
origin=o;
|
origin=o;
|
||||||
number=n;
|
number=n;
|
||||||
SetR(Angle(origin->GetX(), origin->GetY(), this->GetX(), this->GetY()) + 45);
|
SetR(Angle(origin->GetX(), origin->GetY(), this->GetX(), this->GetY()) + 45);
|
||||||
|
@ -18,12 +18,12 @@ func Initialize()
|
||||||
{
|
{
|
||||||
SetGraphics(0, KingOfTheHill_Marker);
|
SetGraphics(0, KingOfTheHill_Marker);
|
||||||
AddEffect("Timer", this, 10, 1, this);
|
AddEffect("Timer", this, 10, 1, this);
|
||||||
this->SetGraphics(nil, KingOfTheHill_Marker);
|
SetGraphics(nil, KingOfTheHill_Marker);
|
||||||
}
|
}
|
||||||
|
|
||||||
func FxTimerTimer()
|
func FxTimerTimer()
|
||||||
{
|
{
|
||||||
this->SetClrModulation(origin->GetStarColor(number));
|
SetClrModulation(origin->GetStarColor(number));
|
||||||
}
|
}
|
||||||
|
|
||||||
local Name = "$Name$";
|
local Name = "$Name$";
|
||||||
|
|
|
@ -11,6 +11,7 @@ local stars;
|
||||||
local color;
|
local color;
|
||||||
local king;
|
local king;
|
||||||
local timer;
|
local timer;
|
||||||
|
local koth_goal;
|
||||||
|
|
||||||
func Initialize() {
|
func Initialize() {
|
||||||
|
|
||||||
|
@ -19,6 +20,11 @@ func Initialize() {
|
||||||
return(1);
|
return(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func SetKotH(object koth)
|
||||||
|
{
|
||||||
|
koth_goal = koth;
|
||||||
|
}
|
||||||
|
|
||||||
func GetKing()
|
func GetKing()
|
||||||
{
|
{
|
||||||
return king;
|
return king;
|
||||||
|
@ -38,7 +44,7 @@ func Destruction()
|
||||||
func PostInitialize()
|
func PostInitialize()
|
||||||
{
|
{
|
||||||
marker=CreateObject(KingOfTheHill_Marker, 0, -5, NO_OWNER);
|
marker=CreateObject(KingOfTheHill_Marker, 0, -5, NO_OWNER);
|
||||||
marker["origin"]=this;
|
marker->SetOrigin(this);
|
||||||
CreateStarCircle();
|
CreateStarCircle();
|
||||||
AddEffect("Timer", this, 10, 10, this);
|
AddEffect("Timer", this, 10, 10, this);
|
||||||
}
|
}
|
||||||
|
@ -63,7 +69,7 @@ func CheckNewKing()
|
||||||
|
|
||||||
if(king) return;
|
if(king) return;
|
||||||
|
|
||||||
var new=FindObject(Find_Distance(Goal_KingOfTheHill->GetRadius()), Find_NoContainer(), Find_OCF(OCF_CrewMember));
|
var new=FindObject(Find_Distance(koth_goal->GetRadius()), Find_NoContainer(), Find_OCF(OCF_CrewMember));
|
||||||
if(new)
|
if(new)
|
||||||
{
|
{
|
||||||
king=new;
|
king=new;
|
||||||
|
@ -131,7 +137,7 @@ func AdjustStarColor()
|
||||||
|
|
||||||
func CreateStarCircle()
|
func CreateStarCircle()
|
||||||
{
|
{
|
||||||
var radius=Goal_KingOfTheHill->GetRadius();
|
var radius=koth_goal->GetRadius();
|
||||||
if(radius == nil) return FatalError("Goal_KingOfTheHill: radius has to be set before use!");
|
if(radius == nil) return FatalError("Goal_KingOfTheHill: radius has to be set before use!");
|
||||||
|
|
||||||
if(GetType(stars) != C4V_Array)
|
if(GetType(stars) != C4V_Array)
|
||||||
|
|
|
@ -8,15 +8,15 @@ Additionally it creates a KingOfTheHill_Location that does the rest.
|
||||||
Interface:
|
Interface:
|
||||||
|
|
||||||
Radius of the area:
|
Radius of the area:
|
||||||
Goal_KingOfTheHill->SetRadius(int x);
|
SetRadius(int x);
|
||||||
Goal_KingOfTheHill->GetRadius();
|
GetRadius();
|
||||||
|
|
||||||
points to achieve for the victory:
|
points to achieve for the victory:
|
||||||
Goal_KingOfTheHill->SetPointLimit(int x);
|
SetPointLimit(int x);
|
||||||
Goal_KingOfTheHill->GetPointLimit();
|
GetPointLimit();
|
||||||
|
|
||||||
automatically place the area on the map:
|
automatically place the area on the map:
|
||||||
Goal_KingOfTheHill->SearchPosition();
|
SearchPosition();
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include Library_Goal
|
#include Library_Goal
|
||||||
|
@ -24,6 +24,8 @@ Goal_KingOfTheHill->SearchPosition();
|
||||||
local player_points;
|
local player_points;
|
||||||
local player_deaths;
|
local player_deaths;
|
||||||
local location;
|
local location;
|
||||||
|
local point_limit;
|
||||||
|
local radius;
|
||||||
|
|
||||||
func Initialize()
|
func Initialize()
|
||||||
{
|
{
|
||||||
|
@ -47,6 +49,7 @@ func PostInitialize()
|
||||||
func Init()
|
func Init()
|
||||||
{
|
{
|
||||||
location=CreateObject(KingOfTheHill_Location, 0, 5, NO_OWNER);
|
location=CreateObject(KingOfTheHill_Location, 0, 5, NO_OWNER);
|
||||||
|
location->SetKotH(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
func Destruction()
|
func Destruction()
|
||||||
|
@ -54,14 +57,7 @@ func Destruction()
|
||||||
if(location) location->RemoveObject();
|
if(location) location->RemoveObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
public func SearchPosition()
|
func SearchPosition()
|
||||||
{
|
|
||||||
var o=FindObject(Find_ID(Goal_KingOfTheHill));
|
|
||||||
if(!o) return;
|
|
||||||
o->CalculatePosition();
|
|
||||||
}
|
|
||||||
|
|
||||||
func CalculatePosition()
|
|
||||||
{
|
{
|
||||||
var a=0, b=LandscapeHeight();
|
var a=0, b=LandscapeHeight();
|
||||||
|
|
||||||
|
@ -92,31 +88,25 @@ func CalculatePosition()
|
||||||
|
|
||||||
public func GetPointLimit()
|
public func GetPointLimit()
|
||||||
{
|
{
|
||||||
return Goal_KingOfTheHill["point_limit"];
|
return point_limit;
|
||||||
}
|
}
|
||||||
|
|
||||||
public func SetPointLimit(int x)
|
public func SetPointLimit(int x)
|
||||||
{
|
{
|
||||||
Goal_KingOfTheHill["point_limit"]=x;
|
point_limit=x;
|
||||||
}
|
}
|
||||||
|
|
||||||
public func GetRadius()
|
public func GetRadius()
|
||||||
{
|
{
|
||||||
return Goal_KingOfTheHill["radius"];
|
return radius;
|
||||||
}
|
}
|
||||||
|
|
||||||
public func SetRadius(int to)
|
public func SetRadius(int to)
|
||||||
{
|
{
|
||||||
Goal_KingOfTheHill["radius"]=to;
|
radius=to;
|
||||||
}
|
}
|
||||||
|
|
||||||
public func DoPoint(player)
|
func DoPoint(player)
|
||||||
{
|
|
||||||
var o=FindObject(Find_ID(Goal_KingOfTheHill));
|
|
||||||
o->DoPointEx(player);
|
|
||||||
}
|
|
||||||
|
|
||||||
func DoPointEx(player)
|
|
||||||
{
|
{
|
||||||
++player_points[player];
|
++player_points[player];
|
||||||
}
|
}
|
||||||
|
@ -124,12 +114,12 @@ func DoPointEx(player)
|
||||||
protected func InitializePlayer()
|
protected func InitializePlayer()
|
||||||
{
|
{
|
||||||
ScheduleCall(this, "RefreshScoreboard", 1);
|
ScheduleCall(this, "RefreshScoreboard", 1);
|
||||||
return Goal_Melee->InitializePlayer(...);
|
return Goal_Melee->InitializePlayer(...); // TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
public func IsFulfilled()
|
public func IsFulfilled()
|
||||||
{
|
{
|
||||||
return Goal_Melee->IsFulfilled();
|
return Goal_Melee->IsFulfilled(); // TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
func OnClonkDeath(object clonk, int killer)
|
func OnClonkDeath(object clonk, int killer)
|
||||||
|
@ -182,7 +172,7 @@ public func Activate(int byplr)
|
||||||
lines[GetLength(lines)]=Format("%s: %d", teams[i]["player_names"], teams[i]["points"] );
|
lines[GetLength(lines)]=Format("%s: %d", teams[i]["player_names"], teams[i]["points"] );
|
||||||
}
|
}
|
||||||
|
|
||||||
var msg=Format("$MsgGoalDesc$", Goal_KingOfTheHill->GetPointLimit());
|
var msg=Format("$MsgGoalDesc$", GetPointLimit());
|
||||||
for(var i=0;i<GetLength(lines);++i)
|
for(var i=0;i<GetLength(lines);++i)
|
||||||
msg=Format("%s|%s", msg, lines[i]);
|
msg=Format("%s|%s", msg, lines[i]);
|
||||||
return MessageWindow(msg, byplr);
|
return MessageWindow(msg, byplr);
|
||||||
|
@ -237,7 +227,7 @@ static const SBRD_Points=1;
|
||||||
func RefreshScoreboard()
|
func RefreshScoreboard()
|
||||||
{
|
{
|
||||||
SetScoreboardData(SBRD_Caption,SBRD_Caption,"King of the Hill",SBRD_Caption);
|
SetScoreboardData(SBRD_Caption,SBRD_Caption,"King of the Hill",SBRD_Caption);
|
||||||
SetScoreboardData(SBRD_Caption,SBRD_Points,Format("{{Sword}} / %d", Goal_KingOfTheHill->GetPointLimit()),SBRD_Caption);
|
SetScoreboardData(SBRD_Caption,SBRD_Points,Format("{{Sword}} / %d", GetPointLimit()),SBRD_Caption);
|
||||||
SetScoreboardData(SBRD_Caption,SBRD_Deaths,"{{Clonk}}",SBRD_Caption);
|
SetScoreboardData(SBRD_Caption,SBRD_Deaths,"{{Clonk}}",SBRD_Caption);
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue