forked from Mirrors/openclonk
Resolved all warnings due to global function in included scripts.
parent
6e303c4e2c
commit
bf795164f2
|
@ -388,38 +388,4 @@ func DoSell(object pObj, int iPlr, bool bRight)
|
|||
return true;
|
||||
}
|
||||
|
||||
// ------------------------ global functions ---------------------------
|
||||
global func Buy (id idBuyObj, int iForPlr, int iPayPlr, object pToBase, bool fShowErrors)
|
||||
{
|
||||
// if no base is given try this
|
||||
if(!pToBase) pToBase = this;
|
||||
// not a base?
|
||||
if( !pToBase->~IsBase() )
|
||||
return 0;
|
||||
return pToBase->DoBuy(idBuyObj, iForPlr, iPayPlr, 0, 0, fShowErrors);
|
||||
}
|
||||
|
||||
global func Sell (int iPlr, object pObj, object pToBase)
|
||||
{
|
||||
// if no base is given try this
|
||||
if(!pToBase) pToBase = this;
|
||||
// not a base?
|
||||
if( !pToBase->~IsBase() )
|
||||
return 0;
|
||||
return pToBase->DoSell(pObj, iPlr);
|
||||
}
|
||||
|
||||
global func FindBase (int iPlr, int iIndex)
|
||||
{
|
||||
return FindObjects(Find_Owner(iPlr), Find_Func("IsBase"))[iIndex];
|
||||
}
|
||||
|
||||
global func GetBase ()
|
||||
{
|
||||
if(!(this->~IsBase())) return NO_OWNER;
|
||||
return GetOwner();
|
||||
}
|
||||
|
||||
local Name = "$Name$";
|
||||
|
||||
|
||||
local Name = "$Name$";
|
|
@ -266,16 +266,6 @@ public func Collect(object item, bool ignoreOCF, int pos, bool force)
|
|||
return success;
|
||||
}
|
||||
|
||||
// disable ShiftContents for objects with ClonkControl.ocd
|
||||
|
||||
global func ShiftContents()
|
||||
{
|
||||
if (this)
|
||||
if (this->~HandObjects() != nil)
|
||||
return false;
|
||||
return _inherited(...);
|
||||
}
|
||||
|
||||
/* ################################################# */
|
||||
|
||||
protected func Construction()
|
||||
|
|
|
@ -48,13 +48,13 @@ func Control2Elevator(int control, object clonk)
|
|||
|
||||
/* Effect */
|
||||
|
||||
global func FxElevatorControlStart(object vehicle, proplist effect, int temp, object case)
|
||||
public func FxElevatorControlStart(object vehicle, proplist effect, int temp, object case)
|
||||
{
|
||||
if (temp) return;
|
||||
effect.case = case;
|
||||
}
|
||||
|
||||
global func FxElevatorControlTimer(object vehicle, proplist effect)
|
||||
public func FxElevatorControlTimer(object vehicle, proplist effect)
|
||||
{
|
||||
if (ObjectDistance(effect.case, vehicle) > 12)
|
||||
return -1;
|
||||
|
@ -65,7 +65,7 @@ global func FxElevatorControlTimer(object vehicle, proplist effect)
|
|||
}
|
||||
}
|
||||
|
||||
global func FxElevatorControlStop(object vehicle, proplist effect, int reason, bool temp)
|
||||
public func FxElevatorControlStop(object vehicle, proplist effect, int reason, bool temp)
|
||||
{
|
||||
if (temp) return;
|
||||
if (effect.controlled)
|
||||
|
|
|
@ -12,33 +12,6 @@ local lflag;
|
|||
|
||||
public func IsFlagpole(){return true;}
|
||||
|
||||
global func GetFlagpoleForPosition(int x, int y)
|
||||
{
|
||||
if(GetType(LibraryFlag_flag_list) != C4V_Array) return nil;
|
||||
|
||||
var oldest = nil, oldest_time = 0;
|
||||
|
||||
for(var flag in LibraryFlag_flag_list)
|
||||
{
|
||||
var d = Distance(GetX() + x, GetY() + y, flag->GetX(), flag->GetY());
|
||||
if(d > flag->GetFlagRadius()) continue;
|
||||
|
||||
if(oldest == nil || flag->GetFlagConstructionTime() < oldest_time)
|
||||
{
|
||||
oldest = flag;
|
||||
oldest_time = flag->GetFlagConstructionTime();
|
||||
}
|
||||
}
|
||||
return oldest;
|
||||
}
|
||||
|
||||
global func GetOwnerOfPosition(int x, int y)
|
||||
{
|
||||
var flag = GetFlagpoleForPosition(x, y);
|
||||
if(!flag) return NO_OWNER;
|
||||
return flag->GetOwner();
|
||||
}
|
||||
|
||||
func RefreshAllFlagLinks()
|
||||
{
|
||||
for(var f in LibraryFlag_flag_list)
|
||||
|
@ -368,12 +341,6 @@ public func SetFlagRadius(int to)
|
|||
return true;
|
||||
}
|
||||
|
||||
global func RedrawAllFlagRadiuses()
|
||||
{
|
||||
for(var f in LibraryFlag_flag_list)
|
||||
f->RedrawFlagRadius();
|
||||
}
|
||||
|
||||
public func GetFlagRadius(){return lflag.radius;}
|
||||
public func GetFlagConstructionTime() {return lflag.construction_time;}
|
||||
public func GetFlagMarkerID(){return LibraryFlag_Marker;}
|
||||
|
|
|
@ -64,56 +64,6 @@ protected func InitializePlayer(int plr)
|
|||
HUD->OnGoalUpdate(this);
|
||||
}
|
||||
|
||||
global func FxIntGoalCheckTimer(object trg, effect, int time)
|
||||
{
|
||||
if (!time)
|
||||
return true;
|
||||
var curr_goal = effect.curr_goal;
|
||||
// Check current goal object
|
||||
if (curr_goal && (curr_goal->GetCategory() & C4D_Goal))
|
||||
{
|
||||
curr_goal->NotifyHUD();
|
||||
if (!curr_goal->~IsFulfilled())
|
||||
return true;
|
||||
}
|
||||
// Current goal is fulfilled/destroyed - check all others
|
||||
var goal_count = 0;
|
||||
for (curr_goal in FindObjects(Find_Category(C4D_Goal)))
|
||||
{
|
||||
++goal_count;
|
||||
if (!curr_goal->~IsFulfilled())
|
||||
{
|
||||
effect.curr_goal = curr_goal;
|
||||
curr_goal->NotifyHUD();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// No goal object? Kill timer
|
||||
if (!goal_count)
|
||||
return FX_Execute_Kill;
|
||||
// Game over :(
|
||||
AllGoalsFulfilled();
|
||||
return FX_Execute_Kill;
|
||||
}
|
||||
|
||||
global func AllGoalsFulfilled()
|
||||
{
|
||||
// Goals fulfilled: Set mission password(s)
|
||||
for (var goal in FindObjects(Find_Category(C4D_Goal)))
|
||||
if (goal.mission_password)
|
||||
GainMissionAccess(goal.mission_password);
|
||||
// Custom scenario goal evaluation?
|
||||
if (GameCall("OnGoalsFulfilled")) return true;
|
||||
// We're done. Play some sound and schedule game over call
|
||||
Sound("Fanfare", true);
|
||||
AddEffect("IntGoalDone", 0, 1, 30, 0);
|
||||
}
|
||||
|
||||
global func FxIntGoalDoneStop()
|
||||
{
|
||||
GameOver();
|
||||
}
|
||||
|
||||
// Set mission password to be gained when all goals are fulfilled
|
||||
public func SetMissionAccess(string str_password)
|
||||
{
|
||||
|
|
|
@ -5,28 +5,6 @@
|
|||
@author Clonkonaut
|
||||
*/
|
||||
|
||||
/* Global */
|
||||
|
||||
/** Pulls the plant above ground if it was buried by PlaceVegetation. A plant must have 'Bottom' and 'Center' CNAT to use this (bottom is the point which should be buried, center the lowest point that must not be buried)
|
||||
*/
|
||||
global func RootSurface()
|
||||
{
|
||||
if (HasCNAT(CNAT_Center))
|
||||
{
|
||||
var i = 0;
|
||||
while(GetContact(-1) & CNAT_Center && i < GetObjHeight()/2) { SetPosition(GetX(),GetY()-1); i++; } //Move up if too far underground
|
||||
}
|
||||
if (HasCNAT(CNAT_Bottom))
|
||||
{
|
||||
i = 0;
|
||||
while(!(GetContact(-1) & CNAT_Bottom) && i < GetObjHeight()/2) { SetPosition(GetX(),GetY()+1); i++; } //Move down if in midair
|
||||
|
||||
if (!Stuck()) SetPosition(GetX(),GetY()+1); // try make the plant stuck
|
||||
}
|
||||
}
|
||||
|
||||
/* Local */
|
||||
|
||||
// This is a plant
|
||||
public func IsPlant()
|
||||
{
|
||||
|
|
|
@ -74,7 +74,7 @@ func Movement() // TimerCall
|
|||
vehicle->SetPosition(GetX(), GetY() + 12 - vehicle->GetObjHeight()/2 );
|
||||
vehicle->SetSpeed();
|
||||
vehicle->SetR();
|
||||
AddEffect("ElevatorControl", vehicle, 30, 5, nil, nil, this);
|
||||
AddEffect("ElevatorControl", vehicle, 30, 5, vehicle, nil, this);
|
||||
}
|
||||
|
||||
// no power?
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
/*--
|
||||
Global functions used in correlation to Objects.ocd\Libraries.ocd\ClonkControl.ocd
|
||||
|
||||
Authors: Newton
|
||||
--*/
|
||||
|
||||
// disable ShiftContents for objects with ClonkControl.ocd
|
||||
|
||||
global func ShiftContents()
|
||||
{
|
||||
if (this)
|
||||
if (this->~HandObjects() != nil)
|
||||
return false;
|
||||
return _inherited(...);
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
/*--
|
||||
Global functions used in correlation to Objects.ocd\Libraries.ocd\Flag.ocd
|
||||
|
||||
Authors: Zapper
|
||||
--*/
|
||||
|
||||
global func GetFlagpoleForPosition(int x, int y)
|
||||
{
|
||||
if(GetType(LibraryFlag_flag_list) != C4V_Array) return nil;
|
||||
|
||||
var oldest = nil, oldest_time = 0;
|
||||
|
||||
for(var flag in LibraryFlag_flag_list)
|
||||
{
|
||||
var d = Distance(GetX() + x, GetY() + y, flag->GetX(), flag->GetY());
|
||||
if(d > flag->GetFlagRadius()) continue;
|
||||
|
||||
if(oldest == nil || flag->GetFlagConstructionTime() < oldest_time)
|
||||
{
|
||||
oldest = flag;
|
||||
oldest_time = flag->GetFlagConstructionTime();
|
||||
}
|
||||
}
|
||||
return oldest;
|
||||
}
|
||||
|
||||
global func GetOwnerOfPosition(int x, int y)
|
||||
{
|
||||
var flag = GetFlagpoleForPosition(x, y);
|
||||
if(!flag) return NO_OWNER;
|
||||
return flag->GetOwner();
|
||||
}
|
||||
|
||||
global func RedrawAllFlagRadiuses()
|
||||
{
|
||||
for(var f in LibraryFlag_flag_list)
|
||||
f->RedrawFlagRadius();
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
/*--
|
||||
Global functions used in correlation to Objects.ocd\Libraries.ocd\Goal.ocd
|
||||
|
||||
Authors: Sven2
|
||||
--*/
|
||||
|
||||
global func FxIntGoalCheckTimer(object trg, effect, int time)
|
||||
{
|
||||
if (!time)
|
||||
return true;
|
||||
var curr_goal = effect.curr_goal;
|
||||
// Check current goal object
|
||||
if (curr_goal && (curr_goal->GetCategory() & C4D_Goal))
|
||||
{
|
||||
curr_goal->NotifyHUD();
|
||||
if (!curr_goal->~IsFulfilled())
|
||||
return true;
|
||||
}
|
||||
// Current goal is fulfilled/destroyed - check all others
|
||||
var goal_count = 0;
|
||||
for (curr_goal in FindObjects(Find_Category(C4D_Goal)))
|
||||
{
|
||||
++goal_count;
|
||||
if (!curr_goal->~IsFulfilled())
|
||||
{
|
||||
effect.curr_goal = curr_goal;
|
||||
curr_goal->NotifyHUD();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// No goal object? Kill timer
|
||||
if (!goal_count)
|
||||
return FX_Execute_Kill;
|
||||
// Game over :(
|
||||
AllGoalsFulfilled();
|
||||
return FX_Execute_Kill;
|
||||
}
|
||||
|
||||
global func AllGoalsFulfilled()
|
||||
{
|
||||
// Goals fulfilled: Set mission password(s)
|
||||
for (var goal in FindObjects(Find_Category(C4D_Goal)))
|
||||
if (goal.mission_password)
|
||||
GainMissionAccess(goal.mission_password);
|
||||
// Custom scenario goal evaluation?
|
||||
if (GameCall("OnGoalsFulfilled")) return true;
|
||||
// We're done. Play some sound and schedule game over call
|
||||
Sound("Fanfare", true);
|
||||
AddEffect("IntGoalDone", 0, 1, 30, 0);
|
||||
}
|
||||
|
||||
global func FxIntGoalDoneStop()
|
||||
{
|
||||
GameOver();
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
/*--
|
||||
Objects.c
|
||||
Authors: Maikel, boni, Ringwaul, Sven2, flgr, Clonkonaut, Günther
|
||||
Authors: Maikel, boni, Ringwaul, Sven2, flgr, Clonkonaut, Günther, Randrian
|
||||
|
||||
Functions generally applicable to objects; not enough to be worth distinct scripts though.
|
||||
--*/
|
||||
|
@ -240,4 +240,53 @@ global func Split2Components()
|
|||
}
|
||||
RemoveObject();
|
||||
return;
|
||||
}
|
||||
|
||||
// Pulls an object above ground if it was buried (e.g. by PlaceVegetation).
|
||||
// The object must have 'Bottom' and 'Center' CNAT to use this.
|
||||
// (bottom is the point which should be buried, center the lowest point that must not be buried)
|
||||
// Mainly used by plants.
|
||||
global func RootSurface()
|
||||
{
|
||||
if (HasCNAT(CNAT_Center))
|
||||
{
|
||||
var i = 0;
|
||||
while(GetContact(-1) & CNAT_Center && i < GetObjHeight()/2) { SetPosition(GetX(),GetY()-1); i++; } //Move up if too far underground
|
||||
}
|
||||
if (HasCNAT(CNAT_Bottom))
|
||||
{
|
||||
i = 0;
|
||||
while(!(GetContact(-1) & CNAT_Bottom) && i < GetObjHeight()/2) { SetPosition(GetX(),GetY()+1); i++; } //Move down if in midair
|
||||
|
||||
if (!Stuck()) SetPosition(GetX(),GetY()+1); // try make the plant stuck
|
||||
}
|
||||
}
|
||||
|
||||
// Buys an object.
|
||||
global func Buy (id idBuyObj, int iForPlr, int iPayPlr, object pToBase, bool fShowErrors)
|
||||
{
|
||||
// if no base is given try this
|
||||
if(!pToBase) pToBase = this;
|
||||
// not a base?
|
||||
if( !pToBase->~IsBase() )
|
||||
return 0;
|
||||
return pToBase->DoBuy(idBuyObj, iForPlr, iPayPlr, 0, 0, fShowErrors);
|
||||
}
|
||||
|
||||
// Sells an object.
|
||||
global func Sell (int iPlr, object pObj, object pToBase)
|
||||
{
|
||||
// if no base is given try this
|
||||
if(!pToBase) pToBase = this;
|
||||
// not a base?
|
||||
if( !pToBase->~IsBase() )
|
||||
return 0;
|
||||
return pToBase->DoSell(pObj, iPlr);
|
||||
}
|
||||
|
||||
// Returns the owner if this is a base.
|
||||
global func GetBase ()
|
||||
{
|
||||
if(!(this->~IsBase())) return NO_OWNER;
|
||||
return GetOwner();
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
/*--
|
||||
Player.c
|
||||
Authors: timi, Maikel, Joern, Zapper
|
||||
Authors: timi, Maikel, Joern, Zapper, Randrian
|
||||
|
||||
Player and team related functions.
|
||||
--*/
|
||||
|
@ -107,4 +107,10 @@ global func MessageWindow(string msg, int for_plr, id icon, string caption)
|
|||
return false;
|
||||
cursor->AddMenuItem(caption, nil, nil, 0, 0, msg);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Find a base of the given player. Use index to search through all bases.
|
||||
global func FindBase (int iPlr, int iIndex)
|
||||
{
|
||||
return FindObjects(Find_Owner(iPlr), Find_Func("IsBase"))[iIndex];
|
||||
}
|
Loading…
Reference in New Issue