xoreos  0.0.5
functions_module.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 
28 
33 
35 
36 namespace Engines {
37 
38 namespace Witcher {
39 
42 }
43 
45  Location loc;
46 
47  loc.setArea (Witcher::ObjectContainer::toArea(ctx.getParams()[0].getObject()));
48  loc.setFacing(ctx.getParams()[2].getFloat());
49 
50  float x, y, z;
51  ctx.getParams()[1].getVector(x, y, z);
52  loc.setPosition(x, y, z);
53 
54  ctx.getReturn() = loc;
55 }
56 
58  ctx.getReturn().setVector(0.0f, 0.0f, 0.0f);
59 
60  Location *loc = Witcher::ObjectContainer::toLocation(ctx.getParams()[0].getEngineType());
61  if (!loc)
62  return;
63 
64  float x, y, z;
65  loc->getPosition(x, y, z);
66 
67  ctx.getReturn().setVector(x, y, z);
68 }
69 
71  std::vector<Common::UString> modules;
72  _game->getModules(modules);
73 
74  for (std::vector<Common::UString>::const_iterator m = modules.begin(); m != modules.end(); ++m) {
75  if (m->equalsIgnoreCase(ctx.getParams()[0].getString())) {
76  _game->getModule().load(*m + ".mod");
77  return;
78  }
79  }
80 
81  warning("Can't start module \"%s\": No such module", ctx.getParams()[0].getString().c_str());
82 }
83 
86 }
87 
89  ctx.getReturn() = (Aurora::NWScript::Object *) 0;
90 }
91 
92 } // End of namespace Witcher
93 
94 } // End of namespace Engines
A container of The Witcher objects.
void setFacing(float facing)
Set the location&#39;s orientation.
Definition: location.cpp:68
void setPosition(float x, float y, float z)
Set the location&#39;s position.
Definition: location.cpp:58
Context of an NWScript function.
static Area * toArea(Aurora::NWScript::Object *object)
void setArea(Area *area)
Set the location&#39;s area.
Definition: location.cpp:48
Module & getModule()
Return the module context.
Definition: game.cpp:67
void getPositionFromLocation(Aurora::NWScript::FunctionContext &ctx)
static void getModules(std::vector< Common::UString > &modules)
Return a list of all modules.
Definition: game.cpp:172
Utility templates and functions.
void getModule(Aurora::NWScript::FunctionContext &ctx)
void setVector(float x, float y, float z)
Definition: variable.cpp:335
void warning(const char *s,...)
Definition: util.cpp:33
void startNewModule(Aurora::NWScript::FunctionContext &ctx)
static Location * toLocation(Aurora::NWScript::EngineType *engineType)
void getPosition(float &x, float &y, float &z) const
Return the location&#39;s position.
Definition: location.cpp:52
void location(Aurora::NWScript::FunctionContext &ctx)
void load(const Common::UString &module, const Common::UString &entryLocation="")
Load a module.
Definition: module.cpp:91
The context needed to run a The Witcher module.
The Witcher engine functions.
void getNextPC(Aurora::NWScript::FunctionContext &ctx)
A location within a The Witcher area.
The context handling the gameplay in The Witcher.
Creature * getPC()
Return the currently playing PC.
Definition: module.cpp:79
void getFirstPC(Aurora::NWScript::FunctionContext &ctx)