xoreos
0.0.5
src
engines
dragonage
script
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
27
#include "
src/aurora/nwscript/functioncontext.h
"
28
#include "
src/aurora/nwscript/variablecontainer.h
"
29
#include "
src/aurora/nwscript/enginetype.h
"
30
31
#include "
src/engines/dragonage/objectcontainer.h
"
32
#include "
src/engines/dragonage/event.h
"
33
34
#include "
src/engines/dragonage/script/functions.h
"
35
#include "
src/engines/dragonage/script/container.h
"
36
37
namespace
Engines
{
38
39
namespace
DragonAge {
40
41
void
Functions::getCurrentEvent
(
Aurora::NWScript::FunctionContext
&ctx) {
42
ctx.
getReturn
() = (
const
Aurora::NWScript::EngineType
*) 0;
43
44
Aurora::NWScript::VariableContainer
*env = ctx.
getCurrentEnvironment
();
45
if
(!env || !env->
hasVariable
(
"Event"
))
46
return
;
47
48
ctx.
getReturn
() = env->
getVariable
(
"Event"
);
49
}
50
51
void
Functions::isEventValid
(
Aurora::NWScript::FunctionContext
&ctx) {
52
const
Event
*
event
=
DragonAge::ObjectContainer::toEvent
(ctx.
getParams
()[0].getEngineType());
53
54
ctx.
getReturn
() =
event
&& (
event
->getType() !=
kEventTypeInvalid
);
55
}
56
57
void
Functions::getEventType
(
Aurora::NWScript::FunctionContext
&ctx) {
58
ctx.
getReturn
() = (
int32
)
kEventTypeInvalid
;
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
67
void
Functions::getEventCreator
(
Aurora::NWScript::FunctionContext
&ctx) {
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
77
void
Functions::getEventTarget
(
Aurora::NWScript::FunctionContext
&ctx) {
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
87
void
Functions::setEventType
(
Aurora::NWScript::FunctionContext
&ctx) {
88
ctx.
getReturn
() = ctx.
getParams
()[0].getEngineType();
89
90
Event
*
event
=
DragonAge::ObjectContainer::toEvent
(ctx.
getReturn
().
getEngineType
());
91
if
(!event)
92
return
;
93
94
event
->
setType
((
EventType
) ctx.
getParams
()[1].getInt());
95
}
96
97
void
Functions::setEventCreator
(
Aurora::NWScript::FunctionContext
&ctx) {
98
ctx.
getReturn
() = ctx.
getParams
()[0].getEngineType();
99
100
Event
*
event
=
DragonAge::ObjectContainer::toEvent
(ctx.
getReturn
().
getEngineType
());
101
if
(!event)
102
return
;
103
104
event
->
setCreator
(ctx.
getParams
()[1].getObject());
105
}
106
107
void
Functions::handleEvent
(
Aurora::NWScript::FunctionContext
&ctx) {
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
Aurora::NWScript::Object
Definition:
object.h:37
Engines::DragonAge::Functions::isEventValid
void isEventValid(Aurora::NWScript::FunctionContext &ctx)
Definition:
functions_event.cpp:51
Engines::DragonAge::Functions::getEventCreator
void getEventCreator(Aurora::NWScript::FunctionContext &ctx)
Definition:
functions_event.cpp:67
Engines::DragonAge::ObjectContainer::toEvent
static Event * toEvent(Aurora::NWScript::EngineType *engineType)
Definition:
objectcontainer.cpp:142
Engines::DragonAge::Functions::setEventType
void setEventType(Aurora::NWScript::FunctionContext &ctx)
Definition:
functions_event.cpp:87
functioncontext.h
Context of an NWScript function.
Aurora::NWScript::VariableContainer::hasVariable
bool hasVariable(const Common::UString &var) const
Definition:
variablecontainer.cpp:39
objectcontainer.h
A container of Dragon Age: Origins objects.
Engines::DragonAge::Functions::handleEvent
void handleEvent(Aurora::NWScript::FunctionContext &ctx)
Definition:
functions_event.cpp:107
Aurora::NWScript::FunctionContext
Definition:
functioncontext.h:42
enginetype.h
An NWScript engine type.
Aurora::NWScript::Variable::getEngineType
EngineType * getEngineType() const
Definition:
variable.cpp:328
util.h
Utility templates and functions.
Aurora::NWScript::EngineType
Definition:
enginetype.h:32
event.h
A scripting event.
Engines::DragonAge::Functions::getEventType
void getEventType(Aurora::NWScript::FunctionContext &ctx)
Definition:
functions_event.cpp:57
Aurora::NWScript::VariableContainer::getVariable
Variable & getVariable(const Common::UString &var, Type type=kTypeVoid)
Definition:
variablecontainer.cpp:43
Engines
Definition:
console.cpp:69
Engines::DragonAge::Functions::getCurrentEvent
void getCurrentEvent(Aurora::NWScript::FunctionContext &ctx)
Definition:
functions_event.cpp:41
Aurora::NWScript::FunctionContext::getCurrentEnvironment
VariableContainer * getCurrentEnvironment() const
Definition:
functioncontext.cpp:167
Aurora::NWScript::VariableContainer
Definition:
variablecontainer.h:38
variablecontainer.h
An NWScript variable container.
Aurora::NWScript::FunctionContext::getParams
Parameters & getParams()
Definition:
functioncontext.cpp:151
Engines::DragonAge::Event::setType
void setType(EventType type)
Definition:
event.cpp:49
Engines::DragonAge::Functions::getEventTarget
void getEventTarget(Aurora::NWScript::FunctionContext &ctx)
Definition:
functions_event.cpp:77
container.h
An object containing scripts.
functions.h
Dragon Age: Origins engine functions.
Engines::DragonAge::Event::setCreator
void setCreator(const Aurora::NWScript::ObjectReference &creator)
Definition:
event.cpp:57
Aurora::NWScript::FunctionContext::getReturn
Variable & getReturn()
Definition:
functioncontext.cpp:143
Engines::DragonAge::Event
Definition:
event.h:44
Engines::DragonAge::kEventTypeInvalid
Definition:
types.h:112
Aurora::NWScript::Variable::getType
Type getType() const
Definition:
variable.cpp:289
Engines::DragonAge::ScriptContainer::runScript
bool runScript(EventType event, const Aurora::NWScript::ObjectReference owner=Aurora::NWScript::ObjectReference(), const Aurora::NWScript::ObjectReference triggerer=Aurora::NWScript::ObjectReference())
Definition:
container.cpp:104
Engines::DragonAge::Functions::setEventCreator
void setEventCreator(Aurora::NWScript::FunctionContext &ctx)
Definition:
functions_event.cpp:97
int32
int32_t int32
Definition:
types.h:203
Engines::DragonAge::EventType
EventType
Types for script events.
Definition:
types.h:110
Generated on Sun Nov 18 2018 15:13:39 for xoreos by
1.8.14