forked from Mirrors/openclonk
rope bridge clean up and cleaner way to create a bridge
Now use Ropebridge->Create(x1, y1, x2, y2) to make a bridge, this allows for some more clean up in a commit to follow.shapetextures
parent
c3fba77ecf
commit
5ffc97f2f0
|
@ -1,14 +1,18 @@
|
|||
/*--- plank of a ropebridge ---*/
|
||||
/**
|
||||
Ropebridge Plank
|
||||
|
||||
@author Randrian
|
||||
*/
|
||||
|
||||
protected func Hit()
|
||||
{
|
||||
Sound("Hits::Materials::Wood::WoodHit?");
|
||||
return 1;
|
||||
return;
|
||||
}
|
||||
|
||||
func Incineration()
|
||||
public func Incineration()
|
||||
{
|
||||
SetClrModulation (RGB(48, 32, 32));
|
||||
SetClrModulation(RGB(48, 32, 32));
|
||||
}
|
||||
|
||||
public func IsFuel() { return true; }
|
||||
|
@ -20,6 +24,5 @@ func SaveScenarioObject() { return false; }
|
|||
local Collectible = 0;
|
||||
local Name = "$Name$";
|
||||
local Description = "$Description$";
|
||||
local Rebuy = false;
|
||||
local BlastIncinerate = 5;
|
||||
local ContactIncinerate = 1;
|
|
@ -1,27 +1,35 @@
|
|||
/*-- Ropebridge_Post --*/
|
||||
/**
|
||||
Ropebridge Post
|
||||
|
||||
@author Randrian
|
||||
*/
|
||||
|
||||
local Double;
|
||||
|
||||
func Initialize()
|
||||
public func Initialize()
|
||||
{
|
||||
if(FindObject(Find_ID(GetID()), Find_Exclude(this), Find_AtPoint()))
|
||||
return; // I am just a double!
|
||||
if(!Double)
|
||||
{
|
||||
Double = CreateObjectAbove(GetID());
|
||||
Double.Plane = 600;
|
||||
Double->SetAction("Attach", this);
|
||||
Double->SetGraphics("Foreground", GetID());
|
||||
}
|
||||
if (FindObject(Find_ID(GetID()), Find_Exclude(this), Find_AtPoint()))
|
||||
return; // I am just a double!
|
||||
if (!Double)
|
||||
{
|
||||
Double = CreateObject(GetID());
|
||||
Double.Plane = 600;
|
||||
Double->SetAction("Attach", this);
|
||||
Double->SetGraphics("Foreground", GetID());
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/*-- Properties --*/
|
||||
|
||||
local ActMap = {
|
||||
Attach = {
|
||||
Prototype = Action,
|
||||
Name = "Attach",
|
||||
Procedure = DFA_ATTACH,
|
||||
FacetBase = 1,
|
||||
},
|
||||
Attach = {
|
||||
Prototype = Action,
|
||||
Name = "Attach",
|
||||
Procedure = DFA_ATTACH,
|
||||
FacetBase = 1,
|
||||
},
|
||||
};
|
||||
local Name = "$Name$";
|
||||
local Description = "$Description$";
|
||||
|
|
|
@ -1,81 +1,87 @@
|
|||
/*-- Ropelbridge_Segment --*/
|
||||
/**
|
||||
Ropebridge Segment
|
||||
|
||||
@author Randrian
|
||||
*/
|
||||
|
||||
local master;
|
||||
local Plank;
|
||||
local fragile;
|
||||
|
||||
func SetMaster(newmaster)
|
||||
{
|
||||
master = newmaster;
|
||||
}
|
||||
|
||||
/* Events */
|
||||
|
||||
protected func Damage(iAmount)
|
||||
{
|
||||
if(GetDamage()>18 && Plank)
|
||||
LoosePlank();
|
||||
}
|
||||
|
||||
func LoosePlank()
|
||||
{
|
||||
var loosePlank = CreateObjectAbove(BridgePlank);
|
||||
loosePlank->SetR(GetR());
|
||||
loosePlank->SetPosition(GetX(100)+Cos(GetR(), -400)+Sin(GetR(), 200), GetY(100)+Sin(GetR(), -400)+Cos(GetR(), 200), 0, 100);
|
||||
Plank = 0;
|
||||
SetSolidMask();
|
||||
SetGraphics(nil, nil, 6);
|
||||
}
|
||||
|
||||
func GetLoadWeight()
|
||||
{
|
||||
if(!Plank) return 10;
|
||||
var weight = 50;
|
||||
var arr = [0,0,0,0,0,0,0];
|
||||
var i = 0;
|
||||
for(obj in FindObjects(Find_AtRect(-3,-10,6,10), Find_Exclude(this), Find_NoContainer()))
|
||||
if(obj->GetID() != Ropebridge_Segment && obj->GetID() != Ropebridge_Post && obj->GetID() != BridgePlank)
|
||||
if (obj->GetContact(-1, 8))
|
||||
{
|
||||
arr[i++] = obj->GetName();
|
||||
weight += obj->GetMass();
|
||||
}
|
||||
if(fragile && weight > 60 && Random(10))
|
||||
{
|
||||
ScheduleCall(this, "LoosePlank", 10);
|
||||
fragile = 0;
|
||||
}
|
||||
return weight;
|
||||
}
|
||||
|
||||
local Double;
|
||||
|
||||
func CreateDouble()
|
||||
public func SetMaster(newmaster)
|
||||
{
|
||||
if(!Double)
|
||||
{
|
||||
Double = CreateObjectAbove(GetID());
|
||||
Double.Plane = 600;
|
||||
//Double->SetAction("Attach", this);
|
||||
}
|
||||
master = newmaster;
|
||||
}
|
||||
|
||||
/*-- Events --*/
|
||||
|
||||
protected func Damage(int amount)
|
||||
{
|
||||
if (GetDamage() > 18 && Plank)
|
||||
LoosePlank();
|
||||
}
|
||||
|
||||
public func LoosePlank()
|
||||
{
|
||||
var loose_plank = CreateObject(BridgePlank);
|
||||
loose_plank->SetR(GetR());
|
||||
loose_plank->SetPosition(GetX(100) + Cos(GetR(), -400) + Sin(GetR(), 200), GetY(100) + Sin(GetR(), -400) + Cos(GetR(), 200), 0, 100);
|
||||
Plank = 0;
|
||||
SetSolidMask();
|
||||
SetGraphics(nil, nil, 6);
|
||||
}
|
||||
|
||||
public func GetLoadWeight()
|
||||
{
|
||||
if (!Plank)
|
||||
return 10;
|
||||
var weight = 50;
|
||||
var arr = [0, 0, 0, 0, 0, 0, 0];
|
||||
var i = 0;
|
||||
for (obj in FindObjects(Find_AtRect(-3, -10, 6, 10), Find_Exclude(this), Find_NoContainer()))
|
||||
if (obj->GetID() != Ropebridge_Segment && obj->GetID() != Ropebridge_Post && obj->GetID() != BridgePlank)
|
||||
if (obj->GetContact(-1, 8))
|
||||
{
|
||||
arr[i++] = obj->GetName();
|
||||
weight += obj->GetMass();
|
||||
}
|
||||
if (fragile && weight > 60 && Random(10))
|
||||
{
|
||||
ScheduleCall(this, "LoosePlank", 10);
|
||||
fragile = 0;
|
||||
}
|
||||
return weight;
|
||||
}
|
||||
|
||||
public func CreateDouble()
|
||||
{
|
||||
if (!Double)
|
||||
{
|
||||
Double = CreateObjectAbove(GetID());
|
||||
Double.Plane = 600;
|
||||
}
|
||||
}
|
||||
|
||||
// Main bridge object is saved
|
||||
func SaveScenarioObject() { return false; }
|
||||
|
||||
|
||||
/*-- Properties --*/
|
||||
|
||||
local ActMap = {
|
||||
Attach = {
|
||||
Prototype = Action,
|
||||
Name = "Attach",
|
||||
Procedure = DFA_ATTACH
|
||||
},
|
||||
Fall = {
|
||||
Prototype = Action,
|
||||
Name = "Fall",
|
||||
Procedure = DFA_NONE,
|
||||
Length=20,
|
||||
Delay=1,
|
||||
EndCall="LoosePlank",
|
||||
NextAction = "Idle",
|
||||
},
|
||||
Attach = {
|
||||
Prototype = Action,
|
||||
Name = "Attach",
|
||||
Procedure = DFA_ATTACH
|
||||
},
|
||||
Fall = {
|
||||
Prototype = Action,
|
||||
Name = "Fall",
|
||||
Procedure = DFA_NONE,
|
||||
Length = 20,
|
||||
Delay = 1,
|
||||
EndCall = "LoosePlank",
|
||||
NextAction = "Idle",
|
||||
},
|
||||
};
|
||||
|
|
|
@ -14,6 +14,22 @@ static const Ladder_SegmentLength = 5;
|
|||
|
||||
local MirrorSegments;
|
||||
|
||||
// Create a rope bridge starting at (x1, y1) and ending at (x2, y2).
|
||||
public func Create(int x1, int y1, int x2, int y2, bool fragile)
|
||||
{
|
||||
if (this != Ropebridge)
|
||||
return;
|
||||
var bridge_post1 = CreateObjectAbove(Ropebridge_Post, x1, y1);
|
||||
var bridge_post2 = CreateObjectAbove(Ropebridge_Post, x2, y2);
|
||||
bridge_post2->SetObjDrawTransform(-1000, 0, 0, 0, 1000);
|
||||
bridge_post2.Double->SetObjDrawTransform(-1000, 0, 0, 0, 1000);
|
||||
var bridge = CreateObjectAbove(Ropebridge, (x1 + x2) / 2, (y1 + y2) / 2);
|
||||
bridge->MakeBridge(bridge_post1, bridge_post2);
|
||||
if (fragile)
|
||||
bridge->SetFragile();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
public func UpdateSegmentOverlays()
|
||||
{
|
||||
|
@ -55,7 +71,7 @@ public func UpdateSegmentOverlays()
|
|||
return;
|
||||
}
|
||||
|
||||
public func MakeBridge(obj1, obj2)
|
||||
public func MakeBridge(object obj1, object obj2)
|
||||
{
|
||||
MirrorSegments = 1;
|
||||
SetProperty("Collectible", 0);
|
||||
|
@ -265,6 +281,9 @@ public func Hit()
|
|||
Sound("Hits::Materials::Wood::WoodHit?");
|
||||
}
|
||||
|
||||
|
||||
/*-- Properties --*/
|
||||
|
||||
local ActMap = {
|
||||
Hanging = {
|
||||
Prototype = Action,
|
||||
|
@ -275,4 +294,3 @@ local ActMap = {
|
|||
};
|
||||
local Name = "$Name$";
|
||||
local Collectible = 1;
|
||||
local Rebuy = true;
|
||||
|
|
|
@ -2,31 +2,14 @@
|
|||
|
||||
func Initialize()
|
||||
{
|
||||
// CreateObjectAbove(Ropeladder, 174, 445)->Unroll(-1, 0, 25);
|
||||
CreateObjectAbove(Ropeladder, 328, 564);
|
||||
CreateObjectAbove(Ropeladder, 226, 330);
|
||||
|
||||
CreateObjectAbove(Rock, 159, 363);
|
||||
CreateObjectAbove(Rock, 232, 388);
|
||||
|
||||
var Anchor1 = CreateObjectAbove(Ropebridge_Post, 515, 547);
|
||||
var Anchor2 = CreateObjectAbove(Ropebridge_Post, 602, 538);
|
||||
Anchor2->SetObjDrawTransform(-1000, 0, 0, 0, 1000);
|
||||
Anchor2.Double->SetObjDrawTransform(-1000, 0, 0, 0, 1000);
|
||||
var bridge = CreateObjectAbove(Ropebridge, 515, 547);
|
||||
bridge->MakeBridge(Anchor1, Anchor2);
|
||||
bridge->SetFragile();
|
||||
|
||||
var Anchor1 = CreateObjectAbove(Ropebridge_Post, 266, 435+6);
|
||||
var Anchor2 = CreateObjectAbove(Ropebridge_Post, 346, 473+6);
|
||||
Anchor2->SetObjDrawTransform(-1000, 0, 0, 0, 1000);
|
||||
Anchor2.Double->SetObjDrawTransform(-1000, 0, 0, 0, 1000);
|
||||
CreateObjectAbove(Ropebridge, 515, 547)->MakeBridge(Anchor1, Anchor2);
|
||||
CreateObjectAbove(Branch, 505, 547);
|
||||
CreateObjectAbove(Rock,495, 547);
|
||||
// CreateObjectAbove(Ropeladder, 197, 432)->MakeBridge(Rock1, Rock2);
|
||||
// for(var i = 0; i < 10; i++)
|
||||
// bridge->CreateObjectAbove(Zap, RandomX(-30,30), -40+RandomX(-30,30));
|
||||
|
||||
|
||||
var obj;
|
||||
|
|
|
@ -13,11 +13,7 @@ public func Initialize()
|
|||
CreateObjectAbove(Ropeladder, 222, 40)->Unroll(1, -1, 12);
|
||||
|
||||
// Ropebridge.
|
||||
var post1 = CreateObjectAbove(Ropebridge_Post, 80, 152);
|
||||
var post2 = CreateObjectAbove(Ropebridge_Post, 176, 152);
|
||||
post2->SetObjDrawTransform(-1000, 0, 0, 0, 1000);
|
||||
post2.Double->SetObjDrawTransform(-1000, 0, 0, 0, 1000);
|
||||
CreateObjectAbove(Ropebridge, 140, 152)->MakeBridge(post1, post2);
|
||||
Ropebridge->Create(80, 152, 176, 152);
|
||||
|
||||
// Series of rope ladders.
|
||||
CreateObjectAbove(Ropeladder, 292, 60)->Unroll(-1, COMD_Up);
|
||||
|
|
|
@ -69,11 +69,7 @@ private func InitStartLake()
|
|||
CreateObjectAbove(Tree_Coconut, 105, 620);
|
||||
|
||||
// Ropebridge over the lake.
|
||||
var post1 = CreateObjectAbove(Ropebridge_Post, 144, 616);
|
||||
var post2 = CreateObjectAbove(Ropebridge_Post, 232, 616);
|
||||
post2->SetObjDrawTransform(-1000, 0, 0, 0, 1000);
|
||||
post2.Double->SetObjDrawTransform(-1000, 0, 0, 0, 1000);
|
||||
CreateObjectAbove(Ropebridge, 186, 616)->MakeBridge(post1, post2);
|
||||
Ropebridge->Create(144, 616, 232, 616);
|
||||
|
||||
// Small sink hole for the water to flow through, cover by a trunk.
|
||||
DrawMaterialQuad("Tunnel", 231, 631, 231, 633, 251, 615, 249, 615, DMQ_Sub);
|
||||
|
|
|
@ -125,12 +125,7 @@ private func InitCliffTop()
|
|||
private func InitAcidLake()
|
||||
{
|
||||
// Ropebridge over the acid lake.
|
||||
var post1 = CreateObjectAbove(Ropebridge_Post, 816, 528);
|
||||
var post2 = CreateObjectAbove(Ropebridge_Post, 928, 528);
|
||||
post2->SetObjDrawTransform(-1000, 0, 0, 0, 1000);
|
||||
post2.Double->SetObjDrawTransform(-1000, 0, 0, 0, 1000);
|
||||
var bridge = CreateObjectAbove(Ropebridge, 872, 528);
|
||||
bridge->MakeBridge(post1, post2);
|
||||
Ropebridge->Create(816, 528, 928, 528);
|
||||
|
||||
// Make the acid lake bubbling a bit.
|
||||
BoilingAcid->Place();
|
||||
|
|
Loading…
Reference in New Issue