forked from Mirrors/openclonk
Engine: Objects hit only if both speed and and relative speed exceed HitSpeed2
This is bugfix to c1b41a96cdc6, since not moving objects like a fused dynamit could induce a hit.
parent
212fb1c934
commit
c5f9eb910f
|
@ -274,18 +274,18 @@ void C4GameObjects::CrossCheck() // Every Tick1 by ExecObjects
|
|||
// handle collision only once
|
||||
if (obj2->Marker == Marker) continue;
|
||||
obj2->Marker = Marker;
|
||||
// Hit
|
||||
// Only hit if target is alive and projectile is an object
|
||||
if ((obj1->OCF & OCF_Alive) && (obj2->Category & C4D_Object))
|
||||
{
|
||||
if(obj2->xdir != 0 || obj2->ydir != 0)
|
||||
{
|
||||
C4Real dXDir = obj2->xdir - obj1->xdir, dYDir = obj2->ydir - obj1->ydir;
|
||||
C4Real speed = dXDir * dXDir + dYDir * dYDir;
|
||||
if (speed > HitSpeed2)
|
||||
// Only hit if obj2's speed and relative speeds are larger than HitSpeed2
|
||||
if ((obj2->OCF & OCF_HitSpeed2) && speed > HitSpeed2)
|
||||
if (!obj1->Call(PSF_QueryCatchBlow, &C4AulParSet(C4VObj(obj2))))
|
||||
{
|
||||
int32_t iHitEnergy = fixtoi(speed * obj2->Mass / 5 );
|
||||
iHitEnergy = Max<int32_t>(iHitEnergy/3, !!iHitEnergy); // hit energy reduced to 1/3rd, but do not drop to zero because of this division
|
||||
// Hit energy reduced to 1/3rd, but do not drop to zero because of this division
|
||||
iHitEnergy = Max<int32_t>(iHitEnergy/3, !!iHitEnergy);
|
||||
obj1->DoEnergy(-iHitEnergy/5, false, C4FxCall_EngObjHit, obj2->Controller);
|
||||
int tmass=Max<int32_t>(obj1->Mass,50);
|
||||
C4PropList* pActionDef = obj1->GetAction();
|
||||
|
@ -298,7 +298,6 @@ void C4GameObjects::CrossCheck() // Every Tick1 by ExecObjects
|
|||
goto out1;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Collection
|
||||
if ((obj1->OCF & OCF_Collection) && (obj2->OCF & OCF_Carryable))
|
||||
|
|
Loading…
Reference in New Issue