#include "quests\quests_abordage.c" #include "quests\quests_check.c" #include "quests\quests_movie.c" #include "quests\characters_task.c" #include "quests\quests_scenes.c" #include "quests\both_reaction.c" #include "quests\quests_reaction.c" #event_handler("LocationWaitNihgtEnd","WaitDatePostEventControl"); #event_handler("evntQuestCameraRestore","QuestCameraRestore"); #event_handler("QuestDelayExit","DoQuestDelayExit"); #event_handler("QuitFromWorldMap","ReloadFromWMtoL_complete"); #event_handler(FORT_DESTROYED,"QuestFortDestroyed"); #event_handler(EVENT_CHARACTER_GROUPDEAD,"QuestGroupDeath"); #event_handler("wdmCreateMap","QuestsCheck"); #event_handler("evntQuestsCheck","QuestsCheck"); #event_handler("evntQuestComplete","procEvntQuestComplete"); void QuestsInit() { ref rch = GetMainCharacter(); aref postEvDelay, arTmp; makearef(postEvDelay,rch.PostEventQuest.questDelay); int q = GetAttributesNum(postEvDelay); for(int i=0; i=minDist) continue; minDist = curDist; findedLocator = refCurLocator; bYesFind = true; } return bYesFind; } // установить персонажа в ближайший локатор группы goto (но не ближе минимальной дистанции) //-------------------------------------------------------------------------------------------- bool SetCharacterToNearLocatorFromMe(string characterID, float minDistance) { int loadLocationIndex = FindLoadedLocation(); if(loadLocationIndex==-1) return false; float dist; aref findedLocator; if( !GetNearLocator( "goto", &dist, &findedLocator, minDistance) ) { Trace("Can't goto group locators into location "+Locations[loadLocationIndex].id); return false; } ChangeCharacterAddress(CharacterFromID(characterID), Locations[loadLocationIndex].id, GetAttributeName(findedLocator)); return true; } // получить ссылку на персонаж через его ID-шник //------------------------------------------------------ ref CharacterFromID(string characterID) { return &characters[GetCharacterIndex(characterID)]; } string sPostWaitName; int postWaitYear,postWaitMonth,postWaitDay,postWaitHour,postWaitMinute; void WaitDatePostEventControl() { AddDataToCurrent(postWaitYear,postWaitMonth,postWaitDay); AddTimeToCurrent(postWaitHour,postWaitMinute); if(sPostWaitName!="") CompleteQuestName(sPostWaitName); QuestsCheck(); } // пропустить некоторое время с фэйдом экрана //---------------------------------------------------- void WaitDate(string postName,int year, int month, int day, int hour, int minute) { sPostWaitName = postName; postWaitYear = year; postWaitMonth = month; postWaitDay = day; postWaitHour = hour; postWaitMinute = minute; WaitDatePostEventControl(); } // установить камеру на просмотр корабля персонажа и вызвать квест через заданное число секунд //--------------------------------------------------------------------------------------------- bool SetCameraToShipView(string characterName, string questCheckName, float viewTimeInSec) { int chrIdx = GetCharacterIndex(characterName); if(chrIdx==-1) return false; ref chrRef = GetCharacter(chrIdx); float xship = stf(chrRef.ship.pos.x); float zship = stf(chrRef.ship.pos.z); float xchar,ychar,zchar; if( false==GetCharacterPos(GetMainCharacter(),&xchar,&ychar,&zchar) ) return false; float dx = xchar-xship; float dz = zchar-zship; float dist = sqrt(dx*dx+dz*dz); dx = dx/dist; dz = dz/dist; float xcam = xchar+dx*6.0; float zcam = zchar+dz*6.0; PostEvent("evntQuestCameraRestore",makeint(viewTimeInSec*1000),"s",questCheckName); return locCameraToPos(xcam,ychar+3.0,zcam,false); } void QuestCameraRestore() { string sCameraQuestCheckName = GetEventData(); locCameraFollow(); if(sCameraQuestCheckName!="") { CompleteQuestName(sCameraQuestCheckName); QuestsCheck(); } } // Закрыть все выходы на море в районе расположения своего корабля //----------------------------------------------------------------- bool QuestCloseSeaExit() { ref mcRef = GetMainCharacter(); int locIdx = FindLocation(mcRef.location.from_sea); if(locIdx==-1) return false; aref reloadRef; makearef(reloadRef,Locations[locIdx].reload); int n = GetAttributesNum(reloadRef); aref locRef; for(int i=0;i xloc*xloc+yloc*yloc+zloc*zloc ) return true; else return false; } // заменить один локатор на новый адрес перегрузкии //--------------------------------------------------- bool ChangeReloadData(string locationName,string locatorName, string toLocationName,string toLocatorName) { aref locRef; if( !FindLocator(locationName,locatorName, &locRef, false) ) { return false; } if(!CheckAttribute(locRef,"old.go")) locRef.old.go = locRef.go; if(!CheckAttribute(locRef,"old.emerge")) locRef.old.emerge = locRef.emerge; if(toLocationName=="") toLocationName=locRef.go; if(toLocatorName=="") toLocatorName=locRef.emerge; locRef.go = toLocationName; locRef.emerge = toLocatorName; return true; } // вернуть локатору старый адрес перегрузки bool ChangeBackReloadData(string locationName,string locatorName) { aref locRef; if( !FindLocator(locationName,locatorName, &locRef, false) ) return false; if(CheckAttribute(locRef,"old.go")) locRef.go = locRef.old.go; if(CheckAttribute(locRef,"old.emerge")) locRef.emerge = locRef.old.emerge; if(CheckAttribute(locRef,"old")) DeleteAttribute(locRef,"old"); return true; } // вызвать проверку квеста через заданное число секунд //------------------------------------------------------ void DoQuestCheckDelay(string questCheckName, float delayInSecond) { bool deleteOldQuest=false; ref mc = GetMainCharacter(); if( CheckAttribute(mc,"quest."+questCheckName) ) deleteOldQuest=true; mc.PostEventQuest.questDelay.(questCheckName).delay = delayInSecond; mc.PostEventQuest.questDelay.(questCheckName).qname = questCheckName; PostEvent("QuestDelayExit",makeint(delayInSecond*1000),"sl",questCheckName,deleteOldQuest); } void DoQuestDelayExit() { string stmp = GetEventData(); bool deleteOldQuest = GetEventData(); ref mc = GetMainCharacter(); DeleteAttribute(mc,"PostEventQuest.questDelay."+stmp); if(stmp!="") { if(deleteOldQuest) { if( CheckAttribute(mc,"quest."+stmp) ) { CompleteQuestName(stmp); mc.quest.(stmp).over = "yes"; QuestsCheck(); return; } } CompleteQuestName(stmp); QuestsCheck(); } } void ExitActAnimation() { aref arch = GetEventData(); if(!CheckAttribute(arch,"activity.endAnimationQuest")) return; ref chref = GetCharacter(sti(arch.index)); CharacterPlayAction(chref,""); string endAniQuestName = chref.activity.endAnimationQuest.Name; DeleteAttribute(chref,"activity.endAnimationQuest"); if(endAniQuestName!="") { CompleteQuestName(endAniQuestName); QuestsCheck(); } } // Временно сохранить все данные о нашем корабле в памяти //-------------------------------------------------------- bool ShipTempRemove(ref _refCharacter) { if( CheckAttribute(_refCharacter,"TmpShipHolder") ) return false; if( !CheckAttribute(_refCharacter,"Ship") ) return false; aref dstRef; makearef(dstRef, _refCharacter.TmpShipHolder); aref srcRef; makearef(srcRef, _refCharacter.Ship); CopyAttributes(dstRef,srcRef); return true; } // Восстановить данные о нашем старом корабле из памяти //------------------------------------------------------ bool RestoreTempRemovedShip(ref _refCharacter) { if( !CheckAttribute(_refCharacter,"TmpShipHolder") ) return false; aref dstRef; makearef(dstRef, _refCharacter.Ship); aref srcRef; makearef(srcRef, _refCharacter.TmpShipHolder); DeleteAttribute(_refCharacter,"Ship"); CopyAttributes(dstRef,srcRef); DeleteAttribute(_refCharacter,"TmpShipHolder"); return true; } // Обменять двух персонажей кораблями //------------------------------------ void ExchangeCharacterShip(ref oneCharacter, ref twoCharacter) { object tmpObj; aref oneShip; makearef(oneShip,oneCharacter.Ship); aref twoShip; makearef(twoShip,twoCharacter.Ship); CopyAttributes(&tmpObj,oneShip); CopyAttributes(oneShip,twoShip); CopyAttributes(twoShip,&tmpObj); } void QuestProcessDialogExit() { aref one_aref = GetEventData(); aref two_aref = GetEventData(); DeleteAttribute(one_aref,"act.disableDialog"); DeleteAttribute(two_aref,"act.disableDialog"); } // Задать квест, выполняемый после выхода из диалога //--------------------------------------------------- void AddDialogExitQuest(string questName) { string attrName; aref ar; ref mc = GetMainCharacter(); if( CheckAttribute(mc,"DialogExitQuests") ) { makearef(ar,mc.DialogExitQuests); attrName = "l" + GetAttributesNum(ar); } else { attrName = "l0"; } mc.DialogExitQuests.(attrName) = questName; } void QuestDialogExitProcedure() { int i = GetEventData(); ref otherCh = GetCharacter(i); aref ar, lref; string attrName; ref mc = GetMainCharacter(); // может быть выполним какую нибудь задачу ExecuteAfterDialogTask(otherCh); ExecuteAfterDialogTask(mc); if( CheckAttribute(mc,"DialogExitQuests") ) { makearef(ar,mc.DialogExitQuests); for(i=0; i0; i++) { idx = GetPassenger(refCh,0); if(idx==-1) break; sTmp = "id"+i; arTmp.(sTmp) = idx; RemovePassenger(refCh,GetCharacter(idx)); ChangeCharacterAddress(GetCharacter(idx),"none",""); } return true; } // Восстановить запомненных ранее пассажиров и по возможности офицеров //---------------------------------------------------------------------- bool RestorePassengers(string idCharacter) { int idxCh = GetCharacterIndex(idCharacter); if(idxCh==-1) return false; ref refCh = GetCharacter(idxCh); if(!CheckAttribute(refCh,"Fellows.Old")) return false; int i,idx; aref arTmp,arCur; // Восстановление пассажиров makearef(arTmp,refCh.Fellows.Old.Passengers); for(i=0; i= 0) { if(locGroup=="") {locGroup="reload";} aref arGroup, arLocator; ref rIsland = GetIslandByIndex(iIsland); makearef(arGroup, rIsland.(locGroup)); int iGroupSize = GetAttributesNum(arGroup); for (int i=0; i