Skip to content

Commit

Permalink
KOTOR: Implement NWScript function JumpToLocation
Browse files Browse the repository at this point in the history
This makes the first "real" area of KotOR2 more playable: the player
is moved out of the kolto tank during the opening cutscene.
  • Loading branch information
DrMcCoy committed Mar 1, 2019
1 parent 9093585 commit c68c3e7
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/engines/kotor/script/function_tables.h
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ const Functions::FunctionPointer Functions::kFunctionPointers[] = {
{ 310, "ActionUseTalentAtLocation" , 0 },
{ 311, "GetGoldPieceValue" , 0 },
{ 312, "GetIsPlayableRacialType" , 0 },
{ 313, "JumpToLocation" , 0 },
{ 313, "JumpToLocation" , &Functions::jumpToLocation },
{ 314, "EffectTemporaryHitpoints" , 0 },
{ 315, "GetSkillRank" , &Functions::getSkillRank },
{ 316, "GetAttackTarget" , 0 },
Expand Down
2 changes: 1 addition & 1 deletion src/engines/kotor2/script/function_tables.h
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ const Functions::FunctionPointer Functions::kFunctionPointers[] = {
{ 310, "ActionUseTalentAtLocation" , 0 },
{ 311, "GetGoldPieceValue" , 0 },
{ 312, "GetIsPlayableRacialType" , 0 },
{ 313, "JumpToLocation" , 0 },
{ 313, "JumpToLocation" , &Functions::jumpToLocation },
{ 314, "EffectTemporaryHitpoints" , 0 },
{ 315, "GetSkillRank" , &Functions::getSkillRank },
{ 316, "GetAttackTarget" , 0 },
Expand Down
2 changes: 2 additions & 0 deletions src/engines/kotorbase/script/functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@ class Functions {
void getArea (Aurora::NWScript::FunctionContext &ctx);
void getLocation(Aurora::NWScript::FunctionContext &ctx);

void jumpToLocation(Aurora::NWScript::FunctionContext &ctx);

void setMinOneHP(Aurora::NWScript::FunctionContext &ctx);
void setMaxHitPoints(Aurora::NWScript::FunctionContext &ctx);

Expand Down
12 changes: 12 additions & 0 deletions src/engines/kotorbase/script/functions_object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,18 @@ void Functions::getLocation(Aurora::NWScript::FunctionContext &ctx) {
ctx.getReturn() = object->getLocation();
}

void Functions::jumpToLocation(Aurora::NWScript::FunctionContext &ctx) {
Object *object = ObjectContainer::toObject(ctx.getCaller());
Location *moveTo = ObjectContainer::toLocation(ctx.getParams()[0].getEngineType());

if (!object || !moveTo)
return;

float x, y, z;
moveTo->getPosition(x, y, z);
object->setPosition(x, y, z);
}

void Functions::getItemInSlot(Aurora::NWScript::FunctionContext &ctx) {
Creature *creature = 0;

Expand Down

0 comments on commit c68c3e7

Please sign in to comment.