Skip to content

Commit

Permalink
KOTORBASE: Add console command to describe objects
Browse files Browse the repository at this point in the history
  • Loading branch information
vkremianskii authored and DrMcCoy committed Sep 22, 2019
1 parent a931f4f commit 700f609
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/engines/kotorbase/console.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ Console::Console(KotOREngine &engine) :
"Usage: getactiveobject\nGet a tag of the active object");
registerCommand("actionmovetoobject" , boost::bind(&Console::cmdActionMoveToObject , this, _1),
"Usage: actionmovetoobject <target> [<range>]\nMake the active creature move to a specified object");
registerCommand("describe" , boost::bind(&Console::cmdDescribe , this, _1),
"Usage: describe\nDescribe the active object or the party leader");
}

void Console::updateCaches() {
Expand Down Expand Up @@ -259,6 +261,35 @@ void Console::cmdActionMoveToObject(const CommandLine &cl) {
creature->addAction(action);
}

void Console::cmdDescribe(const CommandLine &UNUSED(cl)) {
Object *object = _engine->getGame().getModule().getCurrentArea()->getActiveObject();
if (!object) {
object = _engine->getGame().getModule().getPartyLeader();
if (!object)
return;
}
Creature *creature = ObjectContainer::toCreature(object);
if (creature) {
printf("name=\"%s\" tag=\"%s\" temp=\"%s\" hp=%u maxhp=%u str=%u dex=%u con=%u int=%u wis=%u cha=%u",
creature->getName().c_str(),
creature->getTag().c_str(),
creature->getTemplateResRef().c_str(),
creature->getCurrentHitPoints(),
creature->getMaxHitPoints(),
creature->getAbilityScore(kAbilityStrength),
creature->getAbilityScore(kAbilityDexterity),
creature->getAbilityScore(kAbilityConstitution),
creature->getAbilityScore(kAbilityIntelligence),
creature->getAbilityScore(kAbilityWisdom),
creature->getAbilityScore(kAbilityCharisma));
} else {
printf("name=\"%s\" tag=\"%s\" temp=\"%s\"",
object->getName().c_str(),
object->getTag().c_str(),
object->getTemplateResRef().c_str());
}
}

} // End of namespace KotORBase

} // End of namespace Engines
1 change: 1 addition & 0 deletions src/engines/kotorbase/console.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class Console : public Engines::Console {
void cmdAddItem (const CommandLine &cl);
void cmdGetActiveObject (const CommandLine &cl);
void cmdActionMoveToObject (const CommandLine &cl);
void cmdDescribe (const CommandLine &cl);
};

} // End of namespace KotORBase
Expand Down

0 comments on commit 700f609

Please sign in to comment.