mirror of
https://github.com/projectPiki/pikmin2.git
synced 2025-01-19 12:32:09 +00:00
further cleanup Mar and Hanachirashi
This commit is contained in:
parent
1476cbd4a2
commit
35b2b3572a
@ -117,7 +117,7 @@ struct Obj : public EnemyBase {
|
||||
Vector3f mEfxPosition; // _2E8
|
||||
Vector3f mFaceDirection; // _2F4
|
||||
Vector3f mAttackPosition; // _300
|
||||
f32 mCurrentAttackRadius; // _30C
|
||||
f32 mWindScaleTimer; // _30C
|
||||
bool mIsWindAttackActive; // _310
|
||||
f32 mPitchRatio; // _314
|
||||
efx::TFusenDead* mEfxDead; // _318
|
||||
|
@ -48,7 +48,7 @@ void Obj::onInit(CreatureInitArg* initArg)
|
||||
mEfxMatrix = mModel->getJoint("hana3")->getWorldMatrix();
|
||||
setupEffect();
|
||||
|
||||
mCurrentAttackRadius = 0.0f;
|
||||
mWindScaleTimer = 0.0f;
|
||||
|
||||
mFsm->start(this, HANACHIRASHI_Wait, nullptr);
|
||||
|
||||
@ -727,47 +727,46 @@ Vector3f Obj::getAttackPosition()
|
||||
bool Obj::windTarget()
|
||||
{
|
||||
bool isHitPiki = false;
|
||||
if (mCurrentAttackRadius < 1.0f) {
|
||||
mCurrentAttackRadius += 3.0f * sys->mDeltaTime;
|
||||
if (mCurrentAttackRadius > 1.0f) {
|
||||
mCurrentAttackRadius = 1.0f;
|
||||
if (mWindScaleTimer < 1.0f) {
|
||||
mWindScaleTimer += 3.0f * sys->mDeltaTime;
|
||||
if (mWindScaleTimer > 1.0f) {
|
||||
mWindScaleTimer = 1.0f;
|
||||
}
|
||||
}
|
||||
|
||||
f32 radius = mCurrentAttackRadius * C_GENERALPARMS.mAttackRadius();
|
||||
Vector3f efxPos = mEfxPosition; // f16
|
||||
Vector3f faceDir = mFaceDirection; // f29
|
||||
f32 slope = tan(TORADIANS(C_GENERALPARMS.mAttackHitAngle())); // f20
|
||||
f32 radius = mWindScaleTimer * C_GENERALPARMS.mAttackRadius();
|
||||
Vector3f attackStartPos = mEfxPosition; // f16
|
||||
Vector3f faceDirection = mFaceDirection; // f29
|
||||
f32 slope = tan(TORADIANS(C_GENERALPARMS.mAttackHitAngle())); // f20
|
||||
|
||||
Vector3f flatDir = Vector3f(-faceDir.z, faceDir.y, faceDir.x);
|
||||
flatDir.toFlatDirection();
|
||||
Vector3f attackNormal = Vector3f(-faceDirection.z, 0.0f, faceDirection.x);
|
||||
attackNormal.normalise();
|
||||
|
||||
Vector3f crossDir = flatDir.cross(faceDir);
|
||||
Vector3f crossDir = attackNormal.cross(faceDirection);
|
||||
crossDir.normalise();
|
||||
|
||||
Vector3f normFaceDir = faceDir;
|
||||
normFaceDir.toFlatDirection();
|
||||
Vector3f attackDirection2D = faceDirection;
|
||||
attackDirection2D.toFlatDirection();
|
||||
|
||||
Iterator<Navi> iterNavi(naviMgr);
|
||||
CI_LOOP(iterNavi)
|
||||
{
|
||||
Navi* navi = *iterNavi;
|
||||
if (navi->isAlive()) {
|
||||
Vector3f naviPos = navi->getPosition();
|
||||
Vector3f sep = naviPos - efxPos;
|
||||
f32 dotProd = faceDir.dot(sep);
|
||||
if (dotProd < radius && dotProd > 0.0f) {
|
||||
f32 r = dotProd * slope;
|
||||
f32 crossDot = crossDir.dot(sep);
|
||||
f32 flatDot = flatDir.dot(sep);
|
||||
Vector3f dots = Vector3f(flatDot, 0.0f, crossDot);
|
||||
f32 sqrMag = dots.sqrMagnitude2D();
|
||||
if (sqrMag < SQUARE(r)) {
|
||||
f32 normMag = dots.length2D() / r;
|
||||
Vector3f naviPosition = navi->getPosition();
|
||||
Vector3f separationVec = naviPosition - attackStartPos;
|
||||
|
||||
f32 lineEq = normMag * 0.2f + (1.0f - normMag);
|
||||
Vector3f direction(lineEq * (normFaceDir.x * crossDot + flatDir.x * flatDot), 0.0f,
|
||||
lineEq * (normFaceDir.z * crossDot + flatDir.z * flatDot));
|
||||
f32 dotProduct = faceDirection.dot(separationVec);
|
||||
if (dotProduct < radius && dotProduct > 0.0f) {
|
||||
f32 attackRadius = dotProduct * slope;
|
||||
|
||||
Vector2f dots = Vector2f(attackNormal.dot(separationVec), crossDir.dot(separationVec));
|
||||
if (dots.sqrMagnitude() < SQUARE(attackRadius)) {
|
||||
f32 slideFactor = dots.length() / attackRadius;
|
||||
|
||||
f32 windStrength = slideFactor * 0.2f + (1.0f - slideFactor);
|
||||
Vector3f direction(windStrength * (attackDirection2D.x * dots.y + attackNormal.x * dots.x), 0.0f,
|
||||
windStrength * (attackDirection2D.z * dots.y + attackNormal.z * dots.x));
|
||||
|
||||
InteractWind wind(this, C_GENERALPARMS.mAttackDamage(), &direction); // not vec2
|
||||
navi->stimulate(wind);
|
||||
@ -781,25 +780,23 @@ bool Obj::windTarget()
|
||||
{
|
||||
Piki* piki = *iterPiki;
|
||||
if (piki->isAlive() && piki->isPikmin()) {
|
||||
Vector3f pikiPos = piki->getPosition();
|
||||
Vector3f sep = pikiPos - efxPos;
|
||||
f32 dotProd = faceDir.dot(sep);
|
||||
if (dotProd < radius && dotProd > 0.0f) {
|
||||
f32 r = dotProd * slope;
|
||||
f32 crossDot = crossDir.dot(sep);
|
||||
f32 flatDot = flatDir.dot(sep);
|
||||
Vector3f dots = Vector3f(flatDot, 0.0f, crossDot);
|
||||
f32 sqrMag = dots.sqrMagnitude2D();
|
||||
if (sqrMag < SQUARE(r)) {
|
||||
f32 normMag = dots.length2D() / r;
|
||||
Vector3f pikiPos = piki->getPosition();
|
||||
Vector3f separationVec = pikiPos - attackStartPos;
|
||||
|
||||
f32 lineEq = (1.0f - normMag) * 5.0f + normMag;
|
||||
Vector3f velocity;
|
||||
velocity.x = lineEq * (normFaceDir.x * crossDot + flatDir.z * flatDot);
|
||||
velocity.y = (1.0f - normMag) * 50.0f + normMag * 10.0f;
|
||||
velocity.z = lineEq * (normFaceDir.z * crossDot + flatDir.x * flatDot);
|
||||
f32 dotProduct = faceDirection.dot(separationVec);
|
||||
if (dotProduct < radius && dotProduct > 0.0f) {
|
||||
f32 attackRadius = dotProduct * slope;
|
||||
|
||||
InteractHanaChirashi wind(this, C_GENERALPARMS.mAttackDamage(), &velocity); // not vec2
|
||||
Vector2f dots = Vector2f(attackNormal.dot(separationVec), crossDir.dot(separationVec));
|
||||
if (dots.sqrMagnitude() < SQUARE(attackRadius)) {
|
||||
f32 slideFactor = dots.length() / attackRadius;
|
||||
|
||||
f32 windStrength = (1.0f - slideFactor) * 5.0f + slideFactor;
|
||||
Vector3f direction(windStrength * (attackDirection2D.x * dots.y + attackNormal.x * dots.x),
|
||||
(1.0f - slideFactor) * 50.0f + slideFactor * 10.0f,
|
||||
windStrength * (attackDirection2D.z * dots.y + attackNormal.z * dots.x));
|
||||
|
||||
InteractHanaChirashi wind(this, C_GENERALPARMS.mAttackDamage(), &direction); // not vec2
|
||||
isHitPiki = piki->stimulate(wind);
|
||||
}
|
||||
}
|
||||
|
@ -854,7 +854,7 @@ void StateAttack::init(EnemyBase* enemy, StateArg* stateArg)
|
||||
hanachirashi->startMotion(HANACHIANIM_Attack, nullptr);
|
||||
hanachirashi->mNextState = HANACHIRASHI_NULL;
|
||||
hanachirashi->mIsWindAttackActive = false;
|
||||
hanachirashi->mCurrentAttackRadius = 0.0f;
|
||||
hanachirashi->mWindScaleTimer = 0.0f;
|
||||
hanachirashi->createSuckEffect();
|
||||
}
|
||||
|
||||
@ -901,7 +901,7 @@ void StateAttack::cleanup(EnemyBase* enemy)
|
||||
hanachirashi->enableEvent(0, EB_Cullable);
|
||||
hanachirashi->setEmotionCaution();
|
||||
hanachirashi->mIsWindAttackActive = false;
|
||||
hanachirashi->mCurrentAttackRadius = 0.0f;
|
||||
hanachirashi->mWindScaleTimer = 0.0f;
|
||||
hanachirashi->finishWindEffect();
|
||||
}
|
||||
|
||||
|
@ -429,16 +429,13 @@ bool Obj::isTargetLost()
|
||||
{
|
||||
Creature* target = mTargetCreature;
|
||||
if (target && target->isAlive() && !target->isStickToMouth() && target->mSticker != this) {
|
||||
f32 viewAngle = C_GENERALPARMS.mViewAngle.mValue;
|
||||
f32 viewAngle = C_GENERALPARMS.mViewAngle();
|
||||
if (mStuckPikminCount) {
|
||||
viewAngle = 180.0f;
|
||||
}
|
||||
|
||||
f32 sightRad = C_GENERALPARMS.mSightRadius.mValue;
|
||||
f32 privRad = C_GENERALPARMS.mPrivateRadius.mValue;
|
||||
f32 sightDiff = getCreatureViewAngle(target);
|
||||
|
||||
return isTargetWithinRange(target, sightDiff, privRad, sightRad, 12800.0f, viewAngle);
|
||||
return isTargetWithinRange(target, getCreatureViewAngle(target), C_GENERALPARMS.mPrivateRadius(), C_GENERALPARMS.mSightRadius(),
|
||||
12800.0f, viewAngle);
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -991,24 +988,20 @@ void Obj::windTarget()
|
||||
}
|
||||
}
|
||||
|
||||
f32 radius = mWindScaleTimer * C_GENERALPARMS.mAttackRadius.mValue;
|
||||
Vector3f attackStartPosition = mAttackStartPos; // f16
|
||||
Vector3f attackDirection = mAttackDirection; // f29
|
||||
f32 slope = (f32)tan(PI * (DEG2RAD * C_GENERALPARMS.mAttackHitAngle.mValue)); // f20
|
||||
f32 radius = mWindScaleTimer * C_GENERALPARMS.mAttackRadius();
|
||||
Vector3f attackStartPosition = mAttackStartPos; // f16
|
||||
Vector3f attackDirection = mAttackDirection; // f29
|
||||
f32 slope = tan(TORADIANS(C_GENERALPARMS.mAttackHitAngle())); // f20
|
||||
|
||||
// this is probably a new vector
|
||||
Vector3f attackNormal(-attackDirection.z, 0.0f, attackDirection.x);
|
||||
attackNormal.normalise();
|
||||
|
||||
Vector3f crossVec = attackNormal.cross(attackStartPosition);
|
||||
Vector3f crossVec = attackNormal.cross(attackDirection);
|
||||
crossVec.normalise();
|
||||
|
||||
Vector2f direction2D(attackDirection.x, attackDirection.z);
|
||||
f32 directionLength = direction2D.normalise();
|
||||
if (directionLength > 0.0f) {
|
||||
direction2D.x = (attackDirection.x * (1.0f / directionLength));
|
||||
direction2D.y = (attackDirection.z * (1.0f / directionLength));
|
||||
}
|
||||
Vector3f attackDirection2D = attackDirection;
|
||||
attackDirection2D.toFlatDirection();
|
||||
|
||||
Iterator<Navi> iterNavi(naviMgr);
|
||||
CI_LOOP(iterNavi)
|
||||
@ -1020,28 +1013,17 @@ void Obj::windTarget()
|
||||
f32 dotProduct = separationVector.dot(attackDirection);
|
||||
|
||||
if (dotProduct < radius && dotProduct > 0.0f) {
|
||||
f32 slopeAffectedDotProduct = dotProduct * slope;
|
||||
f32 crossVectorDotSeparation = crossVec.dot(separationVector);
|
||||
f32 attackNormalDotSeparation = attackNormal.dot(separationVector);
|
||||
f32 attackRadius = dotProduct * slope;
|
||||
|
||||
f32 combinedDotProduct = SQUARE(attackNormalDotSeparation) * SQUARE(crossVectorDotSeparation);
|
||||
if (combinedDotProduct < SQUARE(slopeAffectedDotProduct)) {
|
||||
f32 slideFactor = 0.0f;
|
||||
if (dotProduct > 0.0f) {
|
||||
slideFactor = 1.0f / sqrtf(dotProduct) * dotProduct;
|
||||
}
|
||||
Vector2f dots = Vector2f(attackNormal.dot(separationVector), crossVec.dot(separationVector));
|
||||
if (dots.sqrMagnitude() < SQUARE(attackRadius)) {
|
||||
f32 slideFactor = dots.length() / attackRadius;
|
||||
f32 windStrength = (1.0f - slideFactor) * 10.0f + slideFactor;
|
||||
|
||||
f32 slideFactorRatio = slideFactor / slopeAffectedDotProduct;
|
||||
f32 inverseSlideFactorRatio = 1.0f - slideFactor / slopeAffectedDotProduct;
|
||||
f32 attackDamage = C_GENERALPARMS.mAttackDamage.mValue;
|
||||
f32 windStrength = 10.0f * inverseSlideFactorRatio + slideFactorRatio;
|
||||
Vector3f windDirection(windStrength * (attackDirection2D.x * dots.y + attackNormal.x * dots.x), 0.0f,
|
||||
windStrength * (attackDirection2D.z * dots.y + attackNormal.z * dots.x));
|
||||
|
||||
Vector3f windDirection;
|
||||
windDirection.x = windStrength * (separationVector.dot(attackNormal) + separationVector.dot(crossVec));
|
||||
windDirection.y = 0.0f;
|
||||
windDirection.z = windStrength * (separationVector.dot(attackNormal) + separationVector.dot(crossVec));
|
||||
|
||||
InteractWind wind(this, attackDamage, &windDirection);
|
||||
InteractWind wind(this, C_GENERALPARMS.mAttackDamage(), &windDirection);
|
||||
navi->stimulate(wind);
|
||||
}
|
||||
}
|
||||
@ -1052,34 +1034,24 @@ void Obj::windTarget()
|
||||
CI_LOOP(iterPiki)
|
||||
{
|
||||
Piki* piki = *iterPiki;
|
||||
if (piki->isAlive()) {
|
||||
if (piki->isAlive() && piki->isPikmin()) {
|
||||
Vector3f pikiPosition = piki->getPosition();
|
||||
Vector3f separationVector = pikiPosition - attackStartPosition;
|
||||
f32 dotProduct = separationVector.dot(attackDirection);
|
||||
|
||||
if (dotProduct < radius && dotProduct > 0.0f) {
|
||||
f32 slopeAffectedDotProduct = dotProduct * slope;
|
||||
f32 crossVectorDotSeparation = crossVec.dot(separationVector);
|
||||
f32 attackNormalDotSeparation = attackNormal.dot(separationVector);
|
||||
f32 attackRadius = dotProduct * slope;
|
||||
|
||||
f32 combinedDotProduct = SQUARE(attackNormalDotSeparation) * SQUARE(crossVectorDotSeparation);
|
||||
if (combinedDotProduct < SQUARE(slopeAffectedDotProduct)) {
|
||||
f32 slideFactor = 0.0f;
|
||||
if (dotProduct > 0.0f) {
|
||||
slideFactor = 1.0f / sqrtf(dotProduct) * dotProduct;
|
||||
}
|
||||
Vector2f dots = Vector2f(attackNormal.dot(separationVector), crossVec.dot(separationVector));
|
||||
if (dots.sqrMagnitude() < SQUARE(attackRadius)) {
|
||||
f32 slideFactor = dots.length() / attackRadius;
|
||||
|
||||
f32 slideFactorRatio = slideFactor / slopeAffectedDotProduct;
|
||||
f32 inverseSlideFactorRatio = 1.0f - slideFactor / slopeAffectedDotProduct;
|
||||
f32 attackDamage = C_GENERALPARMS.mAttackDamage.mValue;
|
||||
f32 windStrength = 10.0f * inverseSlideFactorRatio + slideFactorRatio;
|
||||
f32 windStrength = (1.0f - slideFactor) * 15.0f + slideFactor * 1.5f;
|
||||
Vector3f windDirection(windStrength * (attackDirection2D.x * dots.y + attackNormal.x * dots.x),
|
||||
(1.0f - slideFactor) * 500.0f + slideFactor * 50.0f,
|
||||
windStrength * (attackDirection2D.z * dots.y + attackNormal.z * dots.x));
|
||||
|
||||
Vector3f windDirection;
|
||||
windDirection.x = windStrength * (separationVector.dot(attackNormal) + separationVector.dot(crossVec));
|
||||
windDirection.y = 0.0f;
|
||||
windDirection.z = windStrength * (separationVector.dot(attackNormal) + separationVector.dot(crossVec));
|
||||
|
||||
InteractWind wind(this, attackDamage, &windDirection);
|
||||
InteractWind wind(this, C_GENERALPARMS.mAttackDamage(), &windDirection);
|
||||
piki->stimulate(wind);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user