decrease NoCollectDelay on handled controls

dont use up loam if bridge couldn't be started
stable-5.2
Sven Eberhardt 2010-01-03 23:28:20 +01:00
parent 71cdc8e681
commit ff0c0a6c96
3 changed files with 21 additions and 12 deletions

View File

@ -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; }

View File

@ -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;

View File

@ -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<int32_t>(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);
}