xoreos  0.0.5
functions_party.cpp
Go to the documentation of this file.
1 /* xoreos - A reimplementation of BioWare's Aurora engine
2  *
3  * xoreos is the legal property of its developers, whose names
4  * can be found in the AUTHORS file distributed with this source
5  * distribution.
6  *
7  * xoreos is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 3
10  * of the License, or (at your option) any later version.
11  *
12  * xoreos is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with xoreos. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
25 #include "src/common/util.h"
26 #include "src/common/scopedptr.h"
27 
29 
31 #include "src/engines/kotor/game.h"
35 
37 
38 namespace Engines {
39 
40 namespace KotOR {
41 
43  Aurora::NWScript::Object *object = ctx.getParams()[0].getObject();
44 
45  Creature *creature = ObjectContainer::toCreature(object);
46 
47  if (!creature)
48  throw Common::Exception("Functions::isObjectPartyMember(): object is not a creature");
49 
50  ctx.getReturn() = _game->getModule().isObjectPartyMember(creature);
51 }
52 
54  int index = ctx.getParams()[0].getInt();
55 
56  ctx.getReturn() = _game->getModule().getPartyMember(index);
57 }
58 
60  const Common::UString &exitScript = ctx.getParams()[0].getString();
61  int forceNPC1 = ctx.getParams()[1].getInt();
62  int forceNPC2 = ctx.getParams()[2].getInt();
63 
64  _game->getModule().showPartySelectionGUI(forceNPC1, forceNPC2);
65  ScriptContainer::runScript(exitScript, ctx.getCaller(), ctx.getTriggerer());
66 }
67 
69  int slot = ctx.getParams()[0].getInt();
70 
72 }
73 
75  const int slot = ctx.getParams()[0].getInt();
76  const Common::UString &templ = ctx.getParams()[1].getString();
77 
78  _game->getModule().addAvailablePartyMember(slot, templ);
79 }
80 
81 } // End of namespace KotOR
82 
83 } // End of namespace Engines
A class holding an UTF-8 string.
Definition: ustring.h:48
Context of an NWScript function.
A simple scoped smart pointer template.
void showPartySelectionGUI(Aurora::NWScript::FunctionContext &ctx)
The context handling the gameplay in Star Wars: Knights of the Old Republic.
Utility templates and functions.
A container of Star Wars: Knights of the Old Republic objects.
void addAvailableNPCByTemplate(Aurora::NWScript::FunctionContext &ctx)
bool runScript(Script script, const Aurora::NWScript::ObjectReference owner=Aurora::NWScript::ObjectReference(), const Aurora::NWScript::ObjectReference triggerer=Aurora::NWScript::ObjectReference())
Definition: container.cpp:158
StackException Exception
Definition: error.h:59
Star Wars: Knights of the Old Republic engine functions.
void getPartyMemberByIndex(Aurora::NWScript::FunctionContext &ctx)
void addAvailablePartyMember(int slot, const Common::UString &templ)
Add available party member by template.
Definition: module.cpp:851
bool isAvailableCreature(int slot)
Check if there is a party member available for this id.
Definition: module.cpp:859
static Creature * toCreature(Aurora::NWScript::Object *object)
Module & getModule()
Return the module context.
Definition: game.cpp:65
void isAvailableCreature(Aurora::NWScript::FunctionContext &ctx)
An object in a Star Wars: Knights of the Old Republic area.
The context needed to run a Star Wars: Knights of the Old Republic module.
bool isObjectPartyMember(Creature *creature)
Check if the specified creature is a party member.
Definition: module.cpp:760
Creature * getPartyMember(int index)
Get a party member by index.
Definition: module.cpp:764
Basic Star Wars: Knights of the Old Republic type definitions.
void showPartySelectionGUI(int forceNPC1, int forceNPC2)
Show the party selection GUI.
Definition: module.cpp:802
void isObjectPartyMember(Aurora::NWScript::FunctionContext &ctx)