From d76dd74581a966ca310a10f6b6f30c0cc53bf11c Mon Sep 17 00:00:00 2001 From: Lutz Date: Tue, 7 Nov 2017 16:55:23 -0600 Subject: [PATCH 1/5] * Updated VS Solution --- VS.2015/Barony/Barony.vcxproj.filters | 147 ++++++++++++-------------- VS.2015/editor/editor.vcxproj.filters | 8 +- 2 files changed, 67 insertions(+), 88 deletions(-) diff --git a/VS.2015/Barony/Barony.vcxproj.filters b/VS.2015/Barony/Barony.vcxproj.filters index 611d2dd39..16e3c9a21 100644 --- a/VS.2015/Barony/Barony.vcxproj.filters +++ b/VS.2015/Barony/Barony.vcxproj.filters @@ -249,66 +249,9 @@ Source Files - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - Source Files\magic - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - Source Files\interface @@ -318,15 +261,9 @@ Source Files\interface - - Source Files\interface - Source Files\interface - - Source Files\interface - Source Files\interface @@ -336,9 +273,6 @@ Source Files\interface - - Source Files\interface - Source Files\interface @@ -369,6 +303,69 @@ Source Files\magic + + Source Files\interface + + + Source Files\interface + + + Source Files\interface + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + @@ -443,27 +440,15 @@ Header Files - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - Header Files\interface Header Files\magic + + Header Files + diff --git a/VS.2015/editor/editor.vcxproj.filters b/VS.2015/editor/editor.vcxproj.filters index be346846e..708c21122 100644 --- a/VS.2015/editor/editor.vcxproj.filters +++ b/VS.2015/editor/editor.vcxproj.filters @@ -80,18 +80,12 @@ Source Files - + Source Files Source Files - - Source Files - - - Source Files - From 658268d40c4b7b1c3ef8e7a50b39639762195092 Mon Sep 17 00:00:00 2001 From: Lutz Date: Tue, 7 Nov 2017 17:59:33 -0600 Subject: [PATCH 2/5] + Added 'hostilePlayers[4];' to keep track of hostile Players --- src/entity.hpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/entity.hpp b/src/entity.hpp index d6cfa8582..4fa5140f7 100644 --- a/src/entity.hpp +++ b/src/entity.hpp @@ -41,6 +41,8 @@ struct spell_t; // entity class class Entity { + +private: Sint32& char_gonnavomit; Sint32& char_heal; Sint32& char_energize; @@ -127,6 +129,8 @@ class Entity list_t children; // every entity has a list of child objects Uint32 parent; // id of the entity's "parent" entity + bool hostilePlayers[4] = {false}; // An array of whether or not the Player is hostile, position in array corresponds to position in players[] array + //--PUBLIC CHEST SKILLS-- //skill[4] From e771b2dadeb20d3ce4447305d8191f6790e57b1c Mon Sep 17 00:00:00 2001 From: Lutz Date: Tue, 7 Nov 2017 18:00:05 -0600 Subject: [PATCH 3/5] + Added checks to 'checkEnemy()' and 'checkFriend()' to handle Hostile Players --- src/entity.cpp | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/entity.cpp b/src/entity.cpp index f017a97a5..699647e2a 100644 --- a/src/entity.cpp +++ b/src/entity.cpp @@ -5385,6 +5385,22 @@ bool Entity::checkEnemy(Entity* your) return false; } + if ( myStats->type == HUMAN ) + { + // Individual Humans hold a grudge against individual Players + for ( Uint8 iPlayerIndex = 0; iPlayerIndex < MAXPLAYERS; iPlayerIndex++ ) + { + if ( players[iPlayerIndex] && players[iPlayerIndex]->entity ) + { + // Check if this Player is an Enemy + if ( players[iPlayerIndex]->entity == your ) + { + return hostilePlayers[iPlayerIndex]; + } + } + } + } + // if you have a leader, check whether we are enemies instead Entity* yourLeader = NULL; if ( yourStats->leader_uid ) @@ -5557,6 +5573,23 @@ bool Entity::checkFriend(Entity* your) } if ( !foundFollower ) { + // First do a check to see if there is a grudge against the Player + if ( myStats->type == HUMAN ) + { + // Individual Humans hold a grudge against individual Players + for ( Uint8 iPlayerIndex = 0; iPlayerIndex < MAXPLAYERS; iPlayerIndex++ ) + { + if ( players[iPlayerIndex] && players[iPlayerIndex]->entity ) + { + // Check if this Player is an Enemy + if ( players[iPlayerIndex]->entity == your ) + { + return !hostilePlayers[iPlayerIndex]; + } + } + } + } + // no leader, default to allegiance table result = monsterally[myStats->type][yourStats->type]; } From b157c74a24d7cf8ded29296ae111f264e7cc9c95 Mon Sep 17 00:00:00 2001 From: Lutz Date: Tue, 7 Nov 2017 18:09:12 -0600 Subject: [PATCH 4/5] + Added 'CheckForPlayerHostility()' to process agression towards Humans --- src/actmonster.cpp | 60 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/src/actmonster.cpp b/src/actmonster.cpp index ae2c932ec..ab242a4d1 100644 --- a/src/actmonster.cpp +++ b/src/actmonster.cpp @@ -1994,6 +1994,8 @@ void actMonster(Entity* my) } } + CheckForPlayerHostility(my, myStats); + // state machine if ( my->monsterState == MONSTER_STATE_WAIT ) // wait state { @@ -5156,3 +5158,61 @@ int numTargetsAroundEntity(Entity* my, double distToFind, real_t angleToSearch, } return count; } + +/* actmonster.cpp + * @param pMonster - A pointer to the Monster's Entity + * @param pMonsterStats - A pointer to the Monster's Stats + * Checks to see if a Player has been hostile towards this Monster. Currently only handles Humans + * If a Player was Hostile, then this Human will be permanently Hostile towards only that Player + * Sets 'pMonster->hostilePlayers[iPlayerIndex] = true' if there was hostility + * If @pMonster is a Follower of the Hostile Player, then they will be removed from the 'stats[iPlayerIndex]->FOLLOWERS' list + */ +void CheckForPlayerHostility(Entity* const pMonster, Stat* const pMonsterStats) +{ + // Check if a Player has been Hostile + if ( pMonsterStats->type == HUMAN && pMonsterStats->HP > 0 && pMonster->monsterTarget > 0 ) + { + // Individual Humans hold a grudge against individual Players + for ( Uint8 iPlayerIndex = 0; iPlayerIndex < MAXPLAYERS; iPlayerIndex++ ) + { + if ( players[iPlayerIndex] && players[iPlayerIndex]->entity ) + { + // Skip already hostile Players + if ( pMonster->hostilePlayers[iPlayerIndex] == true ) + { + continue; + } + + // Only process hostility on this Human against that Player + if ( pMonster->monsterTarget != players[iPlayerIndex]->entity->getUID() ) + { + continue; + } + + // If the Player is the target, then hold a grudge + if ( pMonster->monsterTarget == players[iPlayerIndex]->entity->getUID() ) + { + pMonster->hostilePlayers[iPlayerIndex] = true; + + // If the Player is your Leader, stop being a Follower + if ( pMonsterStats->leader_uid != 0 ) + { + Entity* pOldLeader = uidToEntity(pMonsterStats->leader_uid); + + if ( pOldLeader == players[iPlayerIndex]->entity ) + { + Stat* pOldLeaderStats = pOldLeader->getStats(); + + if ( pOldLeaderStats != nullptr ) + { + list_RemoveNodeWithElement(pOldLeaderStats->FOLLOWERS, pMonster->getUID()); + } + } + } + + break; + } + } + } + } +} \ No newline at end of file From 80f14f06f08944acfd482dbf2b6d897554768f54 Mon Sep 17 00:00:00 2001 From: Lutz Date: Wed, 15 Nov 2017 17:29:46 -0600 Subject: [PATCH 5/5] + Added missing header definition for 'CheckForPlayerHostility()' --- src/entity.hpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/entity.hpp b/src/entity.hpp index 4fa5140f7..4af09f600 100644 --- a/src/entity.hpp +++ b/src/entity.hpp @@ -525,3 +525,13 @@ bool isLevitating(Stat * myStats); int getWeaponSkill(Item* weapon); int getStatForProficiency(int skill); void setSpriteAttributes(Entity* entityToSet, Entity* entityToCopy, Entity* entityStatToCopy); + +/* actmonster.cpp + * @param pMonster - A pointer to the Monster's Entity + * @param pMonsterStats - A pointer to the Monster's Stats + * Checks to see if a Player has been hostile towards this Monster. Currently only handles Humans + * If a Player was Hostile, then this Human will be permanently Hostile towards only that Player + * Sets 'pMonster->hostilePlayers[iPlayerIndex] = true' if there was hostility + * If @pMonster is a Follower of the Hostile Player, then they will be removed from the 'stats[iPlayerIndex]->FOLLOWERS' list + */ +void CheckForPlayerHostility(Entity* const pMonster, Stat* const pMonsterStats); \ No newline at end of file