From: Laszlo T. <ave...@us...> - 2005-12-25 10:32:24
|
Update of /cvsroot/gemrb/gemrb/gemrb/plugins/Core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv576/plugins/Core Modified Files: Actions.cpp Actor.h ActorBlock.cpp GSUtils.cpp GSUtils.h GameScript.cpp GameScript.h Inventory.cpp Inventory.h Item.h Map.cpp Map.h PathFinder.h Triggers.cpp Log Message: doors won't overwrite the searchmap implemented special itemtype flags (potion,bag,scroll) fixed iwd2 action buttons to at least not break the flow changed targets to handle non-actors too implemented XthNearestDoor objects Index: GSUtils.h =================================================================== RCS file: /cvsroot/gemrb/gemrb/gemrb/plugins/Core/GSUtils.h,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** GSUtils.h 21 Dec 2005 22:58:25 -0000 1.19 --- GSUtils.h 25 Dec 2005 10:31:39 -0000 1.20 *************** *** 73,76 **** --- 73,82 ---- int DiffCore(ieDword a, ieDword b, int diffmode); Targets *GetMyTarget(Scriptable *Sender, Actor *actor, Targets *parameters); + Targets *XthNearestOf(Targets *parameters, int count); + Targets *XthNearestDoor(Targets *parameters, unsigned int count); + Targets *XthNearestEnemyOf(Targets *parameters, int count); + Targets *XthNearestEnemyOfType(Scriptable *origin, Targets *parameters, unsigned int count); + Targets *XthNearestMyGroupOfType(Scriptable *origin, Targets *parameters, unsigned int count); + void FreeSrc(SrcVector *poi, const ieResRef key); SrcVector *LoadSrc(const ieResRef resname); *************** *** 92,96 **** inline int Bones(ieDword value) { ! return core->Roll((value&0xf000)>>12, (value&0xff0)>>8, value&15); } --- 98,102 ---- inline int Bones(ieDword value) { ! return core->Roll((value&0xf000)>>12, (value&0xff0)>>8, value&15); } Index: GameScript.cpp =================================================================== RCS file: /cvsroot/gemrb/gemrb/gemrb/plugins/Core/GameScript.cpp,v retrieving revision 1.345 retrieving revision 1.346 diff -C2 -d -r1.345 -r1.346 *** GameScript.cpp 21 Dec 2005 17:34:20 -0000 1.345 --- GameScript.cpp 25 Dec 2005 10:31:39 -0000 1.346 *************** *** 289,292 **** --- 289,293 ---- {"reputationgt", GameScript::ReputationGT, 0}, {"reputationlt", GameScript::ReputationLT, 0}, + {"school", GameScript::Kit, 0}, //is this the same? {"see", GameScript::See, 0}, {"specifics", GameScript::Specifics, 0}, *************** *** 311,315 **** {"xp", GameScript::XP, 0}, {"xpgt", GameScript::XPGT, 0}, ! {"xplt", GameScript::XPLT, 0}, { NULL,NULL,0}, }; --- 312,317 ---- {"xp", GameScript::XP, 0}, {"xpgt", GameScript::XPGT, 0}, ! {"xplt", GameScript::XPLT, 0}, ! { NULL,NULL,0} }; *************** *** 744,752 **** {"verbalconstanthead", GameScript::VerbalConstantHead, 0}, {"wait", GameScript::Wait, AF_BLOCKING}, ! {"waitanimation", GameScript::PlaySequenceTimed,AF_BLOCKING},//iwd2 {"waitrandom", GameScript::WaitRandom, AF_BLOCKING}, {"weather", GameScript::Weather, 0}, {"xequipitem", GameScript::XEquipItem, 0}, ! { NULL,NULL, 0}, }; --- 746,754 ---- {"verbalconstanthead", GameScript::VerbalConstantHead, 0}, {"wait", GameScript::Wait, AF_BLOCKING}, ! {"waitanimation", GameScript::WaitAnimation,AF_BLOCKING},//iwd2 {"waitrandom", GameScript::WaitRandom, AF_BLOCKING}, {"weather", GameScript::Weather, 0}, {"xequipitem", GameScript::XEquipItem, 0}, ! { NULL,NULL, 0} }; *************** *** 755,758 **** --- 757,761 ---- {"bestac", GameScript::BestAC}, {"eighthnearest", GameScript::EighthNearest}, + {"eighthnearestdoor", GameScript::EighthNearestDoor}, {"eighthnearestenemyof", GameScript::EighthNearestEnemyOf}, {"eighthnearestenemyoftype", GameScript::EighthNearestEnemyOfType}, *************** *** 762,770 **** --- 765,776 ---- {"eigthnearestmygroupoftype", GameScript::EighthNearestEnemyOfType},//bg2 {"farthest", GameScript::Farthest}, + {"farthestenemyof", GameScript::FarthestEnemyOf}, {"fifthnearest", GameScript::FifthNearest}, + {"fifthnearestdoor", GameScript::FifthNearestDoor}, {"fifthnearestenemyof", GameScript::FifthNearestEnemyOf}, {"fifthnearestenemyoftype", GameScript::FifthNearestEnemyOfType}, {"fifthnearestmygroupoftype", GameScript::FifthNearestEnemyOfType}, {"fourthnearest", GameScript::FourthNearest}, + {"fourthnearestdoor", GameScript::FourthNearestDoor}, {"fourthnearestenemyof", GameScript::FourthNearestEnemyOf}, {"fourthnearestenemyoftype", GameScript::FourthNearestEnemyOfType}, *************** *** 786,789 **** --- 792,796 ---- {"mytarget", GameScript::MyTarget},//see lasttargetedby(myself) {"nearest", GameScript::Nearest}, //actually this seems broken in IE and resolve as Myself + {"nearestdoor", GameScript::NearestDoor}, {"nearestenemyof", GameScript::NearestEnemyOf}, {"nearestenemyoftype", GameScript::NearestEnemyOfType}, *************** *** 791,794 **** --- 798,802 ---- {"nearestpc", GameScript::NearestPC}, {"ninthnearest", GameScript::NinthNearest}, + {"ninthnearestdoor", GameScript::NinthNearestDoor}, {"ninthnearestenemyof", GameScript::NinthNearestEnemyOf}, {"ninthnearestenemyoftype", GameScript::NinthNearestEnemyOfType}, *************** *** 814,817 **** --- 822,826 ---- {"protagonist", GameScript::Protagonist}, {"secondnearest", GameScript::SecondNearest}, + {"secondnearestdoor", GameScript::SecondNearestDoor}, {"secondnearestenemyof", GameScript::SecondNearestEnemyOf}, {"secondnearestenemyoftype", GameScript::SecondNearestEnemyOfType}, *************** *** 819,826 **** --- 828,837 ---- {"selectedcharacter", GameScript::SelectedCharacter}, {"seventhnearest", GameScript::SeventhNearest}, + {"seventhnearestdoor", GameScript::SeventhNearestDoor}, {"seventhnearestenemyof", GameScript::SeventhNearestEnemyOf}, {"seventhnearestenemyoftype", GameScript::SeventhNearestEnemyOfType}, {"seventhnearestmygroupoftype", GameScript::SeventhNearestMyGroupOfType}, {"sixthnearest", GameScript::SixthNearest}, + {"sixthnearestdoor", GameScript::SixthNearestDoor}, {"sixthnearestenemyof", GameScript::SixthNearestEnemyOf}, {"sixthnearestenemyoftype", GameScript::SixthNearestEnemyOfType}, *************** *** 829,836 **** --- 840,849 ---- {"strongestofmale", GameScript::StrongestOfMale}, {"tenthnearest", GameScript::TenthNearest}, + {"tenthnearestdoor", GameScript::TenthNearestDoor}, {"tenthnearestenemyof", GameScript::TenthNearestEnemyOf}, {"tenthnearestenemyoftype", GameScript::TenthNearestEnemyOfType}, {"tenthnearestmygroupoftype", GameScript::TenthNearestMyGroupOfType}, {"thirdnearest", GameScript::ThirdNearest}, + {"thirdnearestdoor", GameScript::ThirdNearestDoor}, {"thirdnearestenemyof", GameScript::ThirdNearestEnemyOf}, {"thirdnearestenemyoftype", GameScript::ThirdNearestEnemyOfType}, *************** *** 838,842 **** {"weakestof", GameScript::WeakestOf}, {"worstac", GameScript::WorstAC}, ! { NULL,NULL}, }; --- 851,855 ---- {"weakestof", GameScript::WeakestOf}, {"worstac", GameScript::WorstAC}, ! { NULL,NULL} }; *************** *** 856,860 **** {"subrace", GameScript::ID_Subrace}, {"team", GameScript::ID_Team}, ! { NULL,NULL}, }; --- 869,873 ---- {"subrace", GameScript::ID_Subrace}, {"team", GameScript::ID_Team}, ! { NULL,NULL} }; *************** *** 948,1005 **** } ! targettype *Targets::GetNextTarget(targetlist::iterator &m) { ! m++; ! if (m!=objects.end() ) { ! return &(*m); } return NULL; } ! targettype *Targets::GetLastTarget() { ! targetlist::const_iterator m = objects.end(); ! if (m!=objects.begin() ) { ! return (targettype *) &(*(--m)); ! } ! return NULL; } ! targettype *Targets::GetFirstTarget(targetlist::iterator &m) { ! m = objects.begin(); ! if (m!=objects.end() ) { ! return &(*m); } return NULL; } ! Actor *Targets::GetTarget(unsigned int index) { targetlist::iterator m = objects.begin(); while(m!=objects.end() ) { ! if (!index) { ! return (*m).actor; } ! index--; } return NULL; } ! void Targets::AddTarget(Actor* actor, unsigned int distance) { ! //i don't know if unselectable actors are targetable by script ! //if yes, then remove GA_SELECT ! if (actor && actor->ValidTarget(GA_SELECT|GA_NO_DEAD) ) { ! targettype Target = {actor, distance}; ! targetlist::iterator m; ! for (m = objects.begin(); m != objects.end(); ++m) { ! if ( (*m).distance>distance) { ! objects.insert( m, Target); ! return; ! } } ! objects.push_back( Target ); } } --- 961,1037 ---- } ! const targettype *Targets::GetLastTarget(int Type) { ! targetlist::const_iterator m = objects.end(); ! while (m--!=objects.begin() ) { ! if ( (Type==-1) || ((*m).actor->Type==Type) ) { ! return &(*(m)); ! } } return NULL; } ! const targettype *Targets::GetFirstTarget(targetlist::iterator &m, int Type) { ! m=objects.begin(); ! return GetNextTarget(m,Type); } ! const targettype *Targets::GetNextTarget(targetlist::iterator &m, int Type) { ! while (m!=objects.end() ) { ! if ( (Type==-1) || ((*m).actor->Type==Type) ) { ! return &(*m++); ! } ! m++; } return NULL; } ! Scriptable *Targets::GetTarget(unsigned int index, int Type) { targetlist::iterator m = objects.begin(); while(m!=objects.end() ) { ! if ( (Type==-1) || ((*m).actor->Type==Type)) { ! if (!index) { ! return (*m).actor; ! } ! index--; } ! m++; } return NULL; } ! //this stuff should be refined, dead actors are sometimes targetable by script? ! void Targets::AddTarget(Scriptable* target, unsigned int distance) { ! if (!target) { ! return; ! } ! ! switch (target->Type) { ! case ST_ACTOR: ! //i don't know if unselectable actors are targetable by script ! //if yes, then remove GA_SELECT ! if (!((Actor *) target)->ValidTarget(GA_SELECT|GA_NO_DEAD) ) { ! return; } ! case ST_CONTAINER: ! break; ! case ST_DOOR: ! break; ! default: ! return; } + targettype Target = {target, distance}; + targetlist::iterator m; + for (m = objects.begin(); m != objects.end(); ++m) { + if ( (*m).distance>distance) { + objects.insert( m, Target); + return; + } + } + objects.push_back( Target ); } *************** *** 1558,1561 **** --- 1590,1643 ---- } + Targets *GameScript::NearestDoor(Scriptable* /*Sender*/, Targets *parameters) + { + return XthNearestDoor(parameters, 0); + } + + Targets *GameScript::SecondNearestDoor(Scriptable* /*Sender*/, Targets *parameters) + { + return XthNearestDoor(parameters, 1); + } + + Targets *GameScript::ThirdNearestDoor(Scriptable* /*Sender*/, Targets *parameters) + { + return XthNearestDoor(parameters, 2); + } + + Targets *GameScript::FourthNearestDoor(Scriptable* /*Sender*/, Targets *parameters) + { + return XthNearestDoor(parameters, 3); + } + + Targets *GameScript::FifthNearestDoor(Scriptable* /*Sender*/, Targets *parameters) + { + return XthNearestDoor(parameters, 4); + } + + Targets *GameScript::SixthNearestDoor(Scriptable* /*Sender*/, Targets *parameters) + { + return XthNearestDoor(parameters, 5); + } + + Targets *GameScript::SeventhNearestDoor(Scriptable* /*Sender*/, Targets *parameters) + { + return XthNearestDoor(parameters, 6); + } + + Targets *GameScript::EighthNearestDoor(Scriptable* /*Sender*/, Targets *parameters) + { + return XthNearestDoor(parameters, 7); + } + + Targets *GameScript::NinthNearestDoor(Scriptable* /*Sender*/, Targets *parameters) + { + return XthNearestDoor(parameters, 8); + } + + Targets *GameScript::TenthNearestDoor(Scriptable* /*Sender*/, Targets *parameters) + { + return XthNearestDoor(parameters, 9); + } + //same as player1 so far Targets *GameScript::Protagonist(Scriptable* /*Sender*/, Targets *parameters) *************** *** 1589,1593 **** Targets *GameScript::LastSeenBy(Scriptable *Sender, Targets *parameters) { ! Actor *actor = parameters->GetTarget(0); if (!actor) { if (Sender->Type==ST_ACTOR) { --- 1671,1675 ---- Targets *GameScript::LastSeenBy(Scriptable *Sender, Targets *parameters) { ! Actor *actor = (Actor *) parameters->GetTarget(0, ST_ACTOR); if (!actor) { if (Sender->Type==ST_ACTOR) { *************** *** 1607,1611 **** Targets *GameScript::LastHelp(Scriptable *Sender, Targets *parameters) { ! Actor *actor = parameters->GetTarget(0); if (!actor) { if (Sender->Type==ST_ACTOR) { --- 1689,1693 ---- Targets *GameScript::LastHelp(Scriptable *Sender, Targets *parameters) { ! Actor *actor = (Actor *) parameters->GetTarget(0, ST_ACTOR); if (!actor) { if (Sender->Type==ST_ACTOR) { *************** *** 1625,1629 **** Targets *GameScript::LastHeardBy(Scriptable *Sender, Targets *parameters) { ! Actor *actor = parameters->GetTarget(0); if (!actor) { if (Sender->Type==ST_ACTOR) { --- 1707,1711 ---- Targets *GameScript::LastHeardBy(Scriptable *Sender, Targets *parameters) { ! Actor *actor = (Actor *) parameters->GetTarget(0, ST_ACTOR); if (!actor) { if (Sender->Type==ST_ACTOR) { *************** *** 1644,1648 **** Targets *GameScript::ProtectorOf(Scriptable *Sender, Targets *parameters) { ! Actor *actor = parameters->GetTarget(0); if (!actor) { if (Sender->Type==ST_ACTOR) { --- 1726,1730 ---- Targets *GameScript::ProtectorOf(Scriptable *Sender, Targets *parameters) { ! Actor *actor = (Actor *) parameters->GetTarget(0, ST_ACTOR); if (!actor) { if (Sender->Type==ST_ACTOR) { *************** *** 1662,1666 **** Targets *GameScript::ProtectedBy(Scriptable *Sender, Targets *parameters) { ! Actor *actor = parameters->GetTarget(0); if (!actor) { if (Sender->Type==ST_ACTOR) { --- 1744,1748 ---- Targets *GameScript::ProtectedBy(Scriptable *Sender, Targets *parameters) { ! Actor *actor = (Actor *) parameters->GetTarget(0, ST_ACTOR); if (!actor) { if (Sender->Type==ST_ACTOR) { *************** *** 1680,1684 **** Targets *GameScript::LastCommandedBy(Scriptable *Sender, Targets *parameters) { ! Actor *actor = parameters->GetTarget(0); if (!actor) { if (Sender->Type==ST_ACTOR) { --- 1762,1766 ---- Targets *GameScript::LastCommandedBy(Scriptable *Sender, Targets *parameters) { ! Actor *actor = (Actor *) parameters->GetTarget(0, ST_ACTOR); if (!actor) { if (Sender->Type==ST_ACTOR) { *************** *** 1705,1709 **** Targets *GameScript::LastTargetedBy(Scriptable *Sender, Targets *parameters) { ! Actor *actor = parameters->GetTarget(0); return GetMyTarget(Sender, actor, parameters); } --- 1787,1791 ---- Targets *GameScript::LastTargetedBy(Scriptable *Sender, Targets *parameters) { ! Actor *actor = (Actor *) parameters->GetTarget(0, ST_ACTOR); return GetMyTarget(Sender, actor, parameters); } *************** *** 1729,1733 **** Targets *GameScript::LastAttackerOf(Scriptable *Sender, Targets *parameters) { ! Actor *actor = parameters->GetTarget(0); if (!actor) { if (Sender->Type==ST_ACTOR) { --- 1811,1815 ---- Targets *GameScript::LastAttackerOf(Scriptable *Sender, Targets *parameters) { ! Actor *actor = (Actor *) parameters->GetTarget(0, ST_ACTOR); if (!actor) { if (Sender->Type==ST_ACTOR) { *************** *** 1747,1751 **** Targets *GameScript::LastHitter(Scriptable *Sender, Targets *parameters) { ! Actor *actor = parameters->GetTarget(0); if (!actor) { if (Sender->Type==ST_ACTOR) { --- 1829,1833 ---- Targets *GameScript::LastHitter(Scriptable *Sender, Targets *parameters) { ! Actor *actor = (Actor *) parameters->GetTarget(0, ST_ACTOR); if (!actor) { if (Sender->Type==ST_ACTOR) { *************** *** 1765,1769 **** Targets *GameScript::LastTalkedToBy(Scriptable *Sender, Targets *parameters) { ! Actor *actor = parameters->GetTarget(0); if (!actor) { if (Sender->Type==ST_ACTOR) { --- 1847,1851 ---- Targets *GameScript::LastTalkedToBy(Scriptable *Sender, Targets *parameters) { ! Actor *actor = (Actor *) parameters->GetTarget(0, ST_ACTOR); if (!actor) { if (Sender->Type==ST_ACTOR) { *************** *** 1783,1787 **** Targets *GameScript::LastSummonerOf(Scriptable* Sender, Targets *parameters) { ! Actor *actor = parameters->GetTarget(0); if (!actor) { if (Sender->Type==ST_ACTOR) { --- 1865,1869 ---- Targets *GameScript::LastSummonerOf(Scriptable* Sender, Targets *parameters) { ! Actor *actor = (Actor *) parameters->GetTarget(0, ST_ACTOR); if (!actor) { if (Sender->Type==ST_ACTOR) { *************** *** 1914,1934 **** { targetlist::iterator m; ! targettype *t = parameters->GetFirstTarget(m); if (!t) { return parameters; } ! Actor *actor=t->actor; int bestac=actor->GetStat(IE_ARMORCLASS); // assignment in while ! while ( (t = parameters->GetNextTarget(m) ) ) { ! int ac=t->actor->GetStat(IE_ARMORCLASS); if (bestac<ac) { bestac=ac; ! actor=t->actor; } } parameters->Clear(); ! parameters->AddTarget(actor, 0); return parameters; } --- 1996,2018 ---- { targetlist::iterator m; ! const targettype *t = parameters->GetFirstTarget(m, ST_ACTOR); if (!t) { return parameters; } ! Scriptable *scr=t->actor; ! Actor *actor=(Actor *) scr; int bestac=actor->GetStat(IE_ARMORCLASS); // assignment in while ! while ( (t = parameters->GetNextTarget(m, ST_ACTOR) ) ) { ! actor = (Actor *) t->actor; ! int ac=actor->GetStat(IE_ARMORCLASS); if (bestac<ac) { bestac=ac; ! scr=t->actor; } } parameters->Clear(); ! parameters->AddTarget(scr, 0); return parameters; } *************** *** 1938,1942 **** { targetlist::iterator m; ! targettype *t = parameters->GetFirstTarget(m); if (!t) { return parameters; --- 2022,2026 ---- { targetlist::iterator m; ! const targettype *t = parameters->GetFirstTarget(m, ST_ACTOR); if (!t) { return parameters; *************** *** 1944,1960 **** int pos=-1; int worsthp=-1; ! Actor *actor = NULL; //assignment intentional ! while ( (t = parameters->GetNextTarget(m) ) ) { ! if (t->actor->GetStat(IE_SEX)!=1) continue; ! int hp=t->actor->GetStat(IE_HITPOINTS); if ((pos==-1) || (worsthp<hp)) { worsthp=hp; ! actor=t->actor; } } parameters->Clear(); ! if (actor) { ! parameters->AddTarget(actor, 0); } return parameters; --- 2028,2045 ---- int pos=-1; int worsthp=-1; ! Scriptable *scr = NULL; //assignment intentional ! while ( (t = parameters->GetNextTarget(m, ST_ACTOR) ) ) { ! Actor *actor = (Actor *) t->actor; ! if (actor->GetStat(IE_SEX)!=1) continue; ! int hp=actor->GetStat(IE_HITPOINTS); if ((pos==-1) || (worsthp<hp)) { worsthp=hp; ! scr=t->actor; } } parameters->Clear(); ! if (scr) { ! parameters->AddTarget(scr, 0); } return parameters; *************** *** 1964,1983 **** { targetlist::iterator m; ! targettype *t = parameters->GetFirstTarget(m); if (!t) { return parameters; } ! Actor *actor=t->actor; int besthp=actor->GetStat(IE_HITPOINTS); // assignment in while ! while ( (t = parameters->GetNextTarget(m) ) ) { ! int hp=t->actor->GetStat(IE_HITPOINTS); if (besthp<hp) { besthp=hp; ! actor=t->actor; } } parameters->Clear(); ! parameters->AddTarget(actor, 0); return parameters; } --- 2049,2070 ---- { targetlist::iterator m; ! const targettype *t = parameters->GetFirstTarget(m, ST_ACTOR); if (!t) { return parameters; } ! Scriptable *scr=t->actor; ! Actor *actor=(Actor *) scr; int besthp=actor->GetStat(IE_HITPOINTS); // assignment in while ! while ( (t = parameters->GetNextTarget(m, ST_ACTOR) ) ) { ! actor = (Actor *) t->actor; ! int hp=actor->GetStat(IE_HITPOINTS); if (besthp<hp) { besthp=hp; ! scr=t->actor; } } parameters->Clear(); ! parameters->AddTarget(scr, 0); return parameters; } *************** *** 1986,2005 **** { targetlist::iterator m; ! targettype *t = parameters->GetFirstTarget(m); if (!t) { return parameters; } ! Actor *actor=t->actor; int worsthp=actor->GetStat(IE_HITPOINTS); // assignment in while ! while ( (t = parameters->GetNextTarget(m) ) ) { ! int hp=t->actor->GetStat(IE_HITPOINTS); if (worsthp>hp) { worsthp=hp; ! actor=t->actor; } } parameters->Clear(); ! parameters->AddTarget(actor, 0); return parameters; } --- 2073,2094 ---- { targetlist::iterator m; ! const targettype *t = parameters->GetFirstTarget(m, ST_ACTOR); if (!t) { return parameters; } ! Scriptable *scr=t->actor; ! Actor *actor=(Actor *) scr; int worsthp=actor->GetStat(IE_HITPOINTS); // assignment in while ! while ( (t = parameters->GetNextTarget(m, ST_ACTOR) ) ) { ! actor = (Actor *) t->actor; ! int hp=actor->GetStat(IE_HITPOINTS); if (worsthp>hp) { worsthp=hp; ! scr=t->actor; } } parameters->Clear(); ! parameters->AddTarget(scr, 0); return parameters; } *************** *** 2008,2027 **** { targetlist::iterator m; ! targettype *t = parameters->GetFirstTarget(m); if (!t) { return parameters; } ! Actor *actor=t->actor; int worstac=actor->GetStat(IE_ARMORCLASS); // assignment in while ! while ( (t = parameters->GetNextTarget(m) ) ) { ! int ac=t->actor->GetStat(IE_ARMORCLASS); if (worstac>ac) { worstac=ac; ! actor=t->actor; } } parameters->Clear(); ! parameters->AddTarget(actor, 0); return parameters; } --- 2097,2118 ---- { targetlist::iterator m; ! const targettype *t = parameters->GetFirstTarget(m, ST_ACTOR); if (!t) { return parameters; } ! Scriptable *scr=t->actor; ! Actor *actor=(Actor *) scr; int worstac=actor->GetStat(IE_ARMORCLASS); // assignment in while ! while ( (t = parameters->GetNextTarget(m, ST_ACTOR) ) ) { ! actor = (Actor *) t->actor; ! int ac=actor->GetStat(IE_ARMORCLASS); if (worstac>ac) { worstac=ac; ! scr=t->actor; } } parameters->Clear(); ! parameters->AddTarget(scr, 0); return parameters; } *************** *** 2030,2049 **** { targetlist::iterator m; ! targettype *t = parameters->GetFirstTarget(m); if (!t) { return parameters; } ! Actor *actor=t->actor; int worsthp=actor->GetStat(IE_MAXHITPOINTS)-actor->GetStat(IE_HITPOINTS); // assignment in while ! while ( (t = parameters->GetNextTarget(m) ) ) { ! int hp=t->actor->GetStat(IE_MAXHITPOINTS)-t->actor->GetStat(IE_HITPOINTS); if (worsthp>hp) { worsthp=hp; ! actor=t->actor; } } parameters->Clear(); ! parameters->AddTarget(actor, 0); return parameters; } --- 2121,2142 ---- { targetlist::iterator m; ! const targettype *t = parameters->GetFirstTarget(m, ST_ACTOR); if (!t) { return parameters; } ! Scriptable *scr = t->actor; ! Actor *actor=(Actor *) scr; int worsthp=actor->GetStat(IE_MAXHITPOINTS)-actor->GetStat(IE_HITPOINTS); // assignment in while ! while ( (t = parameters->GetNextTarget(m, ST_ACTOR) ) ) { ! actor = (Actor *) t->actor; ! int hp=actor->GetStat(IE_MAXHITPOINTS)-actor->GetStat(IE_HITPOINTS); if (worsthp>hp) { worsthp=hp; ! scr=t->actor; } } parameters->Clear(); ! parameters->AddTarget(scr, 0); return parameters; } *************** *** 2051,2213 **** { targetlist::iterator m; ! targettype *t = parameters->GetFirstTarget(m); if (!t) { return parameters; } ! Actor *actor=t->actor; int besthp=actor->GetStat(IE_MAXHITPOINTS)-actor->GetStat(IE_HITPOINTS); // assignment in while ! while ( (t = parameters->GetNextTarget(m) ) ) { ! int hp=t->actor->GetStat(IE_MAXHITPOINTS)-t->actor->GetStat(IE_HITPOINTS); if (besthp<hp) { besthp=hp; ! actor=t->actor; } } parameters->Clear(); ! parameters->AddTarget(actor, 0); ! return parameters; ! } ! ! Targets *GameScript::XthNearestOf(Targets *parameters, int count) ! { ! Actor *origin = parameters->GetTarget(count); ! parameters->Clear(); ! if (!origin) { ! return parameters; ! } ! parameters->AddTarget(origin, 0); return parameters; } - Targets *GameScript::XthNearestMyGroupOfType(Scriptable *origin, Targets *parameters, int count) - { - if (origin->Type != ST_ACTOR) { - parameters->Clear(); - return parameters; - } - - targetlist::iterator m; - targettype *t = parameters->GetFirstTarget(m); - if (!t) { - return parameters; - } - Actor *actor = (Actor *) origin; - //determining the allegiance of the origin - int type = 2; //neutral, has no enemies - if (actor->GetStat(IE_EA) <= EA_GOODCUTOFF) { - type = 0; //PC - } - if (actor->GetStat(IE_EA) >= EA_EVILCUTOFF) { - type = 1; - } - if (type==2) { - parameters->Clear(); - return parameters; - } - - while ( t ) { - if (type) { //origin is enemy, so we remove PC groups - if (t->actor->GetStat(IE_EA) <= EA_GOODCUTOFF) { - t=parameters->RemoveTargetAt(m); - continue; - } - } - else { - if (t->actor->GetStat(IE_EA) >= EA_EVILCUTOFF) { - t=parameters->RemoveTargetAt(m); - continue; - } - } - t = parameters->GetNextTarget(m); - } - return XthNearestOf(parameters,count); - } - - Targets *GameScript::XthNearestEnemyOfType(Scriptable *origin, Targets *parameters, int count) - { - if (origin->Type != ST_ACTOR) { - parameters->Clear(); - return parameters; - } - - targetlist::iterator m; - targettype *t = parameters->GetFirstTarget(m); - if (!t) { - return parameters; - } - Actor *actor = (Actor *) origin; - //determining the allegiance of the origin - int type = 2; //neutral, has no enemies - if (actor->GetStat(IE_EA) <= EA_GOODCUTOFF) { - type = 1; //PC - } - if (actor->GetStat(IE_EA) >= EA_EVILCUTOFF) { - type = 0; - } - if (type==2) { - parameters->Clear(); - return parameters; - } - - while ( t ) { - if (type) { //origin is PC - if (t->actor->GetStat(IE_EA) <= EA_GOODCUTOFF) { - t=parameters->RemoveTargetAt(m); - continue; - } - } - else { - if (t->actor->GetStat(IE_EA) >= EA_EVILCUTOFF) { - t=parameters->RemoveTargetAt(m); - continue; - } - } - t = parameters->GetNextTarget(m); - } - return XthNearestOf(parameters,count); - } - - Targets *GameScript::XthNearestEnemyOf(Targets *parameters, int count) - { - Actor *origin = parameters->GetTarget(0); - parameters->Clear(); - if (!origin) { - return parameters; - } - //determining the allegiance of the origin - int type = 2; //neutral, has no enemies - if (origin->GetStat(IE_EA) <= EA_GOODCUTOFF) { - type = 1; //PC - } - if (origin->GetStat(IE_EA) >= EA_EVILCUTOFF) { - type = 0; - } - if (type==2) { - return parameters; - } - Map *map = origin->GetCurrentArea(); - int i = map->GetActorCount(true); - Actor *ac; - while (i--) { - ac=map->GetActor(i,true); - int distance = Distance(ac, origin); - if (type) { //origin is PC - if (ac->GetStat(IE_EA) >= EA_EVILCUTOFF) { - parameters->AddTarget(ac, distance); - } - } - else { - if (ac->GetStat(IE_EA) <= EA_GOODCUTOFF) { - parameters->AddTarget(ac, distance); - } - } - } - return XthNearestOf(parameters,count); - } - Targets *GameScript::Farthest(Scriptable* /*Sender*/, Targets *parameters) { ! targettype *t = parameters->GetLastTarget(); parameters->Clear(); if (t) { --- 2144,2171 ---- { targetlist::iterator m; ! const targettype *t = parameters->GetFirstTarget(m, ST_ACTOR); if (!t) { return parameters; } ! Scriptable *scr = t->actor; ! Actor *actor = (Actor *) scr; int besthp=actor->GetStat(IE_MAXHITPOINTS)-actor->GetStat(IE_HITPOINTS); // assignment in while ! while ( (t = parameters->GetNextTarget(m, ST_ACTOR) ) ) { ! actor = (Actor *) t->actor; ! int hp=actor->GetStat(IE_MAXHITPOINTS)-actor->GetStat(IE_HITPOINTS); if (besthp<hp) { besthp=hp; ! scr=t->actor; } } parameters->Clear(); ! parameters->AddTarget(scr, 0); return parameters; } Targets *GameScript::Farthest(Scriptable* /*Sender*/, Targets *parameters) { ! const targettype *t = parameters->GetLastTarget(ST_ACTOR); parameters->Clear(); if (t) { *************** *** 2217,2220 **** --- 2175,2183 ---- } + Targets *GameScript::FarthestEnemyOf(Scriptable* /*Sender*/, Targets *parameters) + { + return XthNearestEnemyOf(parameters, -1); + } + Targets *GameScript::NearestEnemyOf(Scriptable* /*Sender*/, Targets *parameters) { Index: GSUtils.cpp =================================================================== RCS file: /cvsroot/gemrb/gemrb/gemrb/plugins/Core/GSUtils.cpp,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -d -r1.44 -r1.45 *** GSUtils.cpp 21 Dec 2005 22:58:25 -0000 1.44 --- GSUtils.cpp 25 Dec 2005 10:31:39 -0000 1.45 *************** *** 248,252 **** continue; bool ret = false; ! if (item->ItemType==ITM_TYPE_BAG) { //the store is the same as the item's name ret = StoreHasItemCore(itemslot->ItemResRef, itemname); --- 248,252 ---- continue; bool ret = false; ! if (core->CanUseItemType(item->ItemType,SLOT_BAG,0,0,NULL) ) { //the store is the same as the item's name ret = StoreHasItemCore(itemslot->ItemResRef, itemname); *************** *** 402,412 **** } targetlist::iterator m; ! targettype *t = tgts->GetFirstTarget(m); while (t) { ! if (!func(t->actor, oC->objectFields[j] ) ) { t = tgts->RemoveTargetAt(m); ! } else { ! t = tgts->GetNextTarget(m); } } } --- 402,416 ---- } targetlist::iterator m; ! const targettype *t = tgts->GetFirstTarget(m, -1); while (t) { ! if (t->actor->Type!=ST_ACTOR) { t = tgts->RemoveTargetAt(m); ! continue; } + if (!func( (Actor *) (t->actor), oC->objectFields[j] ) ) { + t = tgts->RemoveTargetAt(m); + continue; + } + t = tgts->GetNextTarget(m, -1); } } *************** *** 420,424 **** int dist = Distance(Sender->Pos, ac->Pos); if (ac && func(ac, oC->objectFields[j]) ) { ! tgts->AddTarget(ac, dist); } } --- 424,428 ---- int dist = Distance(Sender->Pos, ac->Pos); if (ac && func(ac, oC->objectFields[j]) ) { ! tgts->AddTarget((Scriptable *) ac, dist); } } *************** *** 455,459 **** } else { ! printf("[GameScript]: Unknown object filter: %d %s\n",filterid, objectsTable->GetValue(filterid) ); } if (!tgts->Count()) { --- 459,464 ---- } else { ! printMessage("GameScript"," ", YELLOW); ! printf("Unknown object filter: %d %s\n",filterid, objectsTable->GetValue(filterid) ); } if (!tgts->Count()) { *************** *** 472,486 **** Targets *tgts = GetAllObjects(Sender, oC); if (tgts) { ! Scriptable *object; ! object= (Scriptable *) tgts->GetTarget(0); delete tgts; return object; } if (oC->objectName[0]) { - //It was not an actor... maybe it is a door? Scriptable * aC = Sender->GetCurrentArea()->TMap->GetDoor( oC->objectName ); if (aC) { return aC; } //No... it was not a door... maybe an InfoPoint? aC = Sender->GetCurrentArea()->TMap->GetInfoPoint( oC->objectName ); --- 477,492 ---- Targets *tgts = GetAllObjects(Sender, oC); if (tgts) { ! //now this could return other than actor objects ! Scriptable *object = tgts->GetTarget(0,-1); delete tgts; return object; } + if (oC->objectName[0]) { Scriptable * aC = Sender->GetCurrentArea()->TMap->GetDoor( oC->objectName ); if (aC) { return aC; } + //No... it was not a door... maybe an InfoPoint? aC = Sender->GetCurrentArea()->TMap->GetInfoPoint( oC->objectName ); *************** *** 488,492 **** return aC; } - //No... it was not an infopoint... maybe a Container? aC = Sender->GetCurrentArea()->TMap->GetContainer( oC->objectName ); --- 494,497 ---- *************** *** 920,930 **** if (tgts) { targetlist::iterator m; ! targettype *tt = tgts->GetFirstTarget(m); while (tt) { ! if (tt->actor->GetID() == actorID) { ret = true; break; } ! tt = tgts->GetNextTarget(m); } } --- 925,936 ---- if (tgts) { targetlist::iterator m; ! const targettype *tt = tgts->GetFirstTarget(m, ST_ACTOR); while (tt) { ! Actor *actor = (Actor *) tt->actor; ! if (actor->GetID() == actorID) { ret = true; break; } ! tt = tgts->GetNextTarget(m, ST_ACTOR); } } *************** *** 1684,1685 **** --- 1690,1874 ---- return parameters; } + + Targets *XthNearestDoor(Targets *parameters, unsigned int count) + { + //get the origin + Scriptable *origin = parameters->GetTarget(0, -1); + parameters->Clear(); + if (!origin) { + return parameters; + } + //get the doors based on it + Map *map = origin->GetCurrentArea(); + unsigned int i = map->TMap->GetDoorCount(); + if (count>i) { + return parameters; + } + while (i--) { + Door *door = map->TMap->GetDoor(i); + unsigned int dist = Distance(origin->Pos, door->Pos); + parameters->AddTarget(door, dist); + } + + //now get the xth door + origin = parameters->GetTarget(count, ST_DOOR); + parameters->Clear(); + if (!origin) { + return parameters; + } + parameters->AddTarget(origin, 0); + return parameters; + } + + Targets *XthNearestOf(Targets *parameters, int count) + { + Scriptable *origin; + + if (count<0) { + const targettype *t = parameters->GetLastTarget(ST_ACTOR); + origin = t->actor; + } else { + origin = parameters->GetTarget(count, ST_ACTOR); + } + parameters->Clear(); + if (!origin) { + return parameters; + } + parameters->AddTarget(origin, 0); + return parameters; + } + + Targets *XthNearestMyGroupOfType(Scriptable *origin, Targets *parameters, unsigned int count) + { + if (origin->Type != ST_ACTOR) { + parameters->Clear(); + return parameters; + } + + targetlist::iterator m; + const targettype *t = parameters->GetFirstTarget(m, ST_ACTOR); + if (!t) { + return parameters; + } + Actor *actor = (Actor *) origin; + //determining the allegiance of the origin + int type = 2; //neutral, has no enemies + if (actor->GetStat(IE_EA) <= EA_GOODCUTOFF) { + type = 0; //PC + } + if (actor->GetStat(IE_EA) >= EA_EVILCUTOFF) { + type = 1; + } + if (type==2) { + parameters->Clear(); + return parameters; + } + + while ( t ) { + if (t->actor->Type!=ST_ACTOR) { + t=parameters->RemoveTargetAt(m); + continue; + } + Actor *actor = (Actor *) (t->actor); + if (type) { //origin is enemy, so we remove PC groups + if (actor->GetStat(IE_EA) <= EA_GOODCUTOFF) { + t=parameters->RemoveTargetAt(m); + continue; + } + } + else { + if (actor->GetStat(IE_EA) >= EA_EVILCUTOFF) { + t=parameters->RemoveTargetAt(m); + continue; + } + } + t = parameters->GetNextTarget(m, ST_ACTOR); + } + return XthNearestOf(parameters,count); + } + + Targets *XthNearestEnemyOfType(Scriptable *origin, Targets *parameters, unsigned int count) + { + if (origin->Type != ST_ACTOR) { + parameters->Clear(); + return parameters; + } + + targetlist::iterator m; + const targettype *t = parameters->GetFirstTarget(m, ST_ACTOR); + if (!t) { + return parameters; + } + Actor *actor = (Actor *) origin; + //determining the allegiance of the origin + int type = 2; //neutral, has no enemies + if (actor->GetStat(IE_EA) <= EA_GOODCUTOFF) { + type = 1; //PC + } + if (actor->GetStat(IE_EA) >= EA_EVILCUTOFF) { + type = 0; + } + if (type==2) { + parameters->Clear(); + return parameters; + } + + while ( t ) { + if (t->actor->Type!=ST_ACTOR) { + t=parameters->RemoveTargetAt(m); + continue; + } + Actor *actor = (Actor *) (t->actor); + if (type) { //origin is PC + if (actor->GetStat(IE_EA) <= EA_GOODCUTOFF) { + t=parameters->RemoveTargetAt(m); + continue; + } + } else { + if (actor->GetStat(IE_EA) >= EA_EVILCUTOFF) { + t=parameters->RemoveTargetAt(m); + continue; + } + } + t = parameters->GetNextTarget(m, ST_ACTOR); + } + return XthNearestOf(parameters,count); + } + + Targets *XthNearestEnemyOf(Targets *parameters, int count) + { + Actor *origin = (Actor *) parameters->GetTarget(0, ST_ACTOR); + parameters->Clear(); + if (!origin) { + return parameters; + } + //determining the allegiance of the origin + int type = 2; //neutral, has no enemies + if (origin->GetStat(IE_EA) <= EA_GOODCUTOFF) { + type = 1; //PC + } + if (origin->GetStat(IE_EA) >= EA_EVILCUTOFF) { + type = 0; + } + if (type==2) { + return parameters; + } + Map *map = origin->GetCurrentArea(); + int i = map->GetActorCount(true); + Actor *ac; + while (i--) { + ac=map->GetActor(i,true); + int distance = Distance(ac, origin); + if (type) { //origin is PC + if (ac->GetStat(IE_EA) >= EA_EVILCUTOFF) { + parameters->AddTarget(ac, distance); + } + } + else { + if (ac->GetStat(IE_EA) <= EA_GOODCUTOFF) { + parameters->AddTarget(ac, distance); + } + } + } + return XthNearestOf(parameters,count); + } Index: Inventory.h =================================================================== RCS file: /cvsroot/gemrb/gemrb/gemrb/plugins/Core/Inventory.h,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -d -r1.41 -r1.42 *** Inventory.h 22 Dec 2005 23:29:41 -0000 1.41 --- Inventory.h 25 Dec 2005 10:31:39 -0000 1.42 *************** *** 62,66 **** #define SLOT_CLOAK 1024 #define SLOT_ITEM 2048 //quick item ! // #define SLOT_INVENTORY 0x8000 #define SLOT_ANY -1 --- 62,69 ---- #define SLOT_CLOAK 1024 #define SLOT_ITEM 2048 //quick item ! #define SLOT_SCROLL 4096 ! #define SLOT_BAG 8192 ! #define SLOT_POTION 16384 ! #define SLOT_INVENTORY 0x8000 #define SLOT_ANY -1 *************** *** 207,210 **** --- 210,214 ---- void DropItemAtLocation(const char *resref, unsigned int flags, Map *map, Point &loc); void SetEquippedSlot(int slotcode); + int GetEquipped(); int GetEquippedSlot(); void AddSlotEffects( CREItem* slot ); Index: ActorBlock.cpp =================================================================== RCS file: /cvsroot/gemrb/gemrb/gemrb/plugins/Core/ActorBlock.cpp,v retrieving revision 1.127 retrieving revision 1.128 diff -C2 -d -r1.127 -r1.128 *** ActorBlock.cpp 19 Dec 2005 23:10:50 -0000 1.127 --- ActorBlock.cpp 25 Dec 2005 10:31:39 -0000 1.128 *************** *** 793,802 **** int oval, cval; ! oval = 1; //passable searchmap entry if (Flags & DOOR_TRANSPARENT) { ! cval = 8; //transparent door searchmap entry } else { ! cval = 0; //opaque door searchmap entry } if (Flags &DOOR_OPEN) { --- 793,802 ---- int oval, cval; ! oval = PATH_MAP_IMPASSABLE; if (Flags & DOOR_TRANSPARENT) { ! cval = PATH_MAP_DOOR_TRANSPARENT; } else { ! cval = PATH_MAP_DOOR_OPAQUE; } if (Flags &DOOR_OPEN) { *************** *** 810,817 **** for(i=0;i<oibcount;i++) { ! area->SearchMap->SetPixelIndex( open_ib[i].x, open_ib[i].y, oidx ); } for(i=0;i<cibcount;i++) { ! area->SearchMap->SetPixelIndex( closed_ib[i].x, closed_ib[i].y, cidx ); } InfoPoint *ip=area->TMap->GetInfoPoint(LinkedInfo); --- 810,819 ---- for(i=0;i<oibcount;i++) { ! ieByte tmp = area->SearchMap->GetPixelIndex( open_ib[i].x, open_ib[i].y ) & 15; ! area->SearchMap->SetPixelIndex( open_ib[i].x, open_ib[i].y, tmp|oidx ); } for(i=0;i<cibcount;i++) { ! ieByte tmp = area->SearchMap->GetPixelIndex( closed_ib[i].x, closed_ib[i].y ) & 15; ! area->SearchMap->SetPixelIndex( closed_ib[i].x, closed_ib[i].y, tmp|cidx ); } InfoPoint *ip=area->TMap->GetInfoPoint(LinkedInfo); Index: GameScript.h =================================================================== RCS file: /cvsroot/gemrb/gemrb/gemrb/plugins/Core/GameScript.h,v retrieving revision 1.234 retrieving revision 1.235 diff -C2 -d -r1.234 -r1.235 *** GameScript.h 21 Dec 2005 17:34:20 -0000 1.234 --- GameScript.h 25 Dec 2005 10:31:39 -0000 1.235 *************** *** 88,92 **** typedef struct targettype { ! Actor *actor; unsigned int distance; } targettype; --- 88,92 ---- typedef struct targettype { ! Scriptable *actor; //hmm, could be door unsigned int distance; } targettype; *************** *** 109,117 **** int Count() const; targettype *RemoveTargetAt(targetlist::iterator &m); ! targettype *GetNextTarget(targetlist::iterator &m); ! targettype *GetLastTarget(); ! targettype *GetFirstTarget(targetlist::iterator &m); ! Actor *GetTarget(unsigned int index); ! void AddTarget(Actor* actor, unsigned int distance); void Clear(); }; --- 109,117 ---- int Count() const; targettype *RemoveTargetAt(targetlist::iterator &m); ! const targettype *GetNextTarget(targetlist::iterator &m, int Type); ! const targettype *GetLastTarget(int Type); ! const targettype *GetFirstTarget(targetlist::iterator &m, int Type); ! Scriptable *GetTarget(unsigned int index, int Type); ! void AddTarget(Scriptable* target, unsigned int distance); void Clear(); }; *************** *** 608,622 **** static int ParseInt(const char*& src); static void ParseString(const char*& src, char* tmp); - private: - /* returns true if actor matches the object specs. */ - //static bool MatchActor(Scriptable *Sender, ieDword ID, Object* oC); - /* returns the number of actors matching the IDS targeting */ - //static int GetObjectCount(Scriptable* Sender, Object* oC); - - static Targets *XthNearestOf(Targets *parameters, int count); - static Targets *XthNearestEnemyOf(Targets *parameters, int count); - static Targets *XthNearestEnemyOfType(Scriptable *origin, Targets *parameters, int count); - static Targets *XthNearestMyGroupOfType(Scriptable *origin, Targets *parameters, int count); - private: //Internal variables unsigned long lastRunTime; --- 608,611 ---- *************** *** 876,879 **** --- 865,869 ---- static int ReputationGT(Scriptable* Sender, Trigger* parameters); static int ReputationLT(Scriptable* Sender, Trigger* parameters); + static int School(Scriptable* Sender, Trigger* parameters); static int See(Scriptable* Sender, Trigger* parameters); static int Specifics(Scriptable* Sender, Trigger* parameters); *************** *** 1271,1274 **** --- 1261,1265 ---- static void VerbalConstantHead(Scriptable* Sender, Action* parameters); static void Wait(Scriptable* Sender, Action* parameters); + static void WaitAnimation(Scriptable* Sender, Action* parameters); static void WaitRandom(Scriptable* Sender, Action* parameters); static void Weather(Scriptable* Sender, Action* parameters); *************** *** 1278,1290 **** --- 1269,1285 ---- static Targets *BestAC(Scriptable *Sender, Targets *parameters); static Targets *EighthNearest(Scriptable *Sender, Targets *parameters); + static Targets *EighthNearestDoor(Scriptable *Sender, Targets *parameters); static Targets *EighthNearestEnemyOf(Scriptable *Sender, Targets *parameters); static Targets *EighthNearestEnemyOfType(Scriptable *Sender, Targets *parameters); static Targets *EighthNearestMyGroupOfType(Scriptable *Sender, Targets *parameters); static Targets *Farthest(Scriptable *Sender, Targets *parameters); + static Targets *FarthestEnemyOf(Scriptable *Sender, Targets *parameters); static Targets *FifthNearest(Scriptable *Sender, Targets *parameters); + static Targets *FifthNearestDoor(Scriptable *Sender, Targets *parameters); static Targets *FifthNearestEnemyOf(Scriptable *Sender, Targets *parameters); static Targets *FifthNearestEnemyOfType(Scriptable *Sender, Targets *parameters); static Targets *FifthNearestMyGroupOfType(Scriptable *Sender, Targets *parameters); static Targets *FourthNearest(Scriptable *Sender, Targets *parameters); + static Targets *FourthNearestDoor(Scriptable *Sender, Targets *parameters); static Targets *FourthNearestEnemyOf(Scriptable *Sender, Targets *parameters); static Targets *FourthNearestEnemyOfType(Scriptable *Sender, Targets *parameters); *************** *** 1306,1309 **** --- 1301,1305 ---- static Targets *MyTarget(Scriptable *Sender, Targets *parameters); static Targets *Nearest(Scriptable *Sender, Targets *parameters); + static Targets *NearestDoor(Scriptable *Sender, Targets *parameters); static Targets *NearestEnemyOf(Scriptable *Sender, Targets *parameters); static Targets *NearestEnemyOfType(Scriptable *Sender, Targets *parameters); *************** *** 1311,1314 **** --- 1307,1311 ---- static Targets *NearestPC(Scriptable *Sender, Targets *parameters); static Targets *NinthNearest(Scriptable *Sender, Targets *parameters); + static Targets *NinthNearestDoor(Scriptable *Sender, Targets *parameters); static Targets *NinthNearestEnemyOf(Scriptable *Sender, Targets *parameters); static Targets *NinthNearestEnemyOfType(Scriptable *Sender, Targets *parameters); *************** *** 1331,1334 **** --- 1328,1332 ---- static Targets *ProtectorOf(Scriptable *Sender, Targets *parameters); static Targets *SecondNearest(Scriptable *Sender, Targets *parameters); + static Targets *SecondNearestDoor(Scriptable *Sender, Targets *parameters); static Targets *SecondNearestEnemyOf(Scriptable *Sender, Targets *parameters); static Targets *SecondNearestEnemyOfType(Scriptable *Sender, Targets *parameters); *************** *** 1336,1343 **** --- 1334,1343 ---- static Targets *SelectedCharacter(Scriptable *Sender, Targets *parameters); static Targets *SeventhNearest(Scriptable *Sender, Targets *parameters); + static Targets *SeventhNearestDoor(Scriptable *Sender, Targets *parameters); static Targets *SeventhNearestEnemyOf(Scriptable *Sender, Targets *parameters); static Targets *SeventhNearestEnemyOfType(Scriptable *Sender, Targets *parameters); static Targets *SeventhNearestMyGroupOfType(Scriptable *Sender, Targets *parameters); static Targets *SixthNearest(Scriptable *Sender, Targets *parameters); + static Targets *SixthNearestDoor(Scriptable *Sender, Targets *parameters); static Targets *SixthNearestEnemyOf(Scriptable *Sender, Targets *parameters); static Targets *SixthNearestEnemyOfType(Scriptable *Sender, Targets *parameters); *************** *** 1346,1353 **** --- 1346,1355 ---- static Targets *StrongestOfMale(Scriptable *Sender, Targets *parameters); static Targets *TenthNearest(Scriptable *Sender, Targets *parameters); + static Targets *TenthNearestDoor(Scriptable *Sender, Targets *parameters); static Targets *TenthNearestEnemyOf(Scriptable *Sender, Targets *parameters); static Targets *TenthNearestEnemyOfType(Scriptable *Sender, Targets *parameters); static Targets *TenthNearestMyGroupOfType(Scriptable *Sender, Targets *parameters); static Targets *ThirdNearest(Scriptable *Sender, Targets *parameters); + static Targets *ThirdNearestDoor(Scriptable *Sender, Targets *parameters); static Targets *ThirdNearestEnemyOf(Scriptable *Sender, Targets *parameters); static Targets *ThirdNearestEnemyOfType(Scriptable *Sender, Targets *parameters); Index: Map.cpp =================================================================== RCS file: /cvsroot/gemrb/gemrb/gemrb/plugins/Core/Map.cpp,v retrieving revision 1.215 retrieving revision 1.216 diff -C2 -d -r1.215 -r1.216 *** Map.cpp 21 Dec 2005 16:53:52 -0000 1.215 --- Map.cpp 25 Dec 2005 10:31:39 -0000 1.216 *************** *** 351,355 **** Map* map = game->GetMap(area, false); if (!map) { ! printf("[Map] Invalid map: %s\n",area); command[0]=0; return; --- 351,356 ---- Map* map = game->GetMap(area, false); if (!map) { ! printMessage("Map", " ", LIGHT_RED); ! printf("Invalid map: %s\n",area); command[0]=0; return; *************** *** 358,364 **** int X,Y, face; if (!ent) { ! textcolor( YELLOW ); ! printf( "[Map] WARNING!!! %s EntryPoint does not Exists\n", entrance ); ! textcolor( WHITE ); X = map->TMap->XCellCount * 64; Y = map->TMap->YCellCount * 64; --- 359,364 ---- int X,Y, face; if (!ent) { ! printMessage("Map", " ", YELLOW); ! printf( "WARNING!!! %s EntryPoint does not exists\n", entrance ); X = map->TMap->XCellCount * 64; Y = map->TMap->YCellCount * 64; *************** *** 1025,1032 **** } int Map::GetBlocked(Point &c) { ! int block = SearchMap->GetPixelIndex( c.x / 16, c.y / 12 ); ! return Passable[block]; } --- 1025,1043 ---- } + int Map::GetBlocked(unsigned int x, unsigned int y) + { + int block = SearchMap->GetPixelIndex( x, y ); + if (block&PATH_MAP_DOOR_OPAQUE) { + return PATH_MAP_NO_SEE; + } + if (block&PATH_MAP_DOOR_TRANSPARENT) { + return PATH_MAP_IMPASSABLE; + } + return Passable[block&15]; + } + int Map::GetBlocked(Point &c) { ! return GetBlocked(c.x/16, c.y/12); } *************** *** 1384,1388 **** return; } ! if (!( Passable[SearchMap->GetPixelIndex( x, y )] & PATH_MAP_PASSABLE)) { MapSet[pos] = 65535; return; --- 1395,1399 ---- return; } ! if (!( GetBlocked(x,y) & PATH_MAP_PASSABLE)) { MapSet[pos] = 65535; return; *************** *** 1414,1418 **** for (unsigned int scanx = minx; scanx < maxx; scanx++) { if ((unsigned int) goal.y >= radius) { ! if (Passable[SearchMap->GetPixelIndex( scanx, goal.y - radius )] & PATH_MAP_PASSABLE) { goal.x = scanx; goal.y -= radius; --- 1425,1429 ---- for (unsigned int scanx = minx; scanx < maxx; scanx++) { if ((unsigned int) goal.y >= radius) { ! if (GetBlocked( scanx, goal.y - radius ) & PATH_MAP_PASSABLE) { goal.x = scanx; goal.y -= radius; *************** *** 1421,1425 **** } if (goal.y + radius < Height) { ! if (Passable[SearchMap->GetPixelIndex( scanx, goal.y + radius )] & PATH_MAP_PASSABLE) { goal.x = scanx; goal.y += radius; --- 1432,1436 ---- } if (goal.y + radius < Height) { ! if (GetBlocked( scanx, goal.y + radius ) & PATH_MAP_PASSABLE) { goal.x = scanx; goal.y += radius; *************** *** 1436,1440 **** for (unsigned int scany = miny; scany < maxy; scany++) { if ((unsigned int) goal.x >= radius) { ! if (Passable[SearchMap->GetPixelIndex( goal.x - radius, scany )] & PATH_MAP_PASSABLE) { goal.x -= radius; goal.y = scany; --- 1447,1451 ---- for (unsigned int scany = miny; scany < maxy; scany++) { if ((unsigned int) goal.x >= radius) { ! if (GetBlocked( goal.x - radius, scany ) & PATH_MAP_PASSABLE) { goal.x -= radius; goal.y = scany; *************** *** 1443,1447 **** } if (goal.x + radius < Width) { ! if (Passable[SearchMap->GetPixelIndex( goal.x - radius, scany )] & PATH_MAP_PASSABLE) { goal.x += radius; goal.y = scany; --- 1454,1458 ---- } if (goal.x + radius < Width) { ! if (GetBlocked( goal.x - radius, scany ) & PATH_MAP_PASSABLE) { goal.x += radius; goal.y = scany; *************** *** 1477,1481 **** InternalStack.pop(); ! if (!( Passable[SearchMap->GetPixelIndex( start.x, start.y )] & PATH_MAP_PASSABLE )) { AdjustPosition( start ); } --- 1488,1492 ---- InternalStack.pop(); ! if (!( GetBlocked( start.x, start.y) & PATH_MAP_PASSABLE )) { AdjustPosition( start ); } *************** *** 1568,1575 **** InternalStack.pop(); ! if (!( Passable[SearchMap->GetPixelIndex( goal.x, goal.y )] & PATH_MAP_PASSABLE )) { return true; } ! if (!( Passable[SearchMap->GetPixelIndex( start.x, start.y )] & PATH_MAP_PASSABLE )) { return true; } --- 1579,1586 ---- InternalStack.pop(); ! if (!( GetBlocked( goal.x, goal.y ) & PATH_MAP_PASSABLE )) { return true; } ! if (!( GetBlocked( start.x, start.y ) & PATH_MAP_PASSABLE )) { return true; } *************** *** 1639,1643 **** StartNode->y = y; StartNode->orient = Orientation; ! bool wall = (!( Passable[SearchMap->GetPixelIndex( x, y )] & PATH_MAP_PASSABLE )); if (wall) switch (flags) { case GL_REBOUND: --- 1650,1654 ---- StartNode->y = y; StartNode->orient = Orientation; ! bool wall = !( GetBlocked( x, y ) & PATH_MAP_PASSABLE ); if (wall) switch (flags) { case GL_REBOUND: *************** *** 1662,1666 **** InternalStack.pop(); ! if (!( Passable[SearchMap->GetPixelIndex( goal.x, goal.y )] & PATH_MAP_PASSABLE )) { AdjustPosition( goal ); } --- 1673,1677 ---- InternalStack.pop(); ! if (!( GetBlocked( goal.x, goal.y ) & PATH_MAP_PASSABLE )) { AdjustPosition( goal ); } *************** *** 1779,1788 **** if (sX > dX) { for (int startx = sX; startx > dX; startx--) { ! if (Passable[SearchMap->GetPixelIndex( startx, sY - ( int ) ( ( sX - startx ) / elevationy ) )] & PATH_MAP_NO_SEE) return false; } } else { for (int startx = sX; startx < dX; startx++) { ! if (Passable[SearchMap->GetPixelIndex( startx, sY + ( int ) ( ( sX - startx ) / elevationy ) )] & PATH_MAP_NO_SEE) return false; } --- 1790,1799 ---- if (sX > dX) { for (int startx = sX; startx > dX; startx--) { ! if (GetBlocked( startx, sY - ( int ) ( ( sX - startx ) / elevationy ) ) & PATH_MAP_NO_SEE) return false; } } else { for (int startx = sX; startx < dX; startx++) { ! if (GetBlocked( startx, sY + ( int ) ( ( sX - startx ) / elevationy ) ) & PATH_MAP_NO_SEE) return false; } *************** *** 1792,1801 **** if (sY > dY) { for (int starty = sY; starty > dY; starty--) { ! if (Passable[SearchMap->GetPixelIndex( sX - ( int ) ( ( sY - starty ) / elevationx ), starty )] & PATH_MAP_NO_SEE) return false; } } else { for (int starty = sY; starty < dY; starty++) { ! if (Passable[SearchMap->GetPixelIndex( sX + ( int ) ( ( sY - starty ) / elevationx ), starty )] & PATH_MAP_NO_SEE) return false; } --- 1803,1812 ---- if (sY > dY) { for (int starty = sY; starty > dY; starty--) { ! if (GetBlocked( sX - ( int ) ( ( sY - starty ) / elevationx ), starty ) & PATH_MAP_NO_SEE) return false; } } else { for (int starty = sY; starty < dY; starty++) { ! if (GetBlocked( sX + ( int ) ( ( sY - starty ) / elevationx ), starty ) & PATH_MAP_NO_SEE) return false; } *************** *** 1810,1815 **** unsigned int sX=s.x/16; unsigned int sY=s.y/12; ! if (!(Passable[SearchMap->GetPixelIndex( sX, sY )]&PATH_MAP_TRAVEL)) { ! printf("[Map] This isn't a travel region [%d.%d]?\n",sX, sY); return -1; } --- 1821,1827 ---- unsigned int sX=s.x/16; unsigned int sY=s.y/12; ! if (!(GetBlocked( sX, sY )&PATH_MAP_TRAVEL)) { ! printMessage("Map"," ",YELLOW); ! printf("This isn't a travel region [%d.%d]?\n",sX, sY); return -1; } *************** *** 2112,2117 **** //converting to search square ! position.x/=16; ! position.y/=12; sprintf(heapname,"heap_%hd.%hd",position.x,position.y); //pixel position is centered on search square --- 2124,2129 ---- //converting to search square ! position.x=position.x/16; ! position.y=position.y/12; sprintf(heapname,"heap_%hd.%hd",position.x,position.y); //pixel position is centered on search square Index: Map.h =================================================================== RCS file: /cvsroot/gemrb/gemrb/gemrb/plugins/Core/Map.h,v retrieving revision 1.97 retrieving revision 1.98 diff -C2 -d -r1.97 -r1.98 *** Map.h 12 Dec 2005 18:39:55 -0000 1.97 --- Map.h 25 Dec 2005 10:31:39 -0000 1.98 *************** *** 61,66 **** //area animation flags #define A_ANI_ACTIVE 1 //if not set, animation is invisible ! #define A_ANI_NO_SHADOW 2 //lightmap doesn't affect it ! #define A_ANI_BLEND 4 //blend #define A_ANI_PLAYONCE 8 //stop after endframe #define A_ANI_SYNC 16 //synchronised draw (skip frames if needed) --- 61,66 ---- //area animation flags #define A_ANI_ACTIVE 1 //if not set, animation is invisible ! #define A_ANI_BLEND 2 //blend ! #define A_ANI_NO_SHADOW 4 //lightmap doesn't affect it #define A_ANI_PLAYONCE 8 //stop after endframe #define A_ANI_SYNC 16 //synchronised draw (skip frames if needed) *************** *** 235,238 **** --- 235,239 ---- void Shout(Actor* actor, int shoutID, unsigned int radius); void AddActor(Actor* actor); + int GetBlocked(unsigned int x, unsigned int y); int GetBlocked(Point &p); Actor* GetActorByGlobalID(ieDword objectID); Index: Triggers.cpp =================================================================== RCS file: /cvsroot/gemrb/gemrb/gemrb/plugins/Core/Triggers.cpp,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** Triggers.cpp 21 Dec 2005 22:58:25 -0000 1.35 --- Triggers.cpp 25 Dec 2005 10:31:39 -0000 1.36 *************** *** 317,320 **** --- 317,336 ---- } + int GameScript::School(Scriptable* Sender, Trigger* parameters) + { + Scriptable* scr = GetActorFromObject( Sender, parameters->objectParameter ); + if (!scr || scr->Type!=ST_ACTOR) { + return 0; + } + Actor* actor = (Actor *) scr; + //only the low 2 bytes count + //the School values start from 1 to 9 and the first school value is 0x40 + //so this mild hack will do + if ( (ieWord) actor->GetStat(IE_KIT) == (ieWord) (0x20<<parameters->int0Parameter)) { + return 1; + } + return 0; + } + int GameScript::Kit(Scriptable* Sender, Trigger* parameters) { *************** *** 1131,1135 **** //now objects suicide themselves if they are empty objects //so checking an empty object is easier - //if (parameters->objectParameter->objectFields[0] == 0) { if (parameters->objectParameter == NULL) { if (Sender->LastTrigger) { --- 1147,1150 ---- *************** *** 1139,1148 **** return 0; } ! Scriptable* target = GetActorFromObject( Sender, parameters->objectParameter ); ! if (target->Type == ST_ACTOR) { ! if (Sender->LastTrigger == ((Actor *) target)->GetID()) { ! Sender->AddTrigger (&Sender->LastTrigger); ! return 1; ! } } return 0; --- 1154,1160 ---- return 0; } ! if (MatchActor(Sender, Sender->LastTrigger, parameters->objectParameter)) { ! Sender->AddTrigger (&Sender->LastTrigger); ! return 1; } return 0; *************** *** 1838,1843 **** Scriptable* tar = GetActorFromObject( Sender, parameters->objectParameter ); if (!tar) { ! printMessage("[GameScript]"," ",LIGHT_RED); ! printf("couldn't find door/container:%s\n", parameters->objectParameter? parameters->objectParameter->objectName:"<NULL>"); return 0; } --- 1850,1856 ---- Scriptable* tar = GetActorFromObject( Sender, parameters->objectParameter ); if (!tar) { ! printMessage("GameScript"," ",LIGHT_RED); ! printf("Couldn't find door/container:%s\n", parameters->objectParameter? parameters->objectParameter->objectName:"<NULL>"); ! printf("Sender: %s\n", Sender->GetScriptName() ); return 0; } *************** *** 1855,1859 **** default:; //to remove a warning } ! printMessage("[GameScript]"," ",LIGHT_RED); printf("Not a door/container:%s\n", tar->GetScriptName()); return 0; --- 1868,1872 ---- default:; //to remove a warning } ! printMessage("GameScript"," ",LIGHT_RED); printf("Not a door/container:%s\n", tar->GetScriptName()); return 0; *************** *** 1864,1869 **** Scriptable* tar = GetActorFromObject( Sender, parameters->objectParameter ); if (!tar) { ! printMessage("[GameScript]"," ",LIGHT_RED); ! printf("couldn't find door/container:%s\n", parameters->objectParameter? parameters->objectParameter->objectName:"<NULL>"); return 0; } --- 1877,1883 ---- Scriptable* tar = GetActorFromObject( Sender, parameters->objectParameter ); if (!tar) { ! printMessage("GameScript"," ",LIGHT_RED); ! printf("Couldn't find door/container:%s\n", parameters->objectParameter? parameters->objectParameter->objectName:"<NULL>"); ! printf("Sender: %s\n", Sender->GetScriptName() ); return 0; } *************** *** 1881,1885 **** default:; //to remove a warning } ! printMessage("[GameScript]"," ",LIGHT_RED); printf("Not a door/container:%s\n", tar->GetScriptName()); return 0; --- 1895,1899 ---- default:; //to remove a warning } ! printMessage("GameScript"," ",LIGHT_RED); printf("Not a door/container:%s\n", tar->GetScriptName()); return 0; *************** *** 2600,2612 **** if (tgts) { targetlist::iterator m; ! targettype *tt = tgts->GetFirstTarget(m); ... [truncated message content] |