From 5badcdda466313f7ca34af1e6d0779dc17c6eee9 Mon Sep 17 00:00:00 2001 From: Markus Mittendrein Date: Wed, 2 Jan 2019 18:00:46 +0100 Subject: Fix falling down in some circumstances when directly on a corner (laying on the corner while sleeping and tumbling onto the corner with high speed) --- TemplePushing.c4s/System.c4g/Clonk.c | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) (limited to 'TemplePushing.c4s') diff --git a/TemplePushing.c4s/System.c4g/Clonk.c b/TemplePushing.c4s/System.c4g/Clonk.c index 459a3f0..adc3c41 100644 --- a/TemplePushing.c4s/System.c4g/Clonk.c +++ b/TemplePushing.c4s/System.c4g/Clonk.c @@ -12,7 +12,7 @@ protected func Initialize() { teamHud = CreateObject(THUD); teamHud->Attach(this); - AddEffect("CheckGlitches", this, 20, 1, this); + AddEffect("CheckGlitches", this, 1000, 1, this); AddEffect("CheckBurn", this, 101, 0, this); SetPhysical("Fight", 75000, PHYS_Temporary, this); SetPhysical("Scale", 60000, PHYS_Temporary, this); @@ -105,7 +105,7 @@ private func FxCheckGlitchesTimer(object pTarget, int iEffectNumber, int iEffect { var d = GetDir(pTarget)*2 - 1; var comDir = pTarget->GetComDir(); - if(GetProcedure(pTarget) == "FLIGHT" && EffectVar(0, pTarget, iEffectNumber) == "SCALE" && EffectVar(1, pTarget, iEffectNumber) < 0 && (comDir == COMD_Stop || comDir == COMD_Down) && pTarget->GBackSolid(d * 5, 4) && !pTarget->GBackSolid(d * 5, 3)) + if (GetProcedure(pTarget) == "FLIGHT" && EffectVar(0, pTarget, iEffectNumber) == "SCALE" && EffectVar(1, pTarget, iEffectNumber) < 0 && (comDir == COMD_Stop || comDir == COMD_Down) && pTarget->GBackSolid(d * 5, 4) && !pTarget->GBackSolid(d * 5, 3)) { SetPosition(GetX(pTarget), GetY(pTarget) + 1, pTarget); pTarget->SetAction("Scale"); @@ -116,14 +116,30 @@ private func FxCheckGlitchesTimer(object pTarget, int iEffectNumber, int iEffect EffectVar(1, pTarget, iEffectNumber) = pTarget->GetYDir(0, 65535); EffectVar(2, pTarget, iEffectNumber) = pTarget->GetPhase(); - if (GetAction(pTarget) != "Walk") return; - - if (!pTarget->GBackSolid(0, 4) && !pTarget->GBackSolid(d, 3) && pTarget->GBackSolid(d, 4)) + var action = GetAction(pTarget); + if (action == "Walk") + { + if (!pTarget->GBackSolid(0, 4) && !pTarget->GBackSolid(d, 3) && pTarget->GBackSolid(d, 4)) + { + SetPosition(GetX(pTarget), GetY(pTarget) - 1, pTarget); + ObjectSetAction(pTarget, "KneelDown"); + pTarget->Schedule("SetXDir(0)", 1); + if ((d == -1 && comDir != COMD_Left) || (d == 1 && comDir != COMD_Right)) SetComDir(COMD_Up, pTarget); + } + } + else if (action == "FlatUp") { - SetPosition(GetX(pTarget), GetY(pTarget) - 1, pTarget); - ObjectSetAction(pTarget, "KneelDown"); - pTarget->Schedule("SetXDir(0)", 1); - if ((d == -1 && GetComDir(pTarget) != COMD_Left) || (d == 1 && GetComDir(pTarget) != COMD_Right)) SetComDir(COMD_Up, pTarget); + if ((d == -1) != (GetContact(pTarget, 5, -1) == CNAT_Bottom)) + { + d *= -1; + } + if (!pTarget->GBackSolid(0, 4) && (!pTarget->GBackSolid(d * 2, 3) && pTarget->GBackSolid(d * 2, 4))) + { + if (comDir != COMD_Down && comDir != COMD_Up && ((d == -1 && comDir != COMD_Left) || (d == 1 && comDir != COMD_Right))) + { + SetPosition(GetX(pTarget), GetY(pTarget) + 1, pTarget); + } + } } } -- cgit v1.2.3-54-g00ecf