ActorBarkNotifyProcess.cpp

Go to the documentation of this file.
00001 /*
00002  *  Copyright (C) 2005-2007  The Pentagram Team
00003  *
00004  *  This program is free software; you can redistribute it and/or modify
00005  *  it under the terms of the GNU General Public License as published by
00006  *  the Free Software Foundation; either version 2 of the License, or
00007  *  (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 #include "ActorBarkNotifyProcess.h"
00021 #include "Gump.h"
00022 #include "DelayProcess.h"
00023 #include "Actor.h"
00024 #include "Animation.h"
00025 #include "Kernel.h"
00026 #include "getObject.h"
00027 
00028 #include "IDataSource.h"
00029 #include "ODataSource.h"
00030 
00031 DEFINE_RUNTIME_CLASSTYPE_CODE(ActorBarkNotifyProcess,GumpNotifyProcess);
00032 
00033 ActorBarkNotifyProcess::ActorBarkNotifyProcess()
00034         : GumpNotifyProcess()
00035 {
00036 
00037 }
00038 
00039 ActorBarkNotifyProcess::ActorBarkNotifyProcess(uint16 it)
00040         : GumpNotifyProcess(it)
00041 {
00042 
00043 }
00044 
00045 ActorBarkNotifyProcess::~ActorBarkNotifyProcess(void)
00046 {
00047 
00048 }
00049 
00050 
00051 bool ActorBarkNotifyProcess::run(const uint32)
00052 {
00053         Actor* a = getActor(item_num);
00054         if (!a) return false;
00055 
00056         if (a->isDead() || !a->hasAnim(Animation::talk))
00057                 return false;
00058 
00059         bool doAnim = true;
00060 
00061         // if not standing or talking, don't do talk animation
00062         Animation::Sequence lastanim = a->getLastAnim();
00063         if (lastanim != Animation::stand && lastanim != Animation::talk)
00064                 doAnim = false;
00065         else if (Kernel::get_instance()->getNumProcesses(item_num, 0x00F0) > 0)
00066                 // if busy, don't do talk animation
00067                 doAnim = false;
00068 
00069         // wait a short while (1-2.5 seconds) before doing the next animation
00070         // (or even if not doing the animation)
00071         Process* delayproc = new DelayProcess(30+(std::rand()%45));
00072         ProcId delaypid = Kernel::get_instance()->addProcess(delayproc);
00073 
00074         if (doAnim)
00075                 a->doAnim(Animation::talk, 8);
00076 
00077         waitFor(delaypid);
00078         return false;
00079 }
00080 
00081 void ActorBarkNotifyProcess::saveData(ODataSource* ods)
00082 {
00083         GumpNotifyProcess::saveData(ods);
00084 }
00085 
00086 bool ActorBarkNotifyProcess::loadData(IDataSource* ids, uint32 version)
00087 {
00088         if (!GumpNotifyProcess::loadData(ids, version)) return false;
00089 
00090         return true;
00091 }
00092 
00093 

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