From abcee8afa3b37a43b30496753aa3750f711cd8d6 Mon Sep 17 00:00:00 2001 From: Felix Wagner Date: Fri, 21 Oct 2011 21:16:44 +0100 Subject: [PATCH] Plant library: RootSurface() limits for positioning added --- planet/Objects.ocd/Libraries.ocd/Plant.ocd/Script.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/planet/Objects.ocd/Libraries.ocd/Plant.ocd/Script.c b/planet/Objects.ocd/Libraries.ocd/Plant.ocd/Script.c index ce9835b60..bad2ab3d7 100644 --- a/planet/Objects.ocd/Libraries.ocd/Plant.ocd/Script.c +++ b/planet/Objects.ocd/Libraries.ocd/Plant.ocd/Script.c @@ -11,10 +11,15 @@ */ global func RootSurface() { - if (HasCNAT(CNAT_Center)) while(GetContact(-1) & CNAT_Center) SetPosition(GetX(),GetY()-1); //Move up if too far underground + if (HasCNAT(CNAT_Center)) + { + var i = 0; + while(GetContact(-1) & CNAT_Center && i < GetObjHeight()/2) { SetPosition(GetX(),GetY()-1); i++; } //Move up if too far underground + } if (HasCNAT(CNAT_Bottom)) { - while(!(GetContact(-1) & CNAT_Bottom)) SetPosition(GetX(),GetY()+1); //Move down if in midair + i = 0; + while(!(GetContact(-1) & CNAT_Bottom) && i < GetObjHeight()/2) { SetPosition(GetX(),GetY()+1); i++; } //Move down if in midair if (!Stuck()) SetPosition(GetX(),GetY()+1); // try make the plant stuck }