Skip to content
Permalink
Browse files

Implemented free shapes (=polygons) to be added or cleared from the l…

…andscape:

+ Refactored the ShakeFree, BlastFree, DigFree, DrawQuad etc. functions and
  removed unused functions ClearRectDensity, DigFreeMaterial,...
+ Moved the polygon fill algorithm from StdSurface8.cpp to C4Landscape.cpp
+ Clearance functions which used to subtract a circle now subtract something
  that looks more like a chunk
+ Pickaxe works with BlastFree now
+ Removed Dig2ObjectRequest
  • Loading branch information...
westnordost committed May 30, 2011
1 parent e07761a commit 8c490dca05ce2cdbacf247a091fc69b7e4ea084b
@@ -7,7 +7,6 @@ DigFree=1
BlastFree=1
Dig2Object=Earth
Dig2ObjectRatio=200
Dig2ObjectRequest=1
Blast2PXSRatio=10
MaxAirSpeed=100
MaxSlide=1
@@ -8,7 +8,6 @@ BlastFree=1
Blast2Object=Ice
Dig2Object=Ice
Dig2ObjectRatio=200
Dig2ObjectRequest=0
Blast2ObjectRatio=120
MaxAirSpeed=100
MaxSlide=1
@@ -7,7 +7,6 @@ DigFree=1
BlastFree=1
Dig2Object=Sand
Dig2ObjectRatio=200
Dig2ObjectRequest=1
Blast2PXSRatio=10
MaxAirSpeed=100
MaxSlide=1
@@ -7,7 +7,6 @@ DigFree=1
BlastFree=1
Dig2Object=Sand
Dig2ObjectRatio=200
Dig2ObjectRequest=1
Blast2PXSRatio=10
Instable=1
MaxAirSpeed=75
@@ -24,7 +24,6 @@ PXSGfx=Snow
PXSGfxRt=0,0,16,16,-8,-8
Dig2Object=Snow
Dig2ObjectRatio=400
Dig2ObjectRequest=0

[Reaction]
Type=Convert
@@ -10,8 +10,6 @@ local maxreach;
local swingtime;
local using;

local picked_materials;

public func GetCarryMode() { return CARRY_HandBack; }
public func GetCarryBone() { return "main"; }
public func GetCarrySpecial(clonk) { if(using == 1) return "pos_hand2"; }
@@ -20,10 +18,6 @@ public func GetCarryTransform()
return Trans_Rotate(-90, 0, 1, 0);
}

//TODO: The pick should probably have an internal array that
//keeps the data of how much of which material has been dug.
//I wouldn't have a clue how to do this, so if anyone else
//wants to make that, good luck! :) - Ringwaul

func Definition(def) {
SetProperty("PictureTransformation",Trans_Mul(Trans_Rotate(40, 0, 0, 1),Trans_Rotate(150, 0, 1, 0), Trans_Scale(900), Trans_Translate(600, 400, 1000)),def);
@@ -32,9 +26,8 @@ func Definition(def) {
protected func Initialize()
{
//maxreach is the length of the pick from the clonk's hand
maxreach=16;
maxreach=12;
swingtime=0;
picked_materials = CreatePropList();
}

private func Hit()
@@ -107,42 +100,29 @@ protected func DoSwing(object clonk, int ix, int iy)

var mat = GetMaterial(x2,y2);
var tex = GetTexture(x2,y2);

if(GetMaterialVal("DigFree","Material",mat)==0)
{
Sound("Clang*");
}


// special effects
if(GetMaterialVal("DigFree","Material",mat))
{
var clr = GetAverageTextureColor(tex);
var a = 80;
CreateParticle("Dust",x2,y2,RandomX(-3,3),RandomX(-3,3),RandomX(10,250),DoRGBaValue(clr,-255+a,0));
}

//special effects
if(GetMaterialVal("DigFree","Material",mat)==0)
else
{
CastParticles("Spark",RandomX(3,9),35,x2*9/10,y2*9/10,10,30,RGB(255,255,150),RGB(255,255,200));
Sound("Clang*");
}

//dig out resources too! Don't just remove landscape pixels
var x_obj = clonk->GetX()-GetX(), y_obj = clonk->GetY()+10-GetY();
for(var i = -10; i < 10; i++)
for(var j = -10; j < 10; j++)
if(Distance(0,0,i*10,j*10) <= 90)
PickPixel(i+x, j+y, x_obj, y_obj);

//stops resources from launching into clonk while mining
// for(var resources in FindObjects(Find_Distance(7,x,y), Find_Category(C4D_Object), Find_Not(Find_OCF(OCF_Alive))))
// resources->SetSpeed();
// dig out resources too! Don't just remove landscape pixels
BlastFree(GetX()+x2,GetY()+y2,5,GetController());
}
// else
// Message("Hit nothing"); //for debug
}

func FxIntPickaxeTimer(clonk, effect, time)
{
++swingtime;
if(swingtime >= Pickaxe_SwingTime) //Waits three seconds for animation to run (we could have a clonk swing his pick 3 times)
if(swingtime >= Pickaxe_SwingTime) // Waits three seconds for animation to run (we could have a clonk swing his pick 3 times)
{
DoSwing(clonk,x,y);
swingtime = 0;
@@ -161,50 +141,6 @@ func FxIntPickaxeTimer(clonk, effect, time)
clonk->SetYDir(Cos(angle,-speed),100);
}

func PickPixel(int x, int y, int x_obj, int y_obj)
{
if(!x_obj) x_obj = x;
if(!y_obj) y_obj = y;

var mat = GetMaterial(x,y);

// Has the material do be converted instead of blasted?
var shift = GetMaterialVal("BlastShiftTo", "Material", mat);
if(shift != nil && shift != "")
{
x += GetX(); y += GetY();
DrawMaterialQuad(shift, x,y, x,y, x,y+1, x,y+1, 1);
return;
}

// If material can't be blasted stop here
if(!GetMaterialVal("BlastFree", "Material", mat)) return;

// Remember name for prolist access
var mat_name = MaterialName(mat);

// Remove the pixel
FreeRect(GetX()+x,GetY()+y,1,1);

// Count pixels
if(picked_materials[mat_name] == nil) picked_materials[mat_name] = 1;
else picked_materials[mat_name]++;

// Create freed objects from blast or dig
var amount = GetMaterialVal("Blast2ObjectRatio", "Material", mat);
var def = GetMaterialVal("Blast2Object", "Material", mat);
if(!amount && !GetMaterialVal("Dig2ObjectRequest", "Material", mat))
{
amount = GetMaterialVal("Dig2ObjectRatio", "Material", mat);
def = GetMaterialVal("Dig2Object", "Material", mat);
}
if(amount && picked_materials[mat_name] >= amount)
{
CreateObject(def, x_obj, y_obj);
picked_materials[mat_name] -= amount;
}
}

protected func ControlUseCancel(object clonk, int ix, int iy)
{
Reset(clonk);
@@ -11,6 +11,7 @@
* Copyright (c) 2009 David Dormagen
* Copyright (c) 2009-2010 Nicolas Hake
* Copyright (c) 2010 Benjamin Herr
* Copyright (c) 2011 Tobias Zwick
* Copyright (c) 2001-2009, RedWolf Design GmbH, http://www.clonk.de
*
* Portions might be copyrighted by other authors who have contributed
@@ -1431,18 +1432,6 @@ void C4Game::CastObjects(C4ID id, C4Object *pCreator, int32_t num, int32_t level
}
}

void C4Game::BlastCastObjects(C4ID id, C4Object *pCreator, int32_t num, int32_t tx, int32_t ty, int32_t iController)
{
int32_t cnt;
for (cnt=0; cnt<num; cnt++)
{
CreateObject(id,pCreator,NO_OWNER,
tx,ty,Random(360),
C4REAL10(Random(61)-30), C4REAL10(Random(61)-40),
itofix(Random(3)+1), iController);
}
}

void C4GameSec1Timer::OnSec1Timer()
{
// updates the game clock
@@ -5,6 +5,7 @@
* Copyright (c) 2001-2002, 2004-2005, 2008-2009 Sven Eberhardt
* Copyright (c) 2004, 2006 Peter Wortmann
* Copyright (c) 2005, 2009 Günther Brammer
* Copyright (c) 2011 Tobias Zwick
* Copyright (c) 2001-2009, RedWolf Design GmbH, http://www.clonk.de
*
* Portions might be copyrighted by other authors who have contributed
@@ -214,7 +215,6 @@ class C4Game
int32_t iOwner=ANY_OWNER);*/
int32_t ObjectCount(C4ID id);
void CastObjects(C4ID id, C4Object *pCreator, int32_t num, int32_t level, int32_t tx, int32_t ty, int32_t iOwner=NO_OWNER, int32_t iController=NO_OWNER);
void BlastCastObjects(C4ID id, C4Object *pCreator, int32_t num, int32_t tx, int32_t ty, int32_t iController=NO_OWNER);
C4Object *PlaceVegetation(C4ID id, int32_t iX, int32_t iY, int32_t iWdt, int32_t iHgt, int32_t iGrowth);
C4Object *PlaceAnimal(C4ID idAnimal);

0 comments on commit 8c490dc

Please sign in to comment.
You can’t perform that action at this time.