From: Jaka K. <lyn...@us...> - 2010-10-01 15:22:56
|
gemrb: Infinity Engine emulator The branch master has been updated via 9133c7c91fe402dd3615c3a79f342e03955103fb (commit) via b9c43087c02fd9c1974a890f18c88dfce7b30a2a (commit) Summary of changes: gemrb/core/Core.cpp | 27 +++++++++++++++++++++++++ gemrb/core/GameScript/Actions.cpp | 39 +++++++++++++++++++++++++++++++++++- gemrb/includes/globals.h | 2 + 3 files changed, 66 insertions(+), 2 deletions(-) from d8848f6c6b2cdac05977ad36be255cf09692a932 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://gemrb.git.sourceforge.net/git/gitweb.cgi?p=gemrb/gemrb;a=commitdiff;h=9133c7c91fe402dd3615c3a79f342e03955103fb commit 9133c7c91fe402dd3615c3a79f342e03955103fb Author: Jaka Kranjc <lyn...@us...> Date: Fri Oct 1 17:25:19 2010 +0200 fixed GameScript::BashDoor to be more like the original diff --git a/gemrb/core/GameScript/Actions.cpp b/gemrb/core/GameScript/Actions.cpp index 773e12b..8ba11e0 100644 --- a/gemrb/core/GameScript/Actions.cpp +++ b/gemrb/core/GameScript/Actions.cpp @@ -6159,11 +6159,46 @@ void GameScript::BashDoor(Scriptable* Sender, Action* parameters) Sender->ReleaseCurrentAction(); return; } + if (Sender->Type != ST_ACTOR) { + Sender->ReleaseCurrentAction(); + return; + } + + Scriptable *target = GetActorFromObject(Sender, parameters->objects[1]); + TileMap *tmap = Sender->GetCurrentArea()->TMap; + Door *door = NULL; + Container *container = NULL; + Point pos; + if (target->Type == ST_DOOR) { + // FIXME: actually it chooses from two possible points + pos = target->Pos; + door = tmap->GetDoorByPosition(pos); + } else if(target->Type == ST_CONTAINER) { + pos = target->Pos; + container = tmap->GetContainerByPosition(pos); + } else { + Sender->ReleaseCurrentAction(); + return; + } + + // TODO: "sets a field in the door/container to 1" + + // FIXME: MAX_OPERATING_DISTANCE? + if (SquaredPersonalDistance(pos, Sender) > MAX_OPERATING_DISTANCE) { + MoveNearerTo(Sender, pos, MAX_OPERATING_DISTANCE, 0); + return; + } gc->SetTargetMode(TARGET_MODE_ATTACK); //for bashing doors too - OpenDoor(Sender, parameters); - Sender->ReleaseCurrentAction(); // this is blocking, OpenDoor is not + // try to bash it + if (door) { + door->TryBashLock((Actor *) Sender); + } else if (container) { + container->TryBashLock((Actor *) Sender); + } + + Sender->ReleaseCurrentAction(); } //pst action http://gemrb.git.sourceforge.net/git/gitweb.cgi?p=gemrb/gemrb;a=commitdiff;h=b9c43087c02fd9c1974a890f18c88dfce7b30a2a commit b9c43087c02fd9c1974a890f18c88dfce7b30a2a Author: Jaka Kranjc <lyn...@us...> Date: Fri Oct 1 17:21:34 2010 +0200 Core: added SquaredPersonalDistance diff --git a/gemrb/core/Core.cpp b/gemrb/core/Core.cpp index 9309b4b..f0c0753 100644 --- a/gemrb/core/Core.cpp +++ b/gemrb/core/Core.cpp @@ -164,6 +164,18 @@ unsigned int PersonalDistance(Point p, Scriptable *b) return (unsigned int) ret; } +unsigned int SquaredPersonalDistance(Point p, Scriptable *b) +{ + long x = ( p.x - b->Pos.x ); + long y = ( p.y - b->Pos.y ); + int ret = x*x + y*y; + if (b->Type==ST_ACTOR) { + ret-=((Actor *)b)->size*100; + } + if (ret<0) return (unsigned int) 0; + return (unsigned int) ret; +} + /** Calculates map distance between 2 scriptables */ unsigned int SquaredMapDistance(Scriptable *a, Scriptable *b) { @@ -204,6 +216,21 @@ unsigned int PersonalDistance(Scriptable *a, Scriptable *b) return (unsigned int) ret; } +unsigned int SquaredPersonalDistance(Scriptable *a, Scriptable *b) +{ + long x = ( a->Pos.x - b->Pos.x ); + long y = ( a->Pos.y - b->Pos.y ); + int ret = x*x + y*y; + if (a->Type==ST_ACTOR) { + ret-=((Actor *)a)->size*100; + } + if (b->Type==ST_ACTOR) { + ret-=((Actor *)b)->size*100; + } + if (ret<0) return (unsigned int) 0; + return (unsigned int) ret; +} + // returns EA relation between two scriptables (non actors are always enemies) // it is used for protectile targeting/iwd ids targeting too! int EARelation(Scriptable* Owner, Actor* target) diff --git a/gemrb/includes/globals.h b/gemrb/includes/globals.h index 949565c..97db4d7 100644 --- a/gemrb/includes/globals.h +++ b/gemrb/includes/globals.h @@ -169,9 +169,11 @@ GEM_EXPORT unsigned int Distance(const Point pos, const Point pos2); GEM_EXPORT unsigned int Distance(const Point pos, Scriptable *b); GEM_EXPORT unsigned int SquaredMapDistance(const Point pos, Scriptable *b); GEM_EXPORT unsigned int PersonalDistance(const Point pos, Scriptable *b); +GEM_EXPORT unsigned int SquaredPersonalDistance(const Point pos, Scriptable *b); GEM_EXPORT unsigned int Distance(Scriptable *a, Scriptable *b); GEM_EXPORT unsigned int SquaredDistance(Scriptable *a, Scriptable *b); GEM_EXPORT unsigned int PersonalDistance(Scriptable *a, Scriptable *b); +GEM_EXPORT unsigned int SquaredPersonalDistance(Scriptable *a, Scriptable *b); GEM_EXPORT unsigned int SquaredMapDistance(Scriptable *a, Scriptable *b); GEM_EXPORT int EARelation(Scriptable *a, Actor *b); GEM_EXPORT bool dir_exists(const char* path); ----------------------------------------------------------------------- This is an automated email from the git hooks/post-receive script. -- gemrb: Infinity Engine emulator |