コード例 #1
0
ファイル: C4ObjectCom.cpp プロジェクト: Rocket-Fish/openclonk
bool ObjectComDrop(C4Object *cObj, C4Object *pThing)
{
    // No object specified, first from contents
    if (!pThing) pThing = cObj->Contents.GetObject();
    // Nothing to throw
    if (!pThing) return false;
    // Force and direction
    // When dropping diagonally, drop from edge of shape
    // When doing a diagonal forward drop during flight, exit a bit closer to the Clonk to allow planned tumbling
    // Except when hangling, so you can mine effectively form the ceiling, and when swimming because you cannot tumble then
    C4Real pthrow=C4REAL100(cObj->GetPropertyInt(P_ThrowSpeed));
    int32_t tdir=0;
    int right=0;
    bool isHanglingOrSwimming = false;
    int32_t iProc = -1;
    C4PropList* pActionDef = cObj->GetAction();
    if (pActionDef)
    {
        iProc = pActionDef->GetPropertyP(P_Procedure);
        if (iProc == DFA_HANGLE || iProc == DFA_SWIM) isHanglingOrSwimming = true;
    }
    int32_t iOutposReduction = 1; // don't exit object too far forward during jump
    if (iProc != DFA_SCALE) // never diagonal during scaling (can have com into wall during scaling!)
    {
        if (ComDirLike(cObj->Action.ComDir, COMD_Left)) {
            tdir=-1;
            right = 0;
            if (cObj->xdir < C4REAL10(15) && !isHanglingOrSwimming) --iOutposReduction;
        }
        if (ComDirLike(cObj->Action.ComDir, COMD_Right)) {
            tdir=+1;
            right = 1;
            if (cObj->xdir > C4REAL10(-15) && !isHanglingOrSwimming) --iOutposReduction;
        }
    }
    // Exit object
    pThing->Exit(cObj->GetX() + (cObj->Shape.x + cObj->Shape.Wdt * right) * !!tdir * iOutposReduction,
                 cObj->GetY()+cObj->Shape.y+cObj->Shape.Hgt-(pThing->Shape.y+pThing->Shape.Hgt),0,pthrow*tdir,Fix0,Fix0);
    // Update OCF
    cObj->SetOCF();
    // Ungrab
    ObjectComUnGrab(cObj);
    // Done
    return true;
}
コード例 #2
0
ファイル: C4ObjectCom.cpp プロジェクト: lluchs/clonk-rage
BOOL ObjectComDrop(C4Object *cObj, C4Object *pThing)
  {
  // No object specified, first from contents
	if (!pThing) pThing = cObj->Contents.GetObject();
	// Nothing to throw
	if (!pThing) return FALSE;
	// Force and direction
	// When dropping diagonally, drop from edge of shape
	// When doing a diagonal forward drop during flight, exit a bit closer to the Clonk to allow planned tumbling
	// Except when hangling, so you can mine effectively form the ceiling, and when swimming because you cannot tumble then
  FIXED pthrow=ValByPhysical(400, cObj->GetPhysical()->Throw);
  int32_t tdir=0; int right=0;
	bool isHanglingOrSwimming = false;
	int32_t iProc = DFA_NONE;
	if (cObj->Action.Act >= 0)
		{
		iProc = cObj->Def->ActMap[cObj->Action.Act].Procedure;
		if (iProc == DFA_HANGLE || iProc == DFA_SWIM) isHanglingOrSwimming = true;
		}
	int32_t iOutposReduction = 1; // don't exit object too far forward during jump
	if (iProc != DFA_SCALE) // never diagonal during scaling (can have com into wall during scaling!)
		{
		if (ComDirLike(cObj->Action.ComDir, COMD_Left)) { tdir=-1; right = 0; if (cObj->xdir < FIXED10(15) && !isHanglingOrSwimming) --iOutposReduction; }
		if (ComDirLike(cObj->Action.ComDir, COMD_Right)) { tdir=+1; right = 1;  if (cObj->xdir > FIXED10(-15) && !isHanglingOrSwimming) --iOutposReduction; }
		}
	// Exit object
	pThing->Exit(cObj->x + (cObj->Shape.x + cObj->Shape.Wdt * right) * !!tdir * iOutposReduction,
		cObj->y+cObj->Shape.y+cObj->Shape.Hgt-(pThing->Shape.y+pThing->Shape.Hgt),0,pthrow*tdir,Fix0,Fix0);
	// NoCollectDelay
	cObj->NoCollectDelay=2;
	// Update OCF
	cObj->SetOCF();
	// Ungrab
  ObjectComUnGrab(cObj);
	// Done
  return TRUE;
  }