Esempio n. 1
0
void APBPainPlataform::OnOverlap(class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult & SweepResult)
{
	ActiveCharacter = Cast<APBCharacter>(OtherActor);

	if (ActiveCharacter != nullptr && !IsCausingDamage)
	{
		GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Yellow, "Hit Plataform");
		InflictDamage();
		GetWorldTimerManager().SetTimer(this, &APBPainPlataform::InflictDamage, 1, true);
		IsCausingDamage = true;
	}
}
Esempio n. 2
0
bool kexWorldObject::RangeDamage(const char *damageDef,
                                 const float dmgRadius,
                                 const kexVec3 &dmgOrigin) {
    if(areaLink.node) {
        float dist;
        kexSDNodeObj<kexWorldObject> *areaNode = areaLink.node;

        while(1) {
            for(kexWorldObject *obj = areaNode->objects.Next(); obj != NULL;
                obj = obj->areaLink.link.Next()) {
                    if(obj == this || !obj->bCollision) {
                        continue;
                    }
                    if(target && obj != target) {
                        continue;
                    }

                    dist = ObjectDistance(obj, dmgOrigin);

                    if(kexMath::Sqrt(dist) * 0.5f < radius + dmgRadius) {
                        InflictDamage(obj, defManager.FindDefEntry(damageDef));
                        return true;
                    }
            }

            if(areaNode->axis == -1) {
                break;
            }

            if(bbox.min[areaNode->axis] > areaNode->dist) {
                areaNode = areaNode->children[NODE_FRONT];
            }
            else if(bbox.max[areaNode->axis] < areaNode->dist) {
                areaNode = areaNode->children[NODE_BACK];
            }
            else {
                break;
            }
        }
    }

    return false;
}