From: Laszlo T. <ave...@us...> - 2005-04-18 19:15:14
|
Update of /cvsroot/gemrb/gemrb/gemrb/plugins/Core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25737/Core Modified Files: ActorBlock.cpp ActorBlock.h GameScript.cpp GameScript.h Map.cpp Map.h Log Message: fixed MatchActor to match objects referenced by object filters/target ids added RandomFly, RandomWalk, SetArmourLevel Index: GameScript.h =================================================================== RCS file: /cvsroot/gemrb/gemrb/gemrb/plugins/Core/GameScript.h,v retrieving revision 1.171 retrieving revision 1.172 diff -C2 -d -r1.171 -r1.172 *** GameScript.h 11 Apr 2005 21:41:13 -0000 1.171 --- GameScript.h 18 Apr 2005 19:15:02 -0000 1.172 *************** *** 9,18 **** * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of ! * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software ! * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * $Header$ --- 9,18 ---- * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of ! * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software ! * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * $Header$ *************** *** 645,649 **** static Trigger* GenerateTrigger(char* String); /* returns true if actor matches the object specs. */ ! static bool MatchActor(Actor* actor, Object* oC); /* returns the number of actors matching the IDS targeting */ static int GetObjectCount(Scriptable* Sender, Object* oC); --- 645,649 ---- static Trigger* GenerateTrigger(char* String); /* returns true if actor matches the object specs. */ ! static bool MatchActor(Scriptable *Sender, Actor* actor, Object* oC); /* returns the number of actors matching the IDS targeting */ static int GetObjectCount(Scriptable* Sender, Object* oC); *************** *** 1083,1086 **** --- 1083,1088 ---- static void PlaySoundPoint(Scriptable* Sender, Action* parameters); static void QuitGame(Scriptable* Sender, Action* parameters); + static void RandomWalk(Scriptable* Sender, Action* parameters); + static void RandomFly(Scriptable* Sender, Action* parameters); static void RealSetGlobalTimer(Scriptable* Sender, Action* parameters); static void Recoil(Scriptable* Sender, Action* parameters); *************** *** 1106,1109 **** --- 1108,1112 ---- static void SetAreaFlags(Scriptable* Sender, Action* parameters); static void SetAreaRestFlag(Scriptable* Sender, Action* parameters); + static void SetArmourLevel(Scriptable* Sender, Action* parameters); static void SetBeenInPartyFlags(Scriptable* Sender, Action* parameters); static void SetCorpseEnabled(Scriptable* Sender, Action* parameters); Index: Map.cpp =================================================================== RCS file: /cvsroot/gemrb/gemrb/gemrb/plugins/Core/Map.cpp,v retrieving revision 1.157 retrieving revision 1.158 diff -C2 -d -r1.157 -r1.158 *** Map.cpp 12 Apr 2005 18:42:38 -0000 1.157 --- Map.cpp 18 Apr 2005 19:15:03 -0000 1.158 *************** *** 1157,1161 **** } //run away from dX, dY (ie.: find the best path of limited length that brings us the farthest from dX, dY) ! PathNode* Map::RunAway(Point &s, Point &d, unsigned int PathLen, bool Backing) { Point start = {s.x/16, s.y/12}; --- 1157,1161 ---- } //run away from dX, dY (ie.: find the best path of limited length that brings us the farthest from dX, dY) ! PathNode* Map::RunAway(Point &s, Point &d, unsigned int PathLen, int flags) { Point start = {s.x/16, s.y/12}; *************** *** 1213,1217 **** StartNode->x = best.x; StartNode->y = best.y; ! if (Backing) { StartNode->orient = GetOrient( start, best ); } else { --- 1213,1217 ---- StartNode->x = best.x; StartNode->y = best.y; ! if (flags) { StartNode->orient = GetOrient( start, best ); } else { *************** *** 1240,1244 **** Return->y = n.y; ! if (Backing) { Return->orient = GetOrient( p, n ); } else { --- 1240,1244 ---- Return->y = n.y; ! if (flags) { Return->orient = GetOrient( p, n ); } else { *************** *** 1288,1291 **** --- 1288,1347 ---- } + /* Use this function when you target something by a straight line projectile (like a lightning bolt, arrow, etc) + */ + PathNode* Map::GetLine(Point &start, Point &dest, int flags) + { + int Orientation = GetOrient(start, dest); + int Steps = Distance(start, dest); + + return GetLine(start, dest, Steps, Orientation, flags); + } + + PathNode* Map::GetLine(Point &start, int Steps, int Orientation, int flags) + { + Point dest; + + //FIXME: calculate dest based on distance and orientation + return GetLine(start, dest, Steps, Orientation, flags); + } + + PathNode* Map::GetLine(Point &start, Point &dest, int Steps, int Orientation, int flags) + { + PathNode* StartNode = new PathNode; + PathNode *Return = StartNode; + StartNode->Next = NULL; + StartNode->Parent = NULL; + StartNode->x = start.x; + StartNode->y = start.y; + StartNode->orient = Orientation; + + int Max = Steps; + while(Steps--) { + int x,y; + + StartNode->Next = new PathNode; + StartNode->Next->Parent = StartNode; + StartNode = StartNode->Next; + StartNode->Next = NULL; + x = (start.x + dest.x) * Steps / Max; + y = (start.y + dest.y) * Steps / Max; + StartNode->x = x; + StartNode->y = y; + StartNode->orient = Orientation; + bool wall = (!( Passable[SearchMap->GetPixelIndex( x, y )] & PATH_MAP_PASSABLE )); + if (wall) switch (flags) { + case GL_REBOUND: + Orientation = (Orientation + 8) &15; + break; + case GL_PASS: + break; + default: //premature end + return Return; + } + } + + return Return; + } + PathNode* Map::FindPath(Point &s, Point &d) { Index: Map.h =================================================================== RCS file: /cvsroot/gemrb/gemrb/gemrb/plugins/Core/Map.h,v retrieving revision 1.70 retrieving revision 1.71 diff -C2 -d -r1.70 -r1.71 *** Map.h 9 Apr 2005 19:13:43 -0000 1.70 --- Map.h 18 Apr 2005 19:15:03 -0000 1.71 *************** *** 70,73 **** --- 70,78 ---- #define AF_NAME_OVERRIDE 8 + //getline flags + #define GL_NORMAL 0 + #define GL_PASS 1 + #define GL_REBOUND 2 + typedef struct SongHeaderType { ieDword SongList[5]; *************** *** 178,184 **** void FixAllPositions(); /* Finds the path which leads the farthest from d */ ! PathNode* RunAway(Point &s, Point &d, unsigned int PathLen, bool Backing); /* Returns true if there is no path to d */ bool TargetUnreachable(Point &s, Point &d); /* Finds the path which leads to d */ PathNode* FindPath(Point &s, Point &d); --- 183,192 ---- void FixAllPositions(); /* Finds the path which leads the farthest from d */ ! PathNode* RunAway(Point &s, Point &d, unsigned int PathLen, int flags); /* Returns true if there is no path to d */ bool TargetUnreachable(Point &s, Point &d); + /* Finds straight path from s, length l and orientation o, f=1 passes wall, f=2 rebounds from wall*/ + PathNode* GetLine(Point &start, int Steps, int Orientation, int flags); + PathNode* GetLine(Point &start, Point &dest, int flags); /* Finds the path which leads to d */ PathNode* FindPath(Point &s, Point &d); *************** *** 215,218 **** --- 223,227 ---- void UseExit(Actor *pc, InfoPoint *ip); bool HandleActorStance(Actor *actor, CharAnimations *ca, int StanceID); + PathNode* GetLine(Point &start, Point &dest, int Steps, int Orientation, int flags); }; Index: ActorBlock.h =================================================================== RCS file: /cvsroot/gemrb/gemrb/gemrb/plugins/Core/ActorBlock.h,v retrieving revision 1.68 retrieving revision 1.69 diff -C2 -d -r1.68 -r1.69 *** ActorBlock.h 11 Apr 2005 21:41:11 -0000 1.68 --- ActorBlock.h 18 Apr 2005 19:14:59 -0000 1.69 *************** *** 255,259 **** void DoStep(); void AddWayPoint(Point &Des); ! void RunAwayFrom(Point &Des, int PathLength, bool Backing); void WalkTo(Point &Des); void MoveTo(Point &Des); --- 255,261 ---- void DoStep(); void AddWayPoint(Point &Des); ! void RunAwayFrom(Point &Des, int PathLength, int flags); ! void RandomWalk(); ! void MoveLine(int steps, int Pass); void WalkTo(Point &Des); void MoveTo(Point &Des); Index: GameScript.cpp =================================================================== RCS file: /cvsroot/gemrb/gemrb/gemrb/plugins/Core/GameScript.cpp,v retrieving revision 1.260 retrieving revision 1.261 diff -C2 -d -r1.260 -r1.261 *** GameScript.cpp 11 Apr 2005 21:41:11 -0000 1.260 --- GameScript.cpp 18 Apr 2005 19:14:59 -0000 1.261 *************** *** 140,143 **** --- 140,144 ---- {"harmlessentered", GameScript::Entered,0}, //this isn't sure the same {"hasitem", GameScript::HasItem,0}, + {"hasitemequiped", GameScript::HasItemEquipped,0}, //typo in bg2 {"hasitemequipped", GameScript::HasItemEquipped,0}, {"hasitemslot", GameScript::HasItemSlot,0}, *************** *** 489,492 **** --- 490,495 ---- {"playsoundpoint", GameScript::PlaySoundPoint,0}, {"quitgame", GameScript::QuitGame, 0}, + {"randomfly", GameScript::RandomFly, AF_BLOCKING}, + {"randomwalk", GameScript::RandomWalk, AF_BLOCKING}, {"realsetglobaltimer", GameScript::RealSetGlobalTimer,AF_MERGESTRINGS}, {"recoil", GameScript::Recoil,0}, *************** *** 612,615 **** --- 615,619 ---- {"unlockscroll", GameScript::UnlockScroll,0}, {"unmakeglobal", GameScript::UnMakeGlobal,0}, //this is a GemRB extension + {"vequip",GameScript::SetArmourLevel,0}, {"verbalconstant", GameScript::VerbalConstant,0}, {"verbalconstanthead", GameScript::VerbalConstantHead,0}, *************** *** 1836,1840 **** } ! bool GameScript::MatchActor(Actor* actor, Object* oC) { if (!actor) { --- 1840,1844 ---- } ! bool GameScript::MatchActor(Scriptable *Sender, Actor* actor, Object* oC) { if (!actor) { *************** *** 1844,1849 **** return (stricmp( actor->GetScriptName(), oC->objectName ) == 0); } ! //TODO: the rest ! return false; } --- 1848,1883 ---- return (stricmp( actor->GetScriptName(), oC->objectName ) == 0); } ! Targets *tgts = new Targets(); ! for (int i = 0; i < MaxObjectNesting; i++) { ! int filterid = oC->objectFilters[i]; ! if (!filterid) { ! break; ! } ! ObjectFunction func = objects[filterid]; ! if (func) { ! tgts = func( Sender, tgts); ! } ! else { ! printf("[GameScript]: Unknown object filter: %d %s\n",filterid, objectsTable->GetValue(filterid) ); ! } ! if (!tgts->Count()) { ! delete tgts; ! return false; ! } ! } ! bool ret = false; ! ! if (tgts) { ! targetlist::iterator m; ! targettype *tt = tgts->GetFirstTarget(m); ! while (tt) { ! if (tt->actor == actor) { ! ret = true; ! } ! tt = tgts->GetNextTarget(m); ! } ! } ! delete tgts; ! return ret; } *************** *** 3442,3454 **** int GameScript::InPartySlot(Scriptable* Sender, Trigger* parameters) { ! Scriptable* scr = GetActorFromObject( Sender, parameters->objectParameter ); ! if (!scr) { ! scr = Sender; ! } ! if (scr->Type != ST_ACTOR) { ! return 0; ! } ! Actor* actor = ( Actor* ) scr; ! return actor->InParty == parameters->int0Parameter; } --- 3476,3481 ---- int GameScript::InPartySlot(Scriptable* Sender, Trigger* parameters) { ! Actor *actor = core->GetGame()->GetPC(parameters->int0Parameter); ! return MatchActor(Sender, actor, parameters->objectParameter); } *************** *** 5344,5348 **** } } ! return MatchActor(actor->LastHitter, parameters->objectParameter); } --- 5371,5375 ---- } } ! return MatchActor(Sender, actor->LastHitter, parameters->objectParameter); } *************** *** 5358,5362 **** } } ! return MatchActor(actor->LastHeard, parameters->objectParameter); } --- 5385,5389 ---- } } ! return MatchActor(Sender, actor->LastHeard, parameters->objectParameter); } *************** *** 5367,5371 **** } Actor* actor = ( Actor* ) Sender; ! return MatchActor(actor->LastSeen, parameters->objectParameter); } --- 5394,5398 ---- } Actor* actor = ( Actor* ) Sender; ! return MatchActor(Sender, actor->LastSeen, parameters->objectParameter); } *************** *** 5376,5380 **** } Actor* actor = ( Actor* ) Sender; ! return MatchActor(actor->LastHelp, parameters->objectParameter); } --- 5403,5407 ---- } Actor* actor = ( Actor* ) Sender; ! return MatchActor(Sender, actor->LastHelp, parameters->objectParameter); } *************** *** 8934,8938 **** } Actor *act = (Actor *) Sender; ! act->NewStat(IE_STATE_ID, act->GetStat(IE_STATE_ID)|STATE_PANIC, MOD_ABSOLUTE); } --- 8961,8966 ---- } Actor *act = (Actor *) Sender; ! act->NewStat(IE_MORALEBREAK, 0, MOD_ABSOLUTE); //this will modify state? ! //act->NewStat(IE_STATE_ID, act->GetStat(IE_STATE_ID)|STATE_PANIC, MOD_ABSOLUTE); } *************** *** 9151,9152 **** --- 9179,9217 ---- } + void GameScript::SetArmourLevel(Scriptable* Sender, Action* parameters) + { + Scriptable* tar = GetActorFromObject( Sender, parameters->objects[1] ); + if (!tar || tar->Type!=ST_ACTOR) { + return; + } + Actor *actor = (Actor *) Sender; + actor->NewStat( IE_ARMOR_TYPE, parameters->int0Parameter, MOD_ABSOLUTE ); + } + + void GameScript::RandomWalk(Scriptable* Sender, Action* /*parameters*/) + { + if (Sender->Type != ST_ACTOR) { + Sender->CurrentAction = NULL; + return; + } + Actor* actor = ( Actor* ) Sender; + actor->RandomWalk( ); + } + + void GameScript::RandomFly(Scriptable* Sender, Action* parameters) + { + if (Sender->Type != ST_ACTOR) { + Sender->CurrentAction = NULL; + return; + } + Actor* actor = ( Actor* ) Sender; + int x = rand()&31; + if (x<10) { + actor->SetOrientation((actor->GetOrientation()-1)&15 ); + } else if (x>20) { + actor->SetOrientation((actor->GetOrientation()+1)&15 ); + } + //fly in this direction for 2 steps + actor->MoveLine(2, GL_PASS); + Sender->AddAction( parameters ); + } Index: ActorBlock.cpp =================================================================== RCS file: /cvsroot/gemrb/gemrb/gemrb/plugins/Core/ActorBlock.cpp,v retrieving revision 1.86 retrieving revision 1.87 diff -C2 -d -r1.86 -r1.87 *** ActorBlock.cpp 12 Apr 2005 18:42:38 -0000 1.86 --- ActorBlock.cpp 18 Apr 2005 19:14:59 -0000 1.87 *************** *** 400,403 **** --- 400,413 ---- } + //this could be used for WingBuffet as well + void Moveble::MoveLine(int steps, int Pass) + { + //remove previous path + ClearPath(); + if (!steps) + return; + path = area->GetLine( Pos, steps, Orientation, Pass ); + } + void Moveble::DoStep() { *************** *** 462,469 **** } ! void Moveble::RunAwayFrom(Point &Des, int PathLength, bool Backing) { ClearPath(); ! path = area->RunAway( Pos, Des, PathLength, Backing ); } --- 472,485 ---- } ! void Moveble::RunAwayFrom(Point &Des, int PathLength, int flags) { ClearPath(); ! path = area->RunAway( Pos, Des, PathLength, flags ); ! } ! ! void Moveble::RandomWalk() ! { ! ClearPath(); ! path = area->RunAway( Pos, Pos, 10, 0 ); } |