📄 effectalignmentrecovery.cpp
字号:
//////////////////////////////////////////////////////////////////////////////// Filename : EffectAlignmentRecovery.cpp// Written by : elca// Description : //////////////////////////////////////////////////////////////////////////////#include "Assert.h"#include "EffectAlignmentRecovery.h"#include "Zone.h"#include "DB.h"#include "Slayer.h"#include "Vampire.h"#include "Ousters.h"#include "Player.h"#include "AlignmentManager.h"#include "Gpackets/GCModifyInformation.h"#include "Gpackets/GCOtherModifyInfo.h"//////////////////////////////////////////////////////////////////////////////// class EffectAlignmentRecovery member methods//////////////////////////////////////////////////////////////////////////////EffectAlignmentRecovery::EffectAlignmentRecovery () throw (Error){ __BEGIN_TRY // 辑滚 傈侩 Effect捞促. by sigi. 2002.11.14 m_bBroadcastingEffect = false; __END_CATCH}EffectAlignmentRecovery::EffectAlignmentRecovery (Zone* pZone , ZoneCoord_t x , ZoneCoord_t y , Creature* pCreature , Turn_t delay) throw (Error): Effect(pZone,x,y,pCreature,delay) { __BEGIN_TRY Assert(pZone != NULL); Assert(pCreature != NULL); Assert(getZone() != NULL); Assert(getTarget() != NULL); // 辑滚 傈侩 Effect捞促. by sigi. 2002.11.14 m_bBroadcastingEffect = false; __END_CATCH}EffectAlignmentRecovery::~EffectAlignmentRecovery () throw (Error){ __BEGIN_TRY __END_CATCH}void EffectAlignmentRecovery::affect() throw(Error){ __BEGIN_TRY setNextTime(m_Delay); Creature* pCreature = dynamic_cast<Creature*>(m_pTarget); Assert(pCreature != NULL); affect(pCreature); __END_CATCH}void EffectAlignmentRecovery::affect(Creature* pCreature) throw(Error){ __BEGIN_TRY Assert(pCreature != NULL); Assert(pCreature->isPC()); Timeval CurrentTime; getCurrentTime(CurrentTime); GCModifyInformation gcModifyInformation; Alignment_t CurrentAlignment = 0; Alignment_t NewAlignment = 0; if (pCreature->isSlayer()) { Slayer* pSlayer = dynamic_cast<Slayer*>(pCreature); Assert(pSlayer != NULL); if (m_Period != 0) { // 敲饭弊 吧蓖 pSlayer->setFlag(Effect::EFFECT_CLASS_ALIGNMENT_RECOVERY); // 茄 畔俊 倔付唱 雀汗 矫懦 巴牢啊. CurrentAlignment = pSlayer->getAlignment(); NewAlignment = min(10000, (int)(CurrentAlignment + m_AlignmentQuantity)); pSlayer->setAlignment(NewAlignment); gcModifyInformation.addLongData(MODIFY_ALIGNMENT, NewAlignment); pSlayer->getPlayer()->sendPacket( &gcModifyInformation ); WORD AlignmentSaveCount = pSlayer->getAlignmentSaveCount(); if (AlignmentSaveCount > ALIGNMENT_SAVE_PERIOD) { StringStream msg; msg << "Alignment = " << NewAlignment; pSlayer->tinysave(msg.toString()); AlignmentSaveCount = 0; } else AlignmentSaveCount++; pSlayer->setAlignmentSaveCount(AlignmentSaveCount); } else { // unaffect窍搁辑 菩哦捞 朝酒哎 抛聪鳖.... setDeadline(0); } m_Period--; } else if (pCreature->isVampire()) { Vampire* pVampire = dynamic_cast<Vampire*>(pCreature); Assert(pVampire != NULL); if (m_Period != 0) { // 敲饭弊 吧蓖 pVampire->setFlag(Effect::EFFECT_CLASS_ALIGNMENT_RECOVERY); // 茄 畔俊 倔付唱 雀汗 矫懦 巴牢啊. CurrentAlignment = pVampire->getAlignment(); NewAlignment = min(10000, CurrentAlignment + m_AlignmentQuantity); pVampire->setAlignment(NewAlignment); gcModifyInformation.addLongData(MODIFY_ALIGNMENT, NewAlignment); pVampire->getPlayer()->sendPacket( &gcModifyInformation ); WORD AlignmentSaveCount = pVampire->getAlignmentSaveCount(); if (AlignmentSaveCount > ALIGNMENT_SAVE_PERIOD) { StringStream msg; msg << "Alignment = " << NewAlignment; pVampire->tinysave(msg.toString()); AlignmentSaveCount = 0; } else AlignmentSaveCount++; pVampire->setAlignmentSaveCount(AlignmentSaveCount); } else { // unaffect窍搁辑 菩哦捞 朝酒哎 抛聪鳖.... setDeadline(0); } m_Period--; } else if (pCreature->isOusters()) { Ousters* pOusters = dynamic_cast<Ousters*>(pCreature); Assert(pOusters != NULL); if (m_Period != 0) { // 敲饭弊 吧蓖 pOusters->setFlag(Effect::EFFECT_CLASS_ALIGNMENT_RECOVERY); // 茄 畔俊 倔付唱 雀汗 矫懦 巴牢啊. CurrentAlignment = pOusters->getAlignment(); NewAlignment = min(10000, CurrentAlignment + m_AlignmentQuantity); pOusters->setAlignment(NewAlignment); gcModifyInformation.addLongData(MODIFY_ALIGNMENT, NewAlignment); pOusters->getPlayer()->sendPacket( &gcModifyInformation ); WORD AlignmentSaveCount = pOusters->getAlignmentSaveCount(); if (AlignmentSaveCount > ALIGNMENT_SAVE_PERIOD) { StringStream msg; msg << "Alignment = " << NewAlignment; pOusters->tinysave(msg.toString()); AlignmentSaveCount = 0; } else AlignmentSaveCount++; pOusters->setAlignmentSaveCount(AlignmentSaveCount); } else { // unaffect窍搁辑 菩哦捞 朝酒哎 抛聪鳖.... setDeadline(0); } m_Period--; } else { return; // 奴 狼固绰 绝瘤父.. } // 己氢 窜拌啊 官差搁 促弗 荤恩甸俊霸档 舅妨拎具 茄促. by sigi. 2002.12.28 Alignment beforeAlignment = g_pAlignmentManager->getAlignmentType(CurrentAlignment); Alignment afterAlignment = g_pAlignmentManager->getAlignmentType(NewAlignment); if (beforeAlignment!=afterAlignment) { GCOtherModifyInfo gcOtherModifyInfo; gcOtherModifyInfo.setObjectID(pCreature->getObjectID()); gcOtherModifyInfo.addShortData(MODIFY_ALIGNMENT, NewAlignment); Zone* pZone = pCreature->getZone(); // 2003.1.10 Assert(pZone!=NULL); pZone->broadcastPacket(pCreature->getX(), pCreature->getY(), &gcOtherModifyInfo, pCreature); } __END_CATCH}void EffectAlignmentRecovery::affect (Zone* pZone , ZoneCoord_t x , ZoneCoord_t y , Object* pTarget) throw (Error){ __BEGIN_TRY throw UnsupportedError(); __END_CATCH}void EffectAlignmentRecovery::unaffect() throw(Error){ __BEGIN_TRY Creature* pCreature = dynamic_cast<Creature*>(m_pTarget); Assert(pCreature != NULL); unaffect(pCreature); __END_CATCH}void EffectAlignmentRecovery::unaffect(Creature* pCreature) throw(Error){ __BEGIN_TRY Assert(pCreature != NULL); if (pCreature->isSlayer()) { Slayer* pSlayer = dynamic_cast<Slayer*>(pCreature); Assert(pSlayer != NULL); Zone* pZone = pSlayer->getZone(); Assert(pZone != NULL); if (m_Period != 0) { // 茄 畔俊 倔付唱 雀汗 矫懦 巴牢啊. Alignment_t CurrentAlignment = pSlayer->getAlignment(); Alignment_t NewAlignment = min(10000, (int)(CurrentAlignment + m_AlignmentQuantity* m_Period)); pSlayer->setAlignment(NewAlignment); WORD AlignmentSaveCount = pSlayer->getAlignmentSaveCount(); if (AlignmentSaveCount == 10) { StringStream msg; msg << "Alignment = " << NewAlignment; pSlayer->tinysave(msg.toString()); AlignmentSaveCount = 0; } else AlignmentSaveCount++; pSlayer->setAlignmentSaveCount(AlignmentSaveCount); } // 泅犁 Alignment甫 宏肺靛某胶泼茄促. // 捞力 雀汗捞 场车唱绰 巴阑 舅府档废 茄促. // 磊脚俊霸 刚历 GCModifyInformation gcModifyInformation; gcModifyInformation.addLongData(MODIFY_ALIGNMENT, pSlayer->getAlignment()); pSlayer->getPlayer()->sendPacket(&gcModifyInformation); // 林函荤恩俊霸档 公攫啊甫 朝妨拎具 茄促. // 菩哦阑 货肺 父甸绢具摆瘤.. pSlayer->removeFlag(Effect::EFFECT_CLASS_ALIGNMENT_RECOVERY); } else if (pCreature->isVampire()) { Vampire* pVampire = dynamic_cast<Vampire*>(pCreature); //Zone* pZone = pVampire->getZone(); if (m_Period != 0) { // 茄 畔俊 倔付唱 雀汗 矫懦 巴牢啊. Alignment_t CurrentAlignment = pVampire->getAlignment(); Alignment_t NewAlignment = min(10000, (int)(CurrentAlignment + m_AlignmentQuantity* m_Period)); WORD AlignmentSaveCount = pVampire->getAlignmentSaveCount(); if (AlignmentSaveCount == 10) { StringStream msg; msg << "Alignment = " << NewAlignment; pVampire->tinysave(msg.toString()); AlignmentSaveCount = 0; } else AlignmentSaveCount++; pVampire->setAlignmentSaveCount(AlignmentSaveCount); } // 泅犁 Alignment甫 宏肺靛某胶泼茄促. // 捞力 雀汗捞 场车唱绰 巴阑 舅府档废 茄促. // 磊脚俊霸 刚历 GCModifyInformation gcModifyInformation; gcModifyInformation.addLongData(MODIFY_ALIGNMENT, pVampire->getAlignment()); pVampire->getPlayer()->sendPacket(&gcModifyInformation); // 林函荤恩俊霸档.. pVampire->removeFlag(Effect::EFFECT_CLASS_ALIGNMENT_RECOVERY); } else if (pCreature->isOusters()) { Ousters* pOusters = dynamic_cast<Ousters*>(pCreature); //Zone* pZone = pOusters->getZone(); if (m_Period != 0) { // 茄 畔俊 倔付唱 雀汗 矫懦 巴牢啊. Alignment_t CurrentAlignment = pOusters->getAlignment(); Alignment_t NewAlignment = min(10000, (int)(CurrentAlignment + m_AlignmentQuantity* m_Period)); WORD AlignmentSaveCount = pOusters->getAlignmentSaveCount(); if (AlignmentSaveCount == 10) { StringStream msg; msg << "Alignment = " << NewAlignment; pOusters->tinysave(msg.toString()); AlignmentSaveCount = 0; } else AlignmentSaveCount++; pOusters->setAlignmentSaveCount(AlignmentSaveCount); } // 泅犁 Alignment甫 宏肺靛某胶泼茄促. // 捞力 雀汗捞 场车唱绰 巴阑 舅府档废 茄促. // 磊脚俊霸 刚历 GCModifyInformation gcModifyInformation; gcModifyInformation.addLongData(MODIFY_ALIGNMENT, pOusters->getAlignment()); pOusters->getPlayer()->sendPacket(&gcModifyInformation); // 林函荤恩俊霸档.. pOusters->removeFlag(Effect::EFFECT_CLASS_ALIGNMENT_RECOVERY); } __END_CATCH}void EffectAlignmentRecovery::unaffect (Zone* pZone , ZoneCoord_t x , ZoneCoord_t y , Object* pTarget) throw (Error){ __BEGIN_TRY __END_CATCH}string EffectAlignmentRecovery::toString () const throw (){ __BEGIN_TRY StringStream msg; if (m_pZone) { msg << "EffectAlignmentRecovery(" << "ZoneID:" << (int)m_pZone->getZoneID() << ",X:" << (int)getX() << ",Y:" << (int)getY(); } if (m_pTarget) { msg << ",Target:" << m_pTarget->toString(); } else { msg << ",Target:NULL"; } msg << ",Deadline:" << (int)m_Deadline.tv_sec << "." << (int)m_Deadline.tv_usec << ")"; return msg.toString(); __END_CATCH}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -