Objects: Stonedoor damage now visible through cracks (#669)

Thanks to ringwaul for the graphics.
Maikel de Vries 2011-10-03 14:04:38 +02:00
parent 8073e1cb47
commit 49bfc2aacb
16 changed files with 193 additions and 267 deletions

View File

@ -30,7 +30,7 @@ func Initialize()
var c=goal->AddCheckpoint(1000, 100, mode);
c->SetCPSize(40);
var door=CreateObject(StoneDoor, 135, 60, NO_OWNER);
door->CloseGateDoor();
door->CloseDoor();
AddEffect("AutoOpen",door,100,100);
goal->SetFinishpoint(100, 150, true);
@ -83,7 +83,7 @@ global func FxAutoOpenTimer(object pTarget, effect, int timer)
{
if(FindObject(Find_ID(Plane),Find_InRect(0,0,2000,500)))
{
pTarget->OpenGateDoor();
pTarget->OpenDoor();
return -1;
}
else return 1;
@ -149,7 +149,7 @@ protected func Doors()
var gate = CreateObject(StoneDoor, 865, 1195, NO_OWNER);
var wheel = CreateObject(SpinWheel, 1045, 1165, NO_OWNER);
wheel->SetStoneDoor(gate);
gate->CloseGateDoor();
gate->CloseDoor();
AddEffect("SparklingAttention",wheel,100,100);
var gate = CreateObject(StoneDoor, 1155, 1026, NO_OWNER);
@ -157,54 +157,54 @@ protected func Doors()
var straw = CreateObject(DoorTarget,1850,820,NO_OWNER);
straw->SetGate(gate);
straw->SetAction("Float");
gate->CloseGateDoor();
gate->CloseDoor();
AddEffect("SparklingAttention",wheel,100,100);
var gate = CreateObject(StoneDoor, 1875, 761, NO_OWNER);
var wheel = CreateObject(SpinWheel, 1752, 1148, NO_OWNER);
wheel->SetStoneDoor(gate);
gate->CloseGateDoor();
gate->CloseDoor();
AddEffect("SparklingAttention",wheel,100,100);
var gate = CreateObject(StoneDoor, 1875, 864, NO_OWNER);
var wheel = CreateObject(SpinWheel, 1116, 1038, NO_OWNER);
wheel->SetStoneDoor(gate);
gate->CloseGateDoor();
gate->CloseDoor();
AddEffect("SparklingAttention",wheel,100,100);
var gate = CreateObject(StoneDoor, 3115, 685, NO_OWNER);
var wheel = CreateObject(SpinWheel, 3140, 588, NO_OWNER);
wheel->SetStoneDoor(gate);
gate->CloseGateDoor();
gate->CloseDoor();
AddEffect("SparklingAttention",wheel,100,100);
var gate = CreateObject(StoneDoor, 585, 915, NO_OWNER);
var wheel = CreateObject(SpinWheel, 853, 681, NO_OWNER);
wheel->SetStoneDoor(gate);
gate->CloseGateDoor();
gate->CloseDoor();
AddEffect("SparklingAttention",wheel,100,100);
var gate = CreateObject(StoneDoor, 345, 740, NO_OWNER);
var wheel = CreateObject(SpinWheel, 60, 644, NO_OWNER);
wheel->SetStoneDoor(gate);
gate->CloseGateDoor();
gate->CloseDoor();
AddEffect("SparklingAttention",wheel,100,100);
var gate = CreateObject(StoneDoor, 1935, 550, NO_OWNER);
var wheel = CreateObject(SpinWheel, 1900, 565, NO_OWNER);
wheel->SetStoneDoor(gate);
gate->CloseGateDoor();
gate->CloseDoor();
AddEffect("SparklingAttention",wheel,100,100);
var gate = CreateObject(StoneDoor, 2965, 310, NO_OWNER);
var wheel = CreateObject(SpinWheel, 3260, 328, NO_OWNER);
wheel->SetStoneDoor(gate);
gate->CloseGateDoor();
gate->CloseDoor();
var gate = CreateObject(StoneDoor, 3285, 1150, NO_OWNER);
var wheel = CreateObject(SpinWheel, 3220, 1200, NO_OWNER);
wheel->SetStoneDoor(gate);
gate->CloseGateDoor();
gate->CloseDoor();
}

View File

@ -7,14 +7,14 @@ protected func Initialize()
return;
}
public func OpenGateDoor()
public func OpenDoor()
{
AddEffect("IntMoveGateUp", this, 100, 1, this);
Sound("GateMove");
return;
}
public func CloseGateDoor()
public func CloseDoor()
{
AddEffect("IntMoveGateDown", this, 100, 1, this);
Sound("GateMove");

View File

@ -8,7 +8,7 @@ public func ControlUp(object clonk)
if(GetEffect("SparklingAttention",this)) RemoveEffect("SparklingAttention",this);
if (GetAction() == "Still" && targetdoor)
{
targetdoor->OpenGateDoor();
targetdoor->OpenDoor();
SetAction("SpinLeft");
Sound("Chain.ogg");
}

View File

@ -36,7 +36,7 @@ public func Burst()
{
DrawParticleLine("Straw",0,0,AbsX(gate->GetX()),AbsY(gate->GetY()),6,80,RGB(255,255,255),RGB(255,150,200));
RemoveObject();
gate->OpenGateDoor();
gate->OpenDoor();
CastParticles("Straw",130,30,0,-3,30,40,RGB(255,255,255),RGB(255,120,200));
}

View File

@ -24,12 +24,12 @@ protected func Initialize()
goal->SetFlagBase(2, LandscapeWidth() - 135, 264);
CreateObject(Rule_KillLogs);
var gate = CreateObject(StoneDoor, 345, 273, NO_OWNER);
gate->SetClrModulation(RGB(180,205,255));
AddEffect("AutoControl", gate, 100, 3, gate, nil, 1);
var gate = CreateObject(StoneDoor, LandscapeWidth()-344, 273, NO_OWNER);
gate->SetClrModulation(RGB(180,205,255));
AddEffect("AutoControl", gate, 100, 3, gate, nil, 2);
var gate = CreateObject(StoneDoor, 345, 272, NO_OWNER);
gate->SetClrModulation(RGB(140,185,255));
gate->SetAutoControl(1);
var gate = CreateObject(StoneDoor, LandscapeWidth()-344, 272, NO_OWNER);
gate->SetClrModulation(RGB(140,185,255));
gate->SetAutoControl(2);
// Chests with weapons.
var chest;

View File

@ -2,85 +2,17 @@
#appendto StoneDoor
private func GetStrength() { return 300; }
protected func Damage()
{
if (GetDamage() > 300)
// Destroy if damage above strength.
if (GetDamage() > GetStrength())
{
if (!this)
return false;
var ctr = Contained();
// Transfer all contents to container.
while (Contents())
if (!ctr || !Contents()->Enter(ctr))
Contents()->Exit();
// Split components.
for (var i = 0, compid; compid = GetComponent(nil, i); ++i)
for (var j = 0; j < GetComponent(compid); ++j)
{
var comp = CreateObject(compid, nil, nil, GetOwner());
if (OnFire()) comp->Incinerate();
if (!ctr || !comp->Enter(ctr))
{
comp->SetR(Random(360));
comp->SetXDir(Random(3) - 1);
comp->SetYDir(Random(3) - 1);
comp->SetRDir(Random(3) - 1);
comp->SetClrModulation(RGB(130,190,255));//give rocks the color of brick
}
}
RemoveObject();
CastObjects(Ice, 5, 20);
return RemoveObject();
}
// Change appearance.
DoGraphics();
return;
}
private func IsOpen()
{
if (GBackSolid(0, -20))
return true;
return false;
}
private func IsClosed()
{
if (GBackSolid(0, 19))
return true;
return false;
}
// Automatically open for team stored in effect var 0.
protected func FxAutoControlStart(object target, effect, int temporary, int team)
{
if (temporary == 0)
effect.team = team;
return 1;
}
protected func FxAutoControlTimer(object target, effect, int time)
{
var d = 0;
if (IsOpen())
d = 30;
var team = effect.team;
var open_door = false;
DigFreeRect(target->GetX()-5,target->GetY()-22,10,44);
for (var clonk in FindObjects(Find_OCF(OCF_CrewMember), Find_InRect(-50, d - 30, 100, 60)))
{
var plr = clonk->GetOwner();
var plr_team = GetPlayerTeam(plr);
if (plr_team == team)
open_door = true;
else
{
open_door = false;
break;
}
}
if (open_door && IsClosed())
OpenGateDoor();
if (!open_door && IsOpen())
CloseGateDoor();
return 1;
}

View File

@ -24,21 +24,21 @@ protected func Initialize()
// Doors and spinwheels.
var gate, wheel;
gate = CreateObject(StoneDoor, 365, 449, NO_OWNER);
gate = CreateObject(StoneDoor, 365, 448, NO_OWNER);
gate->DoDamage(50); // Upper doors are easier to destroy
AddEffect("AutoControl", gate, 100, 3, gate, nil, 1);
gate = CreateObject(StoneDoor, 341, 585, NO_OWNER);
AddEffect("AutoControl", gate, 100, 3, gate, nil, 1);
gate->SetAutoControl(1);
gate = CreateObject(StoneDoor, 341, 584, NO_OWNER);
gate->SetAutoControl(1);
gate = CreateObject(StoneDoor, 693, 544, NO_OWNER);
gate->DoDamage(80); // Middle doors even easier
wheel = CreateObject(SpinWheel, 660, 552, NO_OWNER);
wheel->SetStoneDoor(gate);
gate = CreateObject(StoneDoor, LandscapeWidth() - 364, 449, NO_OWNER);
gate = CreateObject(StoneDoor, LandscapeWidth() - 364, 448, NO_OWNER);
gate->DoDamage(50); // Upper doors are easier to destroy
AddEffect("AutoControl", gate, 100, 3, gate, nil, 2);
gate = CreateObject(StoneDoor, LandscapeWidth() - 340, 585, NO_OWNER);
AddEffect("AutoControl", gate, 100, 3, gate, nil, 2);
gate->SetAutoControl(2);
gate = CreateObject(StoneDoor, LandscapeWidth() - 340, 584, NO_OWNER);
gate->SetAutoControl(2);
gate = CreateObject(StoneDoor, LandscapeWidth() - 692, 544, NO_OWNER);
gate->DoDamage(80); // Middle doors even easier
wheel = CreateObject(SpinWheel, LandscapeWidth() - 660, 552, NO_OWNER);

View File

@ -1,84 +0,0 @@
// Stone door destructible, and auto control for the base.
#appendto StoneDoor
protected func Damage()
{
if (GetDamage() > 180)
{
if (!this)
return false;
var ctr = Contained();
// Transfer all contents to container.
while (Contents())
if (!ctr || !Contents()->Enter(ctr))
Contents()->Exit();
// Split components.
for (var i = 0, compid; compid = GetComponent(nil, i); ++i)
for (var j = 0; j < GetComponent(compid); ++j)
{
var comp = CreateObject(compid, nil, nil, GetOwner());
if (OnFire()) comp->Incinerate();
if (!ctr || !comp->Enter(ctr))
{
comp->SetR(Random(360));
comp->SetXDir(Random(3) - 1);
comp->SetYDir(Random(3) - 1);
comp->SetRDir(Random(3) - 1);
comp->SetClrModulation(RGB(240,210,200)); //give rocks the color of brick
}
}
RemoveObject();
}
return;
}
private func IsOpen()
{
if (GBackSolid(0, -20))
return true;
return false;
}
private func IsClosed()
{
if (GBackSolid(0, 19))
return true;
return false;
}
// Automatically open for team stored in effect var 0.
protected func FxAutoControlStart(object target, effect, int temporary, int team)
{
if (temporary == 0)
effect.team = team;
return 1;
}
protected func FxAutoControlTimer(object target, effect, int time)
{
var d = 0;
if (IsOpen())
d = 30;
var team = effect.team;
var open_door = false;
for (var clonk in FindObjects(Find_OCF(OCF_CrewMember), Find_InRect(-50, d - 30, 100, 60)))
{
var plr = clonk->GetOwner();
var plr_team = GetPlayerTeam(plr);
if (plr_team == team)
open_door = true;
else
{
open_door = false;
break;
}
}
if (open_door && IsClosed())
OpenGateDoor();
if (!open_door && IsOpen())
CloseGateDoor();
return 1;
}

View File

@ -5,6 +5,10 @@ Category=C4D_Structure
Width=8
Height=40
Offset=-4,-20
Vertices=2
VertexX=0,0,
VertexY=-19,19
VertexCNAT=4,8
SolidMask=8,0,8,40,0,0
Value=10
Mass=1000

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View File

@ -1,67 +1,139 @@
/*-- Stone Door --*/
/**
Stone Door
A door which can be used in scenarios with lots of bricks.
@authors Ringwaul, Maikel
*/
protected func Initialize()
{
SetAction("Door");
SetComDir(COMD_None);
SetComDir(COMD_Stop);
return;
}
public func OpenGateDoor()
/*-- Movement --*/
public func OpenDoor()
{
AddEffect("IntMoveGateUp", this, 100, 1, this);
SetComDir(COMD_Up);
Sound("GateMove");
return;
}
public func CloseGateDoor()
public func CloseDoor()
{
AddEffect("IntMoveGateDown", this, 100, 1, this);
SetComDir(COMD_Down);
Sound("GateMove");
return;
}
protected func FxIntMoveGateUpTimer(object target)
private func IsOpen()
{
if (GBackSolid(0, -20))
if (GetContact(-1) & CNAT_Top)
return true;
return false;
}
private func IsClosed()
{
if (GetContact(-1) & CNAT_Bottom)
return true;
return false;
}
protected func Hit()
{
Sound("GateHit.ogg");
return;
}
/*-- Automatic movement --*/
public func SetAutoControl(int team)
{
var effect = AddEffect("AutoControl", this, 100, 3, this);
effect.Team = team;
return;
}
protected func FxAutoControlTimer(object target, effect, int time)
{
var d = 0;
if (IsOpen())
d = 30;
var owner = GetOwner();
var team = effect.Team;
var open_door = false;
for (var clonk in FindObjects(Find_OCF(OCF_CrewMember), Find_InRect(-50, d - 30, 100, 60)))
{
Sound("GateHit.ogg");
SetYDir(0);
return -1;
var plr = clonk->GetOwner();
var plr_team = GetPlayerTeam(plr);
if (!Hostile(owner, plr) && plr != NO_OWNER)
open_door = true;
else if (plr_team == team)
open_door = true;
else
{
open_door = false;
break;
}
}
SetYDir(-5);
if (open_door && IsClosed())
OpenDoor();
if (!open_door && IsOpen())
CloseDoor();
return 1;
}
protected func FxIntMoveGateDownTimer(object target)
{
if (GBackSolid(0, 19))
{
Sound("GateHit.ogg");
SetYDir(0);
return -1;
}
SetYDir(5);
return 1;
}
/*-- Destruction --*/
func Definition(def)
private func GetStrength() { return 180; }
protected func Damage()
{
SetProperty("ActMap", {
Door = {
Prototype = Action,
Name = "Door",
Procedure = DFA_FLOAT,
Length = 1,
Delay = 1,
X = 0,
Y = 0,
Wdt = 8,
Hgt = 40,
NextAction = "Door",
},
}, def);
SetProperty("Name", "$Name$", def);
// Destroy if damage above strength.
if (GetDamage() > GetStrength())
{
CastObjects(Rock, 5, 20);
return RemoveObject();
}
// Change appearance.
DoGraphics();
return;
}
private func DoGraphics()
{
// Change appearance according to damage and strength.
if (GetDamage() > 3 * GetStrength() / 4)
SetGraphics("Cracked3");
else if (GetDamage() > GetStrength() / 2)
SetGraphics("Cracked2");
else if (GetDamage() > GetStrength() / 4)
SetGraphics("Cracked1");
else
SetGraphics("");
return;
}
local ActMap = {
Door = {
Prototype = Action,
Name = "Door",
Procedure = DFA_FLOAT,
Speed = 150,
Accel = 12,
Decel = 12,
Length = 1,
Delay = 1,
X = 0,
Y = 0,
Wdt = 8,
Hgt = 40,
NextAction = "Door",
},
};
local Name = "$Name$";

View File

@ -17,7 +17,7 @@ public func ControlUp(object clonk)
{
if (GetAction() == "Still" && targetdoor)
{
targetdoor->OpenGateDoor();
targetdoor->OpenDoor();
SetAction("SpinLeft");
Sound("Chain.ogg");
}
@ -27,44 +27,46 @@ public func ControlDown(object clonk)
{
if (GetAction() == "Still" && targetdoor)
{
targetdoor->CloseGateDoor();
targetdoor->CloseDoor();
SetAction("SpinRight");
Sound("Chain.ogg");
}
}
func Definition(def) {
SetProperty("ActMap", {
Still = {
Prototype = Action,
Name = "Still",
Procedure = DFA_NONE,
Length = 1,
Delay = 1,
NextAction = "Still",
Animation = "SpinLeft",
},
SpinLeft = {
Prototype = Action,
Name = "SpinLeft",
Procedure = DFA_NONE,
Length = 36,
Delay = 1,
NextAction = "Still",
Animation = "SpinLeft",
},
SpinRight = {
Prototype = Action,
Name = "SpinRight",
Procedure = DFA_NONE,
Length = 36,
Delay = 1,
NextAction = "Still",
Animation = "SpinRight",
},
}, def);
SetProperty("Name", "$Name$", def);
SetProperty("PictureTransformation", Trans_Mul(Trans_Scale(800), Trans_Translate(0,0,0),Trans_Rotate(-20,1,0,0),Trans_Rotate(-30,0,1,0)), def);
SetProperty("MeshTransformation", Trans_Rotate(-13,0,1,0));
}
local ActMap = {
Still = {
Prototype = Action,
Name = "Still",
Procedure = DFA_NONE,
Length = 1,
Delay = 1,
NextAction = "Still",
Animation = "SpinLeft",
},
SpinLeft = {
Prototype = Action,
Name = "SpinLeft",
Procedure = DFA_NONE,
Length = 36,
Delay = 1,
NextAction = "Still",
Animation = "SpinLeft",
},
SpinRight = {
Prototype = Action,
Name = "SpinRight",
Procedure = DFA_NONE,
Length = 36,
Delay = 1,
NextAction = "Still",
Animation = "SpinRight",
},
};
local Name = "$Name$";
local Touchable = 2;
func Definition(def)
{
SetProperty("PictureTransformation", Trans_Mul(Trans_Scale(800), Trans_Translate(0,0,0),Trans_Rotate(-20,1,0,0),Trans_Rotate(-30,0,1,0)), def);
SetProperty("MeshTransformation", Trans_Rotate(-13,0,1,0), def);
}

View File

@ -147,7 +147,7 @@ global func FxIntOpenGateTimer(object target)
if (ObjectCount(Find_ID(SwordTarget)) == 0)
{
// Open gate.
target->OpenGateDoor();
target->OpenDoor();
return -1;
}
return 1;