diff --git a/planet/Objects.ocd/Items.ocd/Tools.ocd/DivingHelmet.ocd/Script.c b/planet/Objects.ocd/Items.ocd/Tools.ocd/DivingHelmet.ocd/Script.c index de3e0b9fc..4925a88fd 100644 --- a/planet/Objects.ocd/Items.ocd/Tools.ocd/DivingHelmet.ocd/Script.c +++ b/planet/Objects.ocd/Items.ocd/Tools.ocd/DivingHelmet.ocd/Script.c @@ -45,7 +45,9 @@ public func QueryAirNeed(object pump) { var wearer = Contained(); if (wearer && IsWorn()) + { return wearer->~GetBreath() < wearer->~GetMaxBreath(); + } return false; } @@ -103,28 +105,33 @@ func OnPipeDisconnect(object pipe) var other = air_pipe->GetConnectedObject(this); if (!other || other->GetID() != Pump) + { pipe->SetNeutralPipe(); + } pipe->SetDrainPipe(); other->~CheckState(); } // Called by the interaction menu (OnPipeControl) -public func DoConnectPipe(object pipe, string specific_pipe_state) +public func DoConnectPipe(object pipe, string specific_pipe_state, object clonk) { if (!pipe) return; if (GetConnectedPipe()) - DoCutPipe(GetConnectedPipe()); + { + DoCutPipe(GetConnectedPipe(), clonk); + } pipe->ConnectPipeTo(this, PIPE_STATE_Air); } // Called by the interaction menu (OnPipeControl) -public func DoCutPipe(object pipe) +public func DoCutPipe(object pipe, object clonk) { - if (pipe) - if (pipe->~GetPipeKit()) - pipe->GetPipeKit()->CutLineConnection(this); + if (pipe && pipe->~GetPipeKit()) + { + pipe->GetPipeKit()->CutLineConnection(this, clonk); + } } /*-- Usage --*/ @@ -132,9 +139,13 @@ public func DoCutPipe(object pipe) public func ControlUse(object clonk) { if (IsWorn()) + { TakeOff(); + } else + { PutOn(clonk); + } return true; } @@ -157,13 +168,17 @@ public func QueryConnectPipe(object pipe, bool do_msg) if (GetConnectedPipe()) { if (do_msg) + { pipe->Report("$MsgHasPipe$"); + } return true; } if (pipe->IsSourcePipe()) { if (do_msg) + { pipe->Report("$MsgPipeProhibited$"); + } return true; } return false; @@ -240,12 +255,16 @@ public func OnPipeControlHover(id symbol, string action, desc_menu_target, menu_ GuiUpdateText(text, menu_id, 1, desc_menu_target); } -public func OnPipeControl(symbol_or_object, string action, bool alt) +public func OnPipeControl(symbol_or_object, string action, object clonk) { if (action == "cutpipe") - this->DoCutPipe(air_pipe); + { + this->DoCutPipe(air_pipe, clonk); + } else if (action == "connectpipe") - this->DoConnectPipe(symbol_or_object); + { + this->DoConnectPipe(symbol_or_object, nil, clonk); + } UpdateInteractionMenus(this.GetPipeControlMenuEntries); } @@ -301,4 +320,4 @@ func Definition(def) local Name = "$Name$"; local Description = "$Description$"; local Collectible = true; -local Components = {Wood = 1, Metal = 1}; \ No newline at end of file +local Components = {Wood = 1, Metal = 1}; diff --git a/planet/Objects.ocd/Items.ocd/Tools.ocd/Pipe.ocd/Script.c b/planet/Objects.ocd/Items.ocd/Tools.ocd/Pipe.ocd/Script.c index c8215795a..803686457 100644 --- a/planet/Objects.ocd/Items.ocd/Tools.ocd/Pipe.ocd/Script.c +++ b/planet/Objects.ocd/Items.ocd/Tools.ocd/Pipe.ocd/Script.c @@ -277,31 +277,44 @@ public func AddLineConnectionTo(object target, bool block_cutting) connected to the line. @par target the target object + @par possible_container a container that should try to collect the pipe. */ -public func CutLineConnection(object target) +public func CutLineConnection(object target, object possible_container) { var line = GetConnectedLine(); if (!line) return; + var allow_pickup = false; - // connected only to the kit and a structure + // Connected only to the kit and a structure if (line->IsConnectedTo(this, true)) { target->OnPipeDisconnect(this); line->RemoveObject(); + // Collection by container, should be near enough or else you'd be able to + // retrieve a line where the line kit is down a well, but you simply detach it from the pump... + // Radius is the same as picking up objects via the surrounding + allow_pickup = ObjectDistance(possible_container, this) <= Helper_Surrounding.Radius; } - // connected to the target and another structure + // Connected to the target and another structure else if (line->IsConnectedTo(target, true)) { target->OnPipeDisconnect(this); - Exit(); // the kit was inside the line at this point. + Exit(); // The kit was inside the line at this point. SetPosition(target->GetX(), target->GetY() + target->GetBottom() - this->GetBottom()); line->SwitchConnection(target, this); SetPipeLine(line); + // Can be picked up always + allow_pickup = true; } else { FatalError(Format("An object %v is trying to cut the pipe connection, but only objects %v and %v may request a disconnect", target, line->GetActionTarget(0), line->GetActionTarget(1))); } + // Pick it up + if (possible_container && allow_pickup) + { + possible_container->Collect(this); + } } // Returns whether the cutting pipe is blocked. diff --git a/planet/Objects.ocd/Libraries.ocd/LiquidControl.ocd/LiquidTank.ocd/Script.c b/planet/Objects.ocd/Libraries.ocd/LiquidControl.ocd/LiquidTank.ocd/Script.c index a1c514923..7e1f9fd7a 100644 --- a/planet/Objects.ocd/Libraries.ocd/LiquidControl.ocd/LiquidTank.ocd/Script.c +++ b/planet/Objects.ocd/Libraries.ocd/LiquidControl.ocd/LiquidTank.ocd/Script.c @@ -160,22 +160,36 @@ public func OnPipeControlHover(symbol_or_object, string action, desc_menu_target GuiUpdateText(text, menu_id, 1, desc_menu_target); } -public func OnPipeControl(symbol_or_object, string action, bool alt) +public func OnPipeControl(symbol_or_object, string action, object clonk) { if (action == LIBRARY_TANK_Menu_Action_Add_Source) + { this->DoConnectPipe(symbol_or_object, PIPE_STATE_Source); + } else if (action == LIBRARY_TANK_Menu_Action_Cut_Source) - this->DoCutPipe(GetSourcePipe()); + { + this->DoCutPipe(GetSourcePipe(), clonk); + } else if (action == LIBRARY_TANK_Menu_Action_Add_Drain) + { this->DoConnectPipe(symbol_or_object, PIPE_STATE_Drain); + } else if (action == LIBRARY_TANK_Menu_Action_Cut_Drain) - this->DoCutPipe(GetDrainPipe()); + { + this->DoCutPipe(GetDrainPipe(), clonk); + } else if (action == LIBRARY_TANK_Menu_Action_Add_Neutral) + { this->DoConnectPipe(symbol_or_object, PIPE_STATE_Neutral); + } else if (action == LIBRARY_TANK_Menu_Action_Cut_Neutral) - this->DoCutPipe(GetNeutralPipe()); + { + this->DoCutPipe(GetNeutralPipe(), clonk); + } else if (action == LIBRARY_TANK_Menu_Action_Swap_SourceDrain) + { this->DoSwapSourceDrain(GetSourcePipe(), GetDrainPipe()); + } UpdateInteractionMenus(this.GetPipeControlMenuEntries); } @@ -236,11 +250,11 @@ public func DoConnectPipe(object pipe, string specific_pipe_state) pipe->ConnectPipeTo(this, specific_pipe_state); } -public func DoCutPipe(object pipe) +public func DoCutPipe(object pipe, object clonk) { if (pipe) { - pipe->CutLineConnection(this); + pipe->CutLineConnection(this, clonk); } } diff --git a/planet/Objects.ocd/Structures.ocd/Pump.ocd/Script.c b/planet/Objects.ocd/Structures.ocd/Pump.ocd/Script.c index 1f7dfe43e..eacb8896c 100644 --- a/planet/Objects.ocd/Structures.ocd/Pump.ocd/Script.c +++ b/planet/Objects.ocd/Structures.ocd/Pump.ocd/Script.c @@ -226,11 +226,11 @@ public func OnPipeControlHover(symbol_or_object, string action, desc_menu_target return inherited(symbol_or_object, action, desc_menu_target, menu_id, ...); } -public func OnPipeControl(symbol_or_object, string action, bool alt) +public func OnPipeControl(symbol_or_object, string action, object clonk) { if (action == LIBRARY_TANK_Menu_Action_Cut_AirPipe) { - this->DoCutPipe(GetDrainPipe()); + this->DoCutPipe(GetDrainPipe(), clonk); UpdateInteractionMenus(this.GetPipeControlMenuEntries); return; } @@ -240,7 +240,7 @@ public func OnPipeControl(symbol_or_object, string action, bool alt) UpdateInteractionMenus(this.GetPipeControlMenuEntries); return; } - return inherited(symbol_or_object, action, alt, ...); + return inherited(symbol_or_object, action, clonk, ...); }