xoreos  0.0.5
functions_action.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/error.h"
26 
28 
33 
35 
36 namespace Engines {
37 
38 namespace KotOR2 {
39 
41  Common::UString script = ctx.getScriptName();
42  if (script.empty())
43  throw Common::Exception("Functions::assignCommand(): Script needed");
44 
45  const Aurora::NWScript::ScriptState &state = ctx.getParams()[1].getScriptState();
46 
47  _game->getModule().delayScript(script, state, getParamObject(ctx, 0), ctx.getTriggerer(), 0);
48 }
49 
51  Common::UString script = ctx.getScriptName();
52  if (script.empty())
53  throw Common::Exception("Functions::assignCommand(): Script needed");
54 
55  uint32 delay = ctx.getParams()[0].getFloat() * 1000;
56 
57  const Aurora::NWScript::ScriptState &state = ctx.getParams()[1].getScriptState();
58 
59  _game->getModule().delayScript(script, state, ctx.getCaller(), ctx.getTriggerer(), delay);
60 }
61 
63  const Common::UString &convName = ctx.getParams()[1].getString();
64  _game->getModule().startConversation(convName, ctx.getCaller());
65 }
66 
67 } // End of namespace KotOR2
68 
69 } // End of namespace Engines
A class holding an UTF-8 string.
Definition: ustring.h:48
The context handling the gameplay in Star Wars: Knights of the Old Republic II - The Sith Lords...
A container of Star Wars: Knights of the Old Republic II - The Sith Lords objects.
Context of an NWScript function.
Exception that provides a stack of explanations.
Definition: error.h:36
Basic exceptions to throw.
void delayCommand(Aurora::NWScript::FunctionContext &ctx)
Basic Star Wars: Knights of the Old Republic II - The Sith Lords type definitions.
Star Wars: Knights of the Old Republic II - The Sith Lords engine functions.
Module & getModule()
Return the module context.
Definition: game.cpp:63
const Common::UString & getScriptName() const
bool empty() const
Is the string empty?
Definition: ustring.cpp:245
The context needed to run a Star Wars: Knights of the Old Republic II - The Sith Lords module...
static Aurora::NWScript::Object * getParamObject(const Aurora::NWScript::FunctionContext &ctx, size_t n)
Definition: functions.cpp:115
uint32_t uint32
Definition: types.h:204
void assignCommand(Aurora::NWScript::FunctionContext &ctx)
void actionStartConversation(Aurora::NWScript::FunctionContext &ctx)
void delayScript(const Common::UString &script, const Aurora::NWScript::ScriptState &state, Aurora::NWScript::Object *owner, Aurora::NWScript::Object *triggerer, uint32 delay)
Definition: module.cpp:647
void startConversation(const Common::UString &name, Aurora::NWScript::Object *owner=0)
Definition: module.cpp:713