StartU8Process.cpp

Go to the documentation of this file.
00001 /*
00002 Copyright (C) 2005 The Pentagram team
00003 
00004 This program is free software; you can redistribute it and/or
00005 modify it under the terms of the GNU General Public License
00006 as published by the Free Software Foundation; either version 2
00007 of the License, or (at your option) any later version.
00008 
00009 This program is distributed in the hope that it will be useful,
00010 but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 GNU General Public License for more details.
00013 
00014 You should have received a copy of the GNU General Public License
00015 along with this program; if not, write to the Free Software
00016 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00017 */
00018 
00019 #include "pent_include.h"
00020 
00021 #include "StartU8Process.h"
00022 #include "Game.h"
00023 #include "LoopScript.h"
00024 #include "UCList.h"
00025 #include "CurrentMap.h"
00026 #include "Egg.h"
00027 #include "CameraProcess.h"
00028 #include "World.h"
00029 #include "GUIApp.h"
00030 #include "Kernel.h"
00031 #include "MenuGump.h"
00032 #include "SettingManager.h"
00033 #include "getObject.h"
00034 
00035 #include "IDataSource.h"
00036 #include "ODataSource.h"
00037 
00038 // p_dynamic_cast stuff
00039 DEFINE_RUNTIME_CLASSTYPE_CODE(StartU8Process,Process);
00040 
00041 StartU8Process::StartU8Process() : Process()
00042 {
00043         init = false;
00044 
00045         SettingManager::get_instance()->get("skipstart", skipstart);
00046 }
00047 
00048 
00049 bool StartU8Process::run(const uint32 /*framenum*/)
00050 {
00051         if (!skipstart && !init) {
00052                 init = true;
00053                 ProcId moviepid = Game::get_instance()->playIntroMovie();
00054                 Process* movieproc = Kernel::get_instance()->getProcess(moviepid);
00055                 if (movieproc) {
00056                         waitFor(movieproc);
00057                         return false;
00058                 }
00059         }
00060 
00061         CurrentMap* currentmap = World::get_instance()->getCurrentMap();
00062         UCList uclist(2);
00063 
00064         if (!skipstart) {
00065                 LOOPSCRIPT(script, LS_AND(LS_SHAPE_EQUAL1(73), LS_Q_EQUAL(36)));
00066                 currentmap->areaSearch(&uclist, script, sizeof(script),
00067                                                            0, 256, false, 16188, 7500);
00068                 if (uclist.getSize() < 1) {
00069                         perr << "Unable to find FIRST egg!" << std::endl;
00070                         return false;
00071                 }
00072         
00073                 uint16 objid = uclist.getuint16(0);
00074                 Egg* egg = p_dynamic_cast<Egg*>(getObject(objid));
00075                 sint32 ix, iy, iz;
00076                 egg->getLocation(ix,iy,iz);
00077                 // Center on egg
00078                 CameraProcess::SetCameraProcess(new CameraProcess(ix,iy,iz));
00079                 egg->hatch();
00080         }
00081 
00082         // Music Egg
00083         // Item 2145 (class Item, shape 562, 0, (11551,2079,48) q:52, m:0, n:0, f:2000, ef:2)
00084         uclist.free();
00085         LOOPSCRIPT(musicscript, LS_SHAPE_EQUAL1(562));
00086         currentmap->areaSearch(&uclist, musicscript, sizeof(musicscript),
00087                                                    0, 256, false, 11551, 2079);
00088 
00089         if (uclist.getSize() < 1) {
00090                 perr << "Unable to find MUSIC egg!" << std::endl;
00091         }
00092         else {
00093                 ObjId objid = uclist.getuint16(0);
00094                 Item *musicEgg = getItem(objid);
00095                 musicEgg->callUsecodeEvent_cachein();
00096         }
00097 
00098         if (!skipstart)
00099                 MenuGump::inputName();
00100         else
00101                 GUIApp::get_instance()->setAvatarInStasis(false);
00102 
00103 
00104         terminate();
00105 
00106         return false;
00107 }
00108 
00109 void StartU8Process::saveData(ODataSource* ods)
00110 {
00111         CANT_HAPPEN();
00112 
00113         Process::saveData(ods);
00114 }
00115 
00116 bool StartU8Process::loadData(IDataSource* ids, uint32 version)
00117 {
00118         if (!Process::loadData(ids, version)) return false;
00119 
00120         return true;
00121 }

Generated on Fri Jul 27 22:27:40 2007 for pentagram by  doxygen 1.4.7