forked from Mirrors/openclonk
Zaphive: now C4D_Object + DFA_ATTACH instead of C4D_StaticBack (#1653)
Which means that you can 1) Drag around the tree / nest in editor mode 2) Shoot zapnests that were put into a catapult by a scenario designer 3) Can RemoveObject a tree and the nest will fall down (instead of keep floating) 4) Can put zap nests in earth (just like in CR!)epoxy
parent
0ac6093b1a
commit
71fa846016
|
@ -1,13 +1,14 @@
|
|||
[DefCore]
|
||||
id=Zaphive
|
||||
Version=6,1
|
||||
Category=C4D_StaticBack
|
||||
Category=C4D_Object
|
||||
Width=6
|
||||
Height=8
|
||||
Offset=-3,-4
|
||||
Value=5
|
||||
Mass=2
|
||||
Vertices=4
|
||||
VertexX=0,0,-2,2
|
||||
VertexY=-3,3,0,0
|
||||
VertexFriction=100,100,100,100
|
||||
Vertices=5
|
||||
VertexX=0,0,-2,2,0
|
||||
VertexY=-3,3,0,0,0
|
||||
VertexFriction=100,100,100,100
|
||||
Rotate=1
|
||||
|
|
|
@ -38,15 +38,29 @@ local tree;
|
|||
public func AttachToTree(object to_attach)
|
||||
{
|
||||
tree = to_attach;
|
||||
// Move down (this might break placement by the tree but...yeah!)
|
||||
SetPosition(GetX(), GetY()+4);
|
||||
// Constant offset. The old comment didn't say why this was necessary.
|
||||
var additional_y_offset = 4;
|
||||
// Calculate the offset from the tree, taking into account the target vertex' offset.
|
||||
var offset_x = GetX() - to_attach->GetX() - to_attach->GetVertex(0, VTX_X);
|
||||
var offset_y = GetY() - to_attach->GetY() - to_attach->GetVertex(0, VTX_Y) + additional_y_offset;
|
||||
SetAction("Attach", to_attach);
|
||||
// And specify/set the vertex to attach.
|
||||
SetActionData(4 << 8);
|
||||
SetVertexXY(4, -offset_x, -offset_y);
|
||||
}
|
||||
|
||||
// Called by trees
|
||||
public func DetachFromTree()
|
||||
{
|
||||
AttachTargetLost();
|
||||
}
|
||||
|
||||
public func AttachTargetLost()
|
||||
{
|
||||
// Fall down
|
||||
SetCategory(GetCategory() & ~C4D_StaticBack);
|
||||
SetAction("Idle");
|
||||
SetVertexXY(4, 0, 0);
|
||||
SetRDir(RandomX(-3, 3));
|
||||
}
|
||||
|
||||
/* Creation */
|
||||
|
@ -75,4 +89,14 @@ private func Hit2()
|
|||
RemoveObject();
|
||||
}
|
||||
|
||||
local ActMap = {
|
||||
Attach = {
|
||||
Prototype = Action,
|
||||
Procedure = DFA_ATTACH,
|
||||
FacetBase = 1,
|
||||
Length = 1,
|
||||
Delay = 0
|
||||
},
|
||||
};
|
||||
|
||||
local Name = "$Name$";
|
Loading…
Reference in New Issue