Skip to content

Commit

Permalink
address feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
aronwk-aaron committed Apr 1, 2023
1 parent d6bf2e0 commit 4988015
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 28 deletions.
2 changes: 1 addition & 1 deletion dGame/dBehaviors/AreaOfEffectBehavior.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ void AreaOfEffectBehavior::Calculate(BehaviorContext* context, RakNet::BitStream
if (this->m_useTargetPosition) {
if (branch.target == LWOOBJID_EMPTY) return;
auto branchTarget = EntityManager::Instance()->GetEntity(branch.target);
reference = branchTarget->GetPosition();
if (branchTarget) reference = branchTarget->GetPosition();
}

reference += this->m_offset;
Expand Down
13 changes: 5 additions & 8 deletions dGame/dBehaviors/AreaOfEffectBehavior.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
class AreaOfEffectBehavior final : public Behavior
{
public:
explicit AreaOfEffectBehavior(const uint32_t behaviorId) : Behavior(behaviorId) {}
void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override;
void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override;
void Load() override;
private:
Behavior* m_action;
uint32_t m_maxTargets;
float m_radius;
Expand All @@ -18,12 +23,4 @@ class AreaOfEffectBehavior final : public Behavior
bool m_targetEnemy;
bool m_targetFriend;
bool m_targetTeam;

explicit AreaOfEffectBehavior(const uint32_t behaviorId) : Behavior(behaviorId) {}

void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override;

void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override;

void Load() override;
};
8 changes: 4 additions & 4 deletions dGame/dBehaviors/BehaviorContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ void BehaviorContext::Reset() {
this->scheduledUpdates.clear();
}

void BehaviorContext::FilterTargets(std::vector<Entity*>& targets, std::forward_list<int32_t> ignoreFactionList, std::forward_list<int32_t> includeFactionList, bool targetSelf, bool targetEnemy, bool targetFriend, bool targetTeam) const {
void BehaviorContext::FilterTargets(std::vector<Entity*>& targets, std::forward_list<int32_t>& ignoreFactionList, std::forward_list<int32_t>& includeFactionList, bool targetSelf, bool targetEnemy, bool targetFriend, bool targetTeam) const {

// if we aren't targeting anything, then clear the targets vector
if (!targetSelf && !targetEnemy && !targetFriend && !targetTeam && ignoreFactionList.empty() && includeFactionList.empty()) {
Expand Down Expand Up @@ -368,19 +368,19 @@ bool BehaviorContext::CheckTargetingRequirements(const Entity* target) const {
// if the target is a nullptr, then it's not valid
if (!target) return false;

// only target quickbuilds in the are completed
// ignore entities that don't have destroyable components
auto* targetDestroyableComponent = target->GetComponent<DestroyableComponent>();
if (!targetDestroyableComponent) return false;

// only target quickbuilds in the are completed
// ignore quickbuilds that aren't completed
auto* targetQuickbuildComponent = target->GetComponent<RebuildComponent>();
if (targetQuickbuildComponent && targetQuickbuildComponent->GetState() != REBUILD_COMPLETED) return false;

return true;
}

// returns true if any of the object factions are in the faction list
bool BehaviorContext::CheckFactionList(std::forward_list<int32_t> factionList, std::vector<int32_t> objectsFactions) const {
bool BehaviorContext::CheckFactionList(std::forward_list<int32_t>& factionList, std::vector<int32_t>& objectsFactions) const {
if (factionList.empty() || objectsFactions.empty()) return false;
for (auto faction : factionList){
if(std::find(objectsFactions.begin(), objectsFactions.end(), faction) != objectsFactions.end()) return true;
Expand Down
4 changes: 2 additions & 2 deletions dGame/dBehaviors/BehaviorContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,11 @@ struct BehaviorContext

void Reset();

void FilterTargets(std::vector<Entity*>& targetsReference, std::forward_list<int32_t> ignoreFaction = {}, std::forward_list<int32_t> includeFaction = {}, const bool targetSelf = false, const bool targetEnemy = true, const bool targetFriend = false, const bool targetTeam = false) const;
void FilterTargets(std::vector<Entity*>& targetsReference, std::forward_list<int32_t>& ignoreFaction, std::forward_list<int32_t>& includeFaction, const bool targetSelf = false, const bool targetEnemy = true, const bool targetFriend = false, const bool targetTeam = false) const;

bool CheckTargetingRequirements(const Entity* target) const;

bool CheckFactionList(std::forward_list<int32_t> factionList, std::vector<int32_t> objectsFactions) const;
bool CheckFactionList(std::forward_list<int32_t>& factionList, std::vector<int32_t>& objectsFactions) const;

explicit BehaviorContext(LWOOBJID originator, bool calculation = false);

Expand Down
11 changes: 5 additions & 6 deletions dGame/dBehaviors/TacArcBehavior.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@

class TacArcBehavior final : public Behavior {
public:
explicit TacArcBehavior(const uint32_t behavior_id) : Behavior(behavior_id) {}
void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override;
void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override;
void Load() override;
private:
float m_maxRange;
float m_height;
float m_distanceWeight;
Expand All @@ -29,16 +34,10 @@ class TacArcBehavior final : public Behavior {
float m_nearHeight;
float m_nearWidth;


std::forward_list<int32_t> m_ignoreFactionList {};
std::forward_list<int32_t> m_includeFactionList {};
bool m_targetSelf;
bool m_targetEnemy;
bool m_targetFriend;
bool m_targetTeam;

explicit TacArcBehavior(const uint32_t behavior_id) : Behavior(behavior_id) {}
void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override;
void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override;
void Load() override;
};
2 changes: 0 additions & 2 deletions dGame/dUtilities/SlashCommandHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1899,12 +1899,10 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
ChatPackets::SendSystemMessage(sysAddr, u"Error getting slot.");
return;
} else {
Game::logger->Log("SlashCommandHandler", "Got slot %i", slot);
if (!GeneralUtils::TryParse(args[1], skillId)) {
ChatPackets::SendSystemMessage(sysAddr, u"Error getting skill.");
return;
} else {
Game::logger->Log("SlashCommandHandler", "Got skill %i", skillId);
if(inventoryComponent->SetSkill(slot, skillId)) ChatPackets::SendSystemMessage(sysAddr, u"Set skill to slot successfully");
else ChatPackets::SendSystemMessage(sysAddr, u"Set skill to slot failed");
}
Expand Down
10 changes: 5 additions & 5 deletions docs/Commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,10 @@ These commands are primarily for development and testing. The usage of many of t
|crash|`/crash`|Crashes the server.|9|
|rollloot|`/rollloot <loot matrix index> <item id> <amount>`|Rolls loot matrix.|9|
|castskill|`/castskill <skill id>`|Casts the skill as the player|9|
|setskillslot|`/setskillslot <slot> <skill id>`||9|
|setfaction|`/setfaction <faction id>`|Clears the users current factions and sets it|9|
|addfaction|`/addfaction <faction id>`|Add the faction to the users list of factions|9|
|getfactions|`/getfactions`|Shows the player's factions|9|
|setskillslot|`/setskillslot <slot> <skill id>`||8|
|setfaction|`/setfaction <faction id>`|Clears the users current factions and sets it|8|
|addfaction|`/addfaction <faction id>`|Add the faction to the users list of factions|8|
|getfactions|`/getfactions`|Shows the player's factions|8|

## Detailed `/inspect` Usage

Expand All @@ -125,7 +125,7 @@ Finds the closest entity with the given component or LDF variable (ignoring play
* `-s`: Prints the entity's settings and spawner ID.
* `-p`: Prints the entity's position
* `-f`: If the entity has a destroyable component, prints whether the entity is smashable and its friendly and enemy faction IDs; if `faction` is specified, adds that faction to the entity.
* `-cf`: check if the faction of this entity is your enenmy or friend
* `-cf`: check if the entity is enemy or friend
* `-t`: If the entity has a phantom physics component, prints the effect type, direction, directional multiplier, and whether the effect is active; in any case, if the entity has a trigger, prints the trigger ID.

## Game Master Levels
Expand Down

0 comments on commit 4988015

Please sign in to comment.