add usage to lorry to dump contents into landscape

shapetextures
Maikel de Vries 2015-12-24 18:29:10 +01:00
parent 1bd37eb5c1
commit 50930fec67
4 changed files with 104 additions and 9 deletions

View File

@ -6,16 +6,16 @@ ContactCalls=1
Width=22
Height=16
Offset=-11,-8
Vertices=7
VertexX=-8,7,-6,0,5,-8,7
VertexY=-6,-6,7,7,7,5,5
VertexCNAT=5,6,9,8,10,9,10
VertexFriction=80,80,10,10,10,20,20
Vertices=9
VertexX=-8,7,-6,0,5,-8,7,-8,7
VertexY=-6,-6,7,7,7,5,5,-1,-1
VertexCNAT=5,6,9,8,10,9,10,1,2
VertexFriction=80,80,10,10,10,20,20,60,60
Value=20
Mass=75
Components=Metal=2;Wood=1;
Collection=-12,-8,24,10
GrabPutGet=C4D_GrabGet|C4D_GrabPut
Rotate=30
Rotate=55
UprightAttach=8
BorderBound=1

View File

@ -7,7 +7,6 @@
#include Library_ElevatorControl
local content_menu;
local drive_anim;
local tremble_anim;
local wheel_sound;
@ -40,6 +39,98 @@ protected func Hit3()
Sound("Hits::Materials::Metal::DullMetalHit?");
}
/*-- Content Dumping --*/
public func HoldingEnabled() { return true; }
public func ControlUseStart(object clonk, int x, int y)
{
var direction = DIR_Left;
if (x > 0)
direction = DIR_Right;
if (!GetEffect("DumpContents", this))
AddEffect("DumpContents", this, 100, 1, this, nil, direction);
return true;
}
public func ControlUseHolding(object clonk, int x, int y)
{
var direction = DIR_Left;
if (x > 0)
direction = DIR_Right;
var effect = GetEffect("DumpContents", this);
if (effect)
effect.dump_dir = direction;
return true;
}
public func ControlUseStop(object clonk, int x, int y)
{
RemoveEffect("DumpContents", this);
return true;
}
public func ControlUseCancel(object clonk, int x, int y)
{
RemoveEffect("DumpContents", this);
return true;
}
public func FxDumpContentsStart(object target, proplist effect, int temp, int direction)
{
if (temp)
return FX_OK;
// The time it takes to dump the contents depends on the mass of the lorry.
effect.dump_strength = BoundBy(1000 / GetMass(), 3, 8);
effect.dump_dir = direction;
// Rotate the lorry into the requested direction.
var rdir = -effect.dump_strength;
if (effect.dump_dir == DIR_Right)
rdir = effect.dump_strength;
SetRDir(rdir);
return FX_OK;
}
public func FxDumpContentsTimer(object target, proplist effect, int time)
{
// Rotate the lorry into the requested direction.
var rdir = -effect.dump_strength;
if (effect.dump_dir == DIR_Right)
rdir = effect.dump_strength;
SetRDir(rdir);
// Dump one item every some frames if the angle is above 45 degrees. Only do this if the effect is at least active
// for 10 frames to prevent an accidental click while holding the lorry to dump some of its contents.
if (time >= 10 && ((effect.dump_dir == DIR_Left && GetR() < -45) || (effect.dump_dir == DIR_Right && GetR() > 45)))
{
if (!Random(3))
{
var x = RandomX(6, 8) * Sign(GetR());
var xdir = RandomX(70, 90) * Sign(GetR());
var random_content = FindObject(Find_Container(this), Sort_Random());
if (random_content)
{
random_content->Exit(x, RandomX(2, 3), Random(360), 0, 0, RandomX(-5, 5));
random_content->SetXDir(xdir, 100);
AddEffect("BlockCollectionByLorry", random_content, 100, 8, this);
}
}
}
return FX_OK;
}
public func FxDumpContentsStop(object target, proplist effect, int reason, bool temp)
{
if (temp)
return FX_OK;
// Stop rotating the lorry.
SetRDir(0);
return FX_OK;
}
public func FxBlockCollectionByLorryTimer() { return FX_Execute_Kill; }
/*-- Contents --*/
private func MaxContentsCount()
@ -49,6 +140,10 @@ private func MaxContentsCount()
protected func RejectCollect(id object_id, object obj)
{
// Collection maybe blocked if this object was just dumped.
if (!obj->Contained() && GetEffect("BlockCollectionByLorry", obj))
return true;
// Objects can still be collected.
if (ContentsCount() < this->MaxContentsCount())
{

View File

@ -2,4 +2,4 @@ TxtControl=Steuerung
TxtLorryisfull=Lore ist|voll.
TxtLoadUp=Einladen
Name=Lore
Description=Erleichtert den Transport größerer Materialmengen. Fasst bis zu 50 Objekte.
Description=Erleichtert den Transport größerer Materialmengen. Fasst bis zu 50 Objekte. Drücke [Benutzen] um den Inhalt der Lore aus zu kippen.

View File

@ -2,4 +2,4 @@ TxtControl=Control
TxtLorryisfull=Lorry is full!
TxtLoadUp=Load up
Name=Lorry
Description=Useful to transport large amounts of material. Holds up to 50 items.
Description=Useful to transport large amounts of material. Holds up to 50 items. By pressing [Use] while holding the lorry its contents can be dumped.