Skip to content

Commit

Permalink
ENGINES: Create base creature for KotOR games
Browse files Browse the repository at this point in the history
  • Loading branch information
vkremianskii authored and DrMcCoy committed Feb 18, 2019
1 parent d854b1b commit 8f92fec
Show file tree
Hide file tree
Showing 61 changed files with 510 additions and 1,005 deletions.
13 changes: 7 additions & 6 deletions src/engines/kotor/actionexecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@

#include "src/common/maths.h"

#include "src/engines/kotorbase/creature.h"

#include "src/engines/kotor/actionexecutor.h"
#include "src/engines/kotor/creature.h"
#include "src/engines/kotor/area.h"
#include "src/engines/kotor/module.h"

Expand All @@ -43,24 +44,24 @@ void ActionExecutor::executeActions(Creature &creature, Area &area, float dt) {
if (!action)
return;

switch (action->getType()) {
switch (action->type) {
case kActionMoveToPoint:
executeMoveToPoint(creature, area, *action, dt);
break;
case kActionFollowLeader:
executeFollowLeader(creature, area, *action, dt);
break;
default:
warning("TODO: Handle action %u", (uint)action->getType());
warning("TODO: Handle action %u", (uint)action->type);
break;
}
}

void ActionExecutor::executeMoveToPoint(Creature &creature, Area &area, const Action &action, float dt) {
float x, y, z;
action.getPoint(x, y, z);
float x = action.location.x;
float y = action.location.y;

if (moveTo(creature, area, x, y, action.getRange(), dt))
if (moveTo(creature, area, x, y, action.range, dt))
creature.dequeueAction();
}

Expand Down
2 changes: 1 addition & 1 deletion src/engines/kotor/actionexecutor.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace Engines {

namespace KotOR {

class Action;
struct Action;
class Area;
class Creature;

Expand Down
2 changes: 1 addition & 1 deletion src/engines/kotor/area.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#include "src/engines/aurora/localpathfinding.h"

#include "src/engines/kotorbase/room.h"
#include "src/engines/kotorbase/creature.h"

#include "src/engines/kotor/area.h"
#include "src/engines/kotor/module.h"
Expand All @@ -53,7 +54,6 @@
#include "src/engines/kotor/objectwalkmesh.h"
#include "src/engines/kotor/door.h"
#include "src/engines/kotor/doorwalkmesh.h"
#include "src/engines/kotor/creature.h"
#include "src/engines/kotor/trigger.h"
#include "src/engines/kotor/actionexecutor.h"
#include "src/engines/kotor/sound.h"
Expand Down
3 changes: 2 additions & 1 deletion src/engines/kotor/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,13 @@

#include "src/engines/aurora/util.h"

#include "src/engines/kotorbase/creature.h"

#include "src/engines/kotor/game.h"
#include "src/engines/kotor/kotor.h"
#include "src/engines/kotor/console.h"
#include "src/engines/kotor/module.h"
#include "src/engines/kotor/area.h"
#include "src/engines/kotor/creature.h"

#include "src/engines/kotor/gui/main/main.h"

Expand Down
2 changes: 1 addition & 1 deletion src/engines/kotor/gui/chargen/charactergeneration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ void CharacterGenerationMenu::start() {
hide();

try {
_module->usePC(_pc->getCharacter());
_module->usePC(_pc->createCharacter());
_module->load("end_m01aa");
} catch (...) {
Common::exceptionDispatcherWarning();
Expand Down
3 changes: 2 additions & 1 deletion src/engines/kotor/gui/chargen/charactergeneration.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@
#ifndef ENGINES_KOTOR_GUI_CHARGEN_CHARACTERGENERATION_H
#define ENGINES_KOTOR_GUI_CHARGEN_CHARACTERGENERATION_H

#include "src/engines/kotorbase/gui/chargeninfo.h"

#include "src/engines/kotor/module.h"

#include "src/engines/kotor/gui/gui.h"

#include "src/engines/kotor/gui/chargen/chargeninfo.h"
#include "src/engines/kotor/gui/chargen/chargenbase.h"

namespace Engines {
Expand Down
3 changes: 2 additions & 1 deletion src/engines/kotor/gui/chargen/chargenname.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@

#include "src/engines/odyssey/label.h"

#include "src/engines/kotorbase/gui/chargeninfo.h"

#include "src/engines/kotor/gui/chargen/chargenname.h"
#include "src/engines/kotor/gui/chargen/chargeninfo.h"

namespace Engines {

Expand Down
3 changes: 2 additions & 1 deletion src/engines/kotor/gui/chargen/chargenportrait.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@
#include "src/engines/odyssey/button.h"
#include "src/engines/odyssey/label.h"

#include "src/engines/kotorbase/gui/chargeninfo.h"

#include "src/engines/kotor/gui/chargen/chargenportrait.h"
#include "src/engines/kotor/gui/chargen/chargeninfo.h"

namespace Engines {

Expand Down
2 changes: 1 addition & 1 deletion src/engines/kotor/gui/chargen/classselection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

#include "src/aurora/talkman.h"

#include "src/engines/kotor/creature.h"
#include "src/engines/kotorbase/creature.h"

#include "src/engines/kotor/gui/chargen/classselection.h"
#include "src/engines/kotor/gui/chargen/charactergeneration.h"
Expand Down
5 changes: 2 additions & 3 deletions src/engines/kotor/gui/chargen/classselection.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,11 @@
#include "src/engines/odyssey/button.h"
#include "src/engines/odyssey/label.h"

#include "src/engines/kotorbase/gui/chargeninfo.h"

#include "src/engines/kotor/module.h"

#include "src/engines/kotor/gui/gui.h"
#include "src/engines/kotor/gui/chargen/chargeninfo.h"

#include "src/engines/kotor/gui/chargen/chargeninfo.h"

namespace Engines {

Expand Down
2 changes: 0 additions & 2 deletions src/engines/kotor/gui/chargen/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ src_engines_kotor_libkotor_la_SOURCES += \
src/engines/kotor/gui/chargen/quickorcustom.h \
src/engines/kotor/gui/chargen/quickchar.h \
src/engines/kotor/gui/chargen/customchar.h \
src/engines/kotor/gui/chargen/chargeninfo.h \
src/engines/kotor/gui/chargen/chargenbase.h \
src/engines/kotor/gui/chargen/chargenportrait.h \
src/engines/kotor/gui/chargen/chargenname.h \
Expand All @@ -37,7 +36,6 @@ src_engines_kotor_libkotor_la_SOURCES += \
src/engines/kotor/gui/chargen/quickorcustom.cpp \
src/engines/kotor/gui/chargen/quickchar.cpp \
src/engines/kotor/gui/chargen/customchar.cpp \
src/engines/kotor/gui/chargen/chargeninfo.cpp \
src/engines/kotor/gui/chargen/chargenbase.cpp \
src/engines/kotor/gui/chargen/chargenportrait.cpp \
src/engines/kotor/gui/chargen/chargenname.cpp \
Expand Down
3 changes: 2 additions & 1 deletion src/engines/kotor/gui/dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@
#include "src/engines/odyssey/listbox.h"
#include "src/engines/odyssey/scrollbar.h"

#include "src/engines/kotorbase/creature.h"

#include "src/engines/kotor/module.h"
#include "src/engines/kotor/area.h"
#include "src/engines/kotor/creature.h"

#include "src/engines/kotor/gui/dialog.h"

Expand Down
8 changes: 4 additions & 4 deletions src/engines/kotor/gui/ingame/container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@

#include "src/aurora/talkman.h"

#include "src/engines/kotor/item.h"

#include "src/engines/odyssey/panel.h"
#include "src/engines/odyssey/scrollbar.h"
#include "src/engines/odyssey/listbox.h"
#include "src/engines/odyssey/label.h"

#include "src/engines/kotorbase/item.h"

#include "src/engines/kotorbase/gui/inventoryitem.h"

#include "src/engines/kotor/gui/ingame/container.h"
Expand Down Expand Up @@ -58,8 +58,8 @@ void ContainerMenu::fillFromInventory(const Inventory &inv) {
Odyssey::WidgetListBox *lbItems = getListBox("LB_ITEMS");
lbItems->removeAllItems();

const std::map<Common::UString, InventoryItem> &invItems = inv.getItems();
for (std::map<Common::UString, InventoryItem>::const_iterator i = invItems.begin();
const std::map<Common::UString, Inventory::ItemGroup> &invItems = inv.getItems();
for (std::map<Common::UString, Inventory::ItemGroup>::const_iterator i = invItems.begin();
i != invItems.end(); ++i) {
try {
Item item(i->second.tag);
Expand Down
3 changes: 2 additions & 1 deletion src/engines/kotor/gui/ingame/container.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@

#include "src/engines/aurora/console.h"

#include "src/engines/kotorbase/inventory.h"

#include "src/engines/kotor/module.h"
#include "src/engines/kotor/inventory.h"

#include "src/engines/kotor/gui/gui.h"

Expand Down
4 changes: 2 additions & 2 deletions src/engines/kotor/gui/ingame/hud.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,8 @@ void HUD::showContainer(Inventory &inv) {
if (sub(*_container, kStartCodeNone, true, false) == 1) {
Inventory &partyInventory = _module->getPC()->getInventory();

const std::map<Common::UString, InventoryItem> &items = inv.getItems();
for (std::map<Common::UString, InventoryItem>::const_iterator i = items.begin();
const std::map<Common::UString, Inventory::ItemGroup> &items = inv.getItems();
for (std::map<Common::UString, Inventory::ItemGroup>::const_iterator i = items.begin();
i != items.end(); ++i) {
partyInventory.addItem(i->first, i->second.count);
}
Expand Down
3 changes: 2 additions & 1 deletion src/engines/kotor/gui/ingame/hud.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@

#include "src/engines/aurora/console.h"

#include "src/engines/kotorbase/inventory.h"

#include "src/engines/kotor/module.h"
#include "src/engines/kotor/inventory.h"

#include "src/engines/kotor/gui/gui.h"

Expand Down
3 changes: 2 additions & 1 deletion src/engines/kotor/gui/ingame/ingame.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@

#include "src/engines/aurora/console.h"

#include "src/engines/kotorbase/inventory.h"

#include "src/engines/kotor/module.h"
#include "src/engines/kotor/inventory.h"

#include "src/engines/kotor/gui/ingame/hud.h"
#include "src/engines/kotor/gui/ingame/selectioncircle.h"
Expand Down
10 changes: 5 additions & 5 deletions src/engines/kotor/gui/ingame/menu_equ.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@
#include "src/engines/odyssey/label.h"
#include "src/engines/odyssey/listbox.h"

#include "src/engines/kotorbase/gui/inventoryitem.h"
#include "src/engines/kotorbase/item.h"
#include "src/engines/kotorbase/creature.h"

#include "src/engines/kotor/item.h"
#include "src/engines/kotor/creature.h"
#include "src/engines/kotorbase/gui/inventoryitem.h"

#include "src/engines/kotor/gui/ingame/menu_equ.h"

Expand Down Expand Up @@ -210,8 +210,8 @@ void MenuEquipment::fillEquipableItemsList() {

_visibleItems.clear();

const std::map<Common::UString, InventoryItem> &invItems = inv.getItems();
for (std::map<Common::UString, InventoryItem>::const_iterator i = invItems.begin();
const std::map<Common::UString, Inventory::ItemGroup> &invItems = inv.getItems();
for (std::map<Common::UString, Inventory::ItemGroup>::const_iterator i = invItems.begin();
i != invItems.end(); ++i) {
try {
Item item(i->second.tag);
Expand Down
3 changes: 2 additions & 1 deletion src/engines/kotor/module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,10 @@
#include "src/engines/aurora/freeroamcamera.h"
#include "src/engines/aurora/satellitecamera.h"

#include "src/engines/kotorbase/creature.h"

#include "src/engines/kotor/module.h"
#include "src/engines/kotor/area.h"
#include "src/engines/kotor/creature.h"
#include "src/engines/kotor/placeable.h"

#include "src/engines/kotor/gui/dialog.h"
Expand Down
2 changes: 1 addition & 1 deletion src/engines/kotor/objectcontainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "src/common/util.h"

#include "src/engines/kotorbase/object.h"
#include "src/engines/kotorbase/creature.h"

#include "src/engines/kotor/objectcontainer.h"
#include "src/engines/kotor/module.h"
Expand All @@ -34,7 +35,6 @@
#include "src/engines/kotor/situated.h"
#include "src/engines/kotor/placeable.h"
#include "src/engines/kotor/door.h"
#include "src/engines/kotor/creature.h"
#include "src/engines/kotor/sound.h"

namespace Engines {
Expand Down
5 changes: 3 additions & 2 deletions src/engines/kotor/placeable.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@

#include "src/aurora/types.h"

#include "src/engines/kotorbase/item.h"
#include "src/engines/kotorbase/inventory.h"

#include "src/engines/kotor/situated.h"
#include "src/engines/kotor/item.h"
#include "src/engines/kotor/inventory.h"

namespace Engines {

Expand Down
8 changes: 0 additions & 8 deletions src/engines/kotor/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,12 @@ src_engines_kotor_libkotor_la_SOURCES += \
src/engines/kotor/waypoint.h \
src/engines/kotor/placeable.h \
src/engines/kotor/door.h \
src/engines/kotor/creature.h \
src/engines/kotor/sound.h \
src/engines/kotor/area.h \
src/engines/kotor/objectcontainer.h \
src/engines/kotor/module.h \
src/engines/kotor/item.h \
src/engines/kotor/savedgame.h \
src/engines/kotor/trigger.h \
src/engines/kotor/inventory.h \
src/engines/kotor/action.h \
src/engines/kotor/actionexecutor.h \
src/engines/kotor/partyconfig.h \
src/engines/kotor/pathfinding.h \
Expand All @@ -62,16 +58,12 @@ src_engines_kotor_libkotor_la_SOURCES += \
src/engines/kotor/situated.cpp \
src/engines/kotor/placeable.cpp \
src/engines/kotor/door.cpp \
src/engines/kotor/creature.cpp \
src/engines/kotor/sound.cpp \
src/engines/kotor/area.cpp \
src/engines/kotor/objectcontainer.cpp \
src/engines/kotor/module.cpp \
src/engines/kotor/item.cpp \
src/engines/kotor/savedgame.cpp \
src/engines/kotor/trigger.cpp \
src/engines/kotor/inventory.cpp \
src/engines/kotor/action.cpp \
src/engines/kotor/actionexecutor.cpp \
src/engines/kotor/partyconfig.cpp \
src/engines/kotor/pathfinding.cpp \
Expand Down
6 changes: 3 additions & 3 deletions src/engines/kotor/savedgame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
#include "src/common/filepath.h"
#include "src/common/readfile.h"

#include "src/engines/kotor/savedgame.h"
#include "src/engines/kotorbase/gui/chargeninfo.h"

#include "src/engines/kotor/gui/chargen/chargeninfo.h"
#include "src/engines/kotor/savedgame.h"

namespace Engines {

Expand Down Expand Up @@ -147,7 +147,7 @@ Creature *SavedGame::getPC() {
break;
}

_pc = info->getCharacter();
_pc = info->createCharacter();

if (_pcLoaded)
_pc->setPosition(_pcPosition[0], _pcPosition[1], _pcPosition[2]);
Expand Down
2 changes: 1 addition & 1 deletion src/engines/kotor/savedgame.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#include "src/aurora/erffile.h"
#include "src/aurora/gff3file.h"

#include "src/engines/kotor/creature.h"
#include "src/engines/kotorbase/creature.h"

namespace Engines {

Expand Down
7 changes: 4 additions & 3 deletions src/engines/kotor/script/functions_action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,10 @@ void Functions::actionMoveToObject(Aurora::NWScript::FunctionContext &ctx) {
float x, y, z;
object->getPosition(x, y, z);

Action action(kActionMoveToPoint);
action.setRange(range);
action.setPoint(x, y, z);
Action action;
action.type = kActionMoveToPoint;
action.range = range;
action.location = glm::vec3(x, y, z);

caller->clearActionQueue();
caller->enqueueAction(action);
Expand Down

0 comments on commit 8f92fec

Please sign in to comment.