forked from Mirrors/openclonk
adapt System.ocg headers to style guidelines and small clean ups
parent
f3cadedff1
commit
2b88e77254
|
@ -1,6 +1,9 @@
|
|||
/**
|
||||
Decay.c
|
||||
Animals can use Decay() in their Death() function so they will slowly decay and spawn a few temporary flies.
|
||||
The delay parameter specifies the amount of frames before decaying one Con.
|
||||
|
||||
@author
|
||||
*/
|
||||
|
||||
global func Decay(int delay)
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
/**
|
||||
Contains functions that require definitions from the "disasters" folder.
|
||||
Disasters.c
|
||||
Contains functions that require definitions from the Disasters.ocd folder.
|
||||
|
||||
@author
|
||||
*/
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
/*
|
||||
Effect.c
|
||||
Contains functions for (visual) effects that require particles or definitions from Objects.ocd to be loaded.
|
||||
|
||||
@author
|
||||
*/
|
||||
|
||||
/*
|
||||
|
@ -11,11 +14,11 @@ global func ExplosionEffect(int level, int x, int y, int smoothness, bool silent
|
|||
// Zero-size explosion doesn't affect anything
|
||||
if (level <= 0) return;
|
||||
|
||||
if(!silent) //Does object use it's own explosion sound effect?
|
||||
if (!silent) //Does object use it's own explosion sound effect?
|
||||
{
|
||||
// Select sound according to level: from 1 to 3, add the * to allow alternatives.
|
||||
var grade = BoundBy(level / 10 - 1, 1, 3);
|
||||
if(GBackLiquid(x, y))
|
||||
if (GBackLiquid(x, y))
|
||||
SoundAt(Format("Fire::BlastLiquid%d*",grade), x, y);
|
||||
else
|
||||
SoundAt(Format("Fire::Blast%d*", grade), x, y);
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
/*
|
||||
/**
|
||||
FindLocation.c
|
||||
This script contains the function FindLocation which uses a parameter-system similar to FindObject.
|
||||
This function should mainly be used for placement of objects at the start of a scenario.
|
||||
FindLocation is not guaranteed to always return a spot if a fitting spot exists, it's just best effort.
|
||||
|
@ -8,6 +9,8 @@
|
|||
FindLocation([Loc_Tunnel()]);
|
||||
finds a floor spot but not in front of tunnel:
|
||||
FindLocation([Loc_Not(Find_Tunnel()), Loc_Wall(CNAT_Bottom)]);
|
||||
|
||||
@author Zapper
|
||||
*/
|
||||
|
||||
static const LOC_INVALID = 0;
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
/**
|
||||
GUI.c
|
||||
Contains UI related functions that require definitions from Objects.ocd to be loaded.
|
||||
|
||||
@author Zapper
|
||||
*/
|
||||
|
||||
// The default menu decoration used in most places.
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
/**
|
||||
InflameLandscape.c
|
||||
Engine callback handling for landscape inflammation
|
||||
|
||||
@author
|
||||
*/
|
||||
|
||||
// Callback from engine when landsape is incinerated at an incindiary material.
|
||||
|
|
|
@ -1,7 +1,13 @@
|
|||
/* Configurable pathfinder for graphs */
|
||||
/**
|
||||
AStar.c
|
||||
Configurable pathfinder for graphs.
|
||||
|
||||
@author Luchs
|
||||
*/
|
||||
|
||||
// Generic A* implementation.
|
||||
static const AStar = new Global {
|
||||
static const AStar = new Global
|
||||
{
|
||||
/* Overwrite these functions */
|
||||
/* ========================= */
|
||||
|
||||
|
@ -93,7 +99,8 @@ static const AStar = new Global {
|
|||
//
|
||||
// Graph nodes are a regular grid over the landscape with a configurable size
|
||||
// (step). Nodes are represented as {x, y} proplists.
|
||||
static const AStarMap = new AStar {
|
||||
static const AStarMap = new AStar
|
||||
{
|
||||
// This function is used both as heuristic (node to the goal) and as cost
|
||||
// function (two neighboring nodes).
|
||||
distance = func(proplist a, proplist b)
|
||||
|
@ -132,8 +139,8 @@ static const AStarMap = new AStar {
|
|||
};
|
||||
|
||||
/* Binary Min-Heap */
|
||||
static const MinHeap = new Global {
|
||||
|
||||
static const MinHeap = new Global
|
||||
{
|
||||
// A heap is an array of [key, value] array-tuples.
|
||||
Heapify = func(array heap, int i)
|
||||
{
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*--
|
||||
Action.c
|
||||
Authors: Günther
|
||||
|
||||
Stuff for the proplist changes.
|
||||
--*/
|
||||
/**
|
||||
Action.c
|
||||
Stuff for the proplist changes.
|
||||
|
||||
@author Günther
|
||||
*/
|
||||
|
||||
static const DFA_NONE = nil;
|
||||
static const DFA_WALK = "WALK";
|
||||
|
@ -21,7 +21,8 @@ static const DFA_FLOAT = "FLOAT";
|
|||
static const DFA_ATTACH = "ATTACH";
|
||||
static const DFA_CONNECT = "CONNECT";
|
||||
static const DFA_PULL = "PULL";
|
||||
static const Action = {
|
||||
static const Action =
|
||||
{
|
||||
GetName = Global.GetName,
|
||||
Length = 1,
|
||||
Directions = 1,
|
||||
|
@ -29,9 +30,12 @@ static const Action = {
|
|||
Procedure = DFA_NONE,
|
||||
};
|
||||
|
||||
global func GameCall(string fn, ...) {
|
||||
if (!fn) return;
|
||||
global func GameCall(string fn, ...)
|
||||
{
|
||||
if (!fn)
|
||||
return;
|
||||
var f = Scenario[fn];
|
||||
if (!f) return;
|
||||
if (!f)
|
||||
return;
|
||||
return Scenario->Call(f, ...);
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*--
|
||||
Array.c
|
||||
Authors: Zapper, Sven2
|
||||
|
||||
Global array helper functions.
|
||||
--*/
|
||||
/**
|
||||
Array.c
|
||||
Global array helper functions.
|
||||
|
||||
@author Zapper, Sven2
|
||||
*/
|
||||
|
||||
|
||||
// Concatenates two arrays and returns a new array.
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
/*
|
||||
This file contains functions that can be commonly used to make functions safe.
|
||||
/**
|
||||
Assert.c
|
||||
Functions that can be commonly used to make functions safe.
|
||||
|
||||
Author: Marky
|
||||
@author Marky
|
||||
*/
|
||||
|
||||
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
|
||||
/*--
|
||||
CollectStatistics.c
|
||||
Authors: Luchs
|
||||
|
||||
Global entry point for statistics collection for the masterserver.
|
||||
--*/
|
||||
/**
|
||||
CollectStatistics.c
|
||||
Global entry point for statistics collection for the masterserver.
|
||||
|
||||
@author Luchs
|
||||
*/
|
||||
|
||||
|
||||
// This function is called after the round ends. The return value is passed to
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*--
|
||||
Colors.c
|
||||
Authors: Tyron
|
||||
|
||||
All sorts of operations on colors.
|
||||
--*/
|
||||
/**
|
||||
Colors.c
|
||||
All sorts of operations on colors.
|
||||
|
||||
@author Tyron
|
||||
*/
|
||||
|
||||
static const RGBA_ALPHA = 0;
|
||||
static const RGBA_RED = 1;
|
||||
|
@ -27,7 +27,8 @@ global func SetRGBaValue(int val, int newval, int sel)
|
|||
return val | newval << ((3 - sel) * 8);
|
||||
}
|
||||
|
||||
global func SplitRGBaValue(int rgb) {
|
||||
global func SplitRGBaValue(int rgb)
|
||||
{
|
||||
return [GetRGBaValue(rgb, 1), GetRGBaValue(rgb, 2), GetRGBaValue(rgb, 3), GetRGBaValue(rgb, 0)];
|
||||
}
|
||||
|
||||
|
@ -110,5 +111,5 @@ global func RGB2HSL(int rgb)
|
|||
hue -= 255;
|
||||
}
|
||||
|
||||
return RGB(hue,sat,lightness);
|
||||
return RGB(hue, sat, lightness);
|
||||
}
|
||||
|
|
|
@ -1,38 +1,27 @@
|
|||
/*--
|
||||
Controls.c
|
||||
Authors: boni
|
||||
/**
|
||||
Controls.c
|
||||
Helper functions to find out if a Control fits into a certain category. (Throwing, using, interacting,...).
|
||||
|
||||
Helper functions to find out if a Control fits into a certain category. (Throwing, using, interacting,...)
|
||||
--*/
|
||||
@author boni
|
||||
*/
|
||||
|
||||
/** Control tells the clonk to move */
|
||||
// Control tells the clonk to move.
|
||||
global func IsMovementControl(int ctrl)
|
||||
{
|
||||
// up, up, down, down, left, right, left, right, B, A
|
||||
if(ctrl == CON_Up
|
||||
|| ctrl == CON_Down
|
||||
|| ctrl == CON_Left
|
||||
|| ctrl == CON_Right)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
return ctrl == CON_Up || ctrl == CON_Down || ctrl == CON_Left || ctrl == CON_Right;
|
||||
}
|
||||
|
||||
/** Control throws selected item */
|
||||
// Control throws selected item.
|
||||
global func IsThrowControl(int ctrl)
|
||||
{
|
||||
// right mouse button
|
||||
if(ctrl == CON_Throw)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
return ctrl == CON_Throw;
|
||||
}
|
||||
|
||||
/** Control drops items from inventory (hotkey or selected items) */
|
||||
// Control drops items from inventory (hotkey or selected items).
|
||||
global func IsDropControl(int ctrl)
|
||||
{
|
||||
// selected items
|
||||
if(ctrl == CON_Drop
|
||||
if (ctrl == CON_Drop
|
||||
// hotkeys
|
||||
|| ctrl == CON_DropHotkey0
|
||||
|| ctrl == CON_DropHotkey1
|
||||
|
@ -49,11 +38,11 @@ global func IsDropControl(int ctrl)
|
|||
return false;
|
||||
}
|
||||
|
||||
/** Control has the goal of interacting with some other object (Interaction, Grabbing, Entering,...) */
|
||||
// Control has the goal of interacting with some other object (Interaction, Grabbing, Entering,...).
|
||||
global func IsInteractionControl(int ctrl)
|
||||
{
|
||||
// Interaction itself
|
||||
if(ctrl == CON_Interact
|
||||
if (ctrl == CON_Interact
|
||||
// hotkeys
|
||||
|| ctrl == CON_InteractionHotkey0
|
||||
|| ctrl == CON_InteractionHotkey1
|
||||
|
@ -70,11 +59,11 @@ global func IsInteractionControl(int ctrl)
|
|||
return false;
|
||||
}
|
||||
|
||||
/** Control has the goal of switching the currently selected crewmember */
|
||||
// Control has the goal of switching the currently selected crewmember.
|
||||
global func IsCrewControl(int ctrl)
|
||||
{
|
||||
// next/previous
|
||||
if(ctrl == CON_NextCrew
|
||||
if (ctrl == CON_NextCrew
|
||||
|| ctrl == CON_PreviousCrew
|
||||
// hotkeys
|
||||
|| ctrl == CON_PlayerHotkey0
|
||||
|
@ -93,9 +82,8 @@ global func IsCrewControl(int ctrl)
|
|||
return false;
|
||||
}
|
||||
|
||||
/** Control uses selected item */
|
||||
// Control uses selected item.
|
||||
global func IsUseControl(int ctrl)
|
||||
{
|
||||
if (ctrl == CON_Use || ctrl == CON_UseAlt) return true;
|
||||
return false;
|
||||
return ctrl == CON_Use || ctrl == CON_UseAlt;
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*--
|
||||
Creation.c
|
||||
Authors: Ringwaul, Tyron
|
||||
|
||||
Creation of objects, particles or PSX.
|
||||
--*/
|
||||
/**
|
||||
Creation.c
|
||||
Creation of objects, particles or PSX.
|
||||
|
||||
@author Ringwaul, Tyron
|
||||
*/
|
||||
|
||||
// Creates amount objects of type id inside the indicated rectangle(optional) in the indicated material.
|
||||
// Returns the number of iterations needed, or -1 when the placement failed.
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*--
|
||||
Definition.c
|
||||
Authors: Maikel
|
||||
|
||||
Functions generally applicable to definitions.
|
||||
--*/
|
||||
/**
|
||||
Definition.c
|
||||
Functions generally applicable to definitions.
|
||||
|
||||
@author Maikel
|
||||
*/
|
||||
|
||||
static GetDefinition_Loaded_Definition_List;
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*--
|
||||
Effect.c
|
||||
Authors: Günther
|
||||
|
||||
Prototype for effect prototypes.
|
||||
--*/
|
||||
/**
|
||||
Effect.c
|
||||
Prototype for effect prototypes and useful effects.
|
||||
|
||||
@author Günther
|
||||
*/
|
||||
|
||||
static const Effect = new Global
|
||||
{
|
||||
|
|
|
@ -1,15 +1,12 @@
|
|||
/*--
|
||||
Explode.c
|
||||
Authors: Newton
|
||||
|
||||
Everything about the explosion.
|
||||
TODO: documentation.
|
||||
--*/
|
||||
/**
|
||||
Explode.c
|
||||
Everything about the explosion.
|
||||
|
||||
@author Newton
|
||||
*/
|
||||
|
||||
/*--
|
||||
Particle definitions used by the explosion effect.
|
||||
They will be initialized lazily whenever the first blast goes off.
|
||||
--*/
|
||||
// Particle definitions used by the explosion effect.
|
||||
// They will be initialized lazily whenever the first blast goes off.
|
||||
static ExplosionParticles_Smoke;
|
||||
static ExplosionParticles_Blast;
|
||||
static ExplosionParticles_BlastSmooth;
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
Fade.c
|
||||
Function to fade in and out objects.
|
||||
|
||||
@author
|
||||
*/
|
||||
|
||||
global func FadeOut(int time, bool del)
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*--
|
||||
FindObject.c
|
||||
Authors:
|
||||
/**
|
||||
FindObject.c
|
||||
Wrappers for convenient calls to the FindObject family.
|
||||
|
||||
Wrappers for convenient calls to the FindObject family.
|
||||
--*/
|
||||
@author
|
||||
*/
|
||||
|
||||
|
||||
/*-- Find functions --*/
|
||||
|
@ -142,7 +142,8 @@ Similar to Find_Hostile, but defaults to treating all players as hostile when pl
|
|||
*/
|
||||
global func Find_AnimalHostile(int plr)
|
||||
{
|
||||
if (plr == NO_OWNER) return Find_Not(Find_Owner(NO_OWNER));
|
||||
if (plr == NO_OWNER)
|
||||
return Find_Not(Find_Owner(NO_OWNER));
|
||||
return Find_Or(Find_Owner(NO_OWNER), Find_Hostile(plr));
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
/*--
|
||||
Fire.c
|
||||
Authors: Zapper, Maikel
|
||||
|
||||
The fire effect ported from the engine.
|
||||
|
||||
Functions to be used as documented in the docs.
|
||||
--*/
|
||||
/**
|
||||
Fire.c
|
||||
The fire effect ported from the engine. Functions to be used as documented in the docs.
|
||||
|
||||
@author Zapper, Maikel
|
||||
*/
|
||||
|
||||
static const FIRE_LIGHT_COLOR = 0xc86400;
|
||||
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
/*
|
||||
/**
|
||||
GUI.c
|
||||
This file contains functions that are used for layouting custom menus.
|
||||
|
||||
@author Zapper
|
||||
*/
|
||||
|
||||
/* -- constants used for layout -- */
|
||||
|
|
|
@ -1,15 +1,14 @@
|
|||
/*--
|
||||
GetXVal.c
|
||||
Authors:
|
||||
|
||||
Some functions which request information from the GetXVal family.
|
||||
Attention: These functions directly access internal values of the engine.
|
||||
The usage might, under certain circumstances, lead to desynchronisation in
|
||||
either network games or save games. The most dangerous functions are marked
|
||||
with //(!).
|
||||
|
||||
These functions are also very slow. Values should be cached if possible.
|
||||
--*/
|
||||
/**
|
||||
GetXVal.c
|
||||
Some functions which request information from the GetXVal family.
|
||||
Attention: These functions directly access internal values of the engine.
|
||||
The usage might, under certain circumstances, lead to desynchronisation in
|
||||
either network games or save games. The most dangerous functions are marked
|
||||
with //(!).
|
||||
These functions are also very slow. Values should be cached if possible.
|
||||
|
||||
@author
|
||||
*/
|
||||
|
||||
global func GetActMapVal(string entry, string action, id def, int num)
|
||||
{
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
Heal.c
|
||||
Function to heal livings over time.
|
||||
|
||||
Author: Armin
|
||||
@author Armin
|
||||
*/
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
/*--
|
||||
HitCheck.c
|
||||
Authors: Newton, Boni
|
||||
|
||||
Effect for hit checking.
|
||||
Facilitates any hit check of a projectile. The Projectile hits anything
|
||||
which is either alive or returns for IsProjectileTarget(object projectile,
|
||||
object shooter) true. If the projectile hits something, it calls
|
||||
HitObject(object target) in the projectile.
|
||||
--*/
|
||||
/**
|
||||
HitCheck.c
|
||||
Effect for hit checking.
|
||||
Facilitates any hit check of a projectile. The Projectile hits anything
|
||||
which is either alive or returns for IsProjectileTarget(object projectile,
|
||||
object shooter) true. If the projectile hits something, it calls
|
||||
HitObject(object target) in the projectile.
|
||||
|
||||
@author Newton, Boni
|
||||
*/
|
||||
|
||||
global func FxHitCheckStart(object target, proplist effect, int temp, object by_obj, bool never_shooter)
|
||||
{
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
/*
|
||||
global functions that belong to Libraries.ocd/Inventory.ocd
|
||||
/**
|
||||
Library_Inventory.c
|
||||
Global functions that belong to Libraries.ocd/Inventory.ocd.
|
||||
|
||||
@author
|
||||
*/
|
||||
|
||||
// overload function for objects with Inventory.ocd
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*--
|
||||
Material.c
|
||||
Authors: Ringwaul
|
||||
|
||||
Functions in relation to material; any kind of operations.
|
||||
--*/
|
||||
/**
|
||||
Material.c
|
||||
Functions relating to materials; any kind of operations.
|
||||
|
||||
@author Ringwaul
|
||||
*/
|
||||
|
||||
global func MaterialDepthCheck(int x, int y, string mat, int depth)
|
||||
{
|
||||
|
@ -59,8 +59,8 @@ global func FindPosInMat(string sMat, int iXStart, int iYStart, int iWidth, int
|
|||
global func ExtractLiquid(int x, int y, bool distant_first)
|
||||
{
|
||||
var result = ExtractLiquidAmount(x, y, 1, distant_first);
|
||||
if(!result) return -1;
|
||||
|
||||
if (!result)
|
||||
return -1;
|
||||
return result[0];
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*--
|
||||
Math.c
|
||||
Authors: Maikel, flgr, Newton, Tyron, Zapper
|
||||
|
||||
Any kind of help with calculation.
|
||||
--*/
|
||||
/**
|
||||
Math.c
|
||||
Any kind of help with calculations.
|
||||
|
||||
@author Maikel, flgr, Newton, Tyron, Zapper
|
||||
*/
|
||||
|
||||
// Returns the offset to x.
|
||||
global func AbsX(int x)
|
||||
|
@ -122,7 +122,7 @@ global func GetCalcDir()
|
|||
return GetDir() * 2 - 1;
|
||||
}
|
||||
|
||||
//Moves param 'a' towards param 'b' by 'max' amount per frame
|
||||
// Moves param 'a' towards param 'b' by 'max' amount per frame.
|
||||
global func MoveTowards(int a, int b, int max)
|
||||
{
|
||||
if(b == nil) return false;
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
/*--
|
||||
MeshAnimation.c
|
||||
Authors: ck
|
||||
|
||||
Wrappers for convenient calls to PlayAnimation.
|
||||
--*/
|
||||
|
||||
/**
|
||||
MeshAnimation.c
|
||||
Wrappers for convenient calls to PlayAnimation.
|
||||
|
||||
@author ck
|
||||
*/
|
||||
|
||||
global func Anim_Const(int value)
|
||||
{
|
||||
|
|
|
@ -1,21 +1,20 @@
|
|||
/*--
|
||||
NamedParams.c
|
||||
/**
|
||||
NamedParams.c
|
||||
Adapts some functions with lots of optional parameters to take a proplist instead.
|
||||
|
||||
Adapts some functions with lots of optional parameters to take a proplist instead.
|
||||
--*/
|
||||
@author Marky
|
||||
*/
|
||||
|
||||
global func Sound(string name, opts, ...)
|
||||
{
|
||||
if (GetType(opts) == C4V_PropList)
|
||||
return inherited(name, opts.global, opts.volume, opts.player, opts.loop_count, opts.custom_falloff_distance, opts.pitch, opts.modifier);
|
||||
else
|
||||
return inherited(name, opts, ...);
|
||||
return inherited(name, opts, ...);
|
||||
}
|
||||
|
||||
global func SoundAt(string name, int x, int y, opts, ...)
|
||||
{
|
||||
if (GetType(opts) == C4V_PropList)
|
||||
return inherited(name, x, y, opts.volume, opts.player, opts.custom_falloff_distance, opts.pitch, opts.modifier);
|
||||
else
|
||||
return inherited(name, x, y, opts, ...);
|
||||
return inherited(name, x, y, opts, ...);
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*--
|
||||
Objects.c
|
||||
Authors: Maikel, boni, Ringwaul, Sven2, flgr, Clonkonaut, Günther, Randrian
|
||||
|
||||
Functions generally applicable to objects; not enough to be worth distinct scripts though.
|
||||
--*/
|
||||
/**
|
||||
Objects.c
|
||||
Functions generally applicable to objects; not enough to be worth distinct scripts though.
|
||||
|
||||
@author Maikel, boni, Ringwaul, Sven2, flgr, Clonkonaut, Günther, Randrian
|
||||
*/
|
||||
|
||||
// Does not set the speed of an object. But you can set two components of the velocity vector with this function.
|
||||
global func SetSpeed(int x_dir, int y_dir, int prec)
|
||||
|
@ -321,15 +321,17 @@ global func StonyObjectHit(int x, int y)
|
|||
// Failsafe
|
||||
if (!this) return false;
|
||||
var xdir = GetXDir(), ydir = GetYDir();
|
||||
if(x) x = x / Abs(x);
|
||||
if(y) y = y / Abs(y);
|
||||
if (x) x = x / Abs(x);
|
||||
if (y) y = y / Abs(y);
|
||||
// Check for solid in hit direction
|
||||
var i = 0;
|
||||
var average_obj_size = Distance(0,0, GetObjWidth(), GetObjHeight()) / 2 + 2;
|
||||
while(!GBackSolid(x*i, y*i) && i < average_obj_size) i++;
|
||||
while (!GBackSolid(x * i, y * i) && i < average_obj_size)
|
||||
i++;
|
||||
// To catch some high speed cases: if no solid found, check directly beneath
|
||||
if (!GBackSolid(x*i, y*i))
|
||||
while(!GBackSolid(x*i, y*i) && i < average_obj_size) i++;
|
||||
if (!GBackSolid(x * i, y * i))
|
||||
while (!GBackSolid(x * i, y * i) && i < average_obj_size)
|
||||
i++;
|
||||
// Check if digfree
|
||||
if (!GetMaterialVal("DigFree", "Material", GetMaterial(x*i, y*i)) && GBackSolid(x*i, y*i))
|
||||
return Sound("Hits::Materials::Rock::RockHit?");
|
||||
|
@ -356,76 +358,87 @@ global func RemoveAll(p, ...)
|
|||
return cnt;
|
||||
}
|
||||
|
||||
// Pulls an object above ground if it was buried (e.g. by PlaceVegetation).
|
||||
// Pulls an object above ground if it was buried (e.g. by PlaceVegetation), mainly used by plants.
|
||||
// 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
|
||||
// Move up if too far underground.
|
||||
while (GetContact(-1) & CNAT_Center && i < GetObjHeight()/2)
|
||||
{
|
||||
SetPosition(GetX(), GetY() - 1);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
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
|
||||
// Move down if in midair.
|
||||
while (!(GetContact(-1) & CNAT_Bottom) && i < GetObjHeight()/2)
|
||||
{
|
||||
SetPosition(GetX(), GetY() + 1);
|
||||
i++;
|
||||
}
|
||||
// Try to make the plant stuck.
|
||||
if (!Stuck())
|
||||
SetPosition(GetX(), GetY() + 1);
|
||||
}
|
||||
}
|
||||
|
||||
// Buys an object. Returns the object if it could be bought.
|
||||
global func Buy (id idBuyObj, int iForPlr, int iPayPlr, object pFromVendor, bool fShowErrors)
|
||||
global func Buy(id buy_def, int for_plr, int pay_plr, object from_vendor, bool show_errors)
|
||||
{
|
||||
// if no vendor is given try this
|
||||
if (!pFromVendor) pFromVendor = this;
|
||||
if (!from_vendor)
|
||||
from_vendor = this;
|
||||
// not a vendor?
|
||||
if (!pFromVendor->~IsVendor())
|
||||
if (!from_vendor->~IsVendor())
|
||||
return nil;
|
||||
return pFromVendor->DoBuy(idBuyObj, iForPlr, iPayPlr, nil, 0, fShowErrors);
|
||||
return from_vendor->DoBuy(buy_def, for_plr, pay_plr, nil, 0, show_errors);
|
||||
}
|
||||
|
||||
// Sells an object. Returns true if it could be sold.
|
||||
global func Sell (int iPlr, object pObj, object pToVendor)
|
||||
global func Sell(int plr, object obj, object to_vendor)
|
||||
{
|
||||
// if no vendor is given try this
|
||||
if(!pToVendor) pToVendor = this;
|
||||
if (!to_vendor)
|
||||
to_vendor = this;
|
||||
// not a vendor?
|
||||
if (!pToVendor->~IsVendor())
|
||||
if (!to_vendor->~IsVendor())
|
||||
return false;
|
||||
return pToVendor->DoSell(pObj, iPlr);
|
||||
return to_vendor->DoSell(obj, plr);
|
||||
}
|
||||
|
||||
/* GetXEdge returns the position of the objects top/bottom/left/right edge */
|
||||
// GetXEdge returns the position of the objects top/bottom/left/right edge.
|
||||
global func GetLeftEdge()
|
||||
{
|
||||
return GetX()-GetObjWidth()/2;
|
||||
return GetX() - GetObjWidth() / 2;
|
||||
}
|
||||
|
||||
global func GetRightEdge()
|
||||
{
|
||||
return GetX()+GetObjWidth()/2;
|
||||
return GetX() + GetObjWidth() / 2;
|
||||
}
|
||||
|
||||
global func GetTopEdge()
|
||||
{
|
||||
return GetY()-GetObjHeight()/2;
|
||||
return GetY() - GetObjHeight() / 2;
|
||||
}
|
||||
|
||||
global func GetBottomEdge()
|
||||
{
|
||||
return GetY()+GetObjHeight()/2;
|
||||
return GetY() + GetObjHeight() / 2;
|
||||
}
|
||||
|
||||
// Returns if the object is standing in front of the back-object
|
||||
global func InFrontOf(object back)
|
||||
{
|
||||
var front = this;
|
||||
if(!front)
|
||||
if (!front)
|
||||
return;
|
||||
|
||||
return front->FindObject(front->Find_AtPoint(), Find_Not(Find_Exclude(back))) != nil;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,12 @@
|
|||
/**
|
||||
Particles.c
|
||||
This file contains some default particle behavior definitions as well as helper functions.
|
||||
|
||||
@author Zapper
|
||||
*/
|
||||
|
||||
/* particle helper/effect functions */
|
||||
|
||||
/*-- Helper/Effect Functions --*/
|
||||
|
||||
global func CreateMuzzleFlash(int x, int y, int angle, int size)
|
||||
{
|
||||
|
@ -30,7 +34,8 @@ global func Smoke(int x, int y, int level, int color, bool heavy)
|
|||
}
|
||||
|
||||
|
||||
/* particle definitions */
|
||||
/*-- Particle Definitions --*/
|
||||
|
||||
global func Particles_Dust()
|
||||
{
|
||||
return
|
||||
|
@ -55,7 +60,6 @@ global func Particles_Cloud()
|
|||
};
|
||||
}
|
||||
|
||||
|
||||
global func Particles_Smoke(bool heavy)
|
||||
{
|
||||
return
|
||||
|
@ -294,7 +298,6 @@ global func Particles_Air()
|
|||
};
|
||||
}
|
||||
|
||||
|
||||
global func Particles_Thrust(int size)
|
||||
{
|
||||
size = size ?? 10;
|
||||
|
@ -367,7 +370,8 @@ global func Particles_ElectroSpark2()
|
|||
};
|
||||
}
|
||||
|
||||
/* weather particles */
|
||||
|
||||
/*-- Weather Particles --*/
|
||||
|
||||
global func Particles_Rain(int color)
|
||||
{
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
/*--
|
||||
Player.c
|
||||
Authors: timi, Maikel, Joern, Zapper, Randrian
|
||||
|
||||
Player and team related functions.
|
||||
--*/
|
||||
|
||||
/**
|
||||
Player.c
|
||||
Player and team related functions.
|
||||
|
||||
@author timi, Maikel, Joern, Zapper, Randrian
|
||||
*/
|
||||
|
||||
// Returns the player number of plr_name, or none if there is no such player. (written by timi for CR/CE/CP)
|
||||
global func GetPlayerByName(string plr_name)
|
||||
|
@ -124,8 +123,10 @@ global func DoWealth(int plr, int value)
|
|||
// checks whether two players are allied - that means they are not hostile and neither of them is NO_OWNER
|
||||
global func IsAllied(int plr1, int plr2, bool check_one_way_only /* whether to check the hostility only in one direction */)
|
||||
{
|
||||
if(plr1 == NO_OWNER) return false;
|
||||
if(plr2 == NO_OWNER) return false;
|
||||
if (plr1 == NO_OWNER)
|
||||
return false;
|
||||
if (plr2 == NO_OWNER)
|
||||
return false;
|
||||
return !Hostile(plr1, plr2, check_one_way_only);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
/*--
|
||||
PlayerControl.c
|
||||
Authors: Newton
|
||||
|
||||
Functions to handle player controls (i.e. input keys)
|
||||
--*/
|
||||
|
||||
/**
|
||||
PlayerControl.c
|
||||
Functions to handle player controls (i.e. input keys).
|
||||
|
||||
@author Newton
|
||||
*/
|
||||
|
||||
static const CON_Gamepad_Deadzone = 60;
|
||||
static CON_VC_Players;
|
||||
|
@ -75,7 +74,7 @@ global func PlayerControl(int plr, int ctrl, id spec_id, int x, int y, int stren
|
|||
|
||||
// local coordinates
|
||||
var cursorX = x, cursorY = y;
|
||||
if(x != nil || y != nil)
|
||||
if (x != nil || y != nil)
|
||||
{
|
||||
cursorX -= cursor->GetX();
|
||||
cursorY -= cursor->GetY();
|
||||
|
@ -110,7 +109,7 @@ global func InitializePlayerControl(int plr, string controlset_name, bool keyboa
|
|||
CON_VC_Players[plr] = !mouse;
|
||||
|
||||
// for all clonks...
|
||||
for(var clonk in FindObjects(Find_OCF(OCF_CrewMember)))
|
||||
for (var clonk in FindObjects(Find_OCF(OCF_CrewMember)))
|
||||
{
|
||||
clonk->~ReinitializeControls();
|
||||
}
|
||||
|
@ -118,7 +117,7 @@ global func InitializePlayerControl(int plr, string controlset_name, bool keyboa
|
|||
|
||||
global func PlayerHasVirtualCursor(int plr)
|
||||
{
|
||||
if(!CON_VC_Players)
|
||||
if (!CON_VC_Players)
|
||||
return false;
|
||||
|
||||
return CON_VC_Players[plr];
|
||||
|
@ -189,7 +188,7 @@ global func GetPlayerCursorPos(int plr)
|
|||
global func StopSelected(int plr)
|
||||
{
|
||||
var cursor = GetCursor(plr);
|
||||
if(cursor)
|
||||
if (cursor)
|
||||
{
|
||||
cursor->SetCommand("None");
|
||||
cursor->SetComDir(COMD_Stop);
|
||||
|
@ -207,14 +206,14 @@ global func Control2Effect(int plr, int ctrl, int x, int y, int strength, bool r
|
|||
if (!this) return false;
|
||||
|
||||
// Count down from EffectCount, in case effects get deleted
|
||||
var i = GetEffectCount("*Control*", this), iEffect;
|
||||
var i = GetEffectCount("*Control*", this), fx;
|
||||
while (i--)
|
||||
{
|
||||
iEffect = GetEffect("*Control*", this, i);
|
||||
if (iEffect)
|
||||
if (EffectCall(this, iEffect, "Control", ctrl, x,y,strength, repeat, status))
|
||||
{
|
||||
fx = GetEffect("*Control*", this, i);
|
||||
if (fx)
|
||||
if (EffectCall(this, fx, "Control", ctrl, x,y,strength, repeat, status))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// No effect handled the control
|
||||
return false;
|
||||
}
|
||||
|
@ -283,8 +282,8 @@ global func ObjectControlMovement(int plr, int ctrl, int strength, int status, b
|
|||
if (Contained()) return false;
|
||||
|
||||
// this is for controlling movement with Analogpad
|
||||
if(status == CONS_Down)
|
||||
if(strength != nil && strength < CON_Gamepad_Deadzone)
|
||||
if (status == CONS_Down)
|
||||
if (strength != nil && strength < CON_Gamepad_Deadzone)
|
||||
return true;
|
||||
|
||||
var proc = GetProcedure();
|
||||
|
@ -294,9 +293,9 @@ global func ObjectControlMovement(int plr, int ctrl, int strength, int status, b
|
|||
// Jump control
|
||||
if (ctrl == CON_Jump)
|
||||
{
|
||||
if(proc == "WALK" && GetComDir() == COMD_Up)
|
||||
if (proc == "WALK" && GetComDir() == COMD_Up)
|
||||
SetComDir(COMD_Stop);
|
||||
if(proc == "WALK")
|
||||
if (proc == "WALK")
|
||||
{
|
||||
this->ObjectCommand("Jump");
|
||||
return true;
|
||||
|
@ -501,10 +500,10 @@ global func ObjectComLetGo(int vx, int vy)
|
|||
global func MouseHover(int player, object leaving, object entering, object dragged)
|
||||
{
|
||||
// Leaving the hovering zone should be processed first.
|
||||
if(leaving)
|
||||
if (leaving)
|
||||
leaving->~OnMouseOut(player, dragged);
|
||||
// Then process entering a new hovering zone.
|
||||
if(entering)
|
||||
if (entering)
|
||||
entering->~OnMouseOver(player, dragged);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,10 @@
|
|||
/* Scenario saving functionality */
|
||||
/**
|
||||
SaveScenario.c
|
||||
Scenario saving functionality
|
||||
|
||||
@author Sven2
|
||||
*/
|
||||
|
||||
// Defines script function SaveScenarioObjects, which is called by the
|
||||
// engine to generate the Objects.c file for scenario saving
|
||||
// Also called for object duplication in the editor
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*--
|
||||
Schedule.c
|
||||
Authors:
|
||||
|
||||
Schedule can be used to execute scripts or functions repetitively with delay.
|
||||
--*/
|
||||
/**
|
||||
Schedule.c
|
||||
Schedule can be used to execute scripts or functions repetitively with delay.
|
||||
|
||||
@author
|
||||
*/
|
||||
|
||||
// Executes a script repetitively with delay.
|
||||
global func Schedule(object obj, string script, int interval, int repeats)
|
||||
|
@ -12,21 +12,21 @@ global func Schedule(object obj, string script, int interval, int repeats)
|
|||
if (!repeats)
|
||||
repeats = 1;
|
||||
// Create effect.
|
||||
var effect = AddEffect("IntSchedule", obj, 1, interval, obj);
|
||||
if (!effect)
|
||||
var fx = AddEffect("IntSchedule", obj, 1, interval, obj);
|
||||
if (!fx)
|
||||
return false;
|
||||
// Set variables.
|
||||
effect.Script = script;
|
||||
effect.Repeats = repeats;
|
||||
fx.Script = script;
|
||||
fx.Repeats = repeats;
|
||||
return true;
|
||||
}
|
||||
|
||||
global func FxIntScheduleTimer(object obj, proplist effect)
|
||||
global func FxIntScheduleTimer(object obj, effect fx)
|
||||
{
|
||||
// Just a specific number of repeats.
|
||||
var done = --effect.Repeats <= 0;
|
||||
var done = --fx.Repeats <= 0;
|
||||
// Execute.
|
||||
eval(effect.Script);
|
||||
eval(fx.Script);
|
||||
// Remove schedule if done.
|
||||
if (done)
|
||||
return FX_Execute_Kill;
|
||||
|
@ -42,10 +42,10 @@ global func AddTimer(call_function, int interval)
|
|||
if (interval == nil)
|
||||
interval = 36;
|
||||
// Create effect and add function and repeat infinitely.
|
||||
var effect = AddEffect("IntScheduleCall", this, 1, interval, this);
|
||||
effect.Function = call_function;
|
||||
effect.NoStop = true;
|
||||
effect.Pars = [];
|
||||
var fx = AddEffect("IntScheduleCall", this, 1, interval, this);
|
||||
fx.Function = call_function;
|
||||
fx.NoStop = true;
|
||||
fx.Pars = [];
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -55,12 +55,12 @@ global func RemoveTimer(call_function /* name or pointer to the timer to remove
|
|||
if(!this)
|
||||
return false;
|
||||
|
||||
var effect, index = 0;
|
||||
while(effect = GetEffect("IntScheduleCall", this, index++))
|
||||
var fx, index = 0;
|
||||
while(fx = GetEffect("IntScheduleCall", this, index++))
|
||||
{
|
||||
if(effect.Function != call_function) continue;
|
||||
if(effect.NoStop != true) continue;
|
||||
RemoveEffect(nil, this, effect);
|
||||
if(fx.Function != call_function) continue;
|
||||
if(fx.NoStop != true) continue;
|
||||
RemoveEffect(nil, this, fx);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -75,39 +75,39 @@ global func ScheduleCall(object obj, call_function, int interval, int repeats, p
|
|||
if (!repeats)
|
||||
repeats = 1;
|
||||
// Create effect.
|
||||
var effect = AddEffect("IntScheduleCall", obj, 1, interval, obj);
|
||||
if (!effect)
|
||||
var fx = AddEffect("IntScheduleCall", obj, 1, interval, obj);
|
||||
if (!fx)
|
||||
return false;
|
||||
// Set variables.
|
||||
effect.Function = call_function;
|
||||
effect.Repeats = repeats;
|
||||
effect.Pars = [par0, par1, par2, par3, par4];
|
||||
fx.Function = call_function;
|
||||
fx.Repeats = repeats;
|
||||
fx.Pars = [par0, par1, par2, par3, par4];
|
||||
return true;
|
||||
}
|
||||
|
||||
global func FxIntScheduleCallTimer(object obj, proplist effect)
|
||||
global func FxIntScheduleCallTimer(object obj, effect fx)
|
||||
{
|
||||
// Just a specific number of repeats.
|
||||
var done = --effect.Repeats <= 0;
|
||||
var done = --fx.Repeats <= 0;
|
||||
// Execute.
|
||||
Call(effect.Function, effect.Pars[0], effect.Pars[1], effect.Pars[2], effect.Pars[3], effect.Pars[4]);
|
||||
Call(fx.Function, fx.Pars[0], fx.Pars[1], fx.Pars[2], fx.Pars[3], fx.Pars[4]);
|
||||
// Remove schedule call if done, take into account infinite schedules.
|
||||
if (done && !effect.NoStop)
|
||||
if (done && !fx.NoStop)
|
||||
return FX_Execute_Kill;
|
||||
return FX_OK;
|
||||
}
|
||||
|
||||
global func ClearScheduleCall(object obj, call_function)
|
||||
{
|
||||
var i, effect;
|
||||
var i, fx;
|
||||
// Count downwards from effectnumber, to remove effects.
|
||||
i = GetEffectCount("IntScheduleCall", obj);
|
||||
while (i--)
|
||||
// Check All ScheduleCall-Effects.
|
||||
if (effect = GetEffect("IntScheduleCall", obj, i))
|
||||
if (fx = GetEffect("IntScheduleCall", obj, i))
|
||||
// Found right function.
|
||||
if (effect.Function == call_function)
|
||||
if (fx.Function == call_function)
|
||||
// Remove effect.
|
||||
RemoveEffect(nil, obj, effect);
|
||||
RemoveEffect(nil, obj, fx);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
String.c
|
||||
Functions for string manipulation.
|
||||
|
||||
@authors Maikel
|
||||
@author Maikel
|
||||
*/
|
||||
|
||||
// Returns the reduced string with only the characters in the interval [begin, end) are taken. The value begin starts
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*--
|
||||
Vertices.c
|
||||
Authors: Clonkonaut, flgr
|
||||
|
||||
Vertex related functions.
|
||||
--*/
|
||||
/**
|
||||
Vertices.c
|
||||
Vertex related functions.
|
||||
|
||||
@author Clonkonaut, flgr
|
||||
*/
|
||||
|
||||
// Sets both the X and Y-coordinate of one vertex.
|
||||
global func SetVertexXY(int index, int x, int y)
|
||||
|
@ -88,46 +88,46 @@ global func HalfVehicleFadeJumpStop()
|
|||
{
|
||||
if (!this)
|
||||
return FatalError("this function requires object context");
|
||||
var effect;
|
||||
if(effect = GetEffect("IntHalfVehicleFadeJump", this)) {
|
||||
effect.Interval = 1;
|
||||
}
|
||||
var fx;
|
||||
if (fx = GetEffect("IntHalfVehicleFadeJump", this))
|
||||
fx.Interval = 1;
|
||||
}
|
||||
|
||||
global func FxIntHalfVehicleFadeJumpStart(object target, proplist effect, int temp)
|
||||
global func FxIntHalfVehicleFadeJumpStart(object target, effect fx, int temp)
|
||||
{
|
||||
if (temp)
|
||||
return FX_OK;
|
||||
if (!target) {
|
||||
return FX_Start_Deny;
|
||||
}
|
||||
effect.collideverts = CreateArray();
|
||||
fx.collideverts = CreateArray();
|
||||
for (var i = target->GetVertexNum(); i-->0;)
|
||||
if(!(target->GetVertex(i, VTX_CNAT) & CNAT_PhaseHalfVehicle)) {
|
||||
PushBack(effect.collideverts, i);
|
||||
PushBack(fx.collideverts, i);
|
||||
target->SetVertexCNAT(i, CNAT_PhaseHalfVehicle, true);
|
||||
}
|
||||
effect.origpos = target->GetPosition();
|
||||
fx.origpos = target->GetPosition();
|
||||
return FX_OK;
|
||||
}
|
||||
|
||||
global func FxIntHalfVehicleFadeJumpTimer(object target, proplist effect, int time)
|
||||
global func FxIntHalfVehicleFadeJumpTimer(object target, effect fx, int time)
|
||||
{
|
||||
if (DeepEqual(target->GetPosition(), effect.origpos))
|
||||
if (DeepEqual(target->GetPosition(), fx.origpos))
|
||||
return FX_OK;
|
||||
for (var i = GetLength(effect.collideverts); i-->0;) {
|
||||
if (target->GetMaterial(target->GetVertex(effect.collideverts[i], VTX_X),
|
||||
target->GetVertex(effect.collideverts[i], VTX_Y)) == Material("HalfVehicle"))
|
||||
for (var i = GetLength(fx.collideverts); i-- > 0;)
|
||||
{
|
||||
if (target->GetMaterial(target->GetVertex(fx.collideverts[i], VTX_X),
|
||||
target->GetVertex(fx.collideverts[i], VTX_Y)) == Material("HalfVehicle"))
|
||||
return FX_OK;
|
||||
}
|
||||
return FX_Execute_Kill;
|
||||
// The way this is implemented, it may ignore smaller cracks beteween half-solid masks at high speeds. Fix if necessary.
|
||||
}
|
||||
|
||||
global func FxIntHalfVehicleFadeJumpStop(object target, proplist effect, int reason, bool temp)
|
||||
global func FxIntHalfVehicleFadeJumpStop(object target, effect fx, int reason, bool temp)
|
||||
{
|
||||
if (reason == FX_Call_RemoveClear)
|
||||
return;
|
||||
for (var i = GetLength(effect.collideverts); i-->0;)
|
||||
target->SetVertexCNAT(effect.collideverts[i], CNAT_PhaseHalfVehicle, false);
|
||||
for (var i = GetLength(fx.collideverts); i-- > 0;)
|
||||
target->SetVertexCNAT(fx.collideverts[i], CNAT_PhaseHalfVehicle, false);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue