xoreos  0.0.5
functions_event.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 
30 
33 
36 
37 namespace Engines {
38 
39 namespace DragonAge {
40 
42  ctx.getReturn() = (const Aurora::NWScript::EngineType *) 0;
43 
45  if (!env || !env->hasVariable("Event"))
46  return;
47 
48  ctx.getReturn() = env->getVariable("Event");
49 }
50 
52  const Event *event = DragonAge::ObjectContainer::toEvent(ctx.getParams()[0].getEngineType());
53 
54  ctx.getReturn() = event && (event->getType() != kEventTypeInvalid);
55 }
56 
59 
60  const Event *event = DragonAge::ObjectContainer::toEvent(ctx.getParams()[0].getEngineType());
61  if (!event)
62  return;
63 
64  ctx.getReturn() = (int32) event->getType();
65 }
66 
68  ctx.getReturn() = (Aurora::NWScript::Object *) 0;
69 
70  const Event *event = DragonAge::ObjectContainer::toEvent(ctx.getParams()[0].getEngineType());
71  if (!event)
72  return;
73 
74  ctx.getReturn() = event->getCreator();
75 }
76 
78  ctx.getReturn() = (Aurora::NWScript::Object *) 0;
79 
80  const Event *event = DragonAge::ObjectContainer::toEvent(ctx.getParams()[0].getEngineType());
81  if (!event)
82  return;
83 
84  ctx.getReturn() = event->getTarget();
85 }
86 
88  ctx.getReturn() = ctx.getParams()[0].getEngineType();
89 
91  if (!event)
92  return;
93 
94  event->setType((EventType) ctx.getParams()[1].getInt());
95 }
96 
98  ctx.getReturn() = ctx.getParams()[0].getEngineType();
99 
101  if (!event)
102  return;
103 
104  event->setCreator(ctx.getParams()[1].getObject());
105 }
106 
108  Event invalidEvent;
109 
110  Event *event = DragonAge::ObjectContainer::toEvent(ctx.getParams()[0].getEngineType());
111  if (!event)
112  event = &invalidEvent;
113 
114  // TODO: According to the Dragon Age wiki, "The maximum level of event rerouteing is 8".
115 
116  DragonAge::ScriptContainer::runScript(ctx.getParams()[1].getString(), *event);
117 }
118 
119 } // End of namespace DragonAge
120 
121 } // End of namespace Engines
void isEventValid(Aurora::NWScript::FunctionContext &ctx)
void getEventCreator(Aurora::NWScript::FunctionContext &ctx)
static Event * toEvent(Aurora::NWScript::EngineType *engineType)
void setEventType(Aurora::NWScript::FunctionContext &ctx)
Context of an NWScript function.
bool hasVariable(const Common::UString &var) const
A container of Dragon Age: Origins objects.
void handleEvent(Aurora::NWScript::FunctionContext &ctx)
An NWScript engine type.
EngineType * getEngineType() const
Definition: variable.cpp:328
Utility templates and functions.
A scripting event.
void getEventType(Aurora::NWScript::FunctionContext &ctx)
Variable & getVariable(const Common::UString &var, Type type=kTypeVoid)
void getCurrentEvent(Aurora::NWScript::FunctionContext &ctx)
VariableContainer * getCurrentEnvironment() const
An NWScript variable container.
void setType(EventType type)
Definition: event.cpp:49
void getEventTarget(Aurora::NWScript::FunctionContext &ctx)
An object containing scripts.
Dragon Age: Origins engine functions.
void setCreator(const Aurora::NWScript::ObjectReference &creator)
Definition: event.cpp:57
bool runScript(EventType event, const Aurora::NWScript::ObjectReference owner=Aurora::NWScript::ObjectReference(), const Aurora::NWScript::ObjectReference triggerer=Aurora::NWScript::ObjectReference())
Definition: container.cpp:104
void setEventCreator(Aurora::NWScript::FunctionContext &ctx)
int32_t int32
Definition: types.h:203
EventType
Types for script events.
Definition: types.h:110