fixed King of the Hill

Tobias Zwick 2010-09-23 00:23:32 +02:00
parent b0806668d9
commit aa235b8836
6 changed files with 48 additions and 41 deletions

View File

@ -8,9 +8,9 @@
protected func Initialize()
{
// Goal settings.
CreateObject(Goal_KingOfTheHill, 625, 170, NO_OWNER);
Goal_KingOfTheHill->SetRadius(120);
Goal_KingOfTheHill->SetPointLimit(6);
var goal = CreateObject(Goal_KingOfTheHill, 625, 170, NO_OWNER);
goal->SetRadius(120);
goal->SetPointLimit(6);
// Weapon chests.
CreateObject(Chest, 690, 210, NO_OWNER);

View File

@ -2,7 +2,7 @@
id=KingOfTheHill_Marker
Version=4,9,5
#Category=C4D_StaticBack | C4D_Foreground | C4D_IgnoreFoW
Category=C4D_StaticBack | C4D_Foreground
Category=C4D_StaticBack | C4D_IgnoreFoW
Width=15
Height=15
Offset=-7,-7

View File

@ -1,16 +1,27 @@
/*
Marker for King of the Hill
Author: Zapper
Marker for King of the Hill
Author: Zapper
*/
local origin;
func Initialize()
{
AddEffect("Timer", this, 10, 1, this);
}
func SetOrigin(object o)
{
origin = o;
}
func GetOrigin()
{
return origin;
}
func FxTimerTimer()
{
var origin=this["origin"];
if(!origin) return RemoveObject();
var x, y;

View File

@ -8,7 +8,7 @@ local number;
func Init(o, n)
{
this->SetObjectBlitMode(GFX_BLIT_Mod2);
SetObjectBlitMode(GFX_BLIT_Mod2);
origin=o;
number=n;
SetR(Angle(origin->GetX(), origin->GetY(), this->GetX(), this->GetY()) + 45);
@ -18,12 +18,12 @@ func Initialize()
{
SetGraphics(0, KingOfTheHill_Marker);
AddEffect("Timer", this, 10, 1, this);
this->SetGraphics(nil, KingOfTheHill_Marker);
SetGraphics(nil, KingOfTheHill_Marker);
}
func FxTimerTimer()
{
this->SetClrModulation(origin->GetStarColor(number));
SetClrModulation(origin->GetStarColor(number));
}
local Name = "$Name$";

View File

@ -11,6 +11,7 @@ local stars;
local color;
local king;
local timer;
local koth_goal;
func Initialize() {
@ -19,6 +20,11 @@ func Initialize() {
return(1);
}
func SetKotH(object koth)
{
koth_goal = koth;
}
func GetKing()
{
return king;
@ -38,7 +44,7 @@ func Destruction()
func PostInitialize()
{
marker=CreateObject(KingOfTheHill_Marker, 0, -5, NO_OWNER);
marker["origin"]=this;
marker->SetOrigin(this);
CreateStarCircle();
AddEffect("Timer", this, 10, 10, this);
}
@ -63,7 +69,7 @@ func CheckNewKing()
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)
{
king=new;
@ -131,7 +137,7 @@ func AdjustStarColor()
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(GetType(stars) != C4V_Array)

View File

@ -8,15 +8,15 @@ Additionally it creates a KingOfTheHill_Location that does the rest.
Interface:
Radius of the area:
Goal_KingOfTheHill->SetRadius(int x);
Goal_KingOfTheHill->GetRadius();
SetRadius(int x);
GetRadius();
points to achieve for the victory:
Goal_KingOfTheHill->SetPointLimit(int x);
Goal_KingOfTheHill->GetPointLimit();
SetPointLimit(int x);
GetPointLimit();
automatically place the area on the map:
Goal_KingOfTheHill->SearchPosition();
SearchPosition();
*/
#include Library_Goal
@ -24,6 +24,8 @@ Goal_KingOfTheHill->SearchPosition();
local player_points;
local player_deaths;
local location;
local point_limit;
local radius;
func Initialize()
{
@ -47,6 +49,7 @@ func PostInitialize()
func Init()
{
location=CreateObject(KingOfTheHill_Location, 0, 5, NO_OWNER);
location->SetKotH(this);
}
func Destruction()
@ -54,14 +57,7 @@ func Destruction()
if(location) location->RemoveObject();
}
public func SearchPosition()
{
var o=FindObject(Find_ID(Goal_KingOfTheHill));
if(!o) return;
o->CalculatePosition();
}
func CalculatePosition()
func SearchPosition()
{
var a=0, b=LandscapeHeight();
@ -92,31 +88,25 @@ func CalculatePosition()
public func GetPointLimit()
{
return Goal_KingOfTheHill["point_limit"];
return point_limit;
}
public func SetPointLimit(int x)
{
Goal_KingOfTheHill["point_limit"]=x;
point_limit=x;
}
public func GetRadius()
{
return Goal_KingOfTheHill["radius"];
return radius;
}
public func SetRadius(int to)
{
Goal_KingOfTheHill["radius"]=to;
radius=to;
}
public func DoPoint(player)
{
var o=FindObject(Find_ID(Goal_KingOfTheHill));
o->DoPointEx(player);
}
func DoPointEx(player)
func DoPoint(player)
{
++player_points[player];
}
@ -124,12 +114,12 @@ func DoPointEx(player)
protected func InitializePlayer()
{
ScheduleCall(this, "RefreshScoreboard", 1);
return Goal_Melee->InitializePlayer(...);
return Goal_Melee->InitializePlayer(...); // TODO
}
public func IsFulfilled()
{
return Goal_Melee->IsFulfilled();
return Goal_Melee->IsFulfilled(); // TODO
}
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"] );
}
var msg=Format("$MsgGoalDesc$", Goal_KingOfTheHill->GetPointLimit());
var msg=Format("$MsgGoalDesc$", GetPointLimit());
for(var i=0;i<GetLength(lines);++i)
msg=Format("%s|%s", msg, lines[i]);
return MessageWindow(msg, byplr);
@ -237,7 +227,7 @@ static const SBRD_Points=1;
func RefreshScoreboard()
{
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);