Merge default into rope

rope
Armin Burgmeier 2012-05-06 20:38:24 +02:00
commit d388f1a3f3
50 changed files with 1222 additions and 1182 deletions

View File

@ -24,7 +24,7 @@ AC_INIT([clonk], [5])
AC_COPYRIGHT([©2005-2011 Günther Brammer])
AC_CONFIG_SRCDIR([/src/C4Include.h])
AC_CONFIG_AUX_DIR([autotools])
AC_CONFIG_HEADER([config.h])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_FILES([Makefile])
AC_CANONICAL_HOST
dnl foreign to tell automake to shut up,

View File

@ -20,13 +20,13 @@ stylesheet = clonk.xsl
# find all directories neither beginning nor contained within a directory beginning with a dot
sdk-dirs := $(shell find sdk -name '.*' -prune -o -type d -print)
# find all *.xml files recursively in sdk/
xmlfiles := $(sort $(shell find sdk -name '.*' -prune -o -name 'content.xml' -prune -o -name \*.xml -print))
# misc
extra-files := $(sort $(wildcard *.css *.php *.js images/*.*))
extra-files-chm := $(sort $(wildcard *.css *.js images/*.*))
# find all *.xml files recursively in sdk/
xmlfiles := $(sort $(shell find sdk -name '.*' -prune -o -name 'content.xml' -prune -o -name \*.xml -print))
# Targets:
# strip from all files the .xml, and add a .html
@ -36,8 +36,8 @@ htmlfiles := $(addsuffix .html, $(basename $(xmlfiles)))
sdk-de-dirs := $(subst sdk, sdk-de, $(sdk-dirs))
# For openclonk.org
online-sdk-files := $(foreach lang, en de, $(addprefix online/$(lang)/, $(htmlfiles) sdk/content.html))
online-dirs := $(foreach lang, en de, $(addprefix online/$(lang)/, $(sdk-dirs) images))
online-sdk-files := $(foreach lang, en de, $(addprefix online/$(lang)/, $(htmlfiles) sdk/content.html))
online-extra-files := $(foreach lang, en de, $(addprefix online/$(lang)/, $(extra-files)))
# For Entwickler.chm
@ -45,11 +45,11 @@ chm-dirs := $(foreach lang, en de, $(addprefix chm/$(lang)/, . $(sdk-dirs) image
.PHONY: all online-en chm install check clean
all: $(online-dirs) $(sdk-de-dirs) $(online-extra-files) $(online-sdk-files)
all: $(sdk-de-dirs) $(online-dirs) $(online-sdk-files) $(online-extra-files)
online-en: $(addprefix online/en/, $(sdk-dirs) images $(htmlfiles) sdk/content.html $(extra-files))
chm: $(chm-dirs) $(sdk-de-dirs) chm/en/Developer.chm chm/de/Entwickler.chm
chm: $(sdk-de-dirs) $(chm-dirs) chm/en/Developer.chm chm/de/Entwickler.chm
install: all
$(MKDIR_P) $(prefix)
@ -59,7 +59,7 @@ check:
xmllint --noblanks --noout --valid $(xmlfiles)
clean:
rm -f *.mo Entwickler.chm Developer.chm doku.pot
rm -f *.mo Entwickler.chm Developer.chm doku.pot sdk/content.xml
rm -rf online sdk-de chm
sdk/content.xml: sdk/content.xml.in $(xmlfiles) build_contents.py experimental.py

File diff suppressed because it is too large Load Diff

View File

@ -85,8 +85,8 @@
</row>
<row id="Damage">
<literal_col>Damage</literal_col>
<col>int change, int by_player</col>
<col>When the object is damage.</col>
<col>int change, int cause, int by_player</col>
<col>When the object is damaged. See <emlink href="script/Effects.html#damagecause">Fx*Damage</emlink>for <code>cause</code> values.</col>
</row>
<row id="DeepBreath">
<literal_col>DeepBreath</literal_col>

View File

@ -557,7 +557,7 @@ global func FxExplodeOnDeathCurseStop(object target, proplist effect, int reason
<h>Fx*Damage</h>
<text><code>int Fx*Damage (object target, proplist effect, int damage, int cause);</code></text>
<text>Every effect receives this callback whenever the energy or damage value of the target object is to change. If the function is defined, it should then return whether to allow the change.</text>
<text>This callback is made upon life energy changes in living beings and damage value changes in non-livings - but not vice versa. cause contains the value change and reason:</text>
<text id="damagecause">This callback is made upon life energy changes in living beings and damage value changes in non-livings - but not vice versa. cause contains the value change and reason:</text>
<text>
<table>
<rowh>

View File

@ -48,8 +48,8 @@ func Bar() {
<code>this == self: true
this == self: false
this == self: true</code>
<text>The last call to <code>Foo</code> shows the reason for <code>this</code>: Most of the functions in an object need that object to do something with it, and passing the object to every function would result in a lot of repetetive code.</text>
<text>Note for everyone familiar with previous versions of C4Script: When calling a function in a definition like <code>Flint->Hit();</code>, the definition is returned from <code>this</code>. In the <code>Flint->Hit();</code> example, that will probably result in an error message from the engine like "passed proplist, but expected object".</text>
<text>The last call to <code>Foo</code> shows the reason for <code>this</code>: Most of the functions in an object need that object to do something with it, and passing the object to every function would result in a lot of repetitive code.</text>
<text>Note for everyone familiar with previous versions of C4Script: When calling a function in a definition like <code>Flint->Hit();</code>, the definition is returned from <code>this</code>. In the <code>Flint->Hit();</code> example, that will probably result in an error message from the engine like "passed proplist, but expected object", because the Hit function of the Flint is not designed to be called like that.</text>
<h id="parametertypen">Parameter Types</h>
<text>You can specify the data type that is to be accepted for a given parameter. To do this, simply write the desired <emlink href="script/Typechecks.html">type name</emlink> before the parameter name:</text>
<code>func TypeParameterFunction(object myClonk, id def, int count, string msg)

View File

@ -2,8 +2,8 @@
#include Library_Plant
private func SeedAreaSize() { return 400; }
private func SeedChance() { return 50; }
private func SeedChance() { return 500; }
private func SeedArea() { return 400; }
private func SeedAmount() { return 12; }
func Construction()

View File

@ -1,5 +1,6 @@
/**
Control object for content menus.
This is not a regular menu, because it creates other menus to do the work for it.
@author Newton, Maikel
*/
@ -13,6 +14,8 @@ local menu_object;
local crew_count;
local container_count;
static const MENU_Contents_MaxCrewDist = 20;
/** Creates a content menu for the calling object. This is supposed to be a crew member,
controlled by a player.
@return a pointer to the created menu, or \c nil if failed.
@ -35,7 +38,7 @@ global func CreateContentsMenus()
controller->AddContentMenu(this, index, true);
// add all nearby crewmembers
var teammates = FindObjects(Find_Distance(20), Find_OCF(OCF_CrewMember), Find_Owner(GetOwner()), Find_Exclude(this));
var teammates = FindObjects(Find_Distance(MENU_Contents_MaxCrewDist), Find_OCF(OCF_CrewMember), Find_Owner(GetOwner()), Find_Exclude(this));
index = 1;
for(var t in teammates)
controller->AddContentMenu(t, index++, true);
@ -50,6 +53,9 @@ global func CreateContentsMenus()
return controller;
}
/** Returns the object for which the menu is shown. */
public func GetMenuObject() { return menu_object; }
global func SortInventoryObjs()
{
// left: crew members
@ -62,9 +68,9 @@ global func SortInventoryObjs()
public func IsContentMenu() { return true; }
func SetMenuObject(object menu_object)
func SetMenuObject(object menuObject)
{
menu_object = menu_object;
menu_object = menuObject;
}
func Construction()
@ -151,6 +157,9 @@ func RemoveContentMenu(int index)
circ_menus[index].Menu->RemoveObject();
// for debugging, we'll set debug information here. In case something doesn't work as intended or setLength breaks.
circ_menus[index] = {Debug="RemoveContentMenu was called", Index=index};
// close the gap
for(var i=index; i < length-1; i++)
circ_menus[i] = circ_menus[i+1];
@ -229,7 +238,7 @@ private func PutContentsIntoMenu(object menu, object container)
return;
}
// TODO: find an extra-entry or something like that for this.
// TODO: find an extra-entry or something like that to display this.
if(container->~IsCarryingHeavy())
AddContentsMenuItem(container->GetCarryHeavy(), menu);
}
@ -244,10 +253,6 @@ private func AddContentsMenuItem(object obj, object menu, array stack)
return false;
}
item->SetSymbol(obj);
if(obj.Description)
{
item->SetTooltip(obj.Description);
}
if (stack == nil)
{
item->SetData([obj]);
@ -329,6 +334,11 @@ public func FxContainerTrackerTimer(object target, proplist effect)
effect.CommandTarget->~OnContainerMovement(effect.Menu, target);
effect.Position = target->GetPosition();
// if it's the clonk that moved
if(target == effect.CommandTarget.menu_object)
// check all distances.
effect.CommandTarget->~OnClonkMovement();
return 1;
}
@ -393,6 +403,15 @@ public func FxContainerTrackerUpdate(object target, proplist effect)
}
}
/** Called when the position of the clonk that opened the menu changed.
Checks if containers are still in range, and removes menu if necessary.
*/
public func OnClonkMovement()
{
for(var prop in circ_menus)
OnContainerMovement(prop.Menu, prop.Object);
}
/** Called when the position of a container with an open menu changed.
Checks if object still is in range, and removes menu if necessary.
*/
@ -403,8 +422,18 @@ public func OnContainerMovement(object menu, object container)
return;
// check distance
if(ObjectDistance(menu_object, container) > circ_menus[index].Distance)
RemoveContentMenu(index);
if(menu.isCrew)
{
Log("%s - %s: %d", menu_object->GetName(), container->GetName(), ObjectDistance(menu_object, container));
if(ObjectDistance(menu_object, container) > MENU_Contents_MaxCrewDist)
RemoveContentMenu(index);
}
else
{
// todo: reverse-find_at_point or something more performant than InFrontOf.
if(!menu_object->InFrontOf(container))
RemoveContentMenu(index);
}
}
/** Called when a container with an open menu got removed.

View File

@ -55,7 +55,7 @@ private func GetItemPosition(int n, int total)
// Packing 7 or less circles.
if (total <= 7)
{
if (n == 7)
if (n == 0)
return [0, 0];
else
{
@ -68,7 +68,7 @@ private func GetItemPosition(int n, int total)
// Packing 19 or less circles.
if (total <= 19)
{
if (n == 7)
if (n == 0)
return [0, 0];
else if (n < 7)
{
@ -78,8 +78,8 @@ private func GetItemPosition(int n, int total)
}
else
{
var x = -Cos(30 * (n-5) + 15, 31 * MENU_Radius / 40);
var y = -Sin(30 * (n-5) + 15, 31 * MENU_Radius / 40);
var x = -Cos(30 * (n-4) + 15, 31 * MENU_Radius / 40);
var y = -Sin(30 * (n-4) + 15, 31 * MENU_Radius / 40);
return [x, y];
}
}
@ -87,7 +87,7 @@ private func GetItemPosition(int n, int total)
// Packing 37 or less circles.
if (total <= 37)
{
if (n == 7)
if (n == 0)
return [0, 0];
else if (n < 7)
{
@ -95,16 +95,16 @@ private func GetItemPosition(int n, int total)
var y = -Sin(60 * (n+1), 2 * MENU_Radius / 7);
return [x, y];
}
else if (n <= 19)
else if (n < 19)
{
var x = -Cos(30 * (n-5) + 15, 31 * MENU_Radius / 56);
var y = -Sin(30 * (n-5) + 15, 31 * MENU_Radius / 56);
var x = -Cos(30 * (n-4) + 15, 31 * MENU_Radius / 56);
var y = -Sin(30 * (n-4) + 15, 31 * MENU_Radius / 56);
return [x, y];
}
else
{
var x = -Cos(30 * (n-17), 61 * MENU_Radius / 72);
var y = -Sin(30 * (n-17), 61 * MENU_Radius / 72);
var x = -Cos(30 * (n-16), 61 * MENU_Radius / 72);
var y = -Sin(30 * (n-16), 61 * MENU_Radius / 72);
return [x, y];
}
}
@ -137,7 +137,7 @@ public func UpdateMenu()
for (var i = 0; i < item_count; i++)
{
var pos = GetItemPosition(i + 1, item_count);
var pos = GetItemPosition(i, item_count);
var item = menu_items[i];
if (item)
{

View File

@ -190,8 +190,6 @@ func UpdateInventory()
var item = c->GetItem(inventory[i]->GetSlotId());
inventory[i]->SetSymbol(item);
inventory[i]->SetUnselected();
if(item) inventory[i]->SetTooltip(item.UsageHelp);
else inventory[i]->SetTooltip(nil);
}
// update hand-indicator

View File

@ -50,14 +50,6 @@ public func SetUnselected()
SetGraphics(nil,nil,5);
}
public func SetTooltip(string desc) {
this.Tooltip = desc;
}
public func GetTooltip() {
return this.Tooltip;
}
// SetSymbol from GUI_RingMenu_Icon
public func SetSymbol(obj)
{
@ -70,6 +62,7 @@ public func SetSymbol(obj)
//SetGraphics(nil, nil, 3);
SetName("");
this.MouseDragImage = nil;
this.Tooltip = nil;
}
else
{
@ -93,6 +86,11 @@ public func SetSymbol(obj)
SetName(obj->GetName());
this.MouseDragImage = obj->GetID();
// set tooltip
var desc = obj.UsageHelp;
if(!desc) desc = obj.Description;
this.Tooltip = desc;
}
}

View File

@ -158,7 +158,8 @@ public func UpdateController()
SetOwner(crew->GetController());
// name
var fullname = Format("%s %s",crew->GetObjCoreRankName(),crew->GetName());
SetName(Format("$TxtSelect$",fullname));
SetName(crew->GetName());
this.Tooltip = Format("$TxtSelect$",fullname);
}
public func UpdateSelectionStatus()

View File

@ -397,7 +397,7 @@ public func UpdateSelectionStatus()
if(actiontype == ACTIONTYPE_CARRYHEAVY)
{
SetGraphics("LetGo",GetID(),2,GFXOV_MODE_Base);
SetName(Format("$TxtUnGrab$",myobject->GetName()));
this.Tooltip = Format("$TxtUnGrab$",myobject->GetName());
}
// script...
@ -410,7 +410,7 @@ public func UpdateSelectionStatus()
SetObjDrawTransform(IconSize(),0,-16000,0,IconSize(),20000, 2);
var desc = metainfo["Description"];
if(desc) SetName(desc);
if(desc) this.Tooltip = desc;
if(metainfo["Selected"])
SetObjDrawTransform(1200,0,0,0,1200,0,1);
@ -446,12 +446,12 @@ public func UpdateSelectionStatus()
if(actiontype == ACTIONTYPE_VEHICLE)
{
SetGraphics("LetGo",GetID(),2,GFXOV_MODE_Base);
SetName(Format("$TxtUnGrab$",myobject->GetName()));
this.Tooltip = Format("$TxtUnGrab$",myobject->GetName());
}
else if(actiontype == ACTIONTYPE_STRUCTURE)
{
SetGraphics("Exit",GetID(),2,GFXOV_MODE_Base);
SetName(Format("$TxtExit$",myobject->GetName()));
this.Tooltip = Format("$TxtExit$",myobject->GetName());
}
}
else
@ -467,18 +467,18 @@ public func UpdateSelectionStatus()
if(!(myobject->Contained()))
{
SetGraphics("Grab",GetID(),2,GFXOV_MODE_Base);
SetName(Format("$TxtGrab$",myobject->GetName()));
this.Tooltip = Format("$TxtGrab$",myobject->GetName());
}
else
{
SetGraphics("Exit",GetID(),2,GFXOV_MODE_Base);
SetName(Format("$TxtPushOut$",myobject->GetName()));
this.Tooltip = Format("$TxtPushOut$",myobject->GetName());
}
}
if(actiontype == ACTIONTYPE_STRUCTURE)
{
SetGraphics("Enter",GetID(),2,GFXOV_MODE_Base);
SetName(Format("$TxtEnter$",myobject->GetName()));
this.Tooltip = Format("$TxtEnter$",myobject->GetName());
}
}
SetObjDrawTransform(IconSize(),0,-16000,0,IconSize(),20000, 2);

View File

@ -110,14 +110,6 @@ public func OnMouseOut(int plr, object dragged)
/* Menu item properties */
public func SetTooltip(string desc) {
this.Tooltip = desc;
}
public func GetTooltip() {
return this.Tooltip;
}
public func SetMenu(object menu)
{
item_menu = menu;
@ -182,6 +174,10 @@ public func Update()
// Update item amount.
UpdateCount();
// Update tooltip
UpdateTooltip();
return;
}
@ -270,3 +266,13 @@ private func UpdateCount()
}
return;
}
private func UpdateTooltip()
{
if(!item_object)
this.Tooltip = nil;
else
{
this.Tooltip = item_object.Description;
}
}

View File

@ -100,7 +100,7 @@ public func IsProjectileTarget(target,shooter)
return 1;
}
public func Damage(int change, int byplayer)
public func Damage()
{
Incinerate();
}

View File

@ -131,7 +131,7 @@ public func SetHandItemPos(int hand, int inv)
if(GetHandItem(hand2))
{
this->~OnSlotFull(hand2);
GetItem(inv)->~Selection(this, hand2);
GetHandItem(hand2)->~Selection(this, hand2);
}
else
this->~OnSlotEmpty(hand2);

View File

@ -51,7 +51,6 @@ public func AddMenuStructures(object constructor, object clonk)
if (!AddItem(item))
return item->RemoveObject();
item->SetSymbol(structure);
item->SetTooltip(structure.Description);
}
return;
}

View File

@ -16,38 +16,53 @@ public func IsPlant()
*/
private func SeedChance() { return 500; }
/** Distance the seeds may travel. Default is 300.
/** Distance the seeds may travel. Default is 250.
@return the maximum distance.
*/
private func SeedAreaSize() { return 300; }
private func SeedArea() { return 250; }
/** The amount of plants allowed within SeedAreaSize. Default is 8.
/** The amount of plants allowed within SeedAreaSize. Default is 10.
@return the maximum amount of plants.
*/
private func SeedAmount() { return 8; }
private func SeedAmount() { return 10; }
/** Automated positioning via RootSurface, make sure to call this if needed (in case Construction is overloaded)
*/
protected func Construction()
{
Schedule(this, "RootSurface()", 1);
AddTimer("Seed", 350);
AddTimer("Seed", 72);
_inherited(...);
}
/** Reproduction: Called by a timer (duration is fixed so SeedChance controls the chance to reproduce)
/** Reproduction of plants: Called every 2 seconds by a timer.
*/
public func Seed()
{
if(!Random(SeedChance()))
// Find number of plants in seed area.
var size = SeedArea();
var amount = SeedAmount();
var offset = size / -2;
var plant_cnt = ObjectCount(Find_ID(GetID()), Find_InRect(offset, offset, size, size));
// If there are not much plants in the seed area compared to seed amount
// the chance of seeding is improved, if there are much the chance is reduced.
var chance = SeedChance();
var chance = chance / Max(1, amount - plant_cnt) + chance * Max(0, plant_cnt - amount);
// Place a plant if we are lucky, in principle there can be more than seed amount.
if (!Random(chance))
{
var iSize = SeedAreaSize();
var iOffset = iSize / -2;
if(ObjectCount(Find_ID(this->GetID()), Find_Distance(iSize)) < SeedAmount())
// Place the plant but check if it is not close to another one.
var plant = PlaceVegetation(GetID(), offset, offset, size, size, 3);
if (plant)
{
PlaceVegetation(GetID(), iOffset, iOffset, iSize, iSize, 3);
var neighbour = FindObject(Find_ID(GetID()), Find_Exclude(plant), Sort_Distance(plant->GetX() - GetX(), plant->GetY() - GetY()));
var distance = ObjectDistance(plant, neighbour);
// Closeness determined by seedarea and amount.
if (!Random(distance / (size/amount)))
plant->RemoveObject();
}
}
return;
}
/* Chopping */

View File

@ -57,7 +57,6 @@ public func AddMenuProducts(object producer)
if (!AddItem(item))
return item->RemoveObject();
item->SetSymbol(product);
item->SetTooltip(product.Description);
item.MouseDrag = MD_DragSource;
}
return;

View File

@ -2,6 +2,10 @@
#include Library_Plant
private func SeedChance() { return 400; }
private func SeedArea() { return 120; }
private func SeedAmount() { return 4; }
func Construction()
{
StartGrowth(1);
@ -21,4 +25,5 @@ public func Incineration()
local Name = "$Name$";
local BlastIncinerate = 1;
local ContactIncinerate = 3;
local ContactIncinerate = 3;
local Placement = 4;

View File

@ -2,9 +2,9 @@
#include Library_Plant
private func SeedChance() { return 250; }
private func SeedAreaSize() { return 150; }
private func SeedAmount() { return 5; }
private func SeedChance() { return 400; }
private func SeedArea() { return 150; }
private func SeedAmount() { return 6; }
/* Initialisation */

View File

@ -14,4 +14,3 @@ StretchGrowth=1
Oversize=1
Float=1
Rotate=1

View File

@ -3,9 +3,20 @@
private func Initialize()
{
SetProperty("MeshTransformation", Trans_Rotate(RandomX(0,359),0,1,0));
SetR(RandomX(-30,30));
SetR(RandomX(-30,30));
}
func Damage()
{
if (GetDamage() > 15)
{
CastObjects(Wood, 1, 25);
RemoveObject();
}
return;
}
local Name = "$Name$";
local BlastIncinerate = 1;
local ContactIncinerate = 3;
local ContactIncinerate = 3;
local Placement = 4;

View File

@ -1,13 +1,5 @@
/*-- Seaweed --*/
/*
#include Library_Plant
private func SeedChance() { return 300; }
private func SeedAreaSize() { return 600; }
private func SeedAmount() { return 4; }
*/
private func Initialize()
{
SetAction("Sway");

View File

@ -201,7 +201,7 @@ func FxLifeTimerTimer(target, effect, time)
}
}
func Damage(int damage, object from)
func Damage()
{
// splatter
if(grow_anim)
@ -451,4 +451,4 @@ func FxQuickFadeTimer(target, effect, time)
SetClrModulation(RGBa(255, 255, 255, effect.alpha));
if(effect.alpha <= 0) return -1;
return 1;
}
}

View File

@ -2,8 +2,8 @@
#include Library_Plant
private func SeedAreaSize() { return 400; }
private func SeedChance() { return 50; }
private func SeedChance() { return 500; }
private func SeedArea() { return 400; }
private func SeedAmount() { return 12; }
func Construction()

View File

@ -7,4 +7,5 @@ private func Initialize()
local Name = "$Name$";
local BlastIncinerate = 1;
local ContactIncinerate = 3;
local ContactIncinerate = 3;
local Placement = 4;

View File

@ -7,11 +7,16 @@
#include Library_Plant
private func SeedArea() { return 50; }
private func SeedChance() { return 250; }
private func SeedAmount() { return 15; }
local stalks;
protected func Construction()
{
StartGrowth(this.growth);
stalks = [];
return _inherited(...);
}
@ -20,7 +25,6 @@ protected func Initialize()
if (GetLength(stalks)) return;
// Create 3-5 stalks
var num = Random(3);
stalks = CreateArray();
for (var i = 0; i < 3+num; i++)
{
var x = 12/(3+num) * i - 6;
@ -152,10 +156,10 @@ protected func FxWindCheckTimer(object obj, effect)
protected func Destruction()
{
for (var stalk in stalks)
{
if (stalk)
stalk->RemoveObject();
}
{
if (stalk)
stalk->RemoveObject();
}
}
public func IsCrop() { return true; }

View File

@ -286,7 +286,7 @@ public func FaceRight()
public func IsProjectileTarget(target,shooter) { return true; }
public func Damage(int change, int byplayer)
public func Damage()
{
if(GetDamage() > health)
{

View File

@ -10,7 +10,7 @@ protected func Initialize()
public func IsProjectileTarget(target,shooter) { return true; }
public func Damage(int change, int byplayer)
public func Damage()
{
if(GetDamage() > health)
{

View File

@ -195,6 +195,23 @@ global func BlastObjects(int x, int y, int level, object container, int cause_pl
return true;
}
global func BlastObject(int Level, CausedBy)
{
var self = this;
if (CausedBy == nil)
CausedBy = GetController();
DoDamage(Level, FX_Call_DmgBlast, CausedBy);
if (!self) return;
if (GetAlive())
DoEnergy(-Level/3, false, FX_Call_EngBlast, CausedBy);
if (!self) return;
if (this.BlastIncinerate && GetDamage() >= this.BlastIncinerate)
Incinerate(Level, CausedBy);
}
global func BlastObjectsShockwaveCheck(int x, int y)
{
var def = GetID();

View File

@ -67,12 +67,6 @@ global func Incinerate(strength, int caused_by, blasted, incinerating_object)
return true;
}
// Called when an object is hit by an explosion (and can burn).
global func OnBlastIncinerationDamage(int level, int player)
{
return this->Incinerate(level, player);
}
// Called if the object is submerged in incendiary material (for example in lava).
global func OnInIncendiaryMaterial()
{
@ -343,4 +337,4 @@ global func FxFireStop(object target, int effect_number, int reason, bool temp)
global func FxFireInfo(object target, effect)
{
return Format("Is on %d%% fire.", effect.strength); // todo: <--
}
}

View File

@ -66,7 +66,6 @@ Find_* and Sort_* function for FindObject().
OnFire() - Checks whether the object is on fire.
Extinguish() - Extinguishes the object.
Incinerate() - Set the object on fire.
OnBlastIncinerationDamage() - Explosion callback in inflammable objects.
OnInIncendiaryMaterial() - Callback if an inflammable object falls into incendiary material.
MakeNonFlammable() - Makes the object immune to fire.
@ -163,4 +162,4 @@ ClearScheduleCall() - Delete a schedule call.
SetVertexXY() - Sets both the X and Y-coordinate of one vertex.
VerticesStuck() - Returns the number of stuck vertices.
HasCNAT() - Returns whether the object has a vertex with the given CNAT value.
HasCNAT() - Returns whether the object has a vertex with the given CNAT value.

View File

@ -69,7 +69,7 @@ global func MovePosition(int x, int y, int prec)
}
// Returns the position as an array
global func GetPosition(int x, int y, int prec)
global func GetPosition(int prec)
{
return [GetX(prec), GetY(prec)];
}
@ -320,4 +320,14 @@ global func GetTopEdge()
global func GetBottomEdge()
{
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)
return;
return front->FindObject(front->Find_AtPoint(), Find_Not(Find_Exclude(back))) != nil;
}

View File

@ -37,7 +37,7 @@ public func Incineration()
return;
}
public func Damage(int change, int byplayer)
public func Damage()
{
if (GetDamage() > (size/4)) Destroy();
}

View File

@ -1069,10 +1069,10 @@ static C4Value FnCall_C4V(C4AulContext *cthr, C4Value* szFunction_C4V,
// safety
C4String *szFunction = szFunction_C4V->getStr();
if (!szFunction || !cthr->Obj) return C4Value();
if (!szFunction || !cthr->Def) return C4Value();
C4AulParSet Pars;
Copy2ParSet9(Pars, *par);
return cthr->Obj->Call(FnStringPar(szFunction),&Pars/*, true*/);
return cthr->Def->Call(szFunction, &Pars);
}
static C4Value FnDefinitionCall_C4V(C4AulContext *cthr,
@ -1098,16 +1098,14 @@ static C4Value FnGameCall_C4V(C4AulContext *cthr,
C4Value* par0, C4Value* par1, C4Value* par2, C4Value* par3, C4Value* par4,
C4Value* par5, C4Value* par6, C4Value* par7, C4Value* par8/*, C4Value* par9*/)
{
C4String *szFunction = szFunction_C4V->getStr();
const char * fn = FnStringPar(szFunction_C4V->getStr());
if (!fn[0]) return C4Value();
if (!szFunction) return C4Value();
// Make failsafe
char szFunc2[500+1]; sprintf(szFunc2,"~%s",FnStringPar(szFunction));
// copy parameters
C4AulParSet Pars;
Copy2ParSet9(Pars, *par);
// Call
return ::GameScript.Call(szFunc2, &Pars, true);
return ::GameScript.Call(fn, &Pars, true);
}
static C4Value FnGameCallEx_C4V(C4AulContext *cthr,
@ -1115,16 +1113,14 @@ static C4Value FnGameCallEx_C4V(C4AulContext *cthr,
C4Value* par0, C4Value* par1, C4Value* par2, C4Value* par3, C4Value* par4,
C4Value* par5, C4Value* par6, C4Value* par7, C4Value* par8/*, C4Value* par9*/)
{
C4String *szFunction = szFunction_C4V->getStr();
const char * fn = FnStringPar(szFunction_C4V->getStr());
if (!fn[0]) return C4Value();
if (!szFunction) return C4Value();
// Make failsafe
char szFunc2[500+1]; sprintf(szFunc2,"~%s",FnStringPar(szFunction));
// copy parameters
C4AulParSet Pars;
Copy2ParSet9(Pars, *par);
// Call
return ::GameScript.GRBroadcast(szFunc2,&Pars, true);
return ::GameScript.GRBroadcast(fn, &Pars, true);
}
static C4Value FnEditCursor(C4AulContext *cth, C4Value *pPars)
@ -1508,13 +1504,6 @@ static C4String *FnMaterialName(C4AulContext* cthr, long iMat)
return String(::MaterialMap.Map[iMat].Name);
}
static C4String *FnGetNeededMatStr(C4AulContext* cthr)
{
// local/safety
if (!cthr->Obj) throw new NeedObjectContext("GetNeededMatStr");
return String(cthr->Obj->GetNeededMatStr().getData());
}
static bool FnSetSkyAdjust(C4AulContext* cthr, long dwAdjust, long dwBackClr)
{
// set adjust
@ -2491,7 +2480,6 @@ void InitGameFunctionMap(C4AulScriptEngine *pEngine)
AddFunc(pEngine, "GetTime", FnGetTime);
AddFunc(pEngine, "GetMissionAccess", FnGetMissionAccess);
AddFunc(pEngine, "MaterialName", FnMaterialName);
AddFunc(pEngine, "GetNeededMatStr", FnGetNeededMatStr);
AddFunc(pEngine, "DrawMap", FnDrawMap);
AddFunc(pEngine, "DrawDefMap", FnDrawDefMap);
AddFunc(pEngine, "CreateParticle", FnCreateParticle);

View File

@ -130,7 +130,6 @@ bool C4ValueToMatrix(const C4ValueArray& array, StdMeshMatrix* matrix);
#define PSF_CalcSellValue "~CalcSellValue" // C4Object *pObj, int iObjValue
#define PSF_OnJoinCrew "~Recruitment" // int Player
#define PSF_OnRemoveCrew "~DeRecruitment" // int Player
#define PSF_OnBlastIncinerationDamage "OnBlastIncinerationDamage" // int Level, int Player
#define PSF_OnInIncendiaryMaterial "OnInIncendiaryMaterial"
// Effect callbacks

View File

@ -1789,6 +1789,8 @@ void C4Command::Set(int32_t iCommand, C4Object *pObj, C4Object *pTarget, C4Value
cObj=pObj;
Target=pTarget;
Tx=nTx; Ty=iTy;
if (Command != C4CMD_Call && !Tx.CheckConversion(C4V_Int))
Tx.SetInt(0);
Target2=pTarget2;
Data=iData;
UpdateInterval=iUpdateInterval;

View File

@ -404,7 +404,6 @@ void C4DefList::CallEveryDefinition()
#endif
C4AulParSet Pars(C4VPropList(it->second));
it->second->Call(PSF_Definition, &Pars);
it->second->Freeze();
}
}

View File

@ -1195,7 +1195,7 @@ void C4Object::DoDamage(int32_t iChange, int32_t iCausedBy, int32_t iCause)
// Change value
Damage = Max<int32_t>( Damage+iChange, 0 );
// Engine script call
Call(PSF_Damage,&C4AulParSet(C4VInt(iChange), C4VInt(iCausedBy)));
Call(PSF_Damage,&C4AulParSet(C4VInt(iChange), C4VInt(iCause), C4VInt(iCausedBy)));
}
void C4Object::DoEnergy(int32_t iChange, bool fExact, int32_t iCause, int32_t iCausedByPlr)
@ -1238,25 +1238,6 @@ void C4Object::DoBreath(int32_t iChange)
Call(PSF_BreathChange,&C4AulParSet(C4VInt(iChange)));
}
void C4Object::Blast(int32_t iLevel, int32_t iCausedBy)
{
// Damage
DoDamage(iLevel,iCausedBy,C4FxCall_DmgBlast);
// Energy (alive objects)
if (Alive) DoEnergy(-iLevel/3,false,C4FxCall_EngBlast, iCausedBy);
// Incinerate
if (GetPropertyInt(P_BlastIncinerate))
if (Damage >= GetPropertyInt(P_BlastIncinerate))
{
C4AulFunc *pCallFunc = GetFunc(PSF_OnBlastIncinerationDamage);
if (pCallFunc)
{
C4AulParSet Pars(C4VInt(iLevel), C4VInt(iCausedBy));
pCallFunc->Exec(this, &Pars);
}
}
}
void C4Object::DoCon(int32_t iChange)
{
int32_t iStepSize=FullCon/100;

View File

@ -302,7 +302,6 @@ public:
int32_t GetCon() { return Con; }
void DoExperience(int32_t change);
bool Promote(int32_t torank, bool exception, bool fForceRankName);
void Blast(int32_t iLevel, int32_t iCausedBy);
bool Push(C4Real txdir, C4Real dforce, bool fStraighten);
bool Lift(C4Real tydir, C4Real dforce);
void Fling(C4Real txdir, C4Real tydir, bool fAddSpeed); // set/add given speed to current, setting jump/tumble-actions

File diff suppressed because it is too large Load Diff

View File

@ -190,7 +190,6 @@ struct C4AulContext
{
C4Object *Obj;
C4PropList *Def;
struct C4AulScriptContext *Caller;
};
// execution context
@ -383,7 +382,6 @@ protected:
void LinkFunctions();
bool IncludesResolved;
virtual void UnLink(); // reset to unlinked state
virtual void AfterLink(); // called after linking is completed; presearch common funcs here
virtual bool ReloadScript(const char *szPath, const char *szLanguage); // reload given script
virtual bool Parse();
@ -419,7 +417,6 @@ public:
virtual C4PropList * GetPropList();
using C4AulScript::ReloadScript;
bool ReloadScript(const char *szScript, C4DefList *pDefs, const char *szLanguage); // search script and reload + relink, if found
virtual void AfterLink();
C4AulFunc * GetFirstFunc(const char * Name)
{ return FuncLookUp.GetFirstFunc(Name); }
C4AulFunc * GetNextSNFunc(const C4AulFunc * After)

View File

@ -97,11 +97,6 @@ public:
inline bool IsNil() const { return true; }
};
// Some functions require object context.
// Using this type instead of C4AulContext guarantees validity of Obj member.
// Don't add any members to this class, or breakage will occur.
class C4AulObjectContext : public C4AulContext {};
// Some functions are callable in definition context only.
// This exception gets thrown if they are called from anywhere else.
class NeedDefinitionContext : public C4AulExecError
@ -319,7 +314,7 @@ class C4AulDefObjectFunc##N: \
public C4AulDefFuncHelper { \
public: \
/* A pointer to the function which this class wraps */ \
typedef RType (*Func)(C4AulObjectContext * LIST(N, PARS)); \
typedef RType (*Func)(C4Object * LIST(N, PARS)); \
virtual int GetParCount() { return N; } \
virtual C4V_Type GetRetType() \
{ return C4ValueConv<RType>::Type(); } \
@ -332,7 +327,7 @@ public C4AulDefFuncHelper { \
virtual C4Value Exec(C4AulContext *pContext, C4Value pPars[], bool fPassErrors=false) \
{ \
if (!pContext->Obj) throw new NeedObjectContext(GetName()); \
return C4ValueConv<RType>::ToC4V(pFunc(static_cast<C4AulObjectContext*>(pContext) LIST(N, CONV_FROM_C4V))); \
return C4ValueConv<RType>::ToC4V(pFunc(pContext->Obj LIST(N, CONV_FROM_C4V))); \
} \
protected: \
Func pFunc; \
@ -343,7 +338,7 @@ inline void AddFunc(C4AulScript * pOwner, const char * Name, RType (*pFunc)(C4Au
new C4AulDefFunc##N<RType LIST(N, PARS)>(pOwner, Name, pFunc, Public); \
} \
template <typename RType LIST(N, TYPENAMES)> \
inline void AddFunc(C4AulScript * pOwner, const char * Name, RType (*pFunc)(C4AulObjectContext * LIST(N, PARS)), bool Public=true) \
inline void AddFunc(C4AulScript * pOwner, const char * Name, RType (*pFunc)(C4Object * LIST(N, PARS)), bool Public=true) \
{ \
new C4AulDefObjectFunc##N<RType LIST(N, PARS)>(pOwner, Name, pFunc, Public); \
}

View File

@ -108,6 +108,29 @@ void C4AulExec::LogCallStack()
pCtx->dump(StdStrBuf(" by: "));
}
C4String *C4AulExec::FnTranslate(C4AulContext *ctx, C4String *text)
{
if (!text || text->GetData().isNull()) return NULL;
// Find correct script: translations of the context if possible, containing script as fallback
C4AulScript *script = NULL;
if (ctx->Def && ctx->Def->GetDef())
script = &(ctx->Def->GetDef()->Script);
else
script = AulExec.pCurCtx[-1].Func->pOrgScript;
assert(script);
try
{
return ::Strings.RegString(script->Translate(text->GetCStr()).c_str());
}
catch (C4LangStringTable::NoSuchTranslation &)
{
DebugLogF("WARNING: Translate: no translation for string \"%s\"", text->GetCStr());
// Trace
AulExec.LogCallStack();
return text;
}
}
void C4AulExec::ClearPointers(C4Object * obj)
{
#if 0
@ -145,7 +168,6 @@ C4Value C4AulExec::Exec(C4AulScriptFunc *pSFunc, C4PropList * p, C4Value *pnPars
ctx.Func = pSFunc;
ctx.TemporaryScript = fTemporaryScript;
ctx.CPos = NULL;
ctx.Caller = NULL;
PushContext(ctx);
// Execute
@ -832,7 +854,6 @@ C4AulBCC *C4AulExec::Call(C4AulFunc *pFunc, C4Value *pReturn, C4Value *pPars, C4
if (ctx.Obj && !ctx.Obj->Status)
throw new C4AulExecError(ctx.Obj, "using removed object");
ctx.Def = pContext;
ctx.Caller = pCurCtx;
ctx.Return = pReturn;
ctx.Pars = pPars;
ctx.Vars = pCurVal + 1;
@ -859,7 +880,6 @@ C4AulBCC *C4AulExec::Call(C4AulFunc *pFunc, C4Value *pReturn, C4Value *pPars, C4
if (ctx.Obj && !ctx.Obj->Status)
throw new C4AulExecError(ctx.Obj, "using removed object");
ctx.Def = pContext;
ctx.Caller = pCurCtx;
#ifdef DEBUGREC_SCRIPT
StdStrBuf sCallText;
@ -911,7 +931,6 @@ C4AulBCC *C4AulExec::Call(C4AulFunc *pFunc, C4Value *pReturn, C4Value *pPars, C4
C4AulScriptContext ctx;
ctx.Obj = pContext ? pContext->GetObject() : 0;
ctx.Def = pContext;
ctx.Caller = pCurCtx;
ctx.Return = pReturn;
ctx.Pars = pPars;
ctx.Vars = pPars + pFunc->GetParCount();
@ -1059,7 +1078,6 @@ C4Value C4AulFunc::Exec(C4PropList * p, C4AulParSet* pPars, bool fPassErrors)
C4AulContext ctx;
ctx.Obj = p ? p->GetObject() : NULL;
ctx.Def = p;
ctx.Caller = NULL;
// execute
return Exec(&ctx, pPars ? pPars->Par : C4AulParSet().Par, fPassErrors);
}

View File

@ -70,6 +70,7 @@ public:
int GetContextDepth() const { return pCurCtx - Contexts + 1; }
C4AulScriptContext *GetContext(int iLevel) { return iLevel >= 0 && iLevel < GetContextDepth() ? Contexts + iLevel : NULL; }
void LogCallStack();
static C4String *FnTranslate(C4AulContext *ctx, C4String *text);
void ClearPointers(C4Object *);
private:

View File

@ -156,18 +156,11 @@ void C4AulScriptFunc::UnLink()
C4AulFunc::UnLink();
}
void C4AulScript::AfterLink() { }
bool C4AulScript::ReloadScript(const char *szPath, const char *szLanguage)
{
return false;
}
void C4AulScriptEngine::AfterLink()
{
GlobalPropList->Freeze();
}
void C4AulScriptEngine::Link(C4DefList *rDefs)
{
try
@ -191,15 +184,16 @@ void C4AulScriptEngine::Link(C4DefList *rDefs)
// engine is always parsed (for global funcs)
State = ASS_PARSED;
// get common funcs
for (C4AulScript *s = Child0; s; s = s->Next)
s->AfterLink();
AfterLink();
// update material pointers
::MaterialMap.UpdateScriptPointers();
rDefs->CallEveryDefinition();
// Done modifying the proplists now
for (C4AulScript *s = Child0; s; s = s->Next)
s->GetPropList()->Freeze();
GetPropList()->Freeze();
// display state
LogF("C4AulScriptEngine linked - %d line%s, %d warning%s, %d error%s",
lineCnt, (lineCnt != 1 ? "s" : ""), warnCnt, (warnCnt != 1 ? "s" : ""), errCnt, (errCnt != 1 ? "s" : ""));

View File

@ -158,7 +158,7 @@ bool C4ValueToMatrix(const C4ValueArray& array, StdMeshMatrix* matrix)
static C4PropList *Fn_this(C4AulContext *cthr)
{
return cthr->Obj ? cthr->Obj : cthr->Def;
return cthr->Def;
}
static C4PropList * FnCreatePropList(C4AulContext *cthr, C4PropList * prototype)
@ -534,29 +534,6 @@ static bool FnStopScriptProfiler(C4AulContext *ctx)
return true;
}
static C4String *FnTranslate(C4AulContext *ctx, C4String *text)
{
if (!text || text->GetData().isNull()) return NULL;
// Find correct script: translations of the context if possible, containing script as fallback
C4AulScript *script = NULL;
if (ctx->Def && ctx->Def->GetDef())
script = &(ctx->Def->GetDef()->Script);
else
script = ctx->Caller->Func->pOrgScript;
assert(script);
try
{
return ::Strings.RegString(script->Translate(text->GetCStr()).c_str());
}
catch (C4LangStringTable::NoSuchTranslation &)
{
DebugLogF("WARNING: Translate: no translation for string \"%s\"", text->GetCStr());
// Trace
AulExec.LogCallStack();
return text;
}
}
static Nillable<C4String *> FnGetConstantNameByValue(C4AulContext *ctx, int value, Nillable<C4String *> name_prefix, int idx)
{
C4String *name_prefix_s = name_prefix;
@ -666,5 +643,5 @@ void InitCoreFunctionMap(C4AulScriptEngine *pEngine)
AddFunc(pEngine, "this", Fn_this);
AddFunc(pEngine, "GetConstantNameByValue", FnGetConstantNameByValue, false);
AddFunc(pEngine, "Translate", FnTranslate);
AddFunc(pEngine, "Translate", C4AulExec::FnTranslate);
}

View File

@ -166,16 +166,6 @@ bool C4DefScriptHost::Load(C4Group & g, const char * f, const char * l, C4LangSt
return r;
}
void C4DefScriptHost::Clear()
{
C4ScriptHost::Clear();
}
void C4DefScriptHost::AfterLink()
{
C4ScriptHost::AfterLink();
}
C4PropList * C4DefScriptHost::GetPropList() { return Def; }
/*--- C4GameScriptHost ---*/
@ -200,12 +190,6 @@ void C4GameScriptHost::Clear()
C4ScriptHost::Clear();
}
void C4GameScriptHost::AfterLink()
{
C4ScriptHost::AfterLink();
ScenPrototype->Freeze();
}
C4Value C4GameScriptHost::Call(const char *szFunction, C4AulParSet *Pars, bool fPassError)
{
// FIXME: Does fPassError make sense?

View File

@ -83,13 +83,11 @@ class C4DefScriptHost: public C4ScriptHost
{
public:
C4DefScriptHost(C4Def * Def) : C4ScriptHost(), Def(Def) { }
void Clear();
virtual bool Load(C4Group &, const char *, const char *, C4LangStringTable *);
virtual C4PropList * GetPropList();
protected:
C4Def *Def; // owning def file
void AfterLink(); // get common funcs
};
@ -101,7 +99,6 @@ public:
~C4GameScriptHost();
virtual bool Load(C4Group &, const char *, const char *, C4LangStringTable *);
void Clear();
void AfterLink();
virtual C4PropList * GetPropList() { return ScenPrototype; }
C4Value Call(const char *szFunction, C4AulParSet *pPars=0, bool fPassError=false);
C4Value GRBroadcast(const char *szFunction, C4AulParSet *pPars = 0, bool fPassError=false, bool fRejectTest=false); // call function in scenario script and all goals/rules/environment objects