From ff0c0a6c9696434fda5516529f06116551f2b607 Mon Sep 17 00:00:00 2001 From: Sven Eberhardt Date: Sun, 3 Jan 2010 23:28:20 +0100 Subject: [PATCH] decrease NoCollectDelay on handled controls dont use up loam if bridge couldn't be started --- .../Items.c4d/Resources.c4d/Loam.c4d/Script.c | 20 +++++++++---------- planet/System.c4g/PlayerControl.c | 6 +++++- src/game/script/C4Script.cpp | 7 +++++++ 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/planet/Objects.c4d/Items.c4d/Resources.c4d/Loam.c4d/Script.c b/planet/Objects.c4d/Items.c4d/Resources.c4d/Loam.c4d/Script.c index 059a302af..091f8bd92 100644 --- a/planet/Objects.c4d/Items.c4d/Resources.c4d/Loam.c4d/Script.c +++ b/planet/Objects.c4d/Items.c4d/Resources.c4d/Loam.c4d/Script.c @@ -19,17 +19,15 @@ func Hit() func ControlUse(object clonk, int x, int y) { // Clonk must stand on ground - if(clonk->GetAction() == "Walk") - { - // Gfx - clonk->SetAction("Bridge"); - clonk->SetComDir(COMD_None); - clonk->SetXDir(0); - clonk->SetYDir(0); - last_x = BoundBy(x,-0,0)+GetX(); last_y = clonk->GetDefBottom()+3; - last_frame = begin_frame = FrameCounter(); - } - return true; + if(clonk->GetAction() != "Walk") return false; + + // Gfx + clonk->SetAction("Bridge"); + clonk->SetComDir(COMD_None); + clonk->SetXDir(0); + clonk->SetYDir(0); + last_x = BoundBy(x,-0,0)+GetX(); last_y = clonk->GetDefBottom()+3; + last_frame = begin_frame = FrameCounter(); } func HoldingEnabled() { return true; } diff --git a/planet/System.c4g/PlayerControl.c b/planet/System.c4g/PlayerControl.c index b9457d4ee..5a0125f1d 100644 --- a/planet/System.c4g/PlayerControl.c +++ b/planet/System.c4g/PlayerControl.c @@ -32,7 +32,11 @@ global func PlayerControl(int plr, int ctrl, id spec_id, int x, int y, int stren // Overload by effect? if (cursor->Control2Effect(plr, ctrl, cursorX, cursorY, strength, repeat, release)) return true; - return cursor->ObjectControl(plr, ctrl, cursorX, cursorY, strength, repeat, release); + if (cursor->ObjectControl(plr, ctrl, cursorX, cursorY, strength, repeat, release)) + { + if (cursor && !release && !repeat) cursor->DoNoCollectDelay(-1); + return true; + } } // No cursor? Nothing to handle control then return false; diff --git a/src/game/script/C4Script.cpp b/src/game/script/C4Script.cpp index 92eb0b501..544def550 100644 --- a/src/game/script/C4Script.cpp +++ b/src/game/script/C4Script.cpp @@ -5523,6 +5523,12 @@ static bool FnGetPlayerControlEnabled(C4AulContext *ctx, long iplr, long ctrl) return !plrctrl->IsControlDisabled(ctrl); } +static C4Void FnDoNoCollectDelay(C4AulObjectContext *ctx, int change) +{ + ctx->Obj->NoCollectDelay = Max(ctx->Obj->NoCollectDelay + change, 0); + return C4VNull; +} + //=========================== C4Script Function Map =================================== // defined function class @@ -6013,6 +6019,7 @@ void InitFunctionMap(C4AulScriptEngine *pEngine) AddFunc(pEngine, "GetGravity", FnGetGravity); AddFunc(pEngine, "Exit", FnExit); AddFunc(pEngine, "Collect", FnCollect); + AddFunc(pEngine, "DoNoCollectDelay", FnDoNoCollectDelay); AddFunc(pEngine, "Translate", FnTranslate); }