/TGame/TCommon/Gene/Status/GEDOT.cpp
http://awoe.googlecode.com/ · C++ · 172 lines · 132 code · 33 blank · 7 comment · 22 complexity · 0bb9b9b00a06540c6669b16eb6a1e8f8 MD5 · raw file
- ///////////////////////////////////////////////////////////////////////////////////////////////////
- // GEDOT.cpp
- // 2010?1?20?
- // Copyright ?2007, 2010, 8DWorld, Inc. All rights reserved.
- //
- //
- ///////////////////////////////////////////////////////////////////////////////////////////////////
-
-
-
- #include "stdafx.h"
- #include "GEDOT.h"
- #include "Entity/EntityIf.h"
- #include "Combat/CombatSysIf.h"
- #include "Gene/GeneCreateDataIf.h"
-
- GEDOT::GEDOT()
- {
- }
-
-
- bool
- GEDOT::onAttach()
- {
- if (! __super::onAttach())
- {
- return false;
- }
-
- if (m_nTTL<=0 || m_wpSData->getDataZ()<=0)
- {
- return false;
- }
-
- m_nTimeInterval = m_wpSData->getData(ArgIdx_IntervalTime);
- if (m_nTimeInterval<0)
- {
- m_nTimeInterval = 1000;
- }
-
- m_nDamageRemain = m_wpSData->getData(ArgIdx_FullBaseDamage);
-
- CalculateDamage(m_nDamageRemain);
-
- m_nDamagePerTime = m_nDamageRemain * m_nTimeInterval / m_wpSData->getDataZ();
-
- if (m_nDamagePerTime==0)
- {
- LOG_WARN("Wain, Damage Per Time is zeo in Dot\n");
- }
-
- m_nTimeNextDamage = m_wpSData->getDataZ() - m_nTimeInterval;
-
- if (m_wpSData->getDataZ()>0 && m_wpSData->getDataZ()!=m_nTTL)
- {
- while(m_nTimeNextDamage>=m_nTTL)
- {
- m_nTimeNextDamage -= m_nTimeInterval;
- m_nDamageRemain -= m_nDamagePerTime;
- }
- }
-
- return true;
- }
-
-
- bool
- GEDOT::onUpdate(int nElapse)
- {
- __super::onUpdate(nElapse);
-
- if (m_nTTL<=0)
- {
- m_wpCombat->updateHP(m_nDamageRemain);
- return false;
- }
- else if (m_nTTL<=m_nTimeNextDamage)
- {
- m_nDamageRemain -= m_nDamagePerTime;
- m_nTimeNextDamage -= m_nTimeInterval;
- m_wpCombat->updateHP(m_nDamagePerTime);
- }
- return true;
- }
-
- bool
- GEDOT::CalculateDamage(int& nD)
- {
- if (nD<0)
- {
- return true;
- }
- else if (nD>0)
- {
- nD = -nD;
- }
- else
- {
- nD = -1;
- }
- return false;
- }
-
-
- GEDOT_Element::GEDOT_Element(short nElemID)
- :m_nWhichElement(nElemID), m_nTheElementValue(0), m_nTheCaster(0)
- {
-
- }
-
- bool
- GEDOT_Element::onInit(IGeneCreateData& createData)
- {
- if (m_nWhichElement<Combat::CBP_Start || m_nWhichElement>=Combat::CBP_End)
- {
- m_nWhichElement = Combat::CBP_Fire;
- }
-
-
- m_nTheCaster = createData.getSrcEntityID();
- IEntity* pCaster = createData.getSrcEntity();
- if (pCaster && pCaster->getCombatSys())
- {
- m_nTheElementValue = 0;
- }
- else
- {
- m_nTheElementValue = 0;
- }
- return true;
- }
-
-
-
- bool GEDOT_Element::onAttach()
- {
- if (__super::onAttach())
- {
- m_nDamageRatioOnElement = m_wpSData->getData(ArgIdx_DamageRatio_OnElement);
-
- if (m_nDamageRatioOnElement<=0)
- {
- m_nDamageRatioOnElement = 1;
- }
- return true;
- }
- else
- {
- return false;
- }
- }
-
-
- bool GEDOT_Element::CalculateDamage(int& nD)
- {
- int nDamage = m_nDamageRatioOnElement * m_nTheElementValue / 1000;
-
- if (nD<=0)
- {
- nD = nD - nDamage;
- }
- else
- {
- nD = -nD - nDamage;
- }
-
- if (nD>=0)
- {
- nD = -1;
- }
- return true;
- }