Scripted the Hatch that Ringwaul made ages ago. Can be built on top of basements (or without) to make a vertical opening.
|
@ -1,15 +0,0 @@
|
|||
[DefCore]
|
||||
id=Hatch
|
||||
Version=6,0
|
||||
Category=C4D_Structure
|
||||
Width=26
|
||||
Height=26
|
||||
Offset=-13,-13
|
||||
Vertices=5
|
||||
VertexX=0,-12,12,-10,10
|
||||
VertexY=0,0,0,6,6
|
||||
VertexFriction=100,100,100,100,100
|
||||
VertexCNAT=64,1,2,1,2
|
||||
SolidMask=0,0,20,20,0,0
|
||||
Construction=1
|
||||
Mass=10
|
Before Width: | Height: | Size: 272 B |
|
@ -1,7 +0,0 @@
|
|||
[DefCore]
|
||||
id=Hatch_Graphic
|
||||
Version=6,0
|
||||
Width=26
|
||||
Height=26
|
||||
Offset=-13,-13
|
||||
Category=C4D_Structure
|
|
@ -1,45 +0,0 @@
|
|||
//Hatch Graphic
|
||||
|
||||
local hatch_anim;
|
||||
local parent;
|
||||
|
||||
protected func Initialize()
|
||||
{
|
||||
SetProperty("MeshTransformation", Trans_Mul(Trans_Translate(0,-10000), Trans_Rotate(-10,0,1,0), Trans_Rotate(-8,1,0,0)));
|
||||
}
|
||||
|
||||
public func SetHatchParent(object hatch)
|
||||
{
|
||||
parent = hatch;
|
||||
}
|
||||
|
||||
func Anim(string anim_name)
|
||||
{
|
||||
var animstart = 0;
|
||||
if(hatch_anim)
|
||||
{
|
||||
if(GetAnimationPosition(hatch_anim) != GetAnimationLength(anim_name))
|
||||
{
|
||||
animstart = GetAnimationLength(anim_name) - GetAnimationPosition(hatch_anim);
|
||||
}
|
||||
}
|
||||
|
||||
StopAnimation(hatch_anim);
|
||||
hatch_anim = PlayAnimation(anim_name, 5, Anim_Linear(animstart, 0, GetAnimationLength(anim_name), 14, ANIM_Hold));
|
||||
}
|
||||
|
||||
local ActMap = {
|
||||
Attach = {
|
||||
Prototype = Action,
|
||||
Name = "Attach",
|
||||
Procedure = DFA_ATTACH,
|
||||
Directions = 1,
|
||||
X = 0,
|
||||
Y = 0,
|
||||
Wdt = 26,
|
||||
Hgt = 26,
|
||||
NextAction = "Attach",
|
||||
},
|
||||
};
|
||||
|
||||
local Plane = 100;
|
|
@ -1,58 +0,0 @@
|
|||
/*
|
||||
Hatch
|
||||
Author: Ringwaul
|
||||
*/
|
||||
|
||||
local graphic;
|
||||
|
||||
protected func Initialize()
|
||||
{
|
||||
SetAction("Hatch");
|
||||
graphic = CreateObjectAbove(Hatch_Graphic);
|
||||
graphic->SetAction("Attach", this);
|
||||
graphic->SetHatchParent(this);
|
||||
return 1;
|
||||
}
|
||||
|
||||
func ControlUp(object clonk)
|
||||
{
|
||||
if(GetPhase() != 0)
|
||||
{
|
||||
graphic->Anim("Close");
|
||||
SetPhase(0);
|
||||
SetSolidMask(0,0,26,26,0,0);
|
||||
}
|
||||
}
|
||||
|
||||
func ControlDown(object clonk)
|
||||
{
|
||||
if(GetPhase() != 1)
|
||||
{
|
||||
graphic->Anim("Open");
|
||||
SetPhase(1);
|
||||
SetSolidMask(26,0,26,26,0,0);
|
||||
}
|
||||
}
|
||||
|
||||
protected func Definition(def)
|
||||
{
|
||||
SetProperty("PictureTransformation", Trans_Mul(Trans_Translate(0,-3000,-5000), Trans_Rotate(-30,1,0,0), Trans_Rotate(30,0,1,0), Trans_Translate(1000,1,0)),def);
|
||||
}
|
||||
|
||||
local Name = "$Name$";
|
||||
local Touchable = 2;
|
||||
local ActMap = {
|
||||
Hatch = {
|
||||
Prototype = Action,
|
||||
Name = "Hatch",
|
||||
Procedure = DFA_NONE,
|
||||
Directions = 1,
|
||||
FlipDir = 0,
|
||||
Length = 2,
|
||||
Delay = 0,
|
||||
X = 0,
|
||||
Y = 0,
|
||||
Wdt = 1,
|
||||
Hgt = 1,
|
||||
},
|
||||
};
|
|
@ -1 +0,0 @@
|
|||
Name=Hatch
|
|
@ -1 +0,0 @@
|
|||
Name=Hatch
|
|
@ -0,0 +1,15 @@
|
|||
[DefCore]
|
||||
id=Hatch
|
||||
Version=8,0
|
||||
Category=C4D_Structure
|
||||
Width=26
|
||||
Height=26
|
||||
Offset=-13,-13
|
||||
Vertices=4
|
||||
VertexX=-12,-12,12,12
|
||||
VertexY=-3,3,-3,3
|
||||
VertexFriction=100,100,100,100
|
||||
SolidMask=0,0,26,4,0,11
|
||||
Construction=1
|
||||
Mass=1000
|
||||
Exclusive=1
|
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 24 KiB |
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
|
@ -0,0 +1,15 @@
|
|||
[DefCore]
|
||||
id=HatchBasement
|
||||
Version=8,0
|
||||
Category=C4D_Structure
|
||||
Width=40
|
||||
Height=8
|
||||
Offset=-20,-4
|
||||
Vertices=5
|
||||
VertexX=0,-20,-20,20,20
|
||||
VertexY=0,-4,4,-4,4
|
||||
VertexFriction=100,100,100,100,100
|
||||
Mass=2000
|
||||
Exclusive=1
|
||||
Construction=1
|
||||
SolidMask=0,0,40,8,0,0
|
After Width: | Height: | Size: 16 KiB |
|
@ -0,0 +1,18 @@
|
|||
/**
|
||||
Basement
|
||||
Provides basements to structures, but can also be built as a single object.
|
||||
|
||||
@author: Maikel
|
||||
*/
|
||||
|
||||
#include Basement
|
||||
|
||||
public func IsHammerBuildable() { return false; }
|
||||
|
||||
/*-- Properties --*/
|
||||
|
||||
local Name = "$Name$";
|
||||
local Description ="$Description$";
|
||||
local HitPoints = 80;
|
||||
local Plane = 190;
|
||||
local Components = {Rock = 2};
|
After Width: | Height: | Size: 2.8 KiB |
|
@ -0,0 +1,3 @@
|
|||
Name=Fundament
|
||||
Description=Eine stabile Basis für Gebäude.
|
||||
Width=Breite
|
|
@ -0,0 +1,3 @@
|
|||
Name=Basement
|
||||
Description=A stable base for any building.
|
||||
Width=Width
|
|
@ -0,0 +1,247 @@
|
|||
/*
|
||||
Hatch
|
||||
|
||||
@authors: Clonkonaut, Ringwaul (Graphics)
|
||||
*/
|
||||
|
||||
#include Library_Structure
|
||||
|
||||
local opened = false;
|
||||
|
||||
/*-- Engine Callbacks --*/
|
||||
|
||||
func Construction()
|
||||
{
|
||||
SetProperty("MeshTransformation", Trans_Mul(Trans_Translate(0,-10000), Trans_Rotate(-10,0,1,0), Trans_Rotate(-8,1,0,0)));
|
||||
SetCategory(C4D_StaticBack);
|
||||
|
||||
return _inherited(...);
|
||||
}
|
||||
|
||||
/*-- Callbacks --*/
|
||||
|
||||
public func IsHammerBuildable() { return true; }
|
||||
|
||||
public func DoConstructionEffects(object construction_site)
|
||||
{
|
||||
// The hatch sets itself a bit lower after it has been placed with the construction previewer
|
||||
SetPosition(GetX(), GetY()+4);
|
||||
return false;
|
||||
}
|
||||
|
||||
public func NoConstructionFlip() { return true; }
|
||||
|
||||
public func ConstructionCombineWith() { return "IsBasement"; }
|
||||
|
||||
public func ConstructionCombineDirection(object other) { return CONSTRUCTION_STICK_Top; }
|
||||
|
||||
public func ConstructionCombineOffset(object other)
|
||||
{
|
||||
return [0, 0];
|
||||
}
|
||||
|
||||
public func CombineWith(object stick_to)
|
||||
{
|
||||
if (stick_to && stick_to->~IsBasement())
|
||||
stick_to->SetParent(this);
|
||||
|
||||
SetPosition(GetX(), GetY()+1);
|
||||
}
|
||||
|
||||
/*-- Library overloads --*/
|
||||
|
||||
func MoveOutOfSolidMask()
|
||||
{
|
||||
// Find all objects inside the solid mask which are stuck.
|
||||
var lying_around = FindObjects(Find_Or(Find_Category(C4D_Vehicle), Find_Category(C4D_Object), Find_Category(C4D_Living)), Find_InRect(-13, -2, 26, 4), Find_NoContainer());
|
||||
// Move up these objects.
|
||||
for (var obj in lying_around)
|
||||
{
|
||||
var x = obj->GetX();
|
||||
var y = obj->GetY();
|
||||
var delta_y = 0;
|
||||
var max_delta = obj->GetObjHeight();
|
||||
// Move up object until it is not stuck any more.
|
||||
while (obj->Stuck() || obj->GetContact(-1, CNAT_Bottom))
|
||||
{
|
||||
// Only move up the object by at most its height plus the basements height.
|
||||
if (delta_y > max_delta)
|
||||
{
|
||||
obj->SetPosition(x, y);
|
||||
break;
|
||||
}
|
||||
delta_y++;
|
||||
obj->SetPosition(x, y - delta_y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*-- Basement --*/
|
||||
|
||||
public func GetBasementWidth()
|
||||
{
|
||||
return 40;
|
||||
}
|
||||
|
||||
public func SetBasement(object to_basement)
|
||||
{
|
||||
_inherited(to_basement);
|
||||
|
||||
if (!to_basement) return;
|
||||
|
||||
to_basement->ChangeDef(HatchBasement);
|
||||
}
|
||||
|
||||
public func GetBasementOffset() { return [0, -15]; }
|
||||
|
||||
/*-- Interaction --*/
|
||||
|
||||
public func IsInteractable(object clonk)
|
||||
{
|
||||
if (GetCon() < 100)
|
||||
return false;
|
||||
if (opened && FindClonkInHatchArea())
|
||||
return false;
|
||||
|
||||
if (Hostile(clonk->GetOwner(), GetOwner()))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public func GetInteractionMetaInfo(object clonk)
|
||||
{
|
||||
if (!ActIdle())
|
||||
return { Description = "$Close$", IconName = nil, IconID = Icon_Exit, Selected = false };
|
||||
return { Description = "$Open$", IconName = nil, IconID = Icon_Enter, Selected = false };
|
||||
}
|
||||
|
||||
public func Interact(object clonk)
|
||||
{
|
||||
if (ActIdle())
|
||||
return DoOpen();
|
||||
if (GetAction() == "Open")
|
||||
return DoClose();
|
||||
return false;
|
||||
}
|
||||
|
||||
/*-- Open/Close --*/
|
||||
|
||||
public func DoOpen()
|
||||
{
|
||||
SetAction("Open");
|
||||
Sound("Structures::DoorOpen?");
|
||||
return true;
|
||||
}
|
||||
|
||||
public func DoClose()
|
||||
{
|
||||
if (opened)
|
||||
{
|
||||
if (FindClonkInHatchArea())
|
||||
return false;
|
||||
SetAction("Close");
|
||||
Sound("Structures::DoorClose?");
|
||||
opened = false;
|
||||
return true;
|
||||
}
|
||||
if (GetAction() == "Open")
|
||||
{
|
||||
var phase = 2 - GetPhase();
|
||||
SetAction("Close");
|
||||
Sound("Structures::DoorClose?");
|
||||
SetPhase(phase);
|
||||
return true;
|
||||
}
|
||||
SetAction("Close");
|
||||
Sound("Structures::DoorClose?");
|
||||
return true;
|
||||
}
|
||||
|
||||
func FindClonkInHatchArea()
|
||||
{
|
||||
return FindObject(Find_InRect(-16, -12, 32, 24), Find_OCF(OCF_CrewMember), Find_OCF(OCF_Alive), Find_AnyLayer(), Find_NoContainer());
|
||||
}
|
||||
|
||||
func ChangeSolidMask()
|
||||
{
|
||||
if (opened)
|
||||
return;
|
||||
if (GetAction() == "Close") // Upon closing, the solid mask must reappear instantaneously
|
||||
// to prevent clonks from getting stuck
|
||||
return SetSolidMask(0,0, 26,4, 0,11);
|
||||
|
||||
var phase = GetPhase();
|
||||
var width = 26 - 8*phase;
|
||||
|
||||
if (phase == 3) {
|
||||
ClosingTimer();
|
||||
width -= 2;
|
||||
}
|
||||
|
||||
SetSolidMask(0,0, width,4, 0,11);
|
||||
}
|
||||
|
||||
func ClosingTimer()
|
||||
{
|
||||
opened = true;
|
||||
|
||||
ScheduleCall(this, "CheckForClose", 15);
|
||||
}
|
||||
|
||||
func CheckForClose()
|
||||
{
|
||||
if (GetAction() == "Close" || ActIdle())
|
||||
return;
|
||||
|
||||
if (!FindClonkInHatchArea())
|
||||
return ScheduleCall(this, "CloseForReal", 25);
|
||||
|
||||
ScheduleCall(this, "CheckForClose", 5);
|
||||
}
|
||||
|
||||
func CloseForReal()
|
||||
{
|
||||
// One final check that the hatch is clear
|
||||
if (FindClonkInHatchArea())
|
||||
return ScheduleCall(this, "CheckForClose", 5);
|
||||
|
||||
DoClose();
|
||||
}
|
||||
|
||||
/*-- Display --*/
|
||||
|
||||
func Definition(def)
|
||||
{
|
||||
SetProperty("PictureTransformation", Trans_Mul(Trans_Translate(0,-3000,-5000), Trans_Rotate(-30,1,0,0), Trans_Rotate(30,0,1,0), Trans_Translate(1000,1,0)), def);
|
||||
return _inherited(def);
|
||||
}
|
||||
|
||||
/*-- Properties --*/
|
||||
|
||||
local ActMap = {
|
||||
Open = {
|
||||
Prototype = Action,
|
||||
Name = "Open",
|
||||
Length = 3,
|
||||
Delay = 5,
|
||||
Animation = "Open",
|
||||
NextAction = "Hold",
|
||||
PhaseCall = "ChangeSolidMask"
|
||||
},
|
||||
Close = {
|
||||
Prototype = Action,
|
||||
Name = "Close",
|
||||
Length = 3,
|
||||
Delay = 5,
|
||||
Animation = "Close",
|
||||
NextAction = "Idle",
|
||||
PhaseCall = "ChangeSolidMask"
|
||||
},
|
||||
};
|
||||
|
||||
local Name = "$Name$";
|
||||
local Description = "$Description$";
|
||||
local BlastIncinerate = 100;
|
||||
local HitPoints = 70;
|
||||
local Components = {Wood = 2};
|
After Width: | Height: | Size: 2.8 KiB |
|
@ -0,0 +1,4 @@
|
|||
Name=Luke
|
||||
Description=Eine einfache Bodenluke. Kann nach Belieben geöffnet werden, um einen vertikalen Durchlass zu ermöglichen. Kann auf einfachen Fundamenten errichtet werden.
|
||||
Open=Öffnen
|
||||
Close=Schließen
|
|
@ -0,0 +1,4 @@
|
|||
Name=Hatch
|
||||
Description=A simple trap door. Can be opened at will and be passed vertically. Can be built on top of regular basement.
|
||||
Open=Open
|
||||
Close=Close
|