Differentiate between COMD_None and COMD_Stop

Was necessary after 267ebb600481 and current abuse of FLOAT procedure. None keeps the current motion, Stop halts the current motion of a procedure.
Maikel de Vries 2011-07-06 18:13:39 +02:00
parent eb530c6017
commit d550f7c7da
17 changed files with 34 additions and 81 deletions

View File

@ -9,7 +9,7 @@
<subcat>Movement</subcat>
<version>5.1 OC</version>
<syntax><rtype>int</rtype></syntax>
<desc>Movement direction: up. For more information see <funclink>SetComDir</funclink>.</desc>
<desc>Movement direction: down. For more information see <funclink>SetComDir</funclink>.</desc>
<examples>
<example>
<code><funclink>FindObject</funclink>(<funclink>Find_ID</funclink>(Airship))-&gt;<funclink>SetComDir</funclink>(COMD_Down);</code>

View File

@ -9,7 +9,7 @@
<subcat>Movement</subcat>
<version>5.1 OC</version>
<syntax><rtype>int</rtype></syntax>
<desc>Movement direction: up. For more information see <funclink>SetComDir</funclink>.</desc>
<desc>Movement direction: left. For more information see <funclink>SetComDir</funclink>.</desc>
<examples>
<example>
<code><funclink>FindObject</funclink>(<funclink>Find_ID</funclink>(Airship))-&gt;<funclink>SetComDir</funclink>(COMD_Left);</code>

View File

@ -9,12 +9,13 @@
<subcat>Movement</subcat>
<version>5.1 OC</version>
<syntax><rtype>int</rtype></syntax>
<desc>Movement direction: stop. For more information see <funclink>SetComDir</funclink>.</desc>
<remark>COMD_None and <funclink>COMD_Stop</funclink> are identical and have the value 0.</remark>
<desc>Movement direction: keep current motion. For more information see <funclink>SetComDir</funclink>.</desc>
<examples>
<example>
<code><funclink>GetCursor</funclink>(0)-&gt;<funclink>SetComDir</funclink>(COMD_None);</code>
<text>Makes the currently selected clonk of the first player stop.</text>
<code><funclink>FindObject</funclink>(<funclink>Find_ID</funclink>(ButterFly))-&gt;<funclink>SetAction</funclink>("Fly");
FindObject</funclink>(<funclink>Find_ID</funclink>(ButterFly))-&gt;<funclink>SetComDir</funclink>(COMD_None);
FindObject</funclink>(<funclink>Find_ID</funclink>(ButterFly))-&gt;<funclink>SetSpeed</funclink>(20, 30);</code>
<text>This code will let a butterfly fly in an alternative direction than the predefined ones for the FLOAT procedure</text>
</example>
</examples>
<related>

View File

@ -9,7 +9,7 @@
<subcat>Movement</subcat>
<version>5.1 OC</version>
<syntax><rtype>int</rtype></syntax>
<desc>Movement direction: up. For more information see <funclink>SetComDir</funclink>.</desc>
<desc>Movement direction: right. For more information see <funclink>SetComDir</funclink>.</desc>
<examples>
<example>
<code><funclink>FindObject</funclink>(<funclink>Find_ID</funclink>(Airship))-&gt;<funclink>SetComDir</funclink>(COMD_Right);</code>

View File

@ -9,8 +9,7 @@
<subcat>Movement</subcat>
<version>5.1 OC</version>
<syntax><rtype>int</rtype></syntax>
<desc>Movement direction: stop. For more information see <funclink>SetComDir</funclink>.</desc>
<remark><funclink>COMD_None</funclink> and COMD_Stop are identical and have the value 0.</remark>
<desc>Movement direction: stop, hence end current motion. For more information see <funclink>SetComDir</funclink>.</desc>
<examples>
<example>
<code><funclink>GetCursor</funclink>()-&gt;<funclink>SetComDir</funclink>(COMD_None);</code>

View File

@ -12,7 +12,7 @@
<desc>Movement direction: diagonally up and to the left. For more information see <funclink>SetComDir</funclink>.</desc>
<examples>
<example>
<code><funclink>FindObject</funclink>(<funclink>Find_ID</funclink>(Airship))-&gt;<funclink>SetComDir</funclink>(COMD_Up);</code>
<code><funclink>FindObject</funclink>(<funclink>Find_ID</funclink>(Airship))-&gt;<funclink>SetComDir</funclink>(COMD_UpLeft);</code>
<text>Changes the flight direction of a blimp.</text>
</example>
</examples>

View File

@ -12,7 +12,7 @@
<desc>Movement direction: diagonally up and to the right. For more information see <funclink>SetComDir</funclink>.</desc>
<examples>
<example>
<code><funclink>FindObject</funclink>(<funclink>Find_ID</funclink>(Airship))-&gt;<funclink>SetComDir</funclink>(COMD_Up);</code>
<code><funclink>FindObject</funclink>(<funclink>Find_ID</funclink>(Airship))-&gt;<funclink>SetComDir</funclink>(COMD_UpRight);</code>
<text>Changes the flight direction of an airship.</text>
</example>
</examples>

View File

@ -14,26 +14,28 @@
<param>
<type>int</type>
<name>com_dir</name>
<desc>Order direction. Must be <funclink>COMD_None</funclink>(), <funclink>COMD_Down</funclink>(), <funclink>COMD_DownLeft</funclink>(), <funclink>COMD_DownRight</funclink>(), <funclink>COMD_Left</funclink>(), <funclink>COMD_Right</funclink>(), <funclink>COMD_Up</funclink>(), <funclink>COMD_UpLeft</funclink>() or <funclink>COMD_UpRight</funclink>().</desc>
<desc>Order direction. Must be <funclink>COMD_None</funclink>, <funclink>COMD_Stop</funclink>, <funclink>COMD_Down</funclink>, <funclink>COMD_DownLeft</funclink>, <funclink>COMD_DownRight</funclink>, <funclink>COMD_Left</funclink>, <funclink>COMD_Right</funclink>, <funclink>COMD_Up</funclink>, <funclink>COMD_UpLeft</funclink> or <funclink>COMD_UpRight</funclink>.</desc>
</param>
</params>
</syntax>
<desc>Sets the order direction of an object (see <funclink>GetComDir</funclink>).</desc>
<desc>Sets the command direction of an object (see <funclink>GetComDir</funclink>).</desc>
<examples>
<example>
<code>var clonk = <funclink>GetHiRank</funclink>(0);
clonk-&gt;SetComDir(<funclink>COMD_None</funclink>());
clonk-&gt;SetComDir(<funclink>COMD_None</funclink>);
clonk-&gt;<funclink>SetCommand</funclink>(&quot;&quot;);</code>
<text>Tells the highest ranking clonk of player 1 to stop. Any current activity will be stopped.</text>
<code>var clonk = <funclink>GetHiRank</funclink>(0);
<text>Tells the highest ranking clonk of the first player to stop. Any current activity will be stopped.</text>
<code>var clonk = <funclink>GetCursor</funclink>(0);
<funclink>clonk-&gt;SetAction</funclink>(&quot;Dig&quot;);
clonk-&gt;SetComDir(<funclink>COMD_DownRight</funclink>());</code>
<text>Makes the highest ranking clonk of player 1 dig towards the lower right.</text>
clonk-&gt;SetComDir(<funclink>COMD_DownRight</funclink>);</code>
<text>Makes the currently selected clonk of the first player dig towards the lower right.</text>
</example>
</examples>
<related>
<emlink href="definition/procedures.html">Procedure</emlink>
<funclink>GetComDir</funclink>
<funclink>SetDir</funclink>
<funclink>GetProcedure</funclink>
</related>
</func>
<author>jwk</author><date>2002-08</date>

View File

@ -1271,21 +1271,6 @@ func FxIntScaleStop(target, effect, reason, tmp)
SetObjDrawTransform(1000, 0, 0, 0, 1000, 0);*/
}
// This is just for test... TODO RemoveMe
func NameComDir(comdir)
{
if(comdir == COMD_Stop) return "COMD_Stop";
if(comdir == COMD_Up) return "COMD_Up";
if(comdir == COMD_UpRight) return "COMD_UpRight";
if(comdir == COMD_UpLeft) return "COMD_UpLeft";
if(comdir == COMD_Right) return "COMD_Right";
if(comdir == COMD_Left) return "COMD_Left";
if(comdir == COMD_Down) return "COMD_Down";
if(comdir == COMD_DownRight) return "COMD_DownRight";
if(comdir == COMD_DownLeft) return "COMD_DownLeft";
if(comdir == COMD_None) return "COMD_None";
}
/* Jump */
func StartJump()

View File

@ -34,7 +34,7 @@ func ControlUseStart(object clonk, int x, int y)
// Gfx
clonk->SetAction("Bridge");
clonk->SetComDir(COMD_None);
clonk->SetComDir(COMD_Stop);
clonk->SetXDir(0);
clonk->SetYDir(0);
last_x = BoundBy(x,-0,0)+GetX(); last_y = clonk->GetDefBottom()+3;

View File

@ -65,7 +65,7 @@ public func FxShovelDigTimer(object clonk, effect, int time)
if (can_dig)
{
clonk->SetAction("Dig");
clonk->SetComDir(COMD_None);
clonk->SetComDir(COMD_Stop);
if (is_scaling)
{
// speed boost when Clonk started digging from scaling, so we don't drop down

View File

@ -319,29 +319,14 @@ global func LaunchProjectile(int angle, int dist, int speed, int x, int y, bool
return false;
}
global func ComDirTransform(int comdir, int tocomdir)
{
if (comdir == tocomdir)
return comdir;
if (comdir == COMD_Stop)
return tocomdir;
if (comdir == (tocomdir + 3) % 8 + 1)
return COMD_Stop;
if (Inside(comdir, tocomdir + 1, tocomdir + 3))
return comdir - 1;
if (Inside(comdir, tocomdir - 1, tocomdir - 3))
return comdir + 1;
if (Inside(comdir, tocomdir - 7, tocomdir - 5))
return (comdir + 6) % 8 + 1;
return comdir % 8 + 1;
}
global func ComDirLike(int comdir1, int comdir2)
{
if (comdir1 == comdir2)
return true;
if (comdir1 == COMD_Stop || comdir2 == COMD_Stop)
return false;
if (comdir1 == COMD_None || comdir2 == COMD_None)
return false;
if (comdir1 % 8 + 1 == comdir2)
return true;
if (comdir1 == comdir2 % 8 + 1)
@ -378,4 +363,4 @@ global func FindPosInMat(string sMat, int iXStart, int iYStart, int iWidth, int
}
}
return 0; // No location found.
}
}

View File

@ -292,7 +292,7 @@ global func ObjectControlMovement(int plr, int ctrl, int strength, bool release,
if (ctrl == CON_Jump)
{
if(proc == "WALK" && GetComDir() == COMD_Up)
SetComDir(COMD_None);
SetComDir(COMD_Stop);
if(proc == "WALK")
return this->ObjectCommand("Jump");
}
@ -435,7 +435,7 @@ global func GetPlayerConDir(int plr, int con_left, int con_up, int con_right, in
if (GetPlayerControlState(plr, con_down)) ++y;
// Creating an array here for every keypress/release
// Would be so cool to have this static const. Guenther?
var dir_coms = [COMD_UpLeft, COMD_Up, COMD_UpRight, COMD_Left, COMD_None, COMD_Right, COMD_DownLeft, COMD_Down, COMD_DownRight];
var dir_coms = [COMD_UpLeft, COMD_Up, COMD_UpRight, COMD_Left, COMD_Stop, COMD_Right, COMD_DownLeft, COMD_Down, COMD_DownRight];
return dir_coms[y*3+x+4];
}

View File

@ -3910,9 +3910,12 @@ void C4Object::ExecAction()
if ((ydir>-accel) && (ydir<+accel)) ydir=0;
break;
}
// xdir/ydir bounds
if (ydir<-limit) ydir=-limit; if (ydir>+limit) ydir=+limit;
if (xdir>+limit) xdir=+limit; if (xdir<-limit) xdir=-limit;
// xdir/ydir bounds, don't apply if COMD_None
if (Action.ComDir != COMD_None)
{
if (ydir<-limit) ydir=-limit; if (ydir>+limit) ydir=+limit;
if (xdir>+limit) xdir=+limit; if (xdir<-limit) xdir=-limit;
}
Mobile=1;
break;

View File

@ -53,7 +53,7 @@
but will try to slow down according to it's current Action. ComDir values
circle clockwise from COMD_Up 1 through COMD_UpLeft 8. */
#define COMD_None 0
#define COMD_None -1
#define COMD_Stop 0
#define COMD_Up 1
#define COMD_UpRight 2

View File

@ -537,25 +537,6 @@ void ObjectComStopDig(C4Object *cObj)
cObj->ClearCommand(cObj->Command);
}
int32_t Coms2ComDir(int32_t iComs)
{
// This is possible because COM_Left - COM_Down are < 32
static int32_t DirComs = (1 << COM_Left) | (1 << COM_Right) | (1 << COM_Up) | (1 << COM_Down);
switch (iComs & DirComs)
{
case (1 << COM_Up): return COMD_Up;
case (1 << COM_Up) | (1 << COM_Right): return COMD_UpRight;
case (1 << COM_Right): return COMD_Right;
case (1 << COM_Down) | (1 << COM_Right): return COMD_DownRight;
case (1 << COM_Down): return COMD_Down;
case (1 << COM_Down) | (1 << COM_Left): return COMD_DownLeft;
case (1 << COM_Left): return COMD_Left;
case (1 << COM_Up) | (1 << COM_Left): return COMD_UpLeft;
// up, right and left could be interpreted as COMD_Up etc., but that's too complicated for now
default: return COMD_Stop;
}
}
bool ComDirLike(int32_t iComDir, int32_t iSample)
{
if (iComDir == iSample) return true;

View File

@ -30,11 +30,8 @@
class C4Facet;
class C4Object;
int32_t Coms2ComDir(int32_t iComs);
bool ComDirLike(int32_t iComDir, int32_t iSample);
const int32_t ComOrderNum = 24;
bool PlayerObjectCommand(int32_t plr, int32_t cmdf, C4Object *pTarget=NULL, int32_t tx=0, int32_t ty=0);
bool ObjectActionWalk(C4Object *cObj);