Working on viewing distance for enemies
This commit is contained in:
parent
33c2b313af
commit
38e45d67b8
@ -49,7 +49,7 @@
|
|||||||
"meshTextures": {
|
"meshTextures": {
|
||||||
"Ghost": "resources/w/ghost/Ghost_BaseColor.png"
|
"Ghost": "resources/w/ghost/Ghost_BaseColor.png"
|
||||||
},
|
},
|
||||||
"positionX": -0.28594,
|
"positionX": 0,
|
||||||
"positionY": 0,
|
"positionY": 0,
|
||||||
"positionZ": 13.9641,
|
"positionZ": 13.9641,
|
||||||
"walkSpeed": 1.5,
|
"walkSpeed": 1.5,
|
||||||
@ -60,6 +60,7 @@
|
|||||||
"modelCorrectionRotZ": 0.0,
|
"modelCorrectionRotZ": 0.0,
|
||||||
"interactionRadius": 1.0,
|
"interactionRadius": 1.0,
|
||||||
"hp": 35,
|
"hp": 35,
|
||||||
|
"visibleRange" : 5.5,
|
||||||
"canAttack": false
|
"canAttack": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -86,6 +87,7 @@
|
|||||||
"modelCorrectionRotY": 180.0,
|
"modelCorrectionRotY": 180.0,
|
||||||
"modelCorrectionRotZ": 0.0,
|
"modelCorrectionRotZ": 0.0,
|
||||||
"hp": 35,
|
"hp": 35,
|
||||||
|
"visibleRange" : 6.5,
|
||||||
"canAttack": true
|
"canAttack": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -112,6 +114,7 @@
|
|||||||
"modelCorrectionRotY": 180.0,
|
"modelCorrectionRotY": 180.0,
|
||||||
"modelCorrectionRotZ": 0.0,
|
"modelCorrectionRotZ": 0.0,
|
||||||
"hp": 35,
|
"hp": 35,
|
||||||
|
"visibleRange" : 6.0,
|
||||||
"canAttack": true
|
"canAttack": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -138,6 +141,7 @@
|
|||||||
"modelCorrectionRotY": 180.0,
|
"modelCorrectionRotY": 180.0,
|
||||||
"modelCorrectionRotZ": 0.0,
|
"modelCorrectionRotZ": 0.0,
|
||||||
"hp": 35,
|
"hp": 35,
|
||||||
|
"visibleRange" : 4.8,
|
||||||
"canAttack": true
|
"canAttack": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@ -16,7 +16,6 @@ namespace ZL {
|
|||||||
extern float x;
|
extern float x;
|
||||||
extern float y;
|
extern float y;
|
||||||
const float ATTACK_RANGE = 1.25f;
|
const float ATTACK_RANGE = 1.25f;
|
||||||
const float VISIBLE_RANGE = 6.f;
|
|
||||||
|
|
||||||
Dialogue::TranslationDatabase Character::nameTranslations;
|
Dialogue::TranslationDatabase Character::nameTranslations;
|
||||||
|
|
||||||
@ -252,12 +251,12 @@ void Character::update(int64_t deltaMs, const CharacterResolver& resolver) {
|
|||||||
|
|
||||||
if (attackTarget != nullptr) {
|
if (attackTarget != nullptr) {
|
||||||
float distToGhost = (attackTarget->state.position - state.position).norm();
|
float distToGhost = (attackTarget->state.position - state.position).norm();
|
||||||
if (distToGhost >= VISIBLE_RANGE) {
|
if (distToGhost >= state.visibleRange) {
|
||||||
if (state.isPlayer) {
|
if (state.isPlayer) {
|
||||||
setTarget(attackTarget->state.position);
|
setTarget(attackTarget->state.position);
|
||||||
}
|
}
|
||||||
state.battle_state = 0;
|
state.battle_state = 0;
|
||||||
} else if (distToGhost < VISIBLE_RANGE && distToGhost >= ATTACK_RANGE) {
|
} else if (distToGhost < state.visibleRange && distToGhost >= ATTACK_RANGE) {
|
||||||
setTarget(attackTarget->state.position);
|
setTarget(attackTarget->state.position);
|
||||||
state.battle_state = 0;
|
state.battle_state = 0;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -53,6 +53,7 @@ void CharacterState::save(nlohmann::json& out) const
|
|||||||
out["pathWaypoints"] = std::move(wpArr);
|
out["pathWaypoints"] = std::move(wpArr);
|
||||||
out["currentWaypointIndex"] = currentWaypointIndex;
|
out["currentWaypointIndex"] = currentWaypointIndex;
|
||||||
out["homeDriftCheckTimer"] = homeDriftCheckTimer;
|
out["homeDriftCheckTimer"] = homeDriftCheckTimer;
|
||||||
|
out["visibleRange"] = visibleRange;
|
||||||
if (!onArrivedCallbackName.empty())
|
if (!onArrivedCallbackName.empty())
|
||||||
out["onArrivedCallbackName"] = onArrivedCallbackName;
|
out["onArrivedCallbackName"] = onArrivedCallbackName;
|
||||||
}
|
}
|
||||||
@ -69,6 +70,7 @@ void CharacterState::load(const nlohmann::json& in)
|
|||||||
facingAngle = in.value("facingAngle", facingAngle);
|
facingAngle = in.value("facingAngle", facingAngle);
|
||||||
targetFacingAngle = in.value("targetFacingAngle", targetFacingAngle);
|
targetFacingAngle = in.value("targetFacingAngle", targetFacingAngle);
|
||||||
hp = in.value("hp", hp);
|
hp = in.value("hp", hp);
|
||||||
|
visibleRange = in.value("visibleRange", visibleRange);
|
||||||
enabled = in.value("enabled", enabled);
|
enabled = in.value("enabled", enabled);
|
||||||
battle_state = in.value("battle_state", battle_state);
|
battle_state = in.value("battle_state", battle_state);
|
||||||
currentState = static_cast<AnimationState>(in.value("currentState", static_cast<int>(currentState)));
|
currentState = static_cast<AnimationState>(in.value("currentState", static_cast<int>(currentState)));
|
||||||
|
|||||||
@ -10,6 +10,8 @@
|
|||||||
|
|
||||||
namespace ZL {
|
namespace ZL {
|
||||||
|
|
||||||
|
constexpr float VISIBLE_RANGE = 6.f;
|
||||||
|
|
||||||
enum class AnimationState {
|
enum class AnimationState {
|
||||||
STAND = 0,
|
STAND = 0,
|
||||||
WALK = 1,
|
WALK = 1,
|
||||||
@ -70,6 +72,8 @@ public:
|
|||||||
float hp = 200.f;
|
float hp = 200.f;
|
||||||
float initialHp = 200.f;
|
float initialHp = 200.f;
|
||||||
|
|
||||||
|
float visibleRange = VISIBLE_RANGE;
|
||||||
|
|
||||||
// --- Combat flags ---
|
// --- Combat flags ---
|
||||||
int battle_state = 0;
|
int battle_state = 0;
|
||||||
bool resetAnim = false;
|
bool resetAnim = false;
|
||||||
|
|||||||
@ -295,6 +295,7 @@ namespace ZL {
|
|||||||
data.modelCorrectionRotZ = item.value("modelCorrectionRotZ", 0.0f) * static_cast<float>(M_PI) / 180.0f;
|
data.modelCorrectionRotZ = item.value("modelCorrectionRotZ", 0.0f) * static_cast<float>(M_PI) / 180.0f;
|
||||||
data.facingAngle = item.value("facingAngle", 0.0f) * static_cast<float>(M_PI) / 180.0f;
|
data.facingAngle = item.value("facingAngle", 0.0f) * static_cast<float>(M_PI) / 180.0f;
|
||||||
data.hp = item.value("hp", 100.0f);
|
data.hp = item.value("hp", 100.0f);
|
||||||
|
data.visibleRange = item.value("visibleRange", VISIBLE_RANGE);
|
||||||
data.canAttack = item.value("canAttack", false);
|
data.canAttack = item.value("canAttack", false);
|
||||||
data.enabled = item.value("enabled", true);
|
data.enabled = item.value("enabled", true);
|
||||||
|
|
||||||
@ -321,6 +322,7 @@ namespace ZL {
|
|||||||
st.modelScale = modelScale;
|
st.modelScale = modelScale;
|
||||||
st.setHp(hp);
|
st.setHp(hp);
|
||||||
st.initialHp = hp;
|
st.initialHp = hp;
|
||||||
|
st.visibleRange = visibleRange;
|
||||||
st.canAttack = canAttack;
|
st.canAttack = canAttack;
|
||||||
st.enabled = enabled;
|
st.enabled = enabled;
|
||||||
st.interactionRadius = interactionRadius;
|
st.interactionRadius = interactionRadius;
|
||||||
|
|||||||
@ -74,6 +74,7 @@ namespace ZL {
|
|||||||
float modelCorrectionRotZ = 0.0f;
|
float modelCorrectionRotZ = 0.0f;
|
||||||
float facingAngle = 0.0f;
|
float facingAngle = 0.0f;
|
||||||
float hp = 100.0f;
|
float hp = 100.0f;
|
||||||
|
float visibleRange = VISIBLE_RANGE;
|
||||||
bool canAttack = false;
|
bool canAttack = false;
|
||||||
bool enabled = true;
|
bool enabled = true;
|
||||||
float interactionRadius = 0.0f;
|
float interactionRadius = 0.0f;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user