mirror of https://github.com/zeldaret/botw.git
getDragonItemDropPosition (#84)
getDragonItemDropPosition - NON_MATCHING fadd arguments mismatch
This commit is contained in:
parent
bf611b1856
commit
4e21ee7613
|
@ -410,7 +410,7 @@ Address,Quality,Size,Name
|
|||
0x000000710000ae74,U,000048,
|
||||
0x000000710000aea4,U,000040,
|
||||
0x000000710000aecc,U,000120,dragon::isWithin1kmOfHyruleCastle
|
||||
0x000000710000af44,U,000720,getDragonItemDropPosition
|
||||
0x000000710000af44,m,000720,_ZN5uking3act25getDragonItemDropPositionEPN4sead7Vector3IfEERKS3_
|
||||
0x000000710000b214,U,001276,Dragon::ctor
|
||||
0x000000710000b710,U,000672,
|
||||
0x000000710000b9b0,U,000648,
|
||||
|
|
Can't render this file because it is too large.
|
|
@ -1,4 +1,6 @@
|
|||
target_sources(uking PRIVATE
|
||||
actDragon.cpp
|
||||
actDragon.h
|
||||
actWeapon.cpp
|
||||
actWeapon.h
|
||||
)
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
#include "Game/Actor/actDragon.h"
|
||||
#include <math/seadVector.h>
|
||||
#include <random/seadGlobalRandom.h>
|
||||
#include "KingSystem/Map/mapObject.h"
|
||||
#include "KingSystem/Map/mapPlacementMgr.h"
|
||||
|
||||
namespace uking::act {
|
||||
|
||||
inline float sqXYZDistance(const sead::Vector3f& a, const sead::Vector3f& b) {
|
||||
sead::Vector3f diff = a;
|
||||
diff -= b;
|
||||
return diff.squaredLength();
|
||||
}
|
||||
|
||||
// NON_MATCHING: Swapped arguments in fadd for distance calcuation
|
||||
bool getDragonItemDropPosition(sead::Vector3f* target_pos, const sead::Vector3f& current_pos) {
|
||||
auto* mgr = ksys::map::PlacementMgr::instance();
|
||||
const auto& results = mgr->mTraverseResults[1 - mgr->mTraverseResultIdx];
|
||||
|
||||
sead::SafeArray<sead::Vector3f, 3> pos;
|
||||
pos.fill(sead::Vector3f::zero);
|
||||
|
||||
bool ok = false;
|
||||
for (const auto& obj : results.dragon_item_drop_targets) {
|
||||
const sead::Vector3f& obj_pos = obj.getTranslate();
|
||||
if (!(obj_pos.y < current_pos.y)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Looks like an Insertion Sort
|
||||
for (int i = 0; i < pos.size(); i++) {
|
||||
bool closer = sqXYZDistance(obj_pos, current_pos) < sqXYZDistance(pos[i], current_pos);
|
||||
if (closer || pos[i] == sead::Vector3f(0, 0, 0)) {
|
||||
if (i > 0) {
|
||||
pos[i - 1] = pos[i];
|
||||
}
|
||||
pos[i] = obj_pos;
|
||||
ok = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!ok) {
|
||||
return false;
|
||||
}
|
||||
int index = sead::GlobalRandom::instance()->getS32Range(0, 3);
|
||||
target_pos->e = pos[index].e;
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace uking::act
|
|
@ -0,0 +1,6 @@
|
|||
#pragma once
|
||||
#include <math/seadVector.h>
|
||||
|
||||
namespace uking::act {
|
||||
bool getDragonItemDropPosition(sead::Vector3f* target_pos, const sead::Vector3f& current_pos);
|
||||
}
|
|
@ -33,7 +33,7 @@ class PlacementMgr {
|
|||
sead::PtrArray<u32> _30;
|
||||
sead::PtrArray<u32> _40;
|
||||
sead::PtrArray<u32> _50;
|
||||
sead::PtrArray<u32> dragon_item_drop_targets;
|
||||
sead::PtrArray<map::Object> dragon_item_drop_targets;
|
||||
sead::PtrArray<u32> _70;
|
||||
};
|
||||
KSYS_CHECK_SIZE_NX150(TraverseResults, 0x80);
|
||||
|
|
Loading…
Reference in New Issue