Merge branch 'master' into lights

issue1247
Armin Burgmeier 2014-11-04 11:26:45 -05:00
commit a6d949d313
199 changed files with 4461 additions and 2226 deletions

View File

@ -56,6 +56,9 @@ option(WITH_AUTOMATIC_UPDATE "Automatic updates are downloaded from the project
# dynamic linking.
option(USE_STATIC_BOOST "Link Boost libraries statically" ON)
# Allow distributions to use the system tinyxml instead of our bundled copy.
option(USE_SYSTEM_TINYXML "Use system tinyxml library" OFF)
# Remove obsolete options
unset(OC_BUILD_MULTIPROCESSOR CACHE)
unset(USE_APPLE_CLANG CACHE)
@ -502,6 +505,7 @@ set(MAPE_SOURCES
src/mape/cpp-handles/c4def-handle.cpp
src/mape/cpp-handles/group-handle.h
src/mape/cpp-handles/group-handle.cpp
src/mape/cpp-handles/landscape-handle.cpp
src/mape/cpp-handles/log-handle.h
src/mape/cpp-handles/log-handle.cpp
src/mape/cpp-handles/mapgen-handle.h
@ -1281,8 +1285,14 @@ if(ICONV_FOUND)
endif()
# TinyXML
add_subdirectory(thirdparty/tinyxml)
target_link_libraries(openclonk tinyxml)
if(WITH_SYSTEM_TINYXML)
pkg_search_module(TINYXML REQUIRED tinyxml)
target_link_libraries(openclonk ${TINYXML_LIBRARIES})
else()
add_subdirectory(thirdparty/tinyxml)
include_directories(thirdparty/tinyxml)
target_link_libraries(openclonk tinyxml)
endif()
if(WIN32)
find_package(DbgHelp)

View File

@ -52,6 +52,10 @@
<col><funclink>Anim_AbsY</funclink></col>
<col>Linear with Y position. However, the animation is always played in the same direction, not taking into account whether the object moves upwards or downwards.</col>
</row>
<row>
<col><funclink>Anim_Dist</funclink></col>
<col>Linear in distance travelled. This is basically a combination of <funclink>Anim_AbsX</funclink> and <funclink>Anim_AbsY</funclink> where both coordinates are taken into account.</col>
</row>
<row>
<col><funclink>Anim_XDir</funclink></col>
<col>Proportional to the horizontal speed of the object.</col>

View File

@ -11,12 +11,84 @@
<text>The mesh is not automatically scaled to the shape (i.e. the width and height values specified in <emlink href="definition/defcore.html">DefCore.txt</emlink>) of the object. Instead one unit in the modeling tool corresponds to one pixel in Clonk. This simplifies using the same magnitude of object sizes for all objects which is especially helpful for attaching meshes (see below). Also pay attention to the coordinate frame: The X axis in the mesh coordinate frame points out of the screen in Clonk, the Y axis points to the right and the Z axis points upwards.</text>
<h id="MaterialScripts">Material scripts</h>
<text>All material scripts (*.material files) are loaded by the engine before the mesh in the same directory is loaded. Material scripts are simple text files which specify the material properties (material colors, textures, etc.) that can be used by meshes. Each material is assigned a name that can normally be specified in the modeling tool. It should be taken care that names are unique (for example by prefixing all material names with the object name of the object they are supposed to be used with) since all loaded materials can directly be used by any mesh so otherwise they could be naming conflicts.</text>
<text>Material scripts can also be crafted or edited by hand. The format is described in the <a href="http://www.ogre3d.org/docs/manual/manual_14.html">OGRE manual</a>. However not all of the features described there are supported (yet): Especially pixel, vertex and geometry shaders cannot be used. Also usage of LOD (Level of Detail) is not yet possible. For the source1 and source2 fields in the colour_op_ex field in texture units the additional value src_player_colour can be specified to refer to the player color of the object's owner. This can be used to colorize objects (partly) by the player color.</text>
<text>Material scripts can also be crafted or edited by hand. The format is described in the <a href="http://www.ogre3d.org/docs/manual/manual_14.html">OGRE manual</a>. However not all of the features described there are supported (yet): Especially usage of LOD (Level of Detail) is not yet possible. The usage of pixel, vertex and geometry shaders has some restrictions, as discussed in the section below. For the source1 and source2 fields in the colour_op_ex field in texture units the additional value src_player_colour can be specified to refer to the player color of the object's owner. This can be used to colorize objects (partly) by the player color.</text>
<text>At runtime the material script can be changed using the C4Script function <funclink>SetMeshMaterial</funclink>.</text>
<h id="Shaders">Shaders</h>
<text>Pixel, vertex and geometry Shaders can be used to customize the appearance of an object beyond what is possible by the declaratinos in OGRE passes and texture units. The <a href="http://www.ogre3d.org/docs/manual/manual_14.html">OGRE manual</a> should be consulted to learn how shaders can be used, however, there are some restrictions in OpenClonk.</text>
<text>First and foremost, only shaders written in the GLSL are supported at the moment. None of the <a href="http://www.ogre3d.org/docs/manual/manual_23.html#param_005findexed_005fauto">automatic parameters</a> are available for shaders, however, some of these are implicitly available as GLSL variables. Instead, the following <em>additional</em> automatic parameters are available:</text>
<text>
<table>
<caption id="OCAutoParameters">Additional automatic shader parameters</caption>
<rowh>
<col>Parameter name</col>
<col>Type</col>
<col>Description</col>
</rowh>
<row>
<literal_col>oc_player_color</literal_col>
<literal_col>float3</literal_col>
<col>The player color of the object being rendered</col>
</row>
<row>
<literal_col>oc_color_modulation</literal_col>
<literal_col>float4</literal_col>
<col>The color modulation of the object being rendered</col>
</row>
<row>
<literal_col>oc_mod2</literal_col>
<literal_col>int</literal_col>
<col>1 if the Mod2 drawing mode is activated, see <emlink href="script/fn/SetObjectBlitMode.html">SetObjectBlitMode</emlink>. 0 otherwise.</col>
</row>
<row>
<literal_col>oc_use_clrmodmap</literal_col>
<literal_col>int</literal_col>
<col>1 if the object drawing should be modulated with the global color modulation map (FoW).</col>
</row>
<row>
<literal_col>oc_clrmodmap</literal_col>
<literal_col>sampler2D</literal_col>
<col>Texture containing the clrmodmap, for lookup of the global modulation value. The corresponding texture transformation matrix is set up such that the fragment coordinate should be used for sampling the texture (gl_FragCoord.xy).</col>
</row>
</table>
</text>
<text>When a custom fragment shader is used, then that shader is responsible for applying the player color and color modulation to the object, since in that case the engine cannot take care of that. The additional parameters mentioned above can be used for that purpose. Also, when a custom fragment shader is used, the colour_op, colour_op_ex, alpha_op and alpha_op_ex directives in all texture units are ignored.</text>
<text>When a fragment shader or a vertex shader (or both) are not specified, then standard shaders are generated. The standard shaders expect certain GLSL varying variables to be propagated from the vertex shader to the fragment shader, so if you implement a vertex shader but not a fragment shader, make sure to create the following varying variables:</text>
<text>
<table>
<caption id="OCStandardVaryings">Varying variables used by the standard shader</caption>
<rowh>
<col>Variable name</col>
<col>Type</col>
<col>Description</col>
</rowh>
<row>
<literal_col>diffuse</literal_col>
<literal_col>vec4</literal_col>
<col>The interpolated diffuse color of the surface from lighting calculations.</col>
</row>
<row>
<literal_col>texcoord</literal_col>
<literal_col>vec2</literal_col>
<col>The interpolated texture coordinate, based on the texture coordinates specified in the mesh.</col>
</row>
</table>
</text>
<text>The standard fragment shader uses these values and possibly processes them with what is specified in the texture units declarations. The standard vertex shader creates these values from the GL state, and is independent of the texture units or other declarations. If no custom vertex shader is provided, the following shader is used:</text>
<code>varying vec4 diffuse;
varying vec2 texcoord;
void main()
{
vec3 normal = normalize(gl_NormalMatrix * gl_Normal);
vec3 lightDir = normalize(gl_LightSource[0].position.xyz);
diffuse = clamp(gl_FrontLightModelProduct.sceneColor + gl_FrontLightProduct[0].ambient + gl_FrontLightProduct[0].diffuse * max(0.0, dot(normal, lightDir)), 0.0, 1.0);
texcoord = gl_MultiTexCoord0.xy;
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
}</code>
<h id="Animations">Animations</h>
<text>As for bitmap based graphics an object can play an animation while executing an action. To do so first a rig for the model and then an animation needs to be created. When exporting it is saved in the *.skeleton (or *.skeleton.xml for the OGRE XML format) file. To play it during an action the Animation field of the action needs to be set in the <emlink href="definition/actmap.html">ActMap</emlink>. The Facet fields are ignored for mesh graphics.</text>
<text>It is also possible, via script, to play multiple animations at the same time or to specify transitions between animations. To learn more about this possibility see <emlink href="definition/animations.html">Animations</emlink>.</text>
<h id="Attachment">Attachment of meshs</h>
<h id="Attachment">Attachment of meshes</h>
<text>Meshes can be attached to each other so that they always move together. This allows the clonk to carry objects or to aim with the bow. To attach two meshes the C4Script function <funclink>AttachMesh</funclink> can be used, or <funclink>DetachMesh</funclink> to detach them again. When attaching a bone of both meshes needs to be specified. The attached mesh is then aligned so that its bone has always the same position and orientation as the one to which it is attached.</text>
<text>However it needs to be taken care of the fact that only the meshes, that is the graphics of the objects, are attached. The real position of the attached object (so what is returned by the functions <funclink>GetX</funclink> and <funclink>GetY</funclink> or the area in which the object is found by the functions <funclink>Find_AtPoint</funclink>, <funclink>Find_InRect</funclink> oder <funclink>Find_AtRect</funclink>) is <em>not</em> affected.</text>
<h id="Picture">Picture graphics.</h>

View File

@ -50,6 +50,7 @@
<funclink>Anim_Y</funclink>
<funclink>Anim_R</funclink>
<funclink>Anim_AbsY</funclink>
<funclink>Anim_Dist</funclink>
<funclink>Anim_XDir</funclink>
<funclink>Anim_YDir</funclink>
<funclink>Anim_Action</funclink>

View File

@ -50,6 +50,7 @@
<funclink>Anim_Y</funclink>
<funclink>Anim_R</funclink>
<funclink>Anim_AbsX</funclink>
<funclink>Anim_Dist</funclink>
<funclink>Anim_XDir</funclink>
<funclink>Anim_YDir</funclink>
<funclink>Anim_Action</funclink>

View File

@ -30,6 +30,7 @@
<funclink>Anim_R</funclink>
<funclink>Anim_AbsX</funclink>
<funclink>Anim_AbsY</funclink>
<funclink>Anim_Dist</funclink>
<funclink>Anim_XDir</funclink>
<funclink>Anim_YDir</funclink>
</related>

View File

@ -35,6 +35,7 @@
<funclink>Anim_R</funclink>
<funclink>Anim_AbsX</funclink>
<funclink>Anim_AbsY</funclink>
<funclink>Anim_Dist</funclink>
<funclink>Anim_XDir</funclink>
<funclink>Anim_YDir</funclink>
<funclink>Anim_Action</funclink>

View File

@ -0,0 +1,61 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!DOCTYPE funcs
SYSTEM '../../../clonk.dtd'>
<?xml-stylesheet type="text/xsl" href="../../../clonk.xsl"?>
<funcs>
<func>
<title>Anim_Dist</title>
<category>Animations</category>
<version>5.6 OC</version>
<syntax>
<rtype>array</rtype>
<params>
<param>
<type>int</type>
<name>position</name>
<desc>Start value. Should be inside the interval given by begin and end.</desc>
</param>
<param>
<type>int</type>
<name>begin</name>
<desc>Start of the interval.</desc>
</param>
<param>
<type>int</type>
<name>end</name>
<desc>End of the interval. If end is greater than begin then the value increases with every movement of the object, otherwise it decreases.</desc>
</param>
<param>
<type>int</type>
<name>length</name>
<desc>Number of pixels to be moved for the animation to be played from begin to end.</desc>
</param>
</params>
</syntax>
<desc>The value depends on the distance travelled by the aboject. Every pixel the object moves increases the value a little bit. Once end has been reached the value is reset to begin. This is a combination of <funclink>Anim_AbsX</funclink> and <funclink>Anim_AbsY</funclink>, where the movement in both coordinates is considered.</desc>
<remark>See the <emlink href="definition/animations.html">animation documentation</emlink> for further explanations of the animation system.</remark>
<examples>
<example>
<code><funclink>PlayAnimation</funclink>(&quot;Fly&quot;, 5, <funclink>Anim_Dist</funclink>(0, 0, <funclink>GetAnimationLength</funclink>(&quot;Fly&quot;), 20), <funclink>Anim_Const</funclink>(1000));</code>
<text>Plays the animation "Fly" in slot 5, superimposing any other potential animations in slot 5. The animation is played the faster the faster the object moves. Once it moved 20 pixels the animation has been played from begin to end and restarts at its beginning. This could be used for an engine animation of a flying object where the engine should only be animated as long as the object is moving.</text>
</example>
</examples>
<related>
<funclink>PlayAnimation</funclink>
<funclink>SetAnimationPosition</funclink>
<funclink>SetAnimationWeight</funclink>
<funclink>Anim_Const</funclink>
<funclink>Anim_Linear</funclink>
<funclink>Anim_X</funclink>
<funclink>Anim_Y</funclink>
<funclink>Anim_R</funclink>
<funclink>Anim_AbsX</funclink>
<funclink>Anim_AbsY</funclink>
<funclink>Anim_Dist</funclink>
<funclink>Anim_XDir</funclink>
<funclink>Anim_YDir</funclink>
<funclink>Anim_Action</funclink>
</related>
</func>
<author>Clonk-Karl</author><date>2014-10</date>
</funcs>

View File

@ -74,6 +74,7 @@ else
<funclink>Anim_R</funclink>
<funclink>Anim_AbsX</funclink>
<funclink>Anim_AbsY</funclink>
<funclink>Anim_Dist</funclink>
<funclink>Anim_XDir</funclink>
<funclink>Anim_YDir</funclink>
<funclink>Anim_Action</funclink>

View File

@ -40,6 +40,7 @@
<funclink>Anim_Y</funclink>
<funclink>Anim_AbsX</funclink>
<funclink>Anim_AbsY</funclink>
<funclink>Anim_Dist</funclink>
<funclink>Anim_XDir</funclink>
<funclink>Anim_YDir</funclink>
<funclink>Anim_Action</funclink>

View File

@ -50,6 +50,7 @@
<funclink>Anim_R</funclink>
<funclink>Anim_AbsX</funclink>
<funclink>Anim_AbsY</funclink>
<funclink>Anim_Dist</funclink>
<funclink>Anim_XDir</funclink>
<funclink>Anim_YDir</funclink>
<funclink>Anim_Action</funclink>

View File

@ -46,6 +46,7 @@
<funclink>Anim_R</funclink>
<funclink>Anim_AbsX</funclink>
<funclink>Anim_AbsY</funclink>
<funclink>Anim_Dist</funclink>
<funclink>Anim_YDir</funclink>
<funclink>Anim_Action</funclink>
</related>

View File

@ -50,6 +50,7 @@
<funclink>Anim_R</funclink>
<funclink>Anim_AbsX</funclink>
<funclink>Anim_AbsY</funclink>
<funclink>Anim_Dist</funclink>
<funclink>Anim_XDir</funclink>
<funclink>Anim_YDir</funclink>
<funclink>Anim_Action</funclink>

View File

@ -46,6 +46,7 @@
<funclink>Anim_R</funclink>
<funclink>Anim_AbsX</funclink>
<funclink>Anim_AbsY</funclink>
<funclink>Anim_Dist</funclink>
<funclink>Anim_XDir</funclink>
<funclink>Anim_Action</funclink>
</related>

View File

@ -17,7 +17,7 @@
</example>
</examples>
<related>
<funclink>GetPlrColor</funclink>
<funclink>GetPlayerColor</funclink>
<funclink>SetColor</funclink>
<funclink>GetClrModulation</funclink>
</related>

View File

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 19 KiB

View File

@ -218,3 +218,45 @@ material IdolGrayColor
}
}
}
material CrashedAirplane
{
receive_shadows on
technique
{
pass
{
cull_hardware none
scene_blend alpha_blend
ambient 0.500000 0.500000 0.500000 1.000000
diffuse 0.800000 0.800000 0.800000 1.000000
specular 0.000000 0.000000 0.000000 1.000000 3.500000
emissive 0.000000 0.000000 0.000000 1.000000
texture_unit Overlay
{
texture CrashedPaint.png
tex_address_mode wrap
filtering trilinear
colour_op_ex modulate src_texture src_player_colour
// take alpha from texture only, ignore player alpha
alpha_op_ex source1 src_texture src_player_colour
}
texture_unit Plane
{
texture Crashedairplane.jpg
tex_address_mode wrap
filtering trilinear
colour_op_ex blend_current_alpha src_current src_texture
// Don't blend alpha, to make sure we have full intensity at the base/overlay border region
alpha_op_ex add src_current src_texture
}
texture_unit Light
{
// apply lighting
colour_op_ex modulate src_current src_diffuse
alpha_op_ex modulate src_current src_diffuse
}
}
}
}

View File

@ -6,6 +6,6 @@ Instable=1
MaxAirSpeed=25
MaxSlide=10000
WindDrift=30
Corrosive=75
Corrosive=60
Placement=10
TextureOverlay=acid

View File

@ -8,6 +8,5 @@ Blast2Object=Amethyst
Blast2ObjectRatio=100
MaxAirSpeed=100
MaxSlide=1
Corrode=60
Placement=21
TextureOverlay=Amethyst

View File

@ -8,6 +8,5 @@ Blast2Object=Ruby
Blast2ObjectRatio=100
MaxAirSpeed=100
MaxSlide=1
Corrode=60
Placement=21
TextureOverlay=Ruby

View File

@ -1,6 +0,0 @@
[DefCore]
id=Deco_AltMaterials2
Version=5,2,0,1
Category=C4D_StaticBack
Width=1
Height=1

Binary file not shown.

Before

Width:  |  Height:  |  Size: 132 B

View File

@ -1 +0,0 @@
This definition is not created. It just serves as a container for custom mesh materials, which aren't loaded unless the definition is valid.

View File

@ -1,41 +0,0 @@
material CrashedAirplane
{
receive_shadows on
technique
{
pass
{
cull_hardware none
scene_blend alpha_blend
ambient 0.500000 0.500000 0.500000 1.000000
diffuse 0.800000 0.800000 0.800000 1.000000
specular 0.000000 0.000000 0.000000 1.000000 3.500000
emissive 0.000000 0.000000 0.000000 1.000000
texture_unit Overlay
{
texture CrashedPaint.png
tex_address_mode wrap
filtering trilinear
colour_op_ex modulate src_texture src_player_colour
// take alpha from texture only, ignore player alpha
alpha_op_ex source1 src_texture src_player_colour
}
texture_unit Plane
{
texture Crashedairplane.jpg
tex_address_mode wrap
filtering trilinear
colour_op_ex blend_current_alpha src_current src_texture
// Don't blend alpha, to make sure we have full intensity at the base/overlay border region
alpha_op_ex add src_current src_texture
}
texture_unit Light
{
// apply lighting
colour_op_ex modulate src_current src_diffuse
alpha_op_ex modulate src_current src_diffuse
}
}
}
}

View File

Before

Width:  |  Height:  |  Size: 3.7 KiB

After

Width:  |  Height:  |  Size: 3.7 KiB

View File

Before

Width:  |  Height:  |  Size: 46 KiB

After

Width:  |  Height:  |  Size: 46 KiB

View File

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

View File

Before

Width:  |  Height:  |  Size: 54 KiB

After

Width:  |  Height:  |  Size: 54 KiB

View File

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

View File

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

Before

Width:  |  Height:  |  Size: 6.4 KiB

After

Width:  |  Height:  |  Size: 6.4 KiB

View File

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

View File

Before

Width:  |  Height:  |  Size: 53 KiB

After

Width:  |  Height:  |  Size: 53 KiB

View File

Before

Width:  |  Height:  |  Size: 158 KiB

After

Width:  |  Height:  |  Size: 158 KiB

View File

Before

Width:  |  Height:  |  Size: 73 KiB

After

Width:  |  Height:  |  Size: 73 KiB

View File

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 26 KiB

View File

Before

Width:  |  Height:  |  Size: 8.4 KiB

After

Width:  |  Height:  |  Size: 8.4 KiB

View File

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

View File

Before

Width:  |  Height:  |  Size: 828 B

After

Width:  |  Height:  |  Size: 828 B

View File

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

Before

Width:  |  Height:  |  Size: 34 KiB

After

Width:  |  Height:  |  Size: 34 KiB

View File

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@ -5,13 +5,8 @@ Category=C4D_Vehicle | C4D_Background
Width=512
Height=350
Offset=-256,-175
Vertices=3
VertexX=-40,40,0
VertexY=0,0,40
Mass=1
Picture=0,0,220,110
Exclusive=1
Components=Cloud=1
Oversize=1
StretchGrowth=1

View File

@ -194,7 +194,7 @@ private func MoveCloud()
// Some other safety.
if (GetY() <= 5)
SetPosition(0, 6);
if (GetYDir()!=0)
if (GetYDir() != 0)
SetYDir(0);
while (Stuck())
SetPosition(GetX(), GetY() - 5);
@ -231,8 +231,8 @@ private func RainDrop(string mat)
// Check if liquid is maybe in frozen form.
var temp = GetTemperature();
var melt_temp = GetMaterialVal("BelowTempConvert", "Material", Material(mat));
if (temp < melt_temp)
mat = GetMaterialVal("BelowTempConvertTo", "Material", Material(mat));
if (melt_temp != nil && temp < melt_temp)
mat = GetMaterialVal("BelowTempConvertTo", "Material", Material(mat));
// Create rain drop.
CastPXS(mat, 1, 1, x, y);
return true;
@ -290,7 +290,7 @@ protected func Evaporation()
y += prec;
// Try to extract the specified material.
if(GetMaterial(evap_x, y) == Material(rain_mat))
if (GetMaterial(evap_x, y) == Material(rain_mat))
{
ExtractMaterialAmount(evap_x, y, Material("Water"), 3);
rain += 3;

View File

@ -19,6 +19,15 @@ public func SetChance(int chance)
return;
}
public func SetExplosiveness(int explosiveness)
{
if (this != Rockfall) return false;
var effect = GetEffect("IntRockfallControl");
if (!effect) return false;
effect.explosiveness = explosiveness;
return true;
}
public func GetChance()
{
if (this != Rockfall)
@ -50,8 +59,11 @@ protected func FxIntRockfallControlTimer(object target, proplist effect, int tim
x = effect.area.x + Random(effect.area.w);
y = effect.area.y + Random(effect.area.h);
}
// Explosive rocks demanded?
var explosive = false;
if (effect.explosiveness && Random(100)<effect.explosiveness) explosive = true;
// Launch rockfall of varying sizes between 40 and 120.
LaunchRockfall(x, y, 80 + Random(41), RandomX(-2, 2), RandomX(4, 8));
LaunchRockfall(x, y, 80 + Random(41), RandomX(-2, 2), RandomX(4, 8), explosive);
}
return FX_OK;
}
@ -60,11 +72,13 @@ protected func FxIntRockfallControlTimer(object target, proplist effect, int tim
public func FxIntRockfallControlSaveScen(obj, fx, props)
{
props->Add("Rockfall", "Rockfall->SetChance(%d)", fx.chance);
props->Add("Rockfall", "Rockfall->SetArea(%v)", fx.area);
if (fx.explosiveness) props->Add("Rockfall", "Rockfall->SetExplosiveness(%d)", fx.explosiveness);
return true;
}
// Launches an earthquake with epicenter (x,y).
global func LaunchRockfall(int x, int y, int size, int xdir, int ydir)
global func LaunchRockfall(int x, int y, int size, int xdir, int ydir, bool explosive)
{
// The rockfall size is constrained between 40 and 120%.
size = BoundBy(size, 40, 120);
@ -86,13 +100,17 @@ global func LaunchRockfall(int x, int y, int size, int xdir, int ydir)
rock->SetYDir(ydir);
rock->SetR(Random(360));
rock->SetRDir(RandomX(-6, 6));
// Make explosive
if (explosive) rock->MakeExplosive();
return true;
}
/*-- Rockfall --*/
local damage;
local damage, is_explosive;
protected func Construction()
{
@ -103,6 +121,13 @@ protected func Construction()
return;
}
public func MakeExplosive()
{
is_explosive = true;
SetClrModulation(0xffff0000);
return true;
}
protected func FxIntRockRollStart(object target, proplist effect, int temporary)
{
if (temporary)
@ -133,6 +158,20 @@ protected func FxIntRockMovementTimer(object target, proplist effect, int time)
protected func Hit(int dx, int dy)
{
// Acid kills rockfall
if (GetMaterialVal("Corrosive", "Material", GetMaterial()))
{
Sound("Pshshsh");
var sz = Max(GetCon()/10, 5);
var particles = new Particles_Dust() { Size = sz*3, };
if (is_explosive)
{ particles.R = 200; particles.G =100; particles.B = 0; }
else
{ particles.R = 100; particles.G =200; particles.B = 100; }
CreateParticle("Dust", PV_Random(-sz, sz), PV_Random(-sz, sz), PV_Random(-3, 3), PV_Random(-3, -3), PV_Random(36, 2 * 36), particles, sz/2);
return RemoveObject();
}
// Determine caused damage to this rock by impact.
damage += Distance(dx, dy, 0, 0) / 100;
if (damage > 12)
@ -182,7 +221,9 @@ protected func Hit(int dx, int dy)
private func SplitRock()
{
var con = GetCon();
var con = GetCon(), erock;
// Explosive rocks do some damage
if (is_explosive) if (erock = CreateObject(Rock,0,4,GetController())) erock->Explode(Max(15 * con / 100,3));
// Split the rock into smaller ones if it is big enough.
if (con > 40)
{
@ -196,11 +237,13 @@ private func SplitRock()
rock->SetXDir(RandomX(-100, 100), 100);
rock->SetYDir(RandomX(-200, -100), 100);
rock->SetRDir(RandomX(-6, 6));
}
if (is_explosive) rock->MakeExplosive();
}
}
// Some particles.
var rock_explode =
{
{
Size = PV_KeyFrames(0, 180, 25, 1000, 50),
DampingY = PV_Random(890, 920, 5),
DampingX = PV_Random(900, 930, 5),

View File

@ -18,7 +18,7 @@ protected func Initialize()
expansion_goal = 0;
// Start running the monte carlo simulation.
mc_data = [];
var effect = AddEffect("IntAreaMonteCarlo", this, 100, 1, this);
AddEffect("IntAreaMonteCarlo", this, 100, 1, this);
return inherited(...);
}

View File

@ -92,6 +92,7 @@ public func SetSymbol(obj)
// set tooltip
var desc = obj.UsageHelp;
if(!desc) desc = obj.Description;
desc = Format("%s: %s", obj.Name, desc);
this.Tooltip = desc;
}
}

View File

@ -68,18 +68,18 @@ public func ShowsItem()
public func MouseSelectionAlt(int plr)
{
if(!myobject) return;
if (!myobject) return;
var desc = myobject.UsageHelp;
if(!desc) desc = myobject.Description; // fall back to general description
if (!desc) desc = myobject.Description; // fall back to general description
// close other messages...
crew->OnDisplayInfoMessage();
if(desc)
if (desc)
{
var msg = Format("<c ff0000>%s</c>",desc);
CustomMessage(msg,this,plr);
var msg = Format("<c ff0000>%s</c>", desc);
CustomMessage(msg, this, plr);
}
return true;
}

View File

@ -273,6 +273,6 @@ private func UpdateTooltip()
this.Tooltip = nil;
else
{
this.Tooltip = item_object.Description;
this.Tooltip = Format("%s: %s", item_object.Name, item_object.Description);
}
}

View File

@ -472,6 +472,8 @@ protected func Ejection(object obj)
for(var c = 0; c < ContentsCount(); ++c)
{
var o = Contents(c);
if (!o)
continue;
if(o->~IsCarryHeavy())
continue;
if (GetItemPos(o) == nil)
@ -1137,7 +1139,7 @@ public func ObjectControl(int plr, int ctrl, int x, int y, int strength, bool re
if (ctrl == CON_ThrowAlt)
{
CancelUse();
if (proc == "SCALE" || proc == "HANGLE")
if (proc == "SCALE" || proc == "HANGLE" || proc == "SWIM")
return ObjectCommand("Drop", contents2);
else
return ObjectCommand("Throw", contents2, x, y);

View File

@ -161,21 +161,8 @@ func RefreshOwnershipOfSurrounding()
}
public func Initialize()
{
// no falling down anymore
SetCategory(C4D_StaticBack);
if(GetIndexOf(LibraryFlag_flag_list, this) == -1)
LibraryFlag_flag_list[GetLength(LibraryFlag_flag_list)] = this;
// redraw
RedrawAllFlagRadiuses();
// ownership
RefreshOwnershipOfSurrounding();
// linked flags - optimization for power system
RefreshAllFlagLinks();
AddOwnership();
AddEffect("IntFlagMovementCheck", this, 100, 12, this);
return _inherited(...);
}
@ -197,6 +184,28 @@ public func Construction()
}
public func Destruction()
{
RemoveOwnership();
return _inherited(...);
}
private func AddOwnership()
{
if(GetIndexOf(LibraryFlag_flag_list, this) == -1)
LibraryFlag_flag_list[GetLength(LibraryFlag_flag_list)] = this;
// redraw
RedrawAllFlagRadiuses();
// ownership
RefreshOwnershipOfSurrounding();
// linked flags - optimization for power system
RefreshAllFlagLinks();
}
private func RemoveOwnership()
{
ClearFlagMarkers();
@ -217,8 +226,43 @@ public func Destruction()
// refresh all flag links
RefreshAllFlagLinks();
return _inherited(...);
}
protected func FxIntFlagMovementCheckStart(object target, proplist effect, int temp)
{
if (temp)
return FX_OK;
effect.moving = false;
effect.Interval = 12;
effect.X = target->GetX();
effect.Y = target->GetY();
return FX_OK;
}
protected func FxIntFlagMovementCheckTimer(object target, proplist effect)
{
// Check if flag started moving.
if (!effect.moving)
{
if (effect.X != target->GetX() || effect.Y != target->GetY())
{
effect.moving = true;
RemoveOwnership();
}
}
// Check if flag stopped moving.
else
{
if (effect.X == target->GetX() && effect.Y == target->GetY())
{
effect.moving = false;
AddOwnership();
}
}
// Update coordinates.
effect.X = target->GetX();
effect.Y = target->GetY();
return FX_OK;
}
func ScheduleRefreshLinkedFlags()

View File

@ -602,6 +602,9 @@ protected func FxProcessProductionStop(object target, proplist effect, int reaso
// Standard behaviour for product ejection.
public func OnProductEjection(object product)
{
// Safety for the product removing itself on construction.
if (!product)
return;
// Vehicles in front fo buildings.
if (product->GetCategory() & C4D_Vehicle)
{

View File

@ -10,7 +10,7 @@ VertexX=-1,10,20,-23,-23,0
VertexY=-17,-25,-14,25,25,25
VertexFriction=50,50,50,100,100,100
Mass=4500
Components=Wood=3;Metal=3
Components=Wood=3;Metal=2
Exclusive=1
Construction=1
ContainBlast=1

View File

@ -61,7 +61,7 @@ protected func FxWorkingTimer()
private func Smoking()
{
Smoke(-10, -40, 6);
Smoke(-10, -28, 6);
}
local ActMap = {

View File

@ -10,7 +10,7 @@ VertexX=-8,-8,8,8
VertexY=-2,11,-2,11
VertexCNAT=5,9,6,10
VertexFriction=50,50,100,100
Components=Wood=3;
Components=Wood=2;
Construction=1
Mass=10
ContainBlast=1

View File

@ -25,7 +25,7 @@ public func IsInteractable() { return true; }
private func MaxContentsCount()
{
return 25;
return 50;
}

View File

@ -7,7 +7,7 @@
protected func Initialize()
{
// SetCategory(C4D_StaticBack);
SetCategory(C4D_StaticBack);
return _inherited(...);
}

View File

@ -10,7 +10,7 @@ VertexX= 1, 1,-24,17,35, 32,-28
VertexY=41,-41, 41,41,41,11,2
VertexFriction=100,10,100,100,100,10,10
Mass=4500
Components=Wood=3;Metal=3
Components=Wood=4;Metal=3
Exclusive=1
Construction=1
ContainBlast=1

Binary file not shown.

Before

Width:  |  Height:  |  Size: 578 KiB

After

Width:  |  Height:  |  Size: 138 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 145 KiB

After

Width:  |  Height:  |  Size: 55 KiB

View File

@ -105,20 +105,48 @@ func Initialize()
public func IsInteractable() { return GetCon() >= 100; }
public func GetInteractionMetaInfo(object clonk)
public func GetInteractionCount()
{
if (switched_on)
return { Description = "$MsgTurnOff$", IconName = nil, IconID = Icon_Stop };
else
return { Description = "$MsgTurnOn$", IconName = nil, IconID = Icon_Play };
var cnt = 1;
if (source_pipe)
cnt++;
if (drain_pipe)
cnt++;
return cnt;
}
/** Turn on or off. */
public func Interact(object clonk)
public func GetInteractionMetaInfo(object clonk, int num)
{
switched_on = !switched_on;
CheckState();
// Turning on/off.
if (num == 0)
{
if (switched_on)
return { Description = "$MsgTurnOff$", IconName = nil, IconID = Icon_Stop };
else
return { Description = "$MsgTurnOn$", IconName = nil, IconID = Icon_Play };
}
// Cutting the source pipe.
if (num == 1 && source_pipe)
return { Description = "$MsgCutSource$", IconName = nil, IconID = Icon_Cancel };
// Cutting the drain pipe.
if ((num == 2 || (num == 1 && !source_pipe)) && drain_pipe)
return { Description = "$MsgCutDrain$", IconName = nil, IconID = Icon_Cancel };
}
public func Interact(object clonk, int num)
{
// Turning on/off.
if (num == 0)
{
switched_on = !switched_on;
CheckState();
}
// Cutting the source pipe.
else if (num == 1 && source_pipe)
source_pipe->RemoveObject();
// Cutting the drain pipe.
else if ((num == 2 || (num == 1 && !source_pipe)) && drain_pipe)
drain_pipe->RemoveObject();
return true;
}
@ -163,7 +191,7 @@ private func GetDrainObject()
return this;
}
/** Re turns object to which the liquid is pumped */
/** Returns object from which the liquid is pumped */
private func GetSourceObject()
{
if (source_pipe) return source_pipe->GetConnectedObject(this) ?? this;

View File

@ -1,4 +1,6 @@
Name=Pumpe
Description=Die Pumpe kann beliebige Flüssigkeiten von A nach B pumpen. Pumpt sie Flüssigkeiten abwärts, erzeugt sie dabei sogar ein wenig Strom.
Description=Die Pumpe kann beliebige Fl<EFBFBD>ssigkeiten von A nach B pumpen. Pumpt sie Fl<46>ssigkeiten abw<62>rts, erzeugt sie dabei sogar ein wenig Strom.
MsgTurnOff=Pumpe abschalten
MsgTurnOn=Pumpe anschalten
MsgTurnOn=Pumpe anschalten
MsgCutSource=Zufluss trennen
MsgCutDrain=Abfluss trennen

View File

@ -1,4 +1,6 @@
Name=Pump
Description=The pump can transport liquid from A to B. If it pumps liquids downwards, it even generates a bit of power.
MsgTurnOff=Turn off pump
MsgTurnOn=Turn on pump
MsgTurnOn=Turn on pump
MsgCutSource=Cut off source
MsgCutDrain=Cut off drain

View File

@ -10,7 +10,7 @@ VertexX=0,-64,58,-64,59, 0
VertexY=53,53,53, 3, 3,-17
VertexFriction=100,100,100,50,50,50
Mass=4500
Components=Wood=12;Metal=6
Components=Wood=4;Metal=3
Exclusive=1
Construction=1
ContainBlast=1

View File

@ -119,7 +119,8 @@ func FxCreatesPowerStop(target, effect, reason, temp)
func FxSmokingTimer()
{
Smoke(-20 * GetCalcDir(), -15, 10);
Smoke(-20 * GetCalcDir(), -26, 10);
Smoke(-20 * GetCalcDir(), -24, 8);
return 1;
}

View File

@ -10,7 +10,7 @@ VertexX=-26,26,-22,23
VertexY=-4,-3,19,19
VertexFriction=50,50,100,100
Mass=4500
Components=Wood=6;Metal=3
Components=Wood=3;Metal=2
Exclusive=1
Construction=1
ContainBlast=1

View File

@ -70,8 +70,8 @@ protected func FxWorkingTimer()
private func Smoking()
{
if (Random(6)) Smoke(16 * GetCalcDir(),-14,16);
if (Random(8)) Smoke(10 * GetCalcDir(),-14,15+Random(3));
if (Random(6)) Smoke(16 * GetCalcDir(), -20, 10);
if (Random(8)) Smoke(14 * GetCalcDir(), -20, 8 + Random(3));
return 1;
}

View File

@ -2,7 +2,7 @@
#include Library_Structure
#include Library_Ownable
#include Library_DoorControl
//#include Library_DoorControl
public func Initialize()
{

View File

@ -0,0 +1,45 @@
vertex_program normal_map_vertex glsl
{
source normal_map_vertex.glsl
}
fragment_program normal_map_fragment glsl
{
source normal_map_fragment.glsl
}
// This material can be derived from in order to use a normal map with a
// single base texture.
material NormalMap
{
receive_shadows on
technique
{
pass
{
texture_unit base
{
}
texture_unit normal
{
}
vertex_program_ref normal_map_vertex
{
}
fragment_program_ref normal_map_fragment
{
param_named_auto oc_Mod2 oc_mod2
param_named_auto oc_ColorModulation oc_color_modulation
param_named_auto oc_UseClrModMap oc_use_clrmodmap
param_named_auto oc_ClrModMap oc_clrmodmap
param_named basemap int 0
param_named normalmap int 1
}
}
}
}

View File

@ -0,0 +1,28 @@
varying vec2 texcoord;
uniform sampler2D basemap;
uniform sampler2D normalmap;
uniform int oc_Mod2;
uniform vec4 oc_ColorModulation;
uniform int oc_UseClrModMap;
uniform sampler2D oc_ClrModMap;
void main()
{
// Do the lights calculation (based on normal map)
vec3 normal = normalize((texture2D(normalmap, texcoord).rgb * 2.0 - 1.0)); // TODO: This might be normalized already
vec3 lightDir = normalize(gl_LightSource[0].position.xyz);
vec4 lightColor = clamp(gl_FrontLightModelProduct.sceneColor + gl_FrontLightProduct[0].ambient + gl_FrontLightProduct[0].diffuse * max(0.0, dot(normal, lightDir)), 0.0, 1.0);
// Modulate with base texture
vec4 finalColor = lightColor * texture2D(basemap, texcoord);
// Apply openclonk blit parameters
vec4 clrModMapClr = vec4(1.0, 1.0, 1.0, 1.0);
if(oc_UseClrModMap != 0)
clrModMapClr = texture2D(oc_ClrModMap, gl_FragCoord.xy);
if(oc_Mod2 != 0)
gl_FragColor = clamp(2.0 * finalColor * oc_ColorModulation * clrModMapClr - 0.5, 0.0, 1.0);
else
gl_FragColor = finalColor * oc_ColorModulation * clrModMapClr;
}

View File

@ -0,0 +1,6 @@
varying vec2 texcoord;
void main()
{
texcoord = gl_MultiTexCoord0.xy;
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
}

View File

@ -1,6 +1,12 @@
/* Global Array helper functions */
/*--
Array.c
Authors: Zapper, Sven2
Global array helper functions.
--*/
// concatenates two arrays and returns a new array
// Concatenates two arrays and returns a new array.
global func Concatenate(array first, array second)
{
var len_first = GetLength(first);
@ -10,7 +16,7 @@ global func Concatenate(array first, array second)
return result;
}
// returns a new array that contains the values of the first array minus the values of the second array
// Returns a new array that contains the values of the first array minus the values of the second array.
global func Subtract(array subject, array subtract)
{
var diff = [];
@ -31,12 +37,12 @@ global func Subtract(array subject, array subtract)
return diff;
}
// removes nil values from an array, returns the amount of values removed
// Removes nil values from an array, returns the amount of values removed.
global func RemoveHoles(array leerdammer)
{
var move = 0;
var len = GetLength(leerdammer);
for(var i = 0; i < len; ++i)
for (var i = 0; i < len; ++i)
{
if(leerdammer[i] == nil)
{
@ -50,16 +56,16 @@ global func RemoveHoles(array leerdammer)
return move;
}
// removes duplicate entries - returns the number of entries removed
// Removes duplicate entries - returns the number of entries removed.
global func RemoveDuplicates(array arr)
{
var working = [];
var cnt = 0;
var len = GetLength(arr);
for(var i = 0; i < len; ++i)
for (var i = 0; i < len; ++i)
{
if(IsValueInArray(working, arr[i]))
if (IsValueInArray(working, arr[i]))
{
++cnt;
continue;
@ -67,58 +73,76 @@ global func RemoveDuplicates(array arr)
working[GetLength(working)] = arr[i];
}
SetLength(arr, GetLength(working));
for(var i = GetLength(working); --i >= 0;)
for (var i = GetLength(working); --i >= 0;)
arr[i] = working[i];
return cnt;
}
// tests whether a value is in an array
// Tests whether a value is in an array.
global func IsValueInArray(array arr, /*any*/ value)
{
return GetIndexOf(arr, value) != -1;
}
// removes a value from an array
// Removes a value from an array.
global func RemoveArrayValue(array arr, /*any*/ value, bool unstable)
{
var i = GetIndexOf(arr, value);
if(i == -1)
if (i == -1)
return false;
if(unstable == true)
if (unstable == true)
return RemoveArrayIndexUnstable(arr, i);
else return RemoveArrayIndex(arr, i);
return RemoveArrayIndex(arr, i);
}
// randomly shuffles an array
// Randomly shuffles an array.
global func ShuffleArray(array arr)
{
var len = GetLength(arr);
var working = arr[:];
while(--len >= 0)
while (--len >= 0)
{
var i = Random(len);
arr[len] = working[i];
working[i] = working[len];
}
return true;
return;
}
//deletes an index from an array, does not change the order of items in the array
// Takes array of format [[x1,y1], [x2,y2], ...] and returns array [[x1,x2,...],[y1,y2,...]]
global func TransposeArray(array v)
{
var result = [], i = 0;
for (var vc in v)
{
var j = 0;
for (var c in vc)
{
if (!result[j])
result[j] = CreateArray(GetLength(v));
result[j][i] = c;
++j;
}
++i;
}
return result;
}
// Deletes an index from an array, does not change the order of items in the array.
global func RemoveArrayIndex(array arr, int index, bool unstable)
{
if(unstable == true)
if (unstable == true)
return RemoveArrayIndexUnstable(arr, index);
// move all elements right of index to the left
arr[index:] = arr[index+1:];
return true;
}
// deletes an array item - might change the order of elements, but is faster
// Deletes an array item - might change the order of elements, but is faster.
global func RemoveArrayIndexUnstable(array arr, int index)
{
arr[index] = arr[-1];
@ -126,37 +150,36 @@ global func RemoveArrayIndexUnstable(array arr, int index)
return true;
}
//inserts an element at the end of an array
// Inserts an element at the end of an array.
global func PushBack(array arr, /*any*/ value)
{
arr[GetLength(arr)] = value;
return true;
}
// inserts an element at the beginning of an array
// Inserts an element at the beginning of an array.
global func PushFront(array arr, /*any*/ value)
{
// move elements one to the right
// Move elements one to the right.
arr[1:] = arr;
arr[0] = value;
return true;
}
// removes the last element from an array and returns it
// Removes the last element from an array and returns it.
global func PopBack(array arr)
{
if(GetLength(arr) == 0)
if (GetLength(arr) == 0)
return nil;
var o = arr[-1];
arr[:] = arr[:-1];
return o;
}
// removes the first element from an array and returns it
// Removes the first element from an array and returns it.
global func PopFront(array arr)
{
if(!GetLength(arr))
if (GetLength(arr) == 0)
return nil;
var o = arr[0];
arr[:] = arr[1:];

Some files were not shown because too many files have changed in this diff Show More