Пример #1
0
bool ObjectComPunch(C4Object *cObj, C4Object *pTarget, int32_t punch)
{
	if (!cObj || !pTarget) return false;
	if (!punch) return true;
	bool fBlowStopped = !!pTarget->Call(PSF_QueryCatchBlow,&C4AulParSet(cObj));
	if (fBlowStopped && punch>1) punch=punch/2; // half damage for caught blow, so shield+armor help in fistfight and vs monsters
	pTarget->DoEnergy(-punch, false, C4FxCall_EngGetPunched, cObj->Controller);
	int32_t tdir=+1; if (cObj->Action.Dir==DIR_Left) tdir=-1;
	pTarget->Action.ComDir=COMD_Stop;
	// No tumbles when blow was caught
	if (fBlowStopped) return false;
	// Hard punch
	if (punch>=10)
		if (ObjectActionTumble(pTarget,pTarget->Action.Dir,C4REAL100(150)*tdir,itofix(-2)))
		{
			pTarget->Call(PSF_CatchBlow,&C4AulParSet(punch, cObj));
			return true;
		}

	// Regular punch
	if (ObjectActionGetPunched(pTarget,C4REAL100(250)*tdir,Fix0))
	{
		pTarget->Call(PSF_CatchBlow,&C4AulParSet(punch, cObj));
		return true;
	}

	return false;
}
Пример #2
0
BOOL ObjectComPunch(C4Object *cObj, C4Object *pTarget, int32_t punch)
  {
  if (!cObj || !pTarget) return FALSE;
	if (!punch)
		if (pTarget->GetPhysical()->Fight) 
			punch=BoundBy<int32_t>(5*cObj->GetPhysical()->Fight/pTarget->GetPhysical()->Fight,0,10);
	if (!punch) return TRUE;
	bool fBlowStopped = !!pTarget->Call(PSF_QueryCatchBlow,&C4AulParSet(C4VObj(cObj)));
	if (fBlowStopped && punch>1) punch=punch/2; // half damage for caught blow, so shield+armor help in fistfight and vs monsters
	pTarget->DoEnergy(-punch, false, C4FxCall_EngGetPunched, cObj->Controller);
  int32_t tdir=+1; if (cObj->Action.Dir==DIR_Left) tdir=-1;
  pTarget->Action.ComDir=COMD_Stop;
	// No tumbles when blow was caught
	if (fBlowStopped) return FALSE;
	// Hard punch
	if (punch>=10) 
		if (ObjectActionTumble(pTarget,pTarget->Action.Dir,FIXED100(150)*tdir,itofix(-2)))
			{
			pTarget->LastEnergyLossCausePlayer = cObj->Controller; // for kill tracing when pushing enemies off a cliff
			pTarget->Call(PSF_CatchBlow,&C4AulParSet(C4VInt(punch), C4VObj(cObj)));
			return TRUE;
			}

	// Regular punch
	if (ObjectActionGetPunched(pTarget,FIXED100(250)*tdir,Fix0))
		{
		pTarget->LastEnergyLossCausePlayer = cObj->Controller; // for kill tracing when pushing enemies off a cliff
		pTarget->Call(PSF_CatchBlow,&C4AulParSet(C4VInt(punch), C4VObj(cObj))); 
		return TRUE;
		}

	return FALSE;
  }