Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
147 changes: 66 additions & 81 deletions VS.2015/Barony/Barony.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -249,66 +249,9 @@
<ClCompile Include="..\..\src\player.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\monster_automaton.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\monster_cockatrice.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\monster_crystalgolem.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\monster_goatman.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\monster_incubus.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\monster_insectoid.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\monster_lichfire.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\monster_lichice.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\monster_scarab.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\monster_shadow.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\monster_vampire.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\magic\act_HandMagic.cpp">
<Filter>Source Files\magic</Filter>
</ClCompile>
<ClCompile Include="..\..\src\monster_kobold.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\actpowercrystal.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\actsummontrap.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\cursors.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\entity_shared.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\item_tool.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\monster_shared.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\stat_shared.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\interface\bookgui.cpp">
<Filter>Source Files\interface</Filter>
</ClCompile>
Expand All @@ -318,15 +261,9 @@
<ClCompile Include="..\..\src\interface\consolecommand.cpp">
<Filter>Source Files\interface</Filter>
</ClCompile>
<ClCompile Include="..\..\src\interface\drawminimap.cpp">
<Filter>Source Files\interface</Filter>
</ClCompile>
<ClCompile Include="..\..\src\interface\drawstatus.cpp">
<Filter>Source Files\interface</Filter>
</ClCompile>
<ClCompile Include="..\..\src\interface\identify_and_appraise.cpp">
<Filter>Source Files\interface</Filter>
</ClCompile>
<ClCompile Include="..\..\src\interface\interface.cpp">
<Filter>Source Files\interface</Filter>
</ClCompile>
Expand All @@ -336,9 +273,6 @@
<ClCompile Include="..\..\src\interface\playerinventory.cpp">
<Filter>Source Files\interface</Filter>
</ClCompile>
<ClCompile Include="..\..\src\interface\removecurse.cpp">
<Filter>Source Files\interface</Filter>
</ClCompile>
<ClCompile Include="..\..\src\interface\screenshot.cpp">
<Filter>Source Files\interface</Filter>
</ClCompile>
Expand Down Expand Up @@ -369,6 +303,69 @@
<ClCompile Include="..\..\src\magic\spell.cpp">
<Filter>Source Files\magic</Filter>
</ClCompile>
<ClCompile Include="..\..\src\interface\identify_and_appraise.cpp">
<Filter>Source Files\interface</Filter>
</ClCompile>
<ClCompile Include="..\..\src\interface\removecurse.cpp">
<Filter>Source Files\interface</Filter>
</ClCompile>
<ClCompile Include="..\..\src\interface\drawminimap.cpp">
<Filter>Source Files\interface</Filter>
</ClCompile>
<ClCompile Include="..\..\src\actpowercrystal.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\entity_shared.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\item_tool.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\monster_automaton.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\monster_cockatrice.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\monster_crystalgolem.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\monster_goatman.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\monster_incubus.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\monster_insectoid.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\monster_kobold.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\monster_lichfire.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\monster_lichice.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\monster_scarab.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\monster_shadow.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\monster_shared.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\monster_vampire.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\stat_shared.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\actsummontrap.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\src\book.hpp">
Expand Down Expand Up @@ -443,27 +440,15 @@
<ClInclude Include="..\..\src\player.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\src\collision.hpp">
<Filter>Source Files</Filter>
</ClInclude>
<ClInclude Include="..\..\src\colors.hpp">
<Filter>Source Files</Filter>
</ClInclude>
<ClInclude Include="..\..\src\cppfuncs.hpp">
<Filter>Source Files</Filter>
</ClInclude>
<ClInclude Include="..\..\src\hash.hpp">
<Filter>Source Files</Filter>
</ClInclude>
<ClInclude Include="..\..\src\paths.hpp">
<Filter>Source Files</Filter>
</ClInclude>
<ClInclude Include="..\..\src\interface\interface.hpp">
<Filter>Header Files\interface</Filter>
</ClInclude>
<ClInclude Include="..\..\src\magic\magic.hpp">
<Filter>Header Files\magic</Filter>
</ClInclude>
<ClInclude Include="..\..\src\collision.hpp">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Image Include="..\..\src\game.ico">
Expand Down
8 changes: 1 addition & 7 deletions VS.2015/editor/editor.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -80,18 +80,12 @@
<ClCompile Include="..\..\src\entity_editor.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\entity_shared.cpp">
<ClCompile Include="..\..\src\items_editor.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\stat_editor.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\stat_shared.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\items_editor.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="..\..\src\wineditoricon.rc">
Expand Down
60 changes: 60 additions & 0 deletions src/actmonster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1994,6 +1994,8 @@ void actMonster(Entity* my)
}
}

CheckForPlayerHostility(my, myStats);

// state machine
if ( my->monsterState == MONSTER_STATE_WAIT ) // wait state
{
Expand Down Expand Up @@ -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<Uint32>(pOldLeaderStats->FOLLOWERS, pMonster->getUID());
}
}
}

break;
}
}
}
}
}
33 changes: 33 additions & 0 deletions src/entity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down Expand Up @@ -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];
}
Expand Down
14 changes: 14 additions & 0 deletions src/entity.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ struct spell_t;
// entity class
class Entity
{

private:
Sint32& char_gonnavomit;
Sint32& char_heal;
Sint32& char_energize;
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -521,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);