Skip to content

Commit

Permalink
Merge pull request #209 from hwoarangmy/development
Browse files Browse the repository at this point in the history
Add support for traps + spike traps + fixed several crash + console command for listing animations from an ogre mesh
  • Loading branch information
Bertram25 committed Oct 1, 2014
2 parents 0a3d1d4 + bcf1aa1 commit a295048
Show file tree
Hide file tree
Showing 53 changed files with 988 additions and 530 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Expand Up @@ -249,6 +249,7 @@ set(OD_SOURCEFILES
${SRC}/Trap.cpp
${SRC}/TrapBoulder.cpp
${SRC}/TrapCannon.cpp
${SRC}/TrapSpike.cpp
${SRC}/Vector3i.cpp
${SRC}/Weapon.cpp
)
Expand Down
1 change: 1 addition & 0 deletions config/console_commands.txt
Expand Up @@ -18,6 +18,7 @@ fps
help
host
list
listanims
load
logfloodfill
ls
Expand Down
1 change: 1 addition & 0 deletions gui/OpenDungeonsIcons.imageset
Expand Up @@ -17,4 +17,5 @@
<Image height="60" name="HatcheryButton" width="60" xPos="322" yPos="97" />

<Image height="60" name="CannonButton" width="60" xPos="132" yPos="159" />
<Image height="60" name="SpikeTrapButton" width="60" xPos="194" yPos="159" />
</Imageset>
Binary file modified gui/OpenDungeonsIcons.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 7 additions & 1 deletion gui/OpenDungeonsMenuTraps.layout
Expand Up @@ -10,7 +10,13 @@
<Window type="OD/ImageButton" name="CannonButton" >
<Property name="Area" value="{{0,20},{0,20},{0,80},{0,80}}" />
<Property name="NormalImage" value="OpenDungeonsIcons/CannonButton" />
<Property name="TooltipText" value="Buid a cannon" />
<Property name="TooltipText" value="Build a cannon" />
<Property name="InheritsAlpha" value="False" />
</Window>
<Window type="OD/ImageButton" name="SpikeTrapButton" >
<Property name="Area" value="{{0,80},{0,20},{0,140},{0,80}}" />
<Property name="NormalImage" value="OpenDungeonsIcons/SpikeTrapButton" />
<Property name="TooltipText" value="Build a spike trap" />
<Property name="InheritsAlpha" value="False" />
</Window>
</Window>
Expand Down
8 changes: 6 additions & 2 deletions levels/skirmish/TestSingleplayerSmall.level
Expand Up @@ -188,8 +188,8 @@ ProtectDungeonTemple NULL
13 45 1 0
14 7 1 0
14 8 1 0
14 9 1 0
14 10 1 0
14 9 6 0 3
14 10 6 0 3
14 11 1 0
14 12 2 100
14 13 2 100
Expand Down Expand Up @@ -730,6 +730,10 @@ Treasury 4

[Traps]
# meshName seatId NextLine: numTiles Subsequent Lines: tileX tileY
Spiketrap 3
2
14 9
14 10
[/Traps]

[Lights]
Expand Down
8 changes: 8 additions & 0 deletions source/Console_executePromptCommand.cpp
Expand Up @@ -1019,6 +1019,14 @@ bool Console::executePromptCommand(const std::string& command, std::string argum
frameListener->mCommandOutput += "\nERROR : This command is available on the server only\n";
}
}
else if (command.compare("listanims") == 0)
{
std::string meshName;
tempSS.str(arguments);
tempSS >> meshName;
std::string anims = RenderManager::consoleListAnimationsForMesh(meshName);
frameListener->mCommandOutput += "\nAnimations for " + meshName + anims;
}
else if (command.compare("possescreature") == 0)
{
tempSS.str("");
Expand Down
5 changes: 5 additions & 0 deletions source/Console_getHelp.cpp
Expand Up @@ -152,6 +152,11 @@ string Console::getHelpText(std::string arg)
return "setdest Sets the creature destination. The path will be computed if reachable. It takes as arguments the creature name, then the tile coordinales. Example : setdest Wizard1 10 10";
}

else if (arg.compare("listanims") == 0)
{
return "listanims List all the animations for the given mesh";
}

else if (arg.compare("list") == 0 || arg.compare("ls") == 0)
{
return "List (or \"ls\" for short is a utility which lists various types of information about the current game. Running list without an argument will produce a list of the lists available. Running list with an argument displays the contents of that list.\n\nExample:\n"
Expand Down
18 changes: 13 additions & 5 deletions source/Creature.cpp
Expand Up @@ -17,7 +17,7 @@

/*TODO list:
* - replace hardcoded calculations by scripts and/or read the numbers from XML defintion files
* - the doTurn() functions needs script support
* - the doUpkeep() functions needs script support
*/

#include "Creature.h"
Expand Down Expand Up @@ -515,7 +515,7 @@ void Creature::detach()
RenderManager::queueRenderRequest(request);
}

void Creature::doTurn()
void Creature::doUpkeep()
{
// if creature is not on map, we do nothing
if(!getIsOnMap())
Expand Down Expand Up @@ -720,7 +720,7 @@ void Creature::doTurn()
break;

default:
LogManager::getSingleton().logMessage("ERROR: Unhandled action type in Creature::doTurn():"
LogManager::getSingleton().logMessage("ERROR: Unhandled action type in Creature::doUpkeep():"
+ Ogre::StringConverter::toString(topActionItem.getType()));
popAction();
loopBack = false;
Expand All @@ -729,14 +729,14 @@ void Creature::doTurn()
}
else
{
LogManager::getSingleton().logMessage("ERROR: Creature has empty action queue in doTurn(), this should not happen.");
LogManager::getSingleton().logMessage("ERROR: Creature has empty action queue in doUpkeep(), this should not happen.");
loopBack = false;
}
} while (loopBack && loops < 20);

if(loops >= 20)
{
LogManager::getSingleton().logMessage("> 20 loops in Creature::doTurn name:" + getName() +
LogManager::getSingleton().logMessage("> 20 loops in Creature::doUpkeep name:" + getName() +
" seat id: " + Ogre::StringConverter::toString(getSeat()->getId()) + ". Breaking out..");
}

Expand Down Expand Up @@ -2945,3 +2945,11 @@ bool Creature::isInBadMood()
// TODO : set bad mood depending on the creature stats
return (mAwakeness < 10.0 && mHunger > 90.0);
}

bool Creature::isAttackable() const
{
if(mHp <= 0.0)
return false;

return true;
}
12 changes: 5 additions & 7 deletions source/Creature.h
Expand Up @@ -85,7 +85,7 @@ class Creature: public MovableGameEntity
inline unsigned int getLevel() const
{ return mLevel; }

double getHP(Tile *tile)
double getHP(Tile *tile) const
{ return getHP(); }

double getHP() const;
Expand Down Expand Up @@ -145,8 +145,8 @@ class Creature: public MovableGameEntity

/*! \brief The main AI routine which decides what the creature will do and carries out that action.
*
* The doTurn routine is the heart of the Creature AI subsystem. The other,
* higher level, functions such as GameMap::doTurn() ultimately just call this
* The doUpkeep routine is the heart of the Creature AI subsystem. The other,
* higher level, functions such as GameMap::doUpkeep() ultimately just call this
* function to make the creatures act.
*
* The function begins in a pre-cognition phase which prepares the creature's
Expand All @@ -173,11 +173,9 @@ class Creature: public MovableGameEntity
* In the future there should also be a post-cognition phase to do any
* additional checks after it tries to move, etc.
*/
void doTurn();
void doUpkeep();

//TODO: convert doTurn to doUpkeep();
bool doUpkeep()
{ return true; }
virtual bool isAttackable() const;

double getHitroll(double range);
double getDefense() const;
Expand Down
17 changes: 3 additions & 14 deletions source/GameEntity.h
Expand Up @@ -71,8 +71,6 @@ class GameEntity
meshName (nMeshName),
meshExists (false),
mSeat (seat),
active (true),
attackable (true),
mIsDeleteRequested (false),
objectType (unknown),
gameMap (NULL)
Expand All @@ -98,11 +96,8 @@ class GameEntity
//! \brief Get if the mesh is already existing
inline bool isMeshExisting () const { return meshExists; }

//! \brief Get if the object is active (doing sth. on its own) or not
inline bool isActive () const { return active; }

//! \brief Get if the object can be attacked or not
inline bool isAttackable () const { return attackable; }
virtual bool isAttackable () const { return false; }

//! \brief Get the type of this object
inline ObjectType getObjectType () const { return objectType; }
Expand Down Expand Up @@ -166,14 +161,14 @@ class GameEntity
};

//! \brief defines what happens on each turn with this object
virtual bool doUpkeep () = 0;
virtual void doUpkeep () = 0;

//! \brief Returns a list of the tiles that this object is in/covering. For creatures and other small objects
//! this will be a single tile, for larger objects like rooms this will be 1 or more tiles.
virtual std::vector<Tile*> getCoveredTiles() = 0;

//! \brief Returns the HP associated with the given tile of the object, it is up to the object how they want to treat the tile/HP relationship.
virtual double getHP(Tile *tile) = 0;
virtual double getHP(Tile *tile) const = 0;

//! \brief Returns defense rating for the object, i.e. how much less than inflicted damage should it recieve.
virtual double getDefense() const = 0;
Expand Down Expand Up @@ -223,12 +218,6 @@ class GameEntity
//! \brief The seat that the object belongs to
Seat* mSeat;

//! \brief A flag saying whether the object is active (doing something on its own) or not
bool active;

//! \brief A flag saying whether the object can be attacked or not
bool attackable;

//! \brief A flag saying whether the object has been requested to delete
bool mIsDeleteRequested;

Expand Down

0 comments on commit a295048

Please sign in to comment.