xoreos
0.0.5
src
engines
kotor
script
functions_creatures.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
27
#include "
src/aurora/nwscript/functioncontext.h
"
28
29
#include "
src/engines/kotor/types.h
"
30
#include "
src/engines/kotor/creature.h
"
31
#include "
src/engines/kotor/objectcontainer.h
"
32
33
#include "
src/engines/kotor/script/functions.h
"
34
35
namespace
Engines
{
36
37
namespace
KotOR {
38
39
void
Functions::getGender
(
Aurora::NWScript::FunctionContext
&ctx) {
40
Aurora::NWScript::Object
*
object
=
getParamObject
(ctx, 0);
41
42
Creature
*creature =
ObjectContainer::toCreature
(
object
);
43
44
if
(!creature)
45
throw
Common::Exception
(
"Functions::getGender(): Object is not a creature"
);
46
47
ctx.
getReturn
() = creature->
getGender
();
48
}
49
50
void
Functions::getLevelByClass
(
Aurora::NWScript::FunctionContext
&ctx) {
51
Class
creatureClass =
Class
(ctx.
getParams
()[0].getInt());
52
Aurora::NWScript::Object
*
object
= ctx.
getParams
()[1].getObject();
53
54
Creature
*creature =
ObjectContainer::toCreature
(
object
);
55
56
if
(!creature)
57
throw
Common::Exception
(
"Functions::getLevelByClass(): Object is not a creature"
);
58
59
ctx.
getReturn
() = creature->
getLevel
(creatureClass);
60
}
61
62
void
Functions::getLevelByPosition
(
Aurora::NWScript::FunctionContext
&ctx) {
63
int
position = ctx.
getParams
()[0].getInt();
64
Aurora::NWScript::Object
*
object
= ctx.
getParams
()[1].getObject();
65
66
Creature
*creature =
ObjectContainer::toCreature
(
object
);
67
68
if
(!creature)
69
throw
Common::Exception
(
"Functions::getLevelByPosition(): Object is not a creature"
);
70
71
ctx.
getReturn
() = creature->
getLevelByPosition
(position - 1);
72
}
73
74
void
Functions::getClassByPosition
(
Aurora::NWScript::FunctionContext
&ctx) {
75
int
position = ctx.
getParams
()[0].getInt();
76
Aurora::NWScript::Object
*
object
= ctx.
getParams
()[1].getObject();
77
78
Creature
*creature =
ObjectContainer::toCreature
(
object
);
79
80
if
(!creature)
81
throw
Common::Exception
(
"Functions::getClassByPosition(): Object is not a creature"
);
82
83
ctx.
getReturn
() = creature->
getClassByPosition
(position - 1);
84
}
85
86
void
Functions::getRacialType
(
Aurora::NWScript::FunctionContext
&ctx) {
87
Aurora::NWScript::Object
*
object
= ctx.
getParams
()[1].getObject();
88
89
Creature
*creature =
ObjectContainer::toCreature
(
object
);
90
91
Race
race;
92
if
(!creature)
93
race =
kRaceInvalid
;
94
else
95
race = creature->
getRace
();
96
97
ctx.
getReturn
() = race;
98
}
99
100
void
Functions::getSubRace
(
Aurora::NWScript::FunctionContext
&ctx) {
101
Aurora::NWScript::Object
*
object
= ctx.
getParams
()[1].getObject();
102
103
Creature
*creature =
ObjectContainer::toCreature
(
object
);
104
105
if
(!creature)
106
throw
Common::Exception
(
"Functions::getSubRace(): Object is not a creature"
);
107
108
ctx.
getReturn
() = creature->
getSubRace
();
109
}
110
111
}
// End of namespace KotOR
112
113
}
// End of namespace Engines
creature.h
A creature in a Star Wars: Knights of the Old Republic area.
Aurora::NWScript::Object
Definition:
object.h:37
Engines::KotOR::Functions::getRacialType
void getRacialType(Aurora::NWScript::FunctionContext &ctx)
Definition:
functions_creatures.cpp:86
functioncontext.h
Context of an NWScript function.
Engines::KotOR::Creature::getClassByPosition
Class getClassByPosition(int position) const
Get the class by its position in the level vector.
Definition:
creature.cpp:153
Aurora::NWScript::FunctionContext
Definition:
functioncontext.h:42
Engines::KotOR::Functions::getClassByPosition
void getClassByPosition(Aurora::NWScript::FunctionContext &ctx)
Definition:
functions_creatures.cpp:74
Engines::KotOR::Creature::getRace
Race getRace() const
Get the race of the creature.
Definition:
creature.cpp:160
Engines::KotOR::Class
Class
Definition:
types.h:125
error.h
Basic exceptions to throw.
objectcontainer.h
A container of Star Wars: Knights of the Old Republic objects.
Engines::KotOR::Functions::getGender
void getGender(Aurora::NWScript::FunctionContext &ctx)
Definition:
functions_creatures.cpp:39
Engines::KotOR::Creature::getGender
Gender getGender() const
Get the gender of the creature.
Definition:
creature.cpp:133
Common::Exception
StackException Exception
Definition:
error.h:59
Engines
Definition:
console.cpp:69
Engines::KotOR::Creature
Definition:
creature.h:48
Engines::KotOR::Creature::getLevelByPosition
int getLevelByPosition(int position) const
Get the level by its position in the level vector.
Definition:
creature.cpp:146
Engines::KotOR::Functions::getSubRace
void getSubRace(Aurora::NWScript::FunctionContext &ctx)
Definition:
functions_creatures.cpp:100
functions.h
Star Wars: Knights of the Old Republic engine functions.
Engines::KotOR::Functions::getLevelByPosition
void getLevelByPosition(Aurora::NWScript::FunctionContext &ctx)
Definition:
functions_creatures.cpp:62
Aurora::NWScript::FunctionContext::getParams
Parameters & getParams()
Definition:
functioncontext.cpp:151
Engines::KotOR::ObjectContainer::toCreature
static Creature * toCreature(Aurora::NWScript::Object *object)
Definition:
objectcontainer.cpp:153
Engines::KotOR::kRaceInvalid
Definition:
types.h:147
Aurora::NWScript::FunctionContext::getReturn
Variable & getReturn()
Definition:
functioncontext.cpp:143
Engines::KotOR::Functions::getParamObject
static Aurora::NWScript::Object * getParamObject(const Aurora::NWScript::FunctionContext &ctx, size_t n)
Definition:
functions.cpp:117
Engines::KotOR::Creature::getSubRace
SubRace getSubRace() const
Get the subrace of the creature.
Definition:
creature.cpp:164
Engines::KotOR::Race
Race
Definition:
types.h:138
Engines::KotOR::Creature::getLevel
int getLevel(const Class &c) const
Get the level of the creature regarding a specific class.
Definition:
creature.cpp:137
types.h
Basic Star Wars: Knights of the Old Republic type definitions.
Engines::KotOR::Functions::getLevelByClass
void getLevelByClass(Aurora::NWScript::FunctionContext &ctx)
Definition:
functions_creatures.cpp:50
Generated on Sun Nov 18 2018 15:13:40 for xoreos by
1.8.14