From 58c2c45751220119ded3e1739579ee4717c0c2d2 Mon Sep 17 00:00:00 2001 From: Clonkonaut Date: Tue, 28 Jan 2014 19:40:11 +0100 Subject: [PATCH] Fixed clonk's physical not being reset sometimes. --- .../Libraries.ocd/CarryHeavy.ocd/Script.c | 18 +++++++++++++----- .../Libraries.ocd/Producer.ocd/Script.c | 2 +- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/planet/Objects.ocd/Libraries.ocd/CarryHeavy.ocd/Script.c b/planet/Objects.ocd/Libraries.ocd/CarryHeavy.ocd/Script.c index d8884adf0..2af524959 100644 --- a/planet/Objects.ocd/Libraries.ocd/CarryHeavy.ocd/Script.c +++ b/planet/Objects.ocd/Libraries.ocd/CarryHeavy.ocd/Script.c @@ -6,6 +6,7 @@ --*/ local liftheavy_carrier; +local liftheavy_effect; public func IsCarryHeavy() { return true; } public func IsInvInteract() { return true; } @@ -114,7 +115,7 @@ func FxIntLiftHeavyTimer(object clonk, proplist effect, int timer) //When the clonk has finished lifting, remove movement-restrictions and add carry effect if(timer >= lift_heavy_time) { - AddEffect("IntCarryHeavy", clonk, 1, 1, this); + liftheavy_effect = AddEffect("IntCarryHeavy", clonk, 1, 1, this); // don't exit the object effect.doExit = false; return -1; @@ -156,6 +157,7 @@ func FxIntCarryHeavyStart(object clonk, proplist effect, int temp) func FxIntCarryHeavyTimer(object clonk, proplist effect, int timer) { + if (!this) return -1; //Delete this effect if not contained in the clonk anymore if(Contained() != clonk) return -1; } @@ -165,8 +167,9 @@ func FxIntCarryHeavyStop(object clonk, proplist effect, int reason, bool temp) if (temp) return; clonk->EnableScale(); clonk->EnableHangle(); - Log("hey"); clonk.ThrowSpeed += effect.throw; + effect.throw = 0; // Failsafe + liftheavy_effect = nil; } // ------------------ @@ -266,7 +269,7 @@ func IsCarryingHeavy(object clonk) return false; } -protected func Entrance(object obj) +func Entrance(object obj) { // tell the carrier to carryheavy if it got moved into it by script if(!liftheavy_carrier) @@ -280,17 +283,22 @@ protected func Entrance(object obj) } } -protected func Departure(object obj) +func Departure(object obj) { if(!liftheavy_carrier) return; + if (GetEffect("IntCarryHeavy", obj)) RemoveEffect("IntCarryHeavy", obj); liftheavy_carrier = nil; } +func Destruction() +{ + if (liftheavy_effect) RemoveEffect(nil,nil, liftheavy_effect); +} // Cannot pickup other carryheavy objects (is that really what you intended, Ringwaul?) -protected func RejectCollect(id collectid, object collect) +func RejectCollect(id collectid, object collect) { if(collect->~IsCarryHeavy()) return true; else diff --git a/planet/Objects.ocd/Libraries.ocd/Producer.ocd/Script.c b/planet/Objects.ocd/Libraries.ocd/Producer.ocd/Script.c index 3e0d34cd5..5835e26bd 100644 --- a/planet/Objects.ocd/Libraries.ocd/Producer.ocd/Script.c +++ b/planet/Objects.ocd/Libraries.ocd/Producer.ocd/Script.c @@ -654,7 +654,7 @@ public func RequestObject(id obj_id, int amount) func Collection2(object obj) { if (obj->~IsChunk()) - Schedule(obj, "Split2Components()", 1); + obj->Split2Components(); // 1 frame delay, so the chunk can trigger the appriopriate carry heavy ending calls // i.e. FxIntCarryHeavyStop }