Skip to content
This repository has been archived by the owner on Apr 29, 2024. It is now read-only.

Commit

Permalink
[location] query NPC_Event_ShotEnemyTest before each shot
Browse files Browse the repository at this point in the history
  • Loading branch information
espkk committed Jan 20, 2022
1 parent 93562e1 commit 2ff1e75
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
13 changes: 12 additions & 1 deletion src/libs/location/src/character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2832,7 +2832,7 @@ if(_stricmp(eventName, "Blade to belt") == 0)
// PlaySound("pistol_shot");
isFired = true;
float kDist;
Character *chr = FindGunTarget(kDist, bShotOnlyEnemyTest);
Character *chr = FindGunTarget(kDist, CheckShotOnlyEnemyTest());
entid_t enemy{};
if (chr)
{
Expand Down Expand Up @@ -5371,3 +5371,14 @@ Location *Character::GetLocation()
loc_id = EntityManager::GetEntityId("location");
return static_cast<Location *>(EntityManager::GetEntityPointer(loc_id));
}

bool Character::CheckShotOnlyEnemyTest() const
{
auto * vd = core.Event("NPC_Event_ShotOnlyEnemyTest", "i", GetId());
int32_t tmpBool = 0;
if (vd)
{
vd->Get(tmpBool);
}
return tmpBool != 0;
}
2 changes: 1 addition & 1 deletion src/libs/location/src/character.h
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,7 @@ class Character : public Entity
float curHeadAX;
float curHeadAY;

bool bShotOnlyEnemyTest{false};
[[nodiscard]] bool CheckShotOnlyEnemyTest() const;

public:
bool isPlayerEnemy;
Expand Down
6 changes: 2 additions & 4 deletions src/libs/location/src/np_character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,7 @@ bool NPCharacter::PostInit()
int32_t tmpInt;
if (vd && vd->Get(tmpInt))
stunChance = tmpInt;
vd = core.Event("NPC_Event_ShotEnemyTest", "i", GetId());
if (vd && vd->Get(tmpBool))
bShotOnlyEnemyTest = tmpBool;

// Parameter normalization
if (attackCur < 0.0f)
attackCur = 0.0f;
Expand Down Expand Up @@ -732,7 +730,7 @@ void NPCharacter::UpdateFightCharacter(float dltTime)
const float _ay = ay;
ay = ang;
float kdst;
Character *target = FindGunTarget(kdst, bShotOnlyEnemyTest, true);
Character *target = FindGunTarget(kdst, CheckShotOnlyEnemyTest(), true);
// Character * target = FindGunTarget(kdst, true);
ay = _ay;
// if((target == c) || (target && bTryAnyTarget))
Expand Down
2 changes: 1 addition & 1 deletion src/libs/location/src/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ void Player::Update(float dltTime)
if (IsFireFindTarget())
{
float kDist;
auto *c = FindGunTarget(kDist, bShotOnlyEnemyTest);
auto *c = FindGunTarget(kDist, CheckShotOnlyEnemyTest());
if (c)
c->Select();
}
Expand Down

0 comments on commit 2ff1e75

Please sign in to comment.