Updates cable cars / lorries with new graphics by pluto. Made everything work again. Integrated control into the interaction menu.
Still needs a lot of work but I'm getting there.liquid_container
|
@ -1,25 +0,0 @@
|
|||
/**
|
||||
Tools Workshop
|
||||
|
||||
@author Clonkonaut
|
||||
*/
|
||||
|
||||
#appendto ToolsWorkshop
|
||||
|
||||
local is_station;
|
||||
|
||||
protected func Initialize()
|
||||
{
|
||||
is_station = true;
|
||||
return _inherited();
|
||||
}
|
||||
|
||||
// Appears in the bottom interaction bar, if cable is connected
|
||||
public func IsInteractable()
|
||||
{
|
||||
if (GetLength(this->~GetDestinations())) return true;
|
||||
return _inherited(...);
|
||||
}
|
||||
|
||||
public func GetCableXOffset() { return 15; }
|
||||
public func GetCableYOffset() { return 5; }
|
|
@ -1,9 +1,6 @@
|
|||
[DefCore]
|
||||
id=CableLine
|
||||
Version=6,0
|
||||
Version=7,0
|
||||
Category=C4D_StaticBack
|
||||
Width=12
|
||||
Height=8
|
||||
Offset=-6,-4
|
||||
Vertices=2
|
||||
#Line=1
|
||||
Line=1
|
Before Width: | Height: | Size: 141 B After Width: | Height: | Size: 141 B |
|
@ -0,0 +1,74 @@
|
|||
/*-- Cable line --*/
|
||||
|
||||
func Initialize()
|
||||
{
|
||||
SetAction("Connect");
|
||||
SetVertexXY(0, GetX(), GetY());
|
||||
SetVertexXY(1, GetX(), GetY());
|
||||
SetProperty("LineColors", [RGB(20, 20, 50), RGB(20, 20, 50)]);
|
||||
}
|
||||
|
||||
public func IsCableLine()
|
||||
{
|
||||
return GetAction() == "Connect";
|
||||
}
|
||||
|
||||
/** Returns whether this cable is connected to an object. */
|
||||
public func IsConnectedTo(object obj)
|
||||
{
|
||||
return GetActionTarget(0) == obj || GetActionTarget(1) == obj;
|
||||
}
|
||||
|
||||
/** Returns the object which is connected to obj through this pipe. */
|
||||
public func GetConnectedObject(object obj)
|
||||
{
|
||||
if (GetActionTarget(0) == obj)
|
||||
return GetActionTarget(1);
|
||||
if (GetActionTarget(1) == obj)
|
||||
return GetActionTarget(0);
|
||||
return;
|
||||
}
|
||||
|
||||
public func SetConnectedObjects(obj1, obj2)
|
||||
{
|
||||
SetActionTargets(obj1, obj2);
|
||||
obj1->AddCableConnection(this);
|
||||
}
|
||||
|
||||
protected func LineBreak(bool no_msg)
|
||||
{
|
||||
Sound("Objects::Connect");
|
||||
if (!no_msg)
|
||||
BreakMessage();
|
||||
return;
|
||||
}
|
||||
|
||||
private func BreakMessage()
|
||||
{
|
||||
var line_end = GetActionTarget(0);
|
||||
if (line_end->GetID() != CableLorryReel)
|
||||
line_end = GetActionTarget(1);
|
||||
if (line_end->Contained()) line_end = line_end->Contained();
|
||||
|
||||
line_end->Message("$TxtLinebroke$");
|
||||
return;
|
||||
}
|
||||
|
||||
public func SaveScenarioObject(props)
|
||||
{
|
||||
if (!inherited(props, ...)) return false;
|
||||
SaveScenarioObjectAction(props);
|
||||
if (IsCableLine()) props->AddCall("Connection", this, "SetConnectedObjects", GetActionTarget(0), GetActionTarget(1));
|
||||
return true;
|
||||
}
|
||||
|
||||
local ActMap = {
|
||||
Connect = {
|
||||
Prototype = Action,
|
||||
Name = "Connect",
|
||||
Procedure = DFA_CONNECT,
|
||||
NextAction = "Connect"
|
||||
}
|
||||
};
|
||||
|
||||
local Name = "$Name$";
|
|
@ -0,0 +1,2 @@
|
|||
TxtLinebroke=Seil gerissen
|
||||
Name=Seilbahnseil
|
Before Width: | Height: | Size: 6.8 KiB After Width: | Height: | Size: 6.8 KiB |
|
@ -9,7 +9,6 @@ public func IsToolProduct() { return true; }
|
|||
|
||||
/*-- Line connection --*/
|
||||
|
||||
// Use will connect power line to building at the clonk's position.
|
||||
protected func ControlUse(object clonk, int x, int y)
|
||||
{
|
||||
// Is there an object which accepts power lines?
|
||||
|
@ -17,20 +16,20 @@ protected func ControlUse(object clonk, int x, int y)
|
|||
// No such object -> message.
|
||||
if (!obj)
|
||||
return clonk->Message("$TxtNoNewLine$");
|
||||
// Is there a power line connected to this wire roll?
|
||||
// Is there a cable connected to this wire roll?
|
||||
var line = FindObject(Find_CableLine());
|
||||
// There already is a power line.
|
||||
// There already is a cable
|
||||
if (line)
|
||||
{
|
||||
if (obj == line->GetActionTarget(0) || obj == line->GetActionTarget(1))
|
||||
{
|
||||
// Power line is already connected to obj -> remove line.
|
||||
// Cable is already connected to obj -> remove line.
|
||||
line->RemoveObject();
|
||||
Sound("Objects::Connect");
|
||||
clonk->Message("$TxtLineRemoval$");
|
||||
return true;
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
// Connect existing power line to obj.
|
||||
if(line->GetActionTarget(0) == this)
|
||||
|
@ -40,15 +39,13 @@ protected func ControlUse(object clonk, int x, int y)
|
|||
else
|
||||
return;
|
||||
Sound("Objects::Connect");
|
||||
line->SetAction("Wait");
|
||||
line->UpdateDraw();
|
||||
obj->AddCableConnection(line);
|
||||
clonk->Message("$TxtConnect$", obj->GetName());
|
||||
//RemoveObject();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else // A new power line needs to be created.
|
||||
else // A new cable needs to be created.
|
||||
{
|
||||
line = CreateObjectAbove(CableLine, 0, 0, NO_OWNER);
|
||||
line->SetActionTargets(this, obj);
|
||||
|
@ -68,4 +65,4 @@ private func Find_CableLine(object obj)
|
|||
|
||||
local Name = "$Name$";
|
||||
local Description = "$Description$";
|
||||
local Collectible = 1;
|
||||
local Collectible = 1;
|
|
@ -0,0 +1,4 @@
|
|||
[DefCore]
|
||||
id=GUI_DestinationSelectionMenu
|
||||
Version=8,0
|
||||
Category=C4D_StaticBack | C4D_Environment
|
|
@ -0,0 +1,193 @@
|
|||
/**
|
||||
DestinationSelectionMenu
|
||||
Handles the destination selection for cable cars.
|
||||
|
||||
@author Clonkonaut
|
||||
*/
|
||||
|
||||
local Name = "$Name$";
|
||||
local Description = "$Description$";
|
||||
|
||||
// used as a static function
|
||||
public func CreateFor(object cursor, object car, object station)
|
||||
{
|
||||
if (!cursor) return;
|
||||
if (!car) return;
|
||||
if (!station) return;
|
||||
|
||||
var obj = CreateObject(GUI_DestinationSelectionMenu, AbsX(0), AbsY(0), cursor->GetOwner());
|
||||
obj.Visibility = VIS_Owner;
|
||||
|
||||
obj->Init(cursor, car, station);
|
||||
cursor->SetMenu(obj);
|
||||
return obj;
|
||||
}
|
||||
|
||||
// The Clonk whom the menu was opened for
|
||||
local cursor;
|
||||
// The menu id of the opened menu
|
||||
local menu_id;
|
||||
// The cable car which opened this menu
|
||||
local cable_car;
|
||||
// The station the cable car is hooked up to
|
||||
local cable_station;
|
||||
// A dummy object used to bring light to stations when previewed
|
||||
local dummy;
|
||||
|
||||
public func Close() { return RemoveObject(); }
|
||||
public func IsDestinationMenu() { return true; }
|
||||
public func Show() { this.Visibility = VIS_Owner; return true; }
|
||||
public func Hide() { this.Visibility = VIS_None; return true; }
|
||||
// Called when the menu is open and the player clicks outside.
|
||||
public func OnMouseClick() { return Close(); }
|
||||
|
||||
func Destruction()
|
||||
{
|
||||
if (menu_id)
|
||||
GuiClose(menu_id);
|
||||
if (dummy)
|
||||
dummy->RemoveObject();
|
||||
if (cursor)
|
||||
SetPlrView(cursor->GetOwner(), cursor, true);
|
||||
}
|
||||
|
||||
public func Init(object cursor, object car, object station)
|
||||
{
|
||||
this.cursor = cursor;
|
||||
this.cable_car = car;
|
||||
this.cable_station = station;
|
||||
this.dummy = CreateObject(Dummy, AbsX(station->GetX()), AbsY(station->GetY()), GetOwner());
|
||||
dummy.Visibility = VIS_Owner;
|
||||
dummy->SetLightRange(5, 20);
|
||||
|
||||
var dest_list = station->GetDestinationList(nil);
|
||||
|
||||
var dest_menu = {
|
||||
Target = this,
|
||||
Decoration = GUI_MenuDeco,
|
||||
BackgroundColor = RGB(0, 0, 0),
|
||||
Bottom = "3em",
|
||||
Left = "50% - 5em",
|
||||
Right = "50% + 5em",
|
||||
Priority = 1,
|
||||
Player = cursor->GetOwner(),
|
||||
caption = {
|
||||
Text = "$SelectDestination$",
|
||||
Bottom = "1em",
|
||||
Priority = 2,
|
||||
},
|
||||
buttons = {
|
||||
Top = "1em",
|
||||
Style = GUI_GridLayout,
|
||||
Priority = 999
|
||||
}
|
||||
};
|
||||
|
||||
FillDestinationButtons(dest_menu, dest_list);
|
||||
|
||||
GuiOpen(dest_menu);
|
||||
}
|
||||
|
||||
func FillDestinationButtons(proplist menu, array list)
|
||||
{
|
||||
var priority = 1000;
|
||||
// Left button
|
||||
var left = {
|
||||
Right = "2em",
|
||||
Bottom = "2em",
|
||||
Symbol = Icon_LibraryCableCar,
|
||||
GraphicsName = "LeftGrey",
|
||||
BackgroundColor = { Std = RGB(0, 0, 0), Hover = RGB(100, 30, 30) },
|
||||
Priority = ++priority
|
||||
};
|
||||
if (list[3] > 3)
|
||||
{
|
||||
left.OnMouseIn = GuiAction_SetTag("Hover");
|
||||
left.OnMouseOut = GuiAction_SetTag("Std");
|
||||
left.GraphicsName = "Left";
|
||||
left.OnClick = GuiAction_Call(this, "ShiftSelection", list[0]);
|
||||
}
|
||||
// List buttons
|
||||
var list_button = {
|
||||
Right = "2em",
|
||||
Bottom = "2em",
|
||||
BackgroundColor = { Std = RGB(0, 0, 0), Hover = RGB(100, 30, 30) },
|
||||
OnMouseOut = GuiAction_SetTag("Std")
|
||||
};
|
||||
var buttons = CreateArray(3);
|
||||
for (var i = 0; i < 3; i++)
|
||||
{
|
||||
if (list[i])
|
||||
{
|
||||
buttons[i] = new list_button{
|
||||
Symbol = list[i],
|
||||
Tooltip = Format("$SendTo$", list[i]->GetName()),
|
||||
OnMouseIn = [GuiAction_SetTag("Hover"), GuiAction_Call(this, "PreviewDestination", list[i])],
|
||||
OnClick = GuiAction_Call(this, "SelectDestination", list[i]),
|
||||
Priority = ++priority
|
||||
};
|
||||
} else {
|
||||
buttons[i] = new list_button {};
|
||||
}
|
||||
}
|
||||
// Right button
|
||||
var right = {
|
||||
Right = "2em",
|
||||
Bottom = "2em",
|
||||
Symbol = Icon_LibraryCableCar,
|
||||
GraphicsName = "Grey",
|
||||
BackgroundColor = { Std = RGB(0, 0, 0), Hover = RGB(100, 30, 30) },
|
||||
Priority = ++priority
|
||||
};
|
||||
if (list[3] > 3)
|
||||
{
|
||||
right.OnMouseIn = GuiAction_SetTag("Hover");
|
||||
right.OnMouseOut = GuiAction_SetTag("Std");
|
||||
right.GraphicsName = nil;
|
||||
right.OnClick = GuiAction_Call(this, "ShiftSelection", list[2]);
|
||||
}
|
||||
// Assemble
|
||||
menu.buttons.left = left;
|
||||
menu.buttons.first = buttons[0];
|
||||
menu.buttons.second = buttons[1];
|
||||
menu.buttons.third = buttons[2];
|
||||
menu.buttons.right = right;
|
||||
}
|
||||
|
||||
func PreviewDestination(object to_preview, int plr, int menu_id, int submenu_id, object target)
|
||||
{
|
||||
if (to_preview == nil) return;
|
||||
if (dummy == nil)
|
||||
{
|
||||
dummy = CreateObject(Dummy, AbsX(to_preview->GetX()), AbsY(to_preview->GetY()), GetOwner());
|
||||
dummy.Visibility = VIS_Owner;
|
||||
dummy->SetLightRange(5, 20);
|
||||
}
|
||||
|
||||
SetPlrView(plr, to_preview, true);
|
||||
dummy->SetPosition(to_preview->GetX(), to_preview->GetY());
|
||||
}
|
||||
|
||||
func ShiftSelection(object new_middle, int plr, int menu_id, int submenu_id, object target)
|
||||
{
|
||||
if (!cable_station) return;
|
||||
if (!menu_id) return;
|
||||
|
||||
var update = { buttons = { } };
|
||||
var list = cable_station->GetDestinationList(new_middle);
|
||||
|
||||
FillDestinationButtons(update, list);
|
||||
GuiUpdate(update, menu_id);
|
||||
Sound("UI::Click", true, nil, plr);
|
||||
}
|
||||
|
||||
func SelectDestination(object target, int plr, int menu_id, int submenu_id, object target)
|
||||
{
|
||||
if (target == nil) return;
|
||||
if (!cable_car) return;
|
||||
|
||||
cable_car->SetDestination(target);
|
||||
Sound("UI::Click", true, nil, plr);
|
||||
|
||||
RemoveObject();
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
Name=Zielwahlmenü
|
||||
Description=
|
|
@ -0,0 +1,4 @@
|
|||
Name=Destination Selection Menu
|
||||
Description=
|
||||
SelectDestination=Select a destination:
|
||||
SendTo=Send the cable car to %s
|
|
@ -0,0 +1,8 @@
|
|||
[DefCore]
|
||||
id=Icon_LibraryCableCar
|
||||
Version=8,0
|
||||
Category=C4D_StaticBack
|
||||
Picture=0,0,32,32
|
||||
Width=32
|
||||
Height=22
|
||||
Offset=-16,-16
|
After Width: | Height: | Size: 4.0 KiB |
After Width: | Height: | Size: 3.8 KiB |
After Width: | Height: | Size: 4.0 KiB |
After Width: | Height: | Size: 3.9 KiB |
|
@ -1,209 +1,315 @@
|
|||
/**
|
||||
Cable Car
|
||||
Library object for the cable car.
|
||||
|
||||
|
||||
@author Randrian, Clonkonaut, Maikel
|
||||
|
||||
Cable cars must set up a movement speed using SetCableSpeed(x);
|
||||
Cable cars handle movement on their own. In order to move along a rail, cable cars must call DoMovement() regularly.
|
||||
E.g. using AddTimer("DoMovement", 1);
|
||||
*/
|
||||
|
||||
//#appendto Lorry
|
||||
// The speed with which the car travels along rails
|
||||
local lib_ccar_speed;
|
||||
// The rail (cable or crossing) that is currently traveled along or stayed at
|
||||
local lib_ccar_rail;
|
||||
// The direction (0 or 1) the rail is travelled along, translates into the cable's action targets (of which there should be two!)
|
||||
local lib_ccar_direction;
|
||||
// The travel progress on the current rail
|
||||
local lib_ccar_progress;
|
||||
// The length of the rail
|
||||
local lib_ccar_max_progress;
|
||||
// This target point for pathfinding
|
||||
local lib_ccar_destination;
|
||||
|
||||
local iMovementSpeed;
|
||||
/*--- Overloads ---*/
|
||||
|
||||
local pRailTarget;
|
||||
local rail_direction; // 2 up the line, 1 down the line, 0 no movement
|
||||
local rail_progress;
|
||||
local rail_max_prog;
|
||||
local rail_destination;
|
||||
// Overload these functions as you feel fit
|
||||
|
||||
// Called after the car is attached to a rail
|
||||
func Engaged() {}
|
||||
|
||||
// Called after the car is detached from the rail
|
||||
func Disengaged() {}
|
||||
|
||||
// To offset the position on the cable from the object's center
|
||||
// position is a 2-value-array [x,y]
|
||||
// prec is nil or a value to multiply your calculations with
|
||||
func GetCableOffset(array position, int prec) {}
|
||||
|
||||
// To add custom interaction menu entries after the regular cable car entries
|
||||
// custom_entry is prototype for proper spacing of buttons
|
||||
// Use priorities > 2000 just to be sure
|
||||
func GetCableCarExtraMenuEntries(array menu_entries, proplist custom_entry, object clonk) {}
|
||||
|
||||
// Whenever movement is about to begin
|
||||
// Movement data like lib_ccar_direction is still nil at this moment
|
||||
func OnStart() {}
|
||||
|
||||
// Whenever the car stops its movement
|
||||
// failed is true if the movement to a destination was cancelled (usually because the path broke in the meantime)
|
||||
func OnStop(bool failed) {}
|
||||
|
||||
/*--- Interface ---*/
|
||||
|
||||
// Sets the speed of the cable car
|
||||
public func SetCableSpeed(int value)
|
||||
{
|
||||
lib_ccar_speed = value;
|
||||
}
|
||||
|
||||
// Positioning of the car along the cable
|
||||
// This should be called regularly, see header comment!
|
||||
public func DoMovement()
|
||||
{
|
||||
if (!GetRailTarget()) return;
|
||||
if (lib_ccar_destination == nil) return;
|
||||
if (lib_ccar_direction == nil) return;
|
||||
|
||||
var start = 1;
|
||||
var end = 0;
|
||||
if (lib_ccar_direction == 1)
|
||||
{
|
||||
start = 0;
|
||||
end = 1;
|
||||
}
|
||||
|
||||
lib_ccar_progress += lib_ccar_speed;
|
||||
var position = CreateArray(2);
|
||||
if (lib_ccar_progress >= lib_ccar_max_progress)
|
||||
{
|
||||
lib_ccar_rail = lib_ccar_rail->GetActionTarget(end);
|
||||
lib_ccar_rail->GetCablePosition(position);
|
||||
GetCableOffset(position);
|
||||
SetPosition(position[0], position[1]);
|
||||
lib_ccar_direction = nil;
|
||||
CrossingReached();
|
||||
return;
|
||||
}
|
||||
|
||||
var prec = 100;
|
||||
var origin = CreateArray(2), ending = CreateArray(2);
|
||||
lib_ccar_rail->GetActionTarget(start)->GetCablePosition(origin, prec);
|
||||
lib_ccar_rail->GetActionTarget(end)->GetCablePosition(ending, prec);
|
||||
position[0] = origin[0] + (ending[0] - origin[0]) * lib_ccar_progress/lib_ccar_max_progress;
|
||||
position[1] = origin[1] + (ending[1] - origin[1]) * lib_ccar_progress/lib_ccar_max_progress;
|
||||
GetCableOffset(position, prec);
|
||||
SetPosition(position[0], position[1], 1, prec);
|
||||
}
|
||||
|
||||
/*--- Status ---*/
|
||||
|
||||
public func IsCableCar() { return true; }
|
||||
|
||||
public func GetRailTarget() { return pRailTarget; }
|
||||
public func GetRailTarget() { return lib_ccar_rail; }
|
||||
|
||||
public func EngageRail(object pRailpoint)
|
||||
public func IsTravelling() { return lib_ccar_destination; }
|
||||
|
||||
/* Interaction */
|
||||
|
||||
// Provides an own interaction menu.
|
||||
public func HasInteractionMenu() { return true; }
|
||||
|
||||
// Show settins in interaction menu
|
||||
public func GetInteractionMenus(object clonk)
|
||||
{
|
||||
if (! pRailpoint->IsCableCrossing()) return false;
|
||||
var menus = _inherited() ?? [];
|
||||
var cablecar_menu =
|
||||
{
|
||||
title = "$CableCarOptions$",
|
||||
entries_callback = this.GetCableCarMenuEntries,
|
||||
callback = nil,
|
||||
callback_hover = "OnCableCarHover",
|
||||
callback_target = this,
|
||||
BackgroundColor = RGB(0, 0, 50),
|
||||
Priority = 20
|
||||
};
|
||||
PushBack(menus, cablecar_menu);
|
||||
|
||||
return menus;
|
||||
}
|
||||
|
||||
public func GetCableCarMenuEntries(object clonk)
|
||||
{
|
||||
var control_prototype =
|
||||
{
|
||||
BackgroundColor = { Std = 0, Selected = RGB(100, 30, 30) },
|
||||
OnMouseIn = GuiAction_SetTag("Selected"),
|
||||
OnMouseOut = GuiAction_SetTag("Std")
|
||||
};
|
||||
|
||||
var custom_entry =
|
||||
{
|
||||
Right = "3em", Bottom = "2em",
|
||||
image = { Prototype = control_prototype }
|
||||
};
|
||||
|
||||
var menu_entries = [];
|
||||
|
||||
// Clickable buttons
|
||||
|
||||
if (!GetRailTarget())
|
||||
{
|
||||
// Engaging onto a rail
|
||||
var stations = FindObjects(Find_AtPoint(), Find_Func("IsCableStation"));
|
||||
var i = 0;
|
||||
for (var station in stations)
|
||||
{
|
||||
var engage = new custom_entry {
|
||||
Priority = 1000 + i,
|
||||
Tooltip = "$TooltipEngage$",
|
||||
OnClick = GuiAction_Call(this, "EngageRail", station)
|
||||
};
|
||||
engage.image.Symbol = station;
|
||||
PushBack(menu_entries, { symbol = station, extra_data = "Engage", custom = engage });
|
||||
i++;
|
||||
}
|
||||
// No station present
|
||||
if (i == 0)
|
||||
{
|
||||
var search = {
|
||||
Priority = 1000,
|
||||
Right = "100%", Bottom = "2em",
|
||||
text = { Text = "$NoStation$", Style = GUI_TextVCenter | GUI_TextHCenter}
|
||||
};
|
||||
PushBack(menu_entries, { symbol = this, extra_data = "NoStation", custom = search });
|
||||
}
|
||||
} else {
|
||||
// Start the trip
|
||||
if (!IsTravelling())
|
||||
{
|
||||
var go = new custom_entry {
|
||||
Priority = 1000,
|
||||
Tooltip = "$TooltipGo$",
|
||||
OnClick = GuiAction_Call(this, "OpenDestinationSelection", clonk)
|
||||
};
|
||||
go.image.Symbol = Icon_Play;
|
||||
PushBack(menu_entries, { symbol = this, extra_data = "Go", custom = go });
|
||||
}
|
||||
}
|
||||
// Add custom entries
|
||||
GetCableCarExtraMenuEntries(menu_entries, custom_entry, clonk);
|
||||
|
||||
return menu_entries;
|
||||
}
|
||||
|
||||
public func OnCableCarHover(symbol, extra_data, desc_menu_target, menu_id)
|
||||
{
|
||||
if (symbol == nil) return;
|
||||
|
||||
var text = "";
|
||||
if (extra_data == "Engage")
|
||||
text = Format("$DescEngage$", GetName(), symbol->GetName());
|
||||
if (extra_data == "Go")
|
||||
text = "$DescGo$";
|
||||
|
||||
GuiUpdate({ Text = text }, menu_id, 1, desc_menu_target);
|
||||
}
|
||||
|
||||
/*--- Travelling ---*/
|
||||
|
||||
// Attach the car onto a crossing
|
||||
public func EngageRail(object crossing, bool silent)
|
||||
{
|
||||
if (! crossing->~IsCableCrossing()) return false;
|
||||
|
||||
var position = CreateArray(2);
|
||||
pRailpoint->GetCablePosition(position);
|
||||
crossing->GetCablePosition(position);
|
||||
GetCableOffset(position);
|
||||
SetPosition(position[0], position[1]);
|
||||
SetSpeed(0,0);
|
||||
SetR(0);
|
||||
SetAction("OnRail");
|
||||
SetRDir(0);
|
||||
SetComDir(COMD_None);
|
||||
pRailTarget = pRailpoint;
|
||||
rail_direction = 0;
|
||||
lib_ccar_rail = crossing;
|
||||
lib_ccar_direction = nil;
|
||||
if (!silent) Sound("Objects::Connect");
|
||||
UpdateInteractionMenus(this.GetCableCarMenuEntries);
|
||||
|
||||
Engaged();
|
||||
}
|
||||
|
||||
// Detach the car from its current holding point (cable or crossing, does not matter)
|
||||
public func DisengageRail()
|
||||
{
|
||||
pRailTarget = nil;
|
||||
rail_direction = 0;
|
||||
rail_progress = 0;
|
||||
rail_max_prog = 0;
|
||||
rail_destination = nil;
|
||||
lib_ccar_rail = nil;
|
||||
lib_ccar_direction = nil;
|
||||
lib_ccar_progress = 0;
|
||||
lib_ccar_max_progress = 0;
|
||||
lib_ccar_destination = nil;
|
||||
UpdateInteractionMenus(this.GetCableCarMenuEntries);
|
||||
|
||||
Disengaged();
|
||||
}
|
||||
|
||||
// Sets a target point for travelling and starts the movement process
|
||||
public func SetDestination(dest)
|
||||
{
|
||||
if(GetType(dest) == C4V_Int)
|
||||
{
|
||||
dest = FindObjects(Find_Func("IsCableCrossing"))[dest];
|
||||
}
|
||||
rail_destination = dest;
|
||||
if(rail_direction == 0)
|
||||
CrossingReached();
|
||||
}
|
||||
|
||||
private func Disengaged() {}
|
||||
|
||||
/* Destination selection */
|
||||
|
||||
public func SelectDestination(object select_clonk, object station)
|
||||
{
|
||||
// Storage effect
|
||||
var effect = AddEffect("DestinationSelection", this, 1, 1, this);
|
||||
effect.select_clonk = select_clonk;
|
||||
effect.station = station;
|
||||
// Helping object
|
||||
effect.cablecar_sel = CreateObjectAbove(CableCar_Selector, 0,0, select_clonk->GetOwner());
|
||||
effect.cablecar_sel->FixTo(station);
|
||||
|
||||
effect.engaging_station = station;
|
||||
}
|
||||
|
||||
public func ShiftSelection(int direction, object selector)
|
||||
{
|
||||
// Determine effect
|
||||
var effect = nil, temp_effect;
|
||||
for (var i = 0; temp_effect = GetEffect("DestinationSelection", this, i); i++)
|
||||
if (temp_effect.cablecar_sel == selector)
|
||||
effect = temp_effect;
|
||||
if (!effect) return false;
|
||||
|
||||
var destinations = [];
|
||||
var connection_list = effect.engaging_station->GetDestinations();
|
||||
|
||||
// Get every possible destination
|
||||
for (var targets in connection_list)
|
||||
{
|
||||
// Is this a valid destination?
|
||||
if (! targets[0]->IsCableStation()) continue;
|
||||
// Check ownership
|
||||
if (targets[0]->GetOwner() != effect.select_clonk->GetOwner() && targets[0]->GetOwner() != NO_OWNER) continue;
|
||||
// Save it
|
||||
destinations[GetLength(destinations)] = targets[0];
|
||||
}
|
||||
// Add current station, for it is a destination
|
||||
destinations[GetLength(destinations)] = effect.engaging_station;
|
||||
// Determine destination actually seen
|
||||
for (var i = 0; i < GetLength(destinations); i++)
|
||||
if (destinations[i] == effect.station)
|
||||
break;
|
||||
// Scale exceeded? Reset to current station
|
||||
if (i == GetLength(destinations)) i--;
|
||||
else { // Select the new destination
|
||||
i += direction;
|
||||
if (i < 0) i = GetLength(destinations) - 1;
|
||||
if (i >= GetLength(destinations)) i = 0;
|
||||
}
|
||||
// Set the view
|
||||
effect.station = destinations[i];
|
||||
effect.cablecar_sel->FixTo(effect.station);
|
||||
return true;
|
||||
}
|
||||
|
||||
protected func FxDestinationSelectionTimer(object target, effect)
|
||||
{
|
||||
// Check cancellation conditions
|
||||
if (! effect.select_clonk) return -1; // Clonk's gone
|
||||
if (! effect.select_clonk->GetAlive()) return -1; // Clonk's dead
|
||||
if (effect.select_clonk->GetActionTarget() != this) return -1; // Clonk's not grabbing anymore
|
||||
if (! effect.cablecar_sel) return -1; // Selector's gone
|
||||
if (! effect.engaging_station) return -1; // Engaging station's gone
|
||||
if (effect.engaging_station->OnFire()) return -1; // Engaging station's burning (destroyed)
|
||||
|
||||
// Check view
|
||||
if (! effect.station) ShiftSelection(0, effect.cablecar_sel); // Current view target is gone
|
||||
if (effect.station->OnFire()) ShiftSelection(0, effect.cablecar_sel); // Current view target is burning (destroyed)
|
||||
}
|
||||
|
||||
protected func FxDestinationSelectionStop(object target, effect, int reason, bool temp)
|
||||
{
|
||||
if (temp) return;
|
||||
|
||||
// Clonk's still alive? Reset Cursor
|
||||
if (effect.select_clonk && effect.select_clonk->GetAlive())
|
||||
{
|
||||
SetPlrView(effect.select_clonk->GetOwner(), effect.select_clonk);
|
||||
SetCursor(effect.select_clonk->GetOwner(), effect.select_clonk, true);
|
||||
}
|
||||
// Remove selector
|
||||
effect.cablecar_sel->RemoveObject();
|
||||
}
|
||||
|
||||
public func AcceptSelection(object selector)
|
||||
{
|
||||
// Determine effect
|
||||
var effect = nil, temp_effect;
|
||||
for (var i = 0; temp_effect = GetEffect("DestinationSelection", this, i); i++)
|
||||
if (temp_effect.cablecar_sel == selector)
|
||||
effect = temp_effect;
|
||||
if (!effect) return false;
|
||||
|
||||
// Reset cursor
|
||||
SetPlrView(effect.select_clonk->GetOwner(), effect.select_clonk);
|
||||
SetCursor(effect.select_clonk->GetOwner(), effect.select_clonk, true);
|
||||
effect.cablecar_sel->RemoveObject();
|
||||
// Ungrab & start!
|
||||
effect.select_clonk->ObjectControl(effect.select_clonk->GetOwner(), CON_Ungrab);
|
||||
SetDestination(effect.station);
|
||||
RemoveEffect(nil, this, effect, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
public func AbortSelection(object selector)
|
||||
{
|
||||
// Determine effect
|
||||
var effect = nil, temp_effect;
|
||||
for (var i = 0; temp_effect = GetEffect("DestinationSelection", this, i); i++)
|
||||
if (temp_effect.cablecar_sel == selector)
|
||||
effect = temp_effect;
|
||||
if (!effect) return false;
|
||||
|
||||
RemoveEffect(nil, this, effect);
|
||||
}
|
||||
|
||||
/* Movement */
|
||||
|
||||
private func CrossingReached()
|
||||
{
|
||||
var target;
|
||||
if(rail_destination != pRailTarget)
|
||||
{
|
||||
if(target = pRailTarget->GetNextWaypoint(rail_destination))
|
||||
MoveTo(target);
|
||||
else
|
||||
DeliveryFailed();
|
||||
}
|
||||
else if (deliver_to) {
|
||||
if (deliver_to == pRailTarget)
|
||||
return DeliverObjects();
|
||||
if (pRailTarget->RequestObjects(this, deliver_id, deliver_amount))
|
||||
ReturnDelivery();
|
||||
else
|
||||
DeliveryFailed();
|
||||
}
|
||||
}
|
||||
|
||||
private func MoveTo(dest)
|
||||
{
|
||||
if(GetType(dest) == C4V_Int)
|
||||
{
|
||||
dest = FindObjects(Find_Func("IsCableCrossing"))[dest];
|
||||
if (!dest) return;
|
||||
}
|
||||
|
||||
lib_ccar_destination = dest;
|
||||
|
||||
if(lib_ccar_direction == nil)
|
||||
{
|
||||
OnStart();
|
||||
CrossingReached();
|
||||
}
|
||||
}
|
||||
|
||||
// Whenever a crossing is reached it must be queried for the next crossing to go to
|
||||
func CrossingReached()
|
||||
{
|
||||
var target;
|
||||
if(lib_ccar_destination != lib_ccar_rail)
|
||||
{
|
||||
if(target = lib_ccar_rail->GetNextWaypoint(lib_ccar_destination))
|
||||
MoveTo(target);
|
||||
else
|
||||
DestinationFailed();
|
||||
}
|
||||
// Destination reached
|
||||
else {
|
||||
DestinationReached();
|
||||
}
|
||||
}
|
||||
|
||||
// When the current destination is reached
|
||||
func DestinationReached()
|
||||
{
|
||||
lib_ccar_destination = nil;
|
||||
lib_ccar_direction = nil;
|
||||
lib_ccar_progress = 0;
|
||||
lib_ccar_max_progress = 0;
|
||||
|
||||
OnStop(false);
|
||||
}
|
||||
|
||||
// When the way to the current destination has vanished somehow
|
||||
func DestinationFailed()
|
||||
{
|
||||
lib_ccar_destination = nil;
|
||||
lib_ccar_direction = nil;
|
||||
lib_ccar_progress = 0;
|
||||
lib_ccar_max_progress = 0;
|
||||
|
||||
OnStop(true);
|
||||
}
|
||||
|
||||
// Setup movement process
|
||||
func MoveTo(dest)
|
||||
{
|
||||
if(GetType(dest) == C4V_Int)
|
||||
{
|
||||
dest = FindObjects(Find_Func("IsCableCrossing"))[dest];
|
||||
if (!dest) return;
|
||||
}
|
||||
|
||||
var rail = 0;
|
||||
for(var test_rail in FindObjects(Find_Func("IsConnectedTo", pRailTarget)))
|
||||
for(var test_rail in FindObjects(Find_Func("IsConnectedTo", lib_ccar_rail)))
|
||||
{
|
||||
if(test_rail->IsConnectedTo(dest))
|
||||
{
|
||||
|
@ -212,74 +318,45 @@ private func MoveTo(dest)
|
|||
}
|
||||
}
|
||||
if(!rail)
|
||||
{
|
||||
Message("No Rail available!");
|
||||
return;
|
||||
}
|
||||
return DestinationFailed(); // Shouldn't happen
|
||||
|
||||
// Target the first or second action target?
|
||||
if(rail->GetActionTarget(0) == dest)
|
||||
{
|
||||
rail_direction = 1;
|
||||
rail_progress = 0;
|
||||
}
|
||||
lib_ccar_direction = 0;
|
||||
else
|
||||
{
|
||||
rail_direction = 2;
|
||||
rail_progress = 0;
|
||||
}
|
||||
rail->GetActionTarget(0)->AddActive(0);
|
||||
rail->GetActionTarget(1)->AddActive(0);
|
||||
rail->AddActive(0);
|
||||
lib_ccar_direction = 1;
|
||||
lib_ccar_progress = 0;
|
||||
var origin = CreateArray(2), ending = CreateArray(2);
|
||||
rail->GetActionTarget(0)->GetCablePosition(origin);
|
||||
rail->GetActionTarget(1)->GetCablePosition(ending);
|
||||
rail_max_prog = Distance(origin[0], origin[1], ending[0], ending[1]);
|
||||
pRailTarget = rail;
|
||||
lib_ccar_max_progress = Distance(origin[0], origin[1], ending[0], ending[1]);
|
||||
lib_ccar_rail = rail;
|
||||
}
|
||||
|
||||
protected func OnRail()
|
||||
/* Destination selection */
|
||||
|
||||
public func OpenDestinationSelection(object clonk)
|
||||
{
|
||||
if(rail_direction == 0 || rail_direction == nil) return;
|
||||
var start = 0;
|
||||
var end = 1;
|
||||
if(rail_direction == 1)
|
||||
{
|
||||
start = 1;
|
||||
end = 0;
|
||||
}
|
||||
if (!clonk) return;
|
||||
if (!GetRailTarget()) return;
|
||||
|
||||
rail_progress += iMovementSpeed;
|
||||
if(rail_progress >= rail_max_prog)
|
||||
{
|
||||
pRailTarget->GetActionTarget(0)->AddActive(1);
|
||||
pRailTarget->GetActionTarget(1)->AddActive(1);
|
||||
pRailTarget->AddActive(1);
|
||||
pRailTarget = pRailTarget->GetActionTarget(end);
|
||||
var position = CreateArray(2);
|
||||
pRailTarget->GetCablePosition(position);
|
||||
SetPosition(position[0], position[1]);
|
||||
rail_direction = 0;
|
||||
CrossingReached();
|
||||
return;
|
||||
}
|
||||
var plr = clonk->GetOwner();
|
||||
// Close interaction menu
|
||||
if (clonk->GetMenu())
|
||||
if (!clonk->TryCancelMenu())
|
||||
return;
|
||||
|
||||
var prec = 100;
|
||||
var origin = CreateArray(2), ending = CreateArray(2);
|
||||
pRailTarget->GetActionTarget(start)->GetCablePosition(origin, prec);
|
||||
pRailTarget->GetActionTarget(end)->GetCablePosition(ending, prec);
|
||||
var x = origin[0] + (ending[0] - origin[0]) * rail_progress/rail_max_prog;
|
||||
var y = origin[1] + (ending[1] - origin[1]) * rail_progress/rail_max_prog;
|
||||
SetPosition(x, y, 1, prec);
|
||||
GUI_DestinationSelectionMenu->CreateFor(clonk, this, GetRailTarget());
|
||||
}
|
||||
|
||||
/*-- Delivery --*/
|
||||
|
||||
/*
|
||||
local deliver_id, deliver_amount, deliver_to;
|
||||
|
||||
// Returns true when this car is not in move
|
||||
public func IsAvailable()
|
||||
{
|
||||
return !rail_destination;
|
||||
return !lib_ccar_destination;
|
||||
}
|
||||
|
||||
public func AddDelivery(object from, object to, id object_id, int amount)
|
||||
|
@ -299,8 +376,8 @@ public func DeliverObjects()
|
|||
{
|
||||
if (ContentsCount(deliver_id) < deliver_amount) return DeliveryFailed();
|
||||
for (var i = 0; i < deliver_amount; i++)
|
||||
FindContents(deliver_id)->Enter(pRailTarget);
|
||||
pRailTarget->DeliveryDone(deliver_id, deliver_amount);
|
||||
FindContents(deliver_id)->Enter(lib_ccar_rail);
|
||||
lib_ccar_rail->DeliveryDone(deliver_id, deliver_amount);
|
||||
deliver_id = false;
|
||||
deliver_amount = false;
|
||||
deliver_to = false;
|
||||
|
@ -310,3 +387,4 @@ private func DeliveryFailed()
|
|||
{
|
||||
|
||||
}
|
||||
*/
|
|
@ -1,7 +0,0 @@
|
|||
[DefCore]
|
||||
id=CableCar_Selector
|
||||
Version=6,0
|
||||
Category=C4D_StaticBack
|
||||
Width=1
|
||||
Height=1
|
||||
Offset=-1,-1
|
|
@ -1,43 +0,0 @@
|
|||
/*-- Cable car selector --*/
|
||||
|
||||
local cable_car;
|
||||
|
||||
|
||||
protected func Construction(object constructor)
|
||||
{
|
||||
cable_car = constructor;
|
||||
SetLightRange(10);
|
||||
this["Visibility"] = VIS_Owner;
|
||||
AddEffect("Particles", this, 1, 2, this);
|
||||
}
|
||||
|
||||
public func FixTo(object station)
|
||||
{
|
||||
// no owner? -> panic
|
||||
if (GetOwner() == NO_OWNER) return RemoveObject();
|
||||
// Set owner's view
|
||||
SetPosition(station->GetX(), station->GetY());
|
||||
SetPlrView(GetOwner(), this);
|
||||
SetCursor(GetOwner(), this, true);
|
||||
}
|
||||
|
||||
public func ObjectControl(int plr, int ctrl, int x, int y, int strength, bool repeat, bool release)
|
||||
{
|
||||
if (release) return false;
|
||||
|
||||
if (ctrl == CON_Left)
|
||||
return cable_car->ShiftSelection(-1, this);
|
||||
if (ctrl == CON_Right)
|
||||
return cable_car->ShiftSelection(+1, this);
|
||||
|
||||
if (ctrl == CON_Use || ctrl == CON_Interact)
|
||||
return cable_car->AcceptSelection(this);
|
||||
if (ctrl == CON_UseAlt)
|
||||
return cable_car->AbortSelection(this);
|
||||
}
|
||||
|
||||
protected func FxParticlesTimer(object target, effect, int time)
|
||||
{
|
||||
var angle = time*10 % 360;
|
||||
CreateParticle("SphereSpark", Sin(angle, 13), -Cos(angle, 13), 0, 0, PV_Random(20, 30), Particles_Spark());
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
CableCarOptions=Seilbahneinstellungen
|
||||
|
||||
TooltipEngage=Das Fahrzeug auf das Seil aufsetzen.
|
||||
DescEngage=%s bei %s auf das Seil aufsetzen.
|
||||
|
||||
TooltipGo=Wähle ein Ziel für das Fahrzeug.
|
||||
DescGo=Öffnet das Zielwahl-Menü für dieses Fahrzeug. Das Fahrzeug fährt los, sobald ein Ziel ausgewählt wurde.
|
||||
|
||||
NoStation=Schiebe das Fahrzeug vor eine Station, um es auf ein Seil zu setzen.
|
|
@ -0,0 +1,9 @@
|
|||
CableCarOptions=Cable Car Options
|
||||
|
||||
TooltipEngage=Put the car on the rail
|
||||
DescEngage=Put %s on the rail at %s.
|
||||
|
||||
TooltipGo=Select a destination for the car.
|
||||
DescGo=Opens the destination selection menu for this cable car. When you select a destination, the car will start going there.
|
||||
|
||||
NoStation=Push the cable car in front of a station to set it up.
|
|
@ -1,102 +1,150 @@
|
|||
/**
|
||||
Cable Station
|
||||
Library for cable stations and crossings. This is included by
|
||||
Library for cable stations and crossings. This is included by
|
||||
cable crossings, and should be included by structures which
|
||||
want to make use of the cable network.
|
||||
|
||||
@author Randrian, Clonkonaut, Maikel
|
||||
*/
|
||||
|
||||
//#appendto ToolsWorkshop
|
||||
/*--- Overloads ---*/
|
||||
|
||||
// Set to true to make this a station
|
||||
local is_station;
|
||||
// Overload these functions as you feel fit
|
||||
|
||||
/*-- State --*/
|
||||
// This function is called whenever a change in the cable network occured, i.e. destinations have been added / removed.
|
||||
private func DestinationsUpdated() { }
|
||||
|
||||
/** This object is a cable crossing
|
||||
* E.g. checked by whatever object wants to connect a cable (so it does not mean there is a cable connected!)
|
||||
/*--- Callbacks ---*/
|
||||
|
||||
// Be sure to always call these via _inherited();
|
||||
|
||||
func Initialize()
|
||||
{
|
||||
destination_list = [];
|
||||
return _inherited(...);
|
||||
}
|
||||
|
||||
/* Removes this crossing from the network
|
||||
It first clears every waypoint from the network and then renews the whole information.
|
||||
Optimisation welcome!
|
||||
*/
|
||||
func Destruction()
|
||||
{
|
||||
for (var connection in FindObjects(Find_Func("IsConnectedTo", this)))
|
||||
{
|
||||
if (! connection->~IsCableLine()) continue;
|
||||
var other_crossing = connection->~GetConnectedObject(this);
|
||||
if (! other_crossing->~IsCableCrossing()) continue;
|
||||
other_crossing->ClearConnections(this);
|
||||
}
|
||||
for (var connection in FindObjects(Find_Func("IsConnectedTo", this)))
|
||||
{
|
||||
if (! connection->~IsCableLine()) continue;
|
||||
var other_crossing = connection->~GetConnectedObject(this);
|
||||
if (! other_crossing->~IsCableCrossing()) continue;
|
||||
other_crossing->RenewConnections(this);
|
||||
}
|
||||
return _inherited(...);
|
||||
}
|
||||
|
||||
/*--- Status ---*/
|
||||
|
||||
local lib_crossing_is_station;
|
||||
|
||||
/** This object is a cable crossing.
|
||||
E.g. checked by whatever object wants to connect a cable.
|
||||
Does not mean that there actually is a cable connected to this crossing.
|
||||
*/
|
||||
public func IsCableCrossing() { return true; }
|
||||
/** Returns whether or not this object is a cable station
|
||||
* A station is a possible (i.e. selectable) destination for cable cars (whereas normal crossings do not appear in the destination selection process)
|
||||
*/
|
||||
public func IsCableStation() { return is_station; }
|
||||
|
||||
// For setting up the cable
|
||||
/** This function should return true if this crossing is considered a station.
|
||||
A station is selectable as a target if a lorry is sent its way.
|
||||
Functional buildings should always be a station, the 'crossing' building only if set to.
|
||||
*/
|
||||
public func IsCableStation() { return lib_crossing_is_station; }
|
||||
|
||||
/*--- Interface ---*/
|
||||
|
||||
// For switching the station status
|
||||
public func SetCableStation(bool station)
|
||||
{
|
||||
lib_crossing_is_station = station;
|
||||
}
|
||||
|
||||
// Returns the cable hookup position for proper positioning of a car along the line.
|
||||
public func GetCablePosition(array coordinates, int prec)
|
||||
{
|
||||
if (!prec) prec = 1;
|
||||
coordinates[0] = GetX(prec);
|
||||
coordinates[1] = GetY(prec);
|
||||
if (this->~GetCableXOffset()) coordinates[0] += this->~GetCableXOffset() * prec;
|
||||
if (this->~GetCableYOffset()) coordinates[1] += this->~GetCableYOffset() * prec;
|
||||
}
|
||||
|
||||
/* Local */
|
||||
|
||||
// Stores the next crossing (waypoint) to take when advancing to a certain final point
|
||||
// Scheme (2D array): [Desired final point, Next waypoint to take, Distance (not airline!) until final point]
|
||||
local destination_list;
|
||||
// According to this scheme, some constants for easy reading
|
||||
local const_finaldestination; // :D
|
||||
local const_nextwaypoint;
|
||||
local const_distance;
|
||||
|
||||
protected func Initialize() //
|
||||
{
|
||||
const_finaldestination = 0;
|
||||
const_nextwaypoint = 1;
|
||||
const_distance = 2;
|
||||
destination_list = [];
|
||||
return _inherited(...);
|
||||
}
|
||||
|
||||
/* Pathfinding for cable cars */
|
||||
|
||||
/** Returns the waypoint to take next for the desired final point \a end
|
||||
* @param end The final destination for the information is queried
|
||||
*/
|
||||
public func GetNextWaypoint(object end)
|
||||
{
|
||||
if (!destination_list) return nil;
|
||||
for (var item in destination_list)
|
||||
if (this.LineAttach)
|
||||
{
|
||||
if (!item) continue;
|
||||
if (item[const_finaldestination] == end)
|
||||
return item[const_nextwaypoint];
|
||||
coordinates[0] += this.LineAttach[0] * prec;
|
||||
coordinates[1] += this.LineAttach[1] * prec;
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
/** Returns the actual traveling distance for the desired final point \a end
|
||||
* This is not the airline distance but the length of all cables to take via traveling
|
||||
* @param end The final destination for the information is queried
|
||||
*/
|
||||
public func GetLengthToTarget(object end)
|
||||
// Usually called by cable cars to retrieve selectable destinations for the destination selection menu.
|
||||
// Returns an array of three objects and one int, one station before and one station after the middle one and the middle one.
|
||||
// The int (fourth array value) is the overall amount of stations found.
|
||||
// If middle is not a station (anymore), the first three found objects are returned.
|
||||
public func GetDestinationList(object middle)
|
||||
{
|
||||
if (!destination_list) return nil;
|
||||
for (var item in destination_list)
|
||||
{
|
||||
if (!item) continue;
|
||||
if (item[const_finaldestination] == end)
|
||||
return item[const_distance];
|
||||
}
|
||||
return nil;
|
||||
var list = CreateArray();
|
||||
var ret = CreateArray(4);
|
||||
for (var destination in destination_list)
|
||||
if (destination[const_finaldestination]->IsCableStation())
|
||||
PushBack(list, destination[const_finaldestination]);
|
||||
if (GetLength(list) == 0) return ret;
|
||||
if (GetLength(list) == 1) return [nil, list[0], nil, 1];
|
||||
if (GetLength(list) == 2) return [list[0], list[1], nil, 2];
|
||||
if (GetLength(list) == 3) return [list[0], list[1], list[2], 3];
|
||||
|
||||
var middle_index = GetIndexOf(list, middle);
|
||||
if (middle_index == -1) middle_index = 1;
|
||||
var left_index = middle_index - 1;
|
||||
if (left_index < 0) left_index = GetLength(list) - 1;
|
||||
var right_index = middle_index + 1;
|
||||
if (right_index >= GetLength(list)) right_index = 0;
|
||||
|
||||
ret[0] = list[left_index];
|
||||
ret[1] = list[middle_index];
|
||||
ret[2] = list[right_index];
|
||||
ret[3] = GetLength(list);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/** Returns the destination array
|
||||
/*--- Maintaining the destination list ---*/
|
||||
|
||||
/* Functions:
|
||||
GetDestinations()
|
||||
AddCableConnection(object cable)
|
||||
AddCableDestinations(array new_list, object crossing)
|
||||
AddCableDestination(object new_destination, object crossing, int distance_add)
|
||||
ClearConnections(object crossing)
|
||||
RenewConnections(object crossing)
|
||||
*/
|
||||
|
||||
/** Returns the destination array so it can be used by other crossings.
|
||||
*/
|
||||
public func GetDestinations()
|
||||
{
|
||||
return destination_list[:];
|
||||
}
|
||||
|
||||
/* Set up pathfinding information */
|
||||
// Stores the next crossing (waypoint) to take when advancing to a certain final point
|
||||
// Scheme (2D array): [Desired final point, Next waypoint to take, Distance (not airline!) until final point]
|
||||
local destination_list;
|
||||
|
||||
// Constants for easier script reading
|
||||
// These correspond to the aforementioned values of destination_list
|
||||
local const_finaldestination = 0; // :D
|
||||
local const_nextwaypoint = 1;
|
||||
local const_distance = 2;
|
||||
|
||||
/** Adds a new connection via the cable \a cable to this crossing
|
||||
* Does nothing if the other connected objects of the cable is not a cable crossing
|
||||
* @param cable The newly connected cable
|
||||
Does nothing if the other connected object of the cable is not a cable crossing
|
||||
@param cable The newly connected cable
|
||||
*/
|
||||
public func AddCableConnection(object cable)
|
||||
{
|
||||
|
@ -104,7 +152,7 @@ public func AddCableConnection(object cable)
|
|||
if (!cable || ! cable->~IsCableLine())
|
||||
return false;
|
||||
// Line setup finished?
|
||||
var other_crossing = cable->~GetOtherConnection(this);
|
||||
var other_crossing = cable->~GetConnectedObject(this);
|
||||
if (! other_crossing->~IsCableCrossing())
|
||||
return false;
|
||||
// Acquire destinations of the other crossing, all these are now in reach
|
||||
|
@ -112,7 +160,7 @@ public func AddCableConnection(object cable)
|
|||
// Send own destinations, now in reach for the other one
|
||||
other_crossing->AddCableDestinations(destination_list[:], this);
|
||||
// Awesome, more power to the network!
|
||||
CheckRailStation();
|
||||
DestinationsUpdated();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -164,7 +212,7 @@ public func AddCableDestinations(array new_list, object crossing)
|
|||
if (list_item[const_finaldestination] != crossing)
|
||||
list_item[const_finaldestination]->AddCableDestination(this, crossing, distance_add);
|
||||
}
|
||||
CheckRailStation();
|
||||
DestinationsUpdated();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -193,7 +241,7 @@ public func AddCableDestination(object new_destination, object crossing, int dis
|
|||
if (!crossing_item) return false;
|
||||
// Save the new destination
|
||||
destination_list[GetLength(destination_list)] = [new_destination, crossing_item[const_nextwaypoint], crossing_item[const_distance] + distance_add];
|
||||
CheckRailStation();
|
||||
DestinationsUpdated();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -223,7 +271,7 @@ public func UpdateCableDestination(object known_destination, object crossing, in
|
|||
// Save the updated path
|
||||
destination_list[destination_item][const_nextwaypoint] = crossing_item[const_nextwaypoint];
|
||||
destination_list[destination_item][const_distance] = crossing_item[const_distance] + distance_add;
|
||||
CheckRailStation();
|
||||
DestinationsUpdated();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -240,7 +288,7 @@ public func ClearConnections(object crossing)
|
|||
for (var connection in FindObjects(Find_Func("IsConnectedTo", this)))
|
||||
{
|
||||
if (! connection->~IsCableLine()) continue;
|
||||
var other_crossing = connection->~GetOtherConnection(this);
|
||||
var other_crossing = connection->~GetConnectedObject(this);
|
||||
if (! other_crossing->~IsCableCrossing()) continue;
|
||||
other_crossing->ClearConnections();
|
||||
}
|
||||
|
@ -256,7 +304,7 @@ public func RenewConnections(object crossing)
|
|||
for(var connection in FindObjects(Find_Func("IsConnectedTo", this)))
|
||||
{
|
||||
if (! connection->~IsCableLine()) continue;
|
||||
var other_crossing = connection->~GetOtherConnection(this);
|
||||
var other_crossing = connection->~GetConnectedObject(this);
|
||||
if (! other_crossing->~IsCableCrossing()) continue;
|
||||
if (other_crossing == crossing) continue;
|
||||
destination_list[GetLength(destination_list)] = [other_crossing, other_crossing, ObjectDistance(other_crossing)];
|
||||
|
@ -264,113 +312,46 @@ public func RenewConnections(object crossing)
|
|||
}
|
||||
}
|
||||
|
||||
/* Station behaviour */
|
||||
/*--- Pathfinding ---*/
|
||||
|
||||
// Prevents the automatic change of the stations status when set to station mode
|
||||
local bManualSetting;
|
||||
|
||||
// IsInteractable is stored in the appendto definitions!
|
||||
|
||||
// A clonk wants to change my station status
|
||||
public func Interact(object pClonk)
|
||||
{
|
||||
// Check ownership
|
||||
if (GetOwner() != NO_OWNER && GetOwner() != pClonk->GetOwner()) return false;
|
||||
// Clonk pushes a cable car?
|
||||
if (pClonk->GetActionTarget() && pClonk->GetActionTarget()->~IsCableCar())
|
||||
{
|
||||
var car = pClonk->GetActionTarget();
|
||||
// Disengage
|
||||
if (car->GetRailTarget() == this)
|
||||
{
|
||||
car->DisengageRail();
|
||||
return true;
|
||||
}
|
||||
// Engage
|
||||
car->EngageRail(this);
|
||||
car->SelectDestination(pClonk, this);
|
||||
return true;
|
||||
}
|
||||
// Change status
|
||||
if (is_station)
|
||||
bManualSetting = false;
|
||||
else
|
||||
bManualSetting = true;
|
||||
CheckRailStation();
|
||||
return _inherited(...);
|
||||
}
|
||||
|
||||
public func GetInteractionMetaInfo(object clonk)
|
||||
{
|
||||
if (is_station)
|
||||
return {IconID = Library_CableStation, IconName = "UnsetStation", Description = "$UnsetStationDesc$"};
|
||||
else
|
||||
return {IconID = Library_CableStation, IconName = "SetStation", Description = "$SetStationDesc$"};
|
||||
}
|
||||
|
||||
/* Animation stuff */
|
||||
|
||||
/** Overload me to do wheel animation
|
||||
@return \c nil.
|
||||
/* Functions:
|
||||
GetNextWaypoint(object end)
|
||||
GetLengthToTarget(object end)
|
||||
*/
|
||||
protected func TurnWheel()
|
||||
{
|
||||
/* EMPTY: Should be overloaded */
|
||||
return;
|
||||
}
|
||||
|
||||
local iActiveCount;
|
||||
// Start/End animation
|
||||
// Call AddActive(0) if any next waypoint wants to start the animation (because a cable car is passing by)
|
||||
// Call AddActive(1) if the cable car passed the line, stopping the animation
|
||||
// Counts up to multiple animated connections
|
||||
public func AddActive(fRemove)
|
||||
{
|
||||
if(!fRemove)
|
||||
iActiveCount++;
|
||||
else
|
||||
iActiveCount--;
|
||||
if(iActiveCount <= 0 && GetAction() == "Active")
|
||||
SetAction("Wait");
|
||||
if(iActiveCount > 0 && GetAction() == "Wait")
|
||||
SetAction("Active");
|
||||
}
|
||||
|
||||
/** Overload me to check station behaviour
|
||||
@return \c nil.
|
||||
/** Returns the waypoint to take next for the desired final point \a end
|
||||
* @param end The final destination for the information is queried
|
||||
*/
|
||||
private func CheckRailStation()
|
||||
public func GetNextWaypoint(object end)
|
||||
{
|
||||
/* EMPTY: Should be overloaded */
|
||||
return _inherited(...);
|
||||
if (!destination_list) return nil;
|
||||
for (var item in destination_list)
|
||||
{
|
||||
if (!item) continue;
|
||||
if (item[const_finaldestination] == end)
|
||||
return item[const_nextwaypoint];
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
/* Destruction */
|
||||
|
||||
/* Removes this crossing from the network
|
||||
It first clears every waypoint from the network and then renews the whole information.
|
||||
Optimisation welcome!
|
||||
/** Returns the actual traveling distance for the desired final point \a end
|
||||
* This is not the airline distance but the length of all cables to take via traveling
|
||||
* @param end The final destination for the information is queried
|
||||
*/
|
||||
protected func Destruction()
|
||||
public func GetLengthToTarget(object end)
|
||||
{
|
||||
for (var connection in FindObjects(Find_Func("IsConnectedTo", this)))
|
||||
if (!destination_list) return nil;
|
||||
for (var item in destination_list)
|
||||
{
|
||||
if (! connection->~IsCableLine()) continue;
|
||||
var other_crossing = connection->~GetOtherConnection(this);
|
||||
if (! other_crossing->~IsCableCrossing()) continue;
|
||||
other_crossing->ClearConnections(this);
|
||||
}
|
||||
for (var connection in FindObjects(Find_Func("IsConnectedTo", this)))
|
||||
{
|
||||
if (! connection->~IsCableLine()) continue;
|
||||
var other_crossing = connection->~GetOtherConnection(this);
|
||||
if (! other_crossing->~IsCableCrossing()) continue;
|
||||
other_crossing->RenewConnections(this);
|
||||
if (!item) continue;
|
||||
if (item[const_finaldestination] == end)
|
||||
return item[const_distance];
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
/*-- Auto production --*/
|
||||
|
||||
/*
|
||||
public func CheckAcquire(id object_id, int amount)
|
||||
{
|
||||
var container = false;
|
||||
|
@ -421,7 +402,7 @@ public func DeliveryDone(id object_id, int amount)
|
|||
}
|
||||
|
||||
/*-- Object requests and deliveries --*/
|
||||
|
||||
/*
|
||||
local reservations; // two dimensional array with ongoing deliveries: [[ID, amount]]
|
||||
|
||||
public func CheckAvailability(id object_id, int amount)
|
||||
|
@ -469,4 +450,4 @@ public func RequestObjects(object requester, id request_id, int amount)
|
|||
for (var i = 0; i < amount; i++)
|
||||
FindContents(request_id)->Enter(requester);
|
||||
return true;
|
||||
}
|
||||
}*/
|
|
@ -1,5 +0,0 @@
|
|||
Name=Cable Crossing
|
||||
SetStation=Bahnhof einrichten
|
||||
SetStationDesc=Diese Kreuzung zu einem Bahnhof umschalten
|
||||
UnsetStation=Bahnhof abschalten
|
||||
UnsetStationDesc=Diese Kreuzung von einem Bahnhof auf eine Kreuzung zurückschalten
|
|
@ -1,5 +0,0 @@
|
|||
Name=Cable Crossing
|
||||
SetStation=Set station
|
||||
SetStationDesc=Change crossing to station
|
||||
UnsetStation=Reset station
|
||||
UnsetStationDesc=Change station to crossing
|
After Width: | Height: | Size: 1.5 MiB |
After Width: | Height: | Size: 21 KiB |
After Width: | Height: | Size: 25 KiB |
Before Width: | Height: | Size: 141 B |
Before Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 1.6 KiB |
Before Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 1.4 KiB |
|
@ -1,217 +0,0 @@
|
|||
/*-- Cable line --*/
|
||||
|
||||
protected func Initialize()
|
||||
{
|
||||
SetAction("Connect");
|
||||
SetVertexXY(0, GetX(), GetY());
|
||||
SetVertexXY(1, GetX(), GetY());
|
||||
SetProperty("LineColors", [RGB(80,80,80), RGB(80,80,80)]);
|
||||
iPhase = 0;
|
||||
iActiveCount = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
local prec, prec2;
|
||||
local Layers;
|
||||
|
||||
public func UpdateDraw()
|
||||
{
|
||||
prec = 100;
|
||||
prec2 = 1000/prec;
|
||||
var origin = CreateArray(2);
|
||||
var ending = CreateArray(2);
|
||||
GetActionTarget(0)->GetCablePosition(origin);
|
||||
GetActionTarget(1)->GetCablePosition(ending);
|
||||
SetPosition(origin[0], origin[1]);
|
||||
var Length = Distance(origin[0], origin[1], ending[0], ending[1])*prec;
|
||||
var pos = 0;
|
||||
var i = 0;
|
||||
GetActionTarget(0)->GetCablePosition(origin, prec);
|
||||
GetActionTarget(1)->GetCablePosition(ending, prec);
|
||||
var angle = Angle(origin[0], origin[1], ending[0], ending[1]);
|
||||
// Log("Length %d Angle %d", Length, angle);
|
||||
var xoff = 0;//Cos(angle, 6*prec);
|
||||
var yoff = 0;//Sin(angle, 6*prec);
|
||||
while(pos < Length)
|
||||
{
|
||||
SetGraphics("Line0", GetID(), i*2+1, GFXOV_MODE_Base);
|
||||
SetLineTransform(-angle, xoff+(ending[0]-origin[0])*pos/Length, yoff+(ending[1]-origin[1])*pos/Length, 1000, i*2+1, 1);
|
||||
SetGraphics("Line0", GetID(), i*2+2, GFXOV_MODE_Base);
|
||||
SetLineTransform(-angle, -xoff+(ending[0]-origin[0])*pos/Length, -yoff+(ending[1]-origin[1])*pos/Length, 1000, i*2+2, 1);
|
||||
SetClrModulation(RGB(255,255*pos/Length), i*2+1);
|
||||
SetClrModulation(RGB(255,255*pos/Length), i*2+2);
|
||||
i++;
|
||||
pos += 8*prec-10;
|
||||
}
|
||||
while(i <= Layers)
|
||||
{
|
||||
SetGraphics(nil, GetID(), i*2+1, GFXOV_MODE_Base);
|
||||
SetGraphics(nil, GetID(), i*2+2, GFXOV_MODE_Base);
|
||||
i++;
|
||||
}
|
||||
Layers = i;
|
||||
}
|
||||
|
||||
protected func UpdateDraw2()
|
||||
{
|
||||
// Breaking
|
||||
var Length = ObjectDistance(GetActionTarget(0), GetActionTarget(1));
|
||||
if (GetVertexNum() > 2 || Length > max_distance)
|
||||
{
|
||||
OnLineBreak();
|
||||
return RemoveObject();
|
||||
}
|
||||
|
||||
prec = 100;
|
||||
prec2 = 1000/prec;
|
||||
SetPosition(GetActionTarget(0)->GetX(), GetActionTarget(0)->GetY());
|
||||
Length *= prec;
|
||||
var pos = 0;
|
||||
var i = 0;
|
||||
var startX = GetActionTarget(0)->GetX(prec), startY = GetActionTarget(0)->GetY(prec), endX = GetActionTarget(1)->GetX(prec), endY = GetActionTarget(1)->GetY(prec);
|
||||
var angle = Angle(startX, startY, endX, endY);
|
||||
var xoff = 0;//Cos(angle, 6*prec);
|
||||
var yoff = 0;//Sin(angle, 6*prec);
|
||||
while(pos < Length)
|
||||
{
|
||||
SetGraphics("Arrange", GetID(), i*2+1, GFXOV_MODE_Base);
|
||||
SetLineTransform(-angle, xoff+(endX-startX)*pos/Length, yoff+(endY-startY)*pos/Length, 1000, i*2+1, 1);
|
||||
// SetGraphics("Line0", GetID(), i*2+2, GFXOV_MODE_Base);
|
||||
// SetLineTransform(-angle, -xoff+(endX-startX)*pos/Length, -yoff+(endY-startY)*pos/Length, 1000, i*2+2, 1);
|
||||
i++;
|
||||
pos += 8*prec-10;
|
||||
}
|
||||
while(i <= Layers)
|
||||
{
|
||||
SetGraphics(nil, GetID(), i*2+1, GFXOV_MODE_Base);
|
||||
SetGraphics(nil, GetID(), i*2+2, GFXOV_MODE_Base);
|
||||
i++;
|
||||
}
|
||||
Layers = i;
|
||||
}
|
||||
|
||||
local iPhase;
|
||||
|
||||
public func Active()
|
||||
{
|
||||
var Name = Format("Line%d", iPhase);
|
||||
iPhase += 2;
|
||||
if(iPhase >= 8) iPhase = 0;
|
||||
for(var i = 0; i <= Layers; i++)
|
||||
{
|
||||
SetGraphics(Name, GetID(), i*2+1, 1);
|
||||
SetGraphics(Name, GetID(), i*2+2, 1);
|
||||
}
|
||||
}
|
||||
|
||||
func SetLineTransform(int r, int xoff, int yoff, int length, int layer, int MirrorSegments) {
|
||||
if(!MirrorSegments) MirrorSegments = 1;
|
||||
var fsin=Sin(r, 1000), fcos=Cos(r, 1000);
|
||||
// set matrix values
|
||||
SetObjDrawTransform (
|
||||
+fcos*MirrorSegments, +fsin*length/1000, xoff*prec2,
|
||||
-fsin*MirrorSegments, +fcos*length/1000, yoff*prec2,layer
|
||||
);
|
||||
}
|
||||
|
||||
// Returns true if this object is a functioning power line.
|
||||
public func IsCableLine()
|
||||
{
|
||||
return GetAction() == "Wait" || GetAction() == "Active";
|
||||
}
|
||||
|
||||
public func GetOtherConnection(object obj)
|
||||
{
|
||||
if(GetActionTarget(0) == obj) return GetActionTarget(1);
|
||||
if(GetActionTarget(1) == obj) return GetActionTarget(0);
|
||||
}
|
||||
|
||||
// Returns whether this power line is connected to an object.
|
||||
public func IsConnectedTo(object obj)
|
||||
{
|
||||
return GetActionTarget(0) == obj || GetActionTarget(1) == obj;
|
||||
}
|
||||
|
||||
// Returns the object which is connected to obj through this power line.
|
||||
public func GetConnectedObject(object obj)
|
||||
{
|
||||
if (GetActionTarget(0) == obj)
|
||||
return GetActionTarget(1);
|
||||
if (GetActionTarget(1) == obj)
|
||||
return GetActionTarget(0);
|
||||
return;
|
||||
}
|
||||
|
||||
public func SetConnectedObjects(obj1, obj2)
|
||||
{
|
||||
SetActionTargets(obj1, obj2);
|
||||
UpdateDraw();
|
||||
SetAction("Wait");
|
||||
obj1->AddCableConnection(this);
|
||||
}
|
||||
|
||||
protected func OnLineBreak(bool no_msg)
|
||||
{
|
||||
Sound("Objects::Connect");
|
||||
if (!no_msg)
|
||||
BreakMessage();
|
||||
return;
|
||||
}
|
||||
|
||||
private func BreakMessage()
|
||||
{
|
||||
var line_end = GetActionTarget(0);
|
||||
if (line_end->GetID() != CableLorryReel)
|
||||
line_end = GetActionTarget(1);
|
||||
if (line_end->Contained()) line_end = line_end->Contained();
|
||||
|
||||
line_end->Message("$TxtLinebroke$");
|
||||
return;
|
||||
}
|
||||
|
||||
local iActiveCount;
|
||||
|
||||
func AddActive(fRemove)
|
||||
{
|
||||
if(!fRemove)
|
||||
iActiveCount++;
|
||||
else
|
||||
iActiveCount--;
|
||||
if(iActiveCount <= 0 && GetAction() == "Active")
|
||||
SetAction("Wait");
|
||||
if(iActiveCount > 0 && GetAction() == "Wait")
|
||||
SetAction("Active");
|
||||
}
|
||||
|
||||
local ActMap = {
|
||||
Connect = {
|
||||
Prototype = Action,
|
||||
Name = "Connect",
|
||||
FacetBase = 0,
|
||||
Procedure = DFA_CONNECT,
|
||||
EndCall = "UpdateDraw2",
|
||||
Length = 1,
|
||||
Delay = 1,
|
||||
NextAction = "Connect",
|
||||
},
|
||||
Wait = {
|
||||
Prototype = Action,
|
||||
Name = "Wait",
|
||||
FacetBase = 0,
|
||||
Procedure = DFA_NONE,//CONNECT,
|
||||
NextAction = "Wait",
|
||||
},
|
||||
Active = {
|
||||
Prototype = Action,
|
||||
Name = "Active",
|
||||
Procedure = DFA_NONE,//CONNECT,
|
||||
Length = 1,
|
||||
Delay = 1,
|
||||
FacetBase = 0,
|
||||
EndCall = "Active",
|
||||
NextAction = "Active",
|
||||
},
|
||||
};
|
||||
|
||||
local Name = "$Name$";
|
||||
local max_distance = 200;
|
|
@ -1,2 +0,0 @@
|
|||
TxtLinebroke=Leitung gerissen
|
||||
Name=Kabelverbindung
|
|
@ -1,18 +1,16 @@
|
|||
[DefCore]
|
||||
id=CableCrossing
|
||||
Version=6,0
|
||||
Version=7,0
|
||||
Category=C4D_Structure
|
||||
Width=20
|
||||
Height=20
|
||||
Offset=-10,-10
|
||||
Vertices=3
|
||||
VertexX=0,-9,9
|
||||
VertexY=0,15,15
|
||||
VertexFriction=50,100,100
|
||||
Width=18
|
||||
Height=26
|
||||
Offset=-9,-13
|
||||
Vertices=5
|
||||
VertexX=6,0,-6,0,6
|
||||
VertexY=-9,0,12,12,12
|
||||
VertexFriction=50,50,100,100,100
|
||||
Value=40
|
||||
Mass=5
|
||||
#Components=Metal=1
|
||||
Picture=0,0,160,160
|
||||
Exclusive=1
|
||||
Construction=1
|
||||
Collection=-10,-10,20,20
|
||||
Construction=1
|
Before Width: | Height: | Size: 20 KiB |
|
@ -0,0 +1,8 @@
|
|||
[DefCore]
|
||||
id=CableCrossing_Icons
|
||||
Version=7,0
|
||||
Category=C4D_StaticBack
|
||||
Picture=0,0,64,64
|
||||
Width=64
|
||||
Height=64
|
||||
Offset=-32,-32
|
After Width: | Height: | Size: 152 B |
After Width: | Height: | Size: 7.2 KiB |
|
@ -0,0 +1,65 @@
|
|||
material CableCarStation
|
||||
{
|
||||
receive_shadows on
|
||||
technique
|
||||
{
|
||||
pass
|
||||
{
|
||||
ambient 0.9 0.9 0.9 1.0
|
||||
diffuse 0.9 0.9 0.9 1.0
|
||||
specular 0.0 0.0 0.0 1.0 12.5
|
||||
emissive 0.0 0.0 0.0 1.0
|
||||
|
||||
texture_unit
|
||||
{
|
||||
texture CableCarStation.png
|
||||
tex_address_mode wrap
|
||||
filtering trilinear
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
material CableCarStation_Sign
|
||||
{
|
||||
receive_shadows on
|
||||
technique
|
||||
{
|
||||
pass
|
||||
{
|
||||
ambient 1.0 1.0 1.0 1.0
|
||||
diffuse 1.0 1.0 1.0 1.0
|
||||
specular 0.0 0.0 0.0 1.0 12.5
|
||||
emissive 1.0 1.0 1.0 1.0
|
||||
|
||||
texture_unit
|
||||
{
|
||||
texture CableCarStation_sign.png
|
||||
tex_address_mode wrap
|
||||
filtering trilinear
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
material CableCarStation_SignStation
|
||||
{
|
||||
receive_shadows on
|
||||
technique
|
||||
{
|
||||
pass
|
||||
{
|
||||
ambient 1.0 1.0 1.0 1.0
|
||||
diffuse 1.0 1.0 1.0 1.0
|
||||
specular 0.0 0.0 0.0 1.0 12.5
|
||||
emissive 1.0 1.0 1.0 1.0
|
||||
|
||||
texture_unit
|
||||
{
|
||||
texture CableCarStation_station.png
|
||||
tex_address_mode wrap
|
||||
filtering trilinear
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,79 +1,133 @@
|
|||
/*--
|
||||
Cable Crossing
|
||||
|
||||
Author: Randrian, Clonkonaut
|
||||
The standard crossing for the cable network.
|
||||
The crossing will automatically be a station if it is at the end of the cable line (i.e. only one cable connected).
|
||||
But the crossing can also manually be set to function as a station.
|
||||
|
||||
Author: Clonkonaut
|
||||
--*/
|
||||
|
||||
#include Library_CableStation
|
||||
|
||||
local rotation = 0;
|
||||
// Prevents the automatic change of the station status when manually set to station mode
|
||||
local manual_setting = false;
|
||||
|
||||
protected func Initialize()
|
||||
// Called from the cable crossing library
|
||||
public func DestinationsUpdated()
|
||||
{
|
||||
SetAction("Wait");
|
||||
SetGraphics(nil, GetID(), 1, GFXOV_MODE_Base);
|
||||
return _inherited(...);
|
||||
// Do nothing if set manually
|
||||
if (manual_setting) return;
|
||||
|
||||
if (GetLength(FindObjects(Find_Func("IsConnectedTo", this))) == 1)
|
||||
SetCableStation(true);
|
||||
else
|
||||
SetCableStation(false);
|
||||
CheckStationStatus();
|
||||
}
|
||||
|
||||
protected func TurnWheel()
|
||||
{
|
||||
rotation -= 4;
|
||||
var fsin = Sin(rotation, 1000), fcos=Cos(rotation, 1000);
|
||||
var xoff = 0;
|
||||
var yoff = 0;
|
||||
// set matrix values
|
||||
SetObjDrawTransform (
|
||||
+fcos, +fsin, (1000-fcos)*xoff - fsin*yoff,
|
||||
-fsin, +fcos, (1000-fcos)*yoff + fsin*xoff, 1
|
||||
);
|
||||
}
|
||||
/* Interaction */
|
||||
|
||||
// Check whether I am a railway station
|
||||
// If so, set up new graphics
|
||||
// If not, disable graphics if needed
|
||||
private func CheckRailStation()
|
||||
// Provides an own interaction menu.
|
||||
public func HasInteractionMenu() { return true; }
|
||||
|
||||
// Show settings in interaction menu
|
||||
public func GetInteractionMenus(object clonk)
|
||||
{
|
||||
if (GetLength(FindObjects(Find_Func("IsConnectedTo", this))) == 1 || bManualSetting)
|
||||
var menus = _inherited() ?? [];
|
||||
var crossing_menu =
|
||||
{
|
||||
if (!is_station)
|
||||
{
|
||||
SetGraphics("Station", Library_CableStation, 2, GFXOV_MODE_Base);
|
||||
is_station = true;
|
||||
}
|
||||
}
|
||||
else if (is_station)
|
||||
{
|
||||
SetGraphics(nil, nil, 2, GFXOV_MODE_Base);
|
||||
is_station = false;
|
||||
}
|
||||
title = "$StationSettings$",
|
||||
entries_callback = this.GetSettingsMenuEntries,
|
||||
callback = nil,
|
||||
callback_hover = "OnSettingsHover",
|
||||
callback_target = this,
|
||||
BackgroundColor = RGB(0, 0, 50),
|
||||
Priority = 20
|
||||
};
|
||||
PushBack(menus, crossing_menu);
|
||||
|
||||
return menus;
|
||||
}
|
||||
|
||||
public func IsInteractable()
|
||||
public func GetSettingsMenuEntries()
|
||||
{
|
||||
var control_prototype =
|
||||
{
|
||||
BackgroundColor = { Std = 0, Selected = RGB(100, 30, 30) },
|
||||
OnMouseIn = GuiAction_SetTag("Selected"),
|
||||
OnMouseOut = GuiAction_SetTag("Std")
|
||||
};
|
||||
|
||||
var custom_entry =
|
||||
{
|
||||
Right = "3em", Bottom = "2em",
|
||||
image = { Prototype = control_prototype }
|
||||
};
|
||||
|
||||
var menu_entries = [];
|
||||
|
||||
// Clickable buttons
|
||||
var station = new custom_entry {
|
||||
Priority = 1000,
|
||||
Tooltip = "$TooltipToggleStation$",
|
||||
OnClick = GuiAction_Call(this, "ToggleStation", false)
|
||||
};
|
||||
station.image.Symbol = CableCrossing_Icons;
|
||||
station.image.GraphicsName = "Station";
|
||||
PushBack(menu_entries, { symbol = CableCrossing_Icons, extra_data = "Station", custom = station });
|
||||
|
||||
return menu_entries;
|
||||
}
|
||||
|
||||
public func OnSettingsHover(symbol, extra_data, desc_menu_target, menu_id)
|
||||
{
|
||||
if (symbol == nil) return;
|
||||
|
||||
var text = "";
|
||||
if (extra_data == "Station")
|
||||
text = "$DescToggleStation$";
|
||||
|
||||
GuiUpdate({ Text = text }, menu_id, 1, desc_menu_target);
|
||||
}
|
||||
|
||||
/* Settings */
|
||||
|
||||
public func ToggleStation(bool silent)
|
||||
{
|
||||
SetCableStation(!IsCableStation());
|
||||
if (!manual_setting)
|
||||
manual_setting = true;
|
||||
if (!silent)
|
||||
Sound("UI::Click2");
|
||||
CheckStationStatus();
|
||||
}
|
||||
|
||||
/* Visuals */
|
||||
|
||||
func CheckStationStatus()
|
||||
{
|
||||
if (IsCableStation())
|
||||
SetMeshMaterial("CableCarStation_SignStation", 1);
|
||||
else
|
||||
SetMeshMaterial("CableCarStation_Sign", 1);
|
||||
}
|
||||
|
||||
public func NoConstructionFlip() { return true; }
|
||||
|
||||
/* Saving */
|
||||
|
||||
func SaveScenarioObject(props)
|
||||
{
|
||||
if (!inherited(props, ...)) return false;
|
||||
if (IsCableStation() && manual_setting)
|
||||
props->AddCall("StationSetting", this, "ToggleStation", true);
|
||||
if (!IsCableStation() && manual_setting)
|
||||
props->AddCall("ManualSetting", this, "SetManual");
|
||||
return true;
|
||||
}
|
||||
|
||||
local ActMap = {
|
||||
Active = {
|
||||
Prototype = Action,
|
||||
Name = "Active",
|
||||
Procedure = DFA_NONE,
|
||||
Length = 1,
|
||||
Delay = 1,
|
||||
FacetBase = 0,
|
||||
NextAction = "Active",
|
||||
StartCall = "TurnWheel",
|
||||
},
|
||||
Wait = {
|
||||
Prototype = Action,
|
||||
Name = "Wait",
|
||||
Procedure = DFA_NONE,
|
||||
Length = 1,
|
||||
Delay = 0,
|
||||
FacetBase = 0,
|
||||
NextAction = "Wait",
|
||||
},
|
||||
};
|
||||
public func SetManual() { manual_setting = true; return true; }
|
||||
|
||||
local Name = "$Name$";
|
||||
local BlastIncinerate = 50;
|
||||
local BlastIncinerate = 50;
|
||||
local LineAttach = [6,-9];
|
|
@ -1,5 +1,7 @@
|
|||
Name=Cable Crossing
|
||||
SetStation=Bahnhof einrichten
|
||||
SetStationDesc=Diese Kreuzung zu einem Bahnhof umschalten
|
||||
UnsetStation=Bahnhof abschalten
|
||||
UnsetStationDesc=Diese Kreuzung von einem Bahnhof auf eine Kreuzung zurückschalten
|
||||
Name=Seilbahnkreuzung
|
||||
|
||||
StationSettings=Seilbahneinstellungen
|
||||
|
||||
TooltipToggleStation=Bahnhofs-Status umstellen.
|
||||
|
||||
DescToggleStation=Diese Kreuzung von Hand zu einem Bahnhof oder wieder zu einer Kreuzung umschalten. Nur Bahnhöfe sind als Ziel wählbar und nur am Bahnhöfen können Fahrzeuge aufgesetzt werden.
|
|
@ -1 +1,7 @@
|
|||
Name=Cable Crossing
|
||||
Name=Cable Crossing
|
||||
|
||||
StationSettings=Cable crossing settings
|
||||
|
||||
TooltipToggleStation=Toggle station status
|
||||
|
||||
DescToggleStation=Manually set or unset this crossing to be a cable station. Cable stations are selectable as targets when engaging a cable car onto the cable.
|
|
@ -0,0 +1,15 @@
|
|||
[DefCore]
|
||||
id=CableHoist
|
||||
Version=7,0
|
||||
Category=C4D_Vehicle
|
||||
Width=26
|
||||
Height=18
|
||||
Offset=-13,-9
|
||||
Vertices=5
|
||||
VertexX=0,-8,8,-9,9
|
||||
VertexY=-6,-5,-5,7,7
|
||||
VertexCNAT=5,6,9,10
|
||||
VertexFriction=50,80,80,30,30
|
||||
Value=20
|
||||
Mass=150
|
||||
Components=Metal=1
|
|
@ -0,0 +1,21 @@
|
|||
material CableHoist
|
||||
{
|
||||
receive_shadows on
|
||||
technique
|
||||
{
|
||||
pass
|
||||
{
|
||||
ambient 1.0 1.0 1.0 1.0
|
||||
diffuse 1.0 1.0 1.0 1.0
|
||||
specular 0.5 0.5 0.5 1.0 12.5
|
||||
emissive 0.0 0.0 0.0 1.0
|
||||
|
||||
texture_unit
|
||||
{
|
||||
texture cable_hoist.png
|
||||
tex_address_mode wrap
|
||||
filtering trilinear
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,141 @@
|
|||
/*-- Cable Hoist --*/
|
||||
|
||||
#include Library_CableCar
|
||||
|
||||
local pickup;
|
||||
|
||||
/* Creation */
|
||||
|
||||
func Construction()
|
||||
{
|
||||
SetProperty("MeshTransformation",Trans_Rotate(13,0,1,0));
|
||||
SetCableSpeed(1);
|
||||
}
|
||||
|
||||
/* Status */
|
||||
|
||||
public func IsToolProduct() { return true; }
|
||||
|
||||
/* Cable Car Library */
|
||||
|
||||
func GetCableOffset(array position, int prec)
|
||||
{
|
||||
if (!prec) prec = 1;
|
||||
position[1] += 7 * prec;
|
||||
}
|
||||
|
||||
func Engaged()
|
||||
{
|
||||
SetAction("OnRail");
|
||||
}
|
||||
|
||||
func GetCableCarExtraMenuEntries(array menu_entries, proplist custom_entry, object clonk)
|
||||
{
|
||||
if (IsTravelling()) return;
|
||||
|
||||
if (!pickup)
|
||||
{
|
||||
// Picking up vehicles
|
||||
var vehicles = FindObjects(Find_AtPoint(), Find_Category(C4D_Vehicle), Find_Not(Find_Func("RejectCableHoistPickup", this)), Find_Exclude(this), Find_Func(pickup));
|
||||
var i = 0;
|
||||
for (var vehicle in vehicles)
|
||||
{
|
||||
if (GetEffect("CableHoistPickup", vehicle)) continue;
|
||||
|
||||
var pickup = new custom_entry {
|
||||
Priority = 2000 + i,
|
||||
Tooltip = "$TooltipPickup$",
|
||||
OnClick = GuiAction_Call(this, "PickupVehicle", vehicle)
|
||||
};
|
||||
pickup.image.Symbol = vehicle;
|
||||
PushBack(menu_entries, { symbol = vehicle, extra_data = "Pickup", custom = pickup });
|
||||
i++;
|
||||
}
|
||||
} else {
|
||||
// Drop the vehicle
|
||||
var drop = new custom_entry {
|
||||
Priority = 2000,
|
||||
Tooltip = "$TooltipDrop$",
|
||||
OnClick = GuiAction_Call(this, "DropVehicle")
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/* Picking up vehicles */
|
||||
|
||||
public func PickupVehicle(object vehicle)
|
||||
{
|
||||
if (!vehicle) return;
|
||||
if (GetEffect("CableHoistPickup", vehicle)) return;
|
||||
var width = vehicle->GetObjWidth() / 2;
|
||||
var height = vehicle->GetObjHeight() / 2;
|
||||
if (!Inside(GetX(), vehicle->GetX() - width, vehicle->GetX() + width))
|
||||
if (!Inside(GetY(), vehicle->GetY() - height, vehicle->GetY() + height))
|
||||
return;
|
||||
|
||||
AddEffect("CableHoistPickup", vehicle, 1, 1, this);
|
||||
UpdateInteractionMenus(this.GetCableCarMenuEntries);
|
||||
}
|
||||
|
||||
public func DropVehicle()
|
||||
{
|
||||
if (!pickup) return;
|
||||
RemoveEffect("CableHoistPickup", pickup);
|
||||
UpdateInteractionMenus(this.GetCableCarMenuEntries);
|
||||
}
|
||||
|
||||
func FxCableHoistPickupStart(object vehicle, proplist effect)
|
||||
{
|
||||
vehicle->SetPosition(GetX(), GetY());
|
||||
vehicle->SetSpeed(0,0);
|
||||
vehicle->SetR(GetR());
|
||||
vehicle->SetRDir(0);
|
||||
|
||||
pickup = vehicle;
|
||||
}
|
||||
|
||||
func FxCableHoistPickupTimer(object vehicle, proplist effect)
|
||||
{
|
||||
vehicle->SetPosition(GetX(), GetY());
|
||||
vehicle->SetSpeed(0,0);
|
||||
}
|
||||
|
||||
func FxCableHoistPickupStop(object vehicle, proplist effect)
|
||||
{
|
||||
pickup = nil;
|
||||
}
|
||||
|
||||
/* Actions */
|
||||
|
||||
func OnRail()
|
||||
{
|
||||
DoMovement();
|
||||
}
|
||||
|
||||
local ActMap = {
|
||||
OnRail = {
|
||||
Prototype = Action,
|
||||
Name = "OnRail",
|
||||
Procedure = DFA_FLOAT,
|
||||
Directions = 2,
|
||||
FlipDir = 1,
|
||||
Length = 1,
|
||||
Delay = 1,
|
||||
X = 0,
|
||||
Y = 0,
|
||||
Wdt = 26,
|
||||
Hgt = 18,
|
||||
EndCall = "OnRail",
|
||||
NextAction = "OnRail",
|
||||
},
|
||||
};
|
||||
|
||||
func Definition(def)
|
||||
{
|
||||
SetProperty("PictureTransformation",Trans_Mul(Trans_Rotate(-25,1,0,0),Trans_Rotate(40,0,1,0)),def);
|
||||
}
|
||||
|
||||
local Name = "$Name$";
|
||||
local Description = "$Description$";
|
||||
local Touchable = 1;
|
||||
local BorderBound = C4D_Border_Sides;
|
|
@ -0,0 +1,5 @@
|
|||
Name=Schlitten
|
||||
Description=Zum Aufsatz auf Kabel. Transportiert Fahrzeuge.
|
||||
|
||||
TooltipPickup=Dieses Fahrzeug an den Schlitten anhängen.
|
||||
TooltipDrop=Dieses Fahrzeug vom Schlitten abnehmen.
|
|
@ -0,0 +1,5 @@
|
|||
Name=Hoist
|
||||
Description=To use on a cable. Transports vehicles.
|
||||
|
||||
TooltipPickup=Attach this vehicle to the hoist.
|
||||
TooltipDrop=Drop this vehicle from the hoist.
|
After Width: | Height: | Size: 191 KiB |
|
@ -0,0 +1,21 @@
|
|||
material Lorry2
|
||||
{
|
||||
receive_shadows on
|
||||
technique
|
||||
{
|
||||
pass
|
||||
{
|
||||
ambient 1 1 1 1.0
|
||||
diffuse 0.9 0.9 0.9 1.0
|
||||
specular 0.5 0.5 0.5 1.0 12.5
|
||||
emissive 0.0 0.0 0.0 1.0
|
||||
|
||||
texture_unit
|
||||
{
|
||||
texture lorry_new.png
|
||||
tex_address_mode wrap
|
||||
filtering trilinear
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,13 +1,11 @@
|
|||
/*-- Lorry --*/
|
||||
|
||||
|
||||
#include Library_CableCar
|
||||
|
||||
local content_menu;
|
||||
|
||||
protected func Construction()
|
||||
{
|
||||
PlayAnimation("Open", 1, Anim_Linear(0, 0, 1, 20, ANIM_Hold));
|
||||
//PlayAnimation("Open", 1, Anim_Linear(0, 0, 1, 20, ANIM_Hold));
|
||||
SetProperty("MeshTransformation",Trans_Rotate(13,0,1,0));
|
||||
}
|
||||
|
||||
|
@ -18,15 +16,18 @@ public func IsToolProduct() { return true; }
|
|||
local drive_anim;
|
||||
local tremble_anim;
|
||||
|
||||
local tilt_anim;
|
||||
|
||||
protected func Initialize()
|
||||
{
|
||||
drive_anim = PlayAnimation("Drive", 5, Anim_Const(0), Anim_Const(500) /* ignored anyway */);
|
||||
tremble_anim = PlayAnimation("Tremble", 5, Anim_Const(0), Anim_Const(500));
|
||||
drive_anim = PlayAnimation("Drive", 1, Anim_Const(0), Anim_Const(500));
|
||||
//tremble_anim = PlayAnimation("Tremble", 5, Anim_Const(0), Anim_Const(500));
|
||||
|
||||
tilt_anim = PlayAnimation("Empty", 1, Anim_Const(0), Anim_Const(100));
|
||||
|
||||
iRotWheels = 0;
|
||||
AddTimer("TurnWheels", 1);
|
||||
iTremble = 0;
|
||||
iMovementSpeed = 2;
|
||||
return _inherited(...);
|
||||
}
|
||||
|
||||
|
@ -92,7 +93,7 @@ func TurnWheels()
|
|||
iTremble += 100;
|
||||
if(iTremble < 0) iTremble += 2000;
|
||||
if(iTremble > 2000) iTremble -= 2000;
|
||||
SetAnimationPosition(tremble_anim, Anim_Const(iTremble));
|
||||
//SetAnimationPosition(tremble_anim, Anim_Const(iTremble));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Before Width: | Height: | Size: 96 KiB |
After Width: | Height: | Size: 1.0 MiB |
After Width: | Height: | Size: 8.9 KiB |
After Width: | Height: | Size: 8.9 KiB |
|
@ -0,0 +1,117 @@
|
|||
/* Automatically created objects file */
|
||||
|
||||
func InitializeObjects()
|
||||
{
|
||||
var CableCrossing001 = CreateObjectAbove(CableCrossing, 347, 389);
|
||||
var CableCrossing002 = CreateObjectAbove(CableCrossing, 554, 391);
|
||||
|
||||
var CableLine001 = CreateObjectAbove(CableLine, 551, 749);
|
||||
CableLine001->SetAction("Connect", CableCrossing001, CableCrossing002);
|
||||
CableLine001->SetConnectedObjects(CableCrossing001, CableCrossing002);
|
||||
|
||||
var CableCrossing003 = CreateObjectAbove(CableCrossing, 209, 390);
|
||||
|
||||
var CableLine002 = CreateObjectAbove(CableLine, 206, 747);
|
||||
CableLine002->SetAction("Connect", CableCrossing001, CableCrossing003);
|
||||
CableLine002->SetConnectedObjects(CableCrossing001, CableCrossing003);
|
||||
|
||||
var CableCrossing004 = CreateObjectAbove(CableCrossing, 652, 491);
|
||||
|
||||
var CableLine003 = CreateObjectAbove(CableLine, 551, 849);
|
||||
CableLine003->SetAction("Connect", CableCrossing004, CableCrossing002);
|
||||
CableLine003->SetConnectedObjects(CableCrossing004, CableCrossing002);
|
||||
|
||||
var CableCrossing005 = CreateObjectAbove(CableCrossing, 694, 419);
|
||||
|
||||
var CableLine004 = CreateObjectAbove(CableLine, 651, 949);
|
||||
CableLine004->SetAction("Connect", CableCrossing005, CableCrossing004);
|
||||
CableLine004->SetConnectedObjects(CableCrossing005, CableCrossing004);
|
||||
|
||||
var CableCrossing006 = CreateObjectAbove(CableCrossing, 770, 360);
|
||||
|
||||
var CableLine005 = CreateObjectAbove(CableLine, 693, 806);
|
||||
CableLine005->SetAction("Connect", CableCrossing006, CableCrossing005);
|
||||
CableLine005->SetConnectedObjects(CableCrossing006, CableCrossing005);
|
||||
|
||||
var CableCrossing007 = CreateObjectAbove(CableCrossing, 810, 351);
|
||||
|
||||
var CableLine006 = CreateObjectAbove(CableLine, 771, 687);
|
||||
CableLine006->SetAction("Connect", CableCrossing007, CableCrossing006);
|
||||
CableLine006->SetConnectedObjects(CableCrossing007, CableCrossing006);
|
||||
|
||||
var CableCrossing008 = CreateObjectAbove(CableCrossing, 939, 360);
|
||||
|
||||
var CableLine007 = CreateObjectAbove(CableLine, 815, 679);
|
||||
CableLine007->SetAction("Connect", CableCrossing008, CableCrossing007);
|
||||
CableLine007->SetConnectedObjects(CableCrossing008, CableCrossing007);
|
||||
|
||||
var CableCrossing009 = CreateObjectAbove(CableCrossing, 599, 257);
|
||||
|
||||
var CableLine008 = CreateObjectAbove(CableLine, 808, 669);
|
||||
CableLine008->SetAction("Connect", CableCrossing009, CableCrossing007);
|
||||
CableLine008->SetConnectedObjects(CableCrossing009, CableCrossing007);
|
||||
|
||||
var CableCrossing010 = CreateObjectAbove(CableCrossing, 519, 259);
|
||||
|
||||
var CableLine009 = CreateObjectAbove(CableLine, 599, 484);
|
||||
CableLine009->SetAction("Connect", CableCrossing010, CableCrossing009);
|
||||
CableLine009->SetConnectedObjects(CableCrossing010, CableCrossing009);
|
||||
|
||||
var CableCrossing011 = CreateObjectAbove(CableCrossing, 465, 289);
|
||||
|
||||
var CableLine010 = CreateObjectAbove(CableLine, 517, 516);
|
||||
CableLine010->SetAction("Connect", CableCrossing011, CableCrossing010);
|
||||
CableLine010->SetConnectedObjects(CableCrossing011, CableCrossing010);
|
||||
var CableLine011 = CreateObjectAbove(CableLine, 465, 645);
|
||||
CableLine011->SetAction("Connect", CableCrossing003, CableCrossing011);
|
||||
CableLine011->SetConnectedObjects(CableCrossing003, CableCrossing011);
|
||||
|
||||
var CableCrossing012 = CreateObjectAbove(CableCrossing, 744, 589);
|
||||
|
||||
var CableLine012 = CreateObjectAbove(CableLine, 652, 1046);
|
||||
CableLine012->SetAction("Connect", CableCrossing012, CableCrossing004);
|
||||
CableLine012->SetConnectedObjects(CableCrossing012, CableCrossing004);
|
||||
|
||||
var CableCrossing013 = CreateObjectAbove(CableCrossing, 680, 619);
|
||||
|
||||
var CableLine013 = CreateObjectAbove(CableLine, 743, 1174);
|
||||
CableLine013->SetAction("Connect", CableCrossing013, CableCrossing012);
|
||||
CableLine013->SetConnectedObjects(CableCrossing013, CableCrossing012);
|
||||
|
||||
var CableCrossing014 = CreateObjectAbove(CableCrossing, 568, 690);
|
||||
|
||||
var CableLine014 = CreateObjectAbove(CableLine, 678, 1278);
|
||||
CableLine014->SetAction("Connect", CableCrossing014, CableCrossing013);
|
||||
CableLine014->SetConnectedObjects(CableCrossing014, CableCrossing013);
|
||||
|
||||
var CableCrossing015 = CreateObjectAbove(CableCrossing, 456, 711);
|
||||
|
||||
var CableLine015 = CreateObjectAbove(CableLine, 570, 1369);
|
||||
CableLine015->SetAction("Connect", CableCrossing015, CableCrossing014);
|
||||
CableLine015->SetConnectedObjects(CableCrossing015, CableCrossing014);
|
||||
|
||||
var CableCrossing016 = CreateObjectAbove(CableCrossing, 372, 650);
|
||||
|
||||
var CableLine016 = CreateObjectAbove(CableLine, 454, 1390);
|
||||
CableLine016->SetAction("Connect", CableCrossing016, CableCrossing015);
|
||||
CableLine016->SetConnectedObjects(CableCrossing016, CableCrossing015);
|
||||
|
||||
var CableCrossing017 = CreateObjectAbove(CableCrossing, 231, 590);
|
||||
|
||||
var CableLine017 = CreateObjectAbove(CableLine, 374, 1266);
|
||||
CableLine017->SetAction("Connect", CableCrossing017, CableCrossing016);
|
||||
CableLine017->SetConnectedObjects(CableCrossing017, CableCrossing016);
|
||||
|
||||
var CableCrossing018 = CreateObjectAbove(CableCrossing, 131, 528);
|
||||
|
||||
var CableLine018 = CreateObjectAbove(CableLine, 231, 1148);
|
||||
CableLine018->SetAction("Connect", CableCrossing018, CableCrossing017);
|
||||
CableLine018->SetConnectedObjects(CableCrossing018, CableCrossing017);
|
||||
|
||||
CreateObjectAbove(CableHoist, 527, 380);
|
||||
|
||||
CreateObjectAbove(CableLorry, 503, 380);
|
||||
|
||||
CreateObjectAbove(CableLorryReel, 530, 388);
|
||||
return true;
|
||||
}
|
|
@ -1,36 +1,29 @@
|
|||
[Head]
|
||||
Icon=26
|
||||
Title=CableLorries
|
||||
Version=6,0
|
||||
Version=8
|
||||
Difficulty=10
|
||||
MaxPlayer=8
|
||||
NoInitialize=0
|
||||
|
||||
[Definitions]
|
||||
Definition1=Objects.ocd
|
||||
NoInitialize=true
|
||||
|
||||
[Game]
|
||||
Rules=RSTR=1
|
||||
|
||||
[Player1]
|
||||
Wealth=50,0,0,250
|
||||
Crew=Clonk=1
|
||||
Knowledge=WoodenCabin=1;Foundry=1;SteamEngine=1;ToolsWorkshop=1;WindGenerator=1;CableCrossing=1;Pickaxe=1;Axe=1;Hammer=1;Shovel=1;DynamiteBox=1;
|
||||
Knowledge=WoodenCabin=1;Foundry=1;SteamEngine=1;ToolsWorkshop=1;WindGenerator=1;CableCrossing=1;Pickaxe=1;Axe=1;Hammer=1;Shovel=1;DynamiteBox=1
|
||||
|
||||
[Player2]
|
||||
Wealth=50,0,0,250
|
||||
Crew=Clonk=1
|
||||
Knowledge=WoodenCabin=1;Foundry=1;SteamEngine=1;ToolsWorkshop=1;WindGenerator=1;CableCrossing=1;Pickaxe=1;Axe=1;Hammer=1;Shovel=1;DynamiteBox=1;
|
||||
Knowledge=WoodenCabin=1;Foundry=1;SteamEngine=1;ToolsWorkshop=1;WindGenerator=1;CableCrossing=1;Pickaxe=1;Axe=1;Hammer=1;Shovel=1;DynamiteBox=1
|
||||
|
||||
[Player3]
|
||||
Wealth=50,0,0,250
|
||||
Crew=Clonk=1
|
||||
Knowledge=WoodenCabin=1;Foundry=1;SteamEngine=1;ToolsWorkshop=1;WindGenerator=1;CableCrossing=1;Pickaxe=1;Axe=1;Hammer=1;Shovel=1;DynamiteBox=1;
|
||||
Knowledge=WoodenCabin=1;Foundry=1;SteamEngine=1;ToolsWorkshop=1;WindGenerator=1;CableCrossing=1;Pickaxe=1;Axe=1;Hammer=1;Shovel=1;DynamiteBox=1
|
||||
|
||||
[Player4]
|
||||
Wealth=50,0,0,250
|
||||
Crew=Clonk=1
|
||||
Knowledge=WoodenCabin=1;Foundry=1;SteamEngine=1;ToolsWorkshop=1;WindGenerator=1;CableCrossing=1;Pickaxe=1;Axe=1;Hammer=1;Shovel=1;DynamiteBox=1;
|
||||
Knowledge=WoodenCabin=1;Foundry=1;SteamEngine=1;ToolsWorkshop=1;WindGenerator=1;CableCrossing=1;Pickaxe=1;Axe=1;Hammer=1;Shovel=1;DynamiteBox=1
|
||||
|
||||
[Landscape]
|
||||
Vegetation=Mushroom=1
|
||||
|
@ -41,7 +34,7 @@ Sky=Clouds2
|
|||
BottomOpen=1
|
||||
MapWidth=500,0,64,10000
|
||||
MapHeight=100,0,40,10000
|
||||
MapZoom=10
|
||||
MapZoom=10,0,5,15
|
||||
Amplitude=10,10,0,100
|
||||
Phase=50,50,0,100
|
||||
Period=10,10,0,100
|
||||
|
@ -50,12 +43,8 @@ Liquid=Water-Smooth
|
|||
LiquidLevel=20,30,0,100
|
||||
Layers=Rock=7;Rock=7;Gold=7;Granite=4;Water=5;Earth-earth=50;Earth-earth_dry=50
|
||||
SkyScrollMode=2
|
||||
NewStyleLandscape=2
|
||||
|
||||
[Weather]
|
||||
Climate=0,0,0,100
|
||||
YearSpeed=20,10,0,100
|
||||
Wind=1,100,-100,100
|
||||
|
||||
[Environment]
|
||||
Objects=EGLN=1;EGRS=1
|
||||
Wind=1,100,-100,100
|
|
@ -10,23 +10,23 @@
|
|||
|
||||
protected func Initialize()
|
||||
{
|
||||
var workshop = CreateObjectAbove(ToolsWorkshop, 835, 360);
|
||||
var c1 = CreateObjectAbove(CableCrossing, 765, 355);
|
||||
var c2 = CreateObjectAbove(CableCrossing, 695, 415);
|
||||
var c3 = CreateObjectAbove(CableCrossing, 585, 415);
|
||||
var c4 = CreateObjectAbove(CableCrossing, 555, 385);
|
||||
var cabin = CreateObjectAbove(WoodenCabin, 490, 390);
|
||||
//var workshop = CreateObjectAbove(ToolsWorkshop, 835, 360);
|
||||
//var c1 = CreateObjectAbove(CableCrossing, 765, 355);
|
||||
//var c2 = CreateObjectAbove(CableCrossing, 695, 415);
|
||||
//var c3 = CreateObjectAbove(CableCrossing, 585, 415);
|
||||
//var c4 = CreateObjectAbove(CableCrossing, 555, 385);
|
||||
//var cabin = CreateObjectAbove(WoodenCabin, 490, 390);
|
||||
// CreateObjectAbove(LiftTower, 935, 360);
|
||||
|
||||
// CreateObjectAbove(CableLine)->SetConnectedObjects(workshop, c1);
|
||||
CreateObjectAbove(CableLine)->SetConnectedObjects(c1, c2);
|
||||
CreateObjectAbove(CableLine)->SetConnectedObjects(c2, c3);
|
||||
CreateObjectAbove(CableLine)->SetConnectedObjects(c3, c4);
|
||||
//CreateObjectAbove(CableLine)->SetConnectedObjects(c1, c2);
|
||||
//CreateObjectAbove(CableLine)->SetConnectedObjects(c2, c3);
|
||||
//CreateObjectAbove(CableLine)->SetConnectedObjects(c3, c4);
|
||||
// CreateObjectAbove(CableLine)->SetConnectedObjects(c4, cabin);
|
||||
|
||||
CreateObjectAbove(Lorry, 835, 360);
|
||||
//CreateObjectAbove(Lorry, 835, 360);
|
||||
|
||||
CreateConstruction(Elevator, 160, 390, NO_OWNER, 100, true)->CreateShaft(150);
|
||||
//CreateConstruction(Elevator, 160, 390, NO_OWNER, 100, true)->CreateShaft(150);
|
||||
|
||||
// Forest on the left side of the map, with sawmill.
|
||||
/* for (var i = 0; i < 20; i++)
|
||||
|
@ -148,7 +148,7 @@ protected func Initialize()
|
|||
protected func InitializePlayer(int plr)
|
||||
{
|
||||
// No FOW here.
|
||||
SetFoW(false, plr);
|
||||
//SetFoW(false, plr);
|
||||
JoinPlayer(plr);
|
||||
return;
|
||||
}
|
||||
|
|