![]() |
|
|
|
|
#1 |
|
Guest
Posts: n/a
|
first, I would like to thank kuroi to answer my PM, I would like to show my second code does not expect a professional code that I'm learning at the moment:
#include "COPCondition_have_cp.h" CSKILL_OPCOND_INSTALL_VMT(COPCondition_have_cp); INT32 nCOPCondition_have_cp = 0; bool COPCondition_have_cp::CanUse(CCreature *pSkillUser, CObject *pTargetObject) { L2SERVER_SHARED_GUARD(nCOPCondition_have_cp); TLS_TRACE_BEGIN; User *caster = (User*)pSkillUser; if(caster->IsValidUser()) { caster->Lock(__FILEW__, __LINE__); int nCurrentCpPer = (caster->SD->fCP / caster->SD->fMaxCP) * 100; caster->Unlock(); if(nCurrentCpPer >= nCpAmount) { return true; } return false; } TLS_TRACE_END; return false; }; #include "Global.H" class CObject; class CCreature; class CSkillInfo; class COPCondition_have_cp : public CBaseOperateCondition { int nCpAmount; public: virtual bool CanUse(CCreature *pSkillUser, CObject *pTargetObject); virtual void Unknown1() { }; virtual void Unknown2() { }; /* Extended Methods */ COPCondition_have_cp(); COPCondition_have_cp(int arg1) { nCpAmount = arg1; }; }; #include "CSkillEffect_i_cp_per_max.h" CSKILL_EFFECT_INSTALL_VMT(CSkillEffect_i_cp_per_ma x) INT32 nCSkillEffect_i_cp_per_maxInstant = 0; /* You dont need to use locks in this skill effect- ncsoft didnt use in i_target_cancel_instant */ void CSkillEffect_i_cp_per_max::Instant(CCreature *pSkillUser, CObject *pTarget, CSkillInfo *pSkillInfo, CSkillAction2 *pAction, double distance) { L2SERVER_SHARED_GUARD(nCSkillEffect_i_cp_per_maxIn stant); TLS_TRACE_BEGIN; User *pUser = (User*)pSkillUser; if(pUser->IsValidUser()) { pUser->Lock(__FILEW__, __LINE__); double nTotalCp = pUser->SD->fMaxCP; double nActualCp = pUser->SD->fCP; pUser->SD->fCP = ((nTotalCp * nPer)/100.0)+nActualCp; pUser->Unlock(); CStatusUpdate *pStatus = new CStatusUpdate(pUser->SD->fCP); pStatus->AddField(STATUSUPDATE_CUR_CP, pUser->SD->fCP); pStatus->ProcessUpdate(pUser); delete pStatus; } TLS_TRACE_END; }; #include "Global.H" class CObject; class CCreature; class CSkillInfo; class CSkillEffect_i_cp_per_max : public CBaseSkillEffect { // Parameters int nPer; public: virtual void CalcSuccess(CCreature *pSkillUser, CObject *pTarget, CSkillInfo *pSkillInfo, CSkillAction2 *pAction) {}; virtual void Instant(CCreature *pSkillUser, CObject *pTarget, CSkillInfo *pSkillInfo, CSkillAction2 *pAction, double distance); virtual void Unk() {}; virtual void Tick() {}; virtual double Unk2() { return 0.0; }; virtual bool CheckPumpCondition(CObject* pTarget) { return true; }; virtual void Pump(CObject* pTarget, CSkillInfo* pSkillInfo) {}; virtual bool Consume(CCreature *pCreature, double param2) { return true; }; virtual bool CheckResisted() { return false; }; /* Extended VMT */ CSkillEffect_i_cp_per_max(bool bInstallVMT); CSkillEffect_i_cp_per_max(int arg1) { nPer = arg1; }; and here is where I need your help more, kuroi told me to use iterators, but I do not understand, if someone could help me with this I would appreciate #include "COPCondition_have_debuff.h" CSKILL_OPCOND_INSTALL_VMT(COPCondition_have_debuff ); INT32 nCOPCondition_have_abnormal = 0; bool COPCondition_have_debuff::CanUse(CCreature *pSkillUser, CObject *pTargetObject) { L2SERVER_SHARED_GUARD(nCOPCondition_have_abnormal) ; TLS_TRACE_BEGIN; User *caster = (User*)pSkillUser; CCreature *target = (CCreature*)pTargetObject; if(caster->IsValidUser() && caster->IsValidCreature()) { bool hasAbnormal = foundDebuff(target, debuff); if(hasAbnormal == true) { return true; } else { return false; } } TLS_TRACE_END; }; bool COPCondition_have_debuff::foundDebuff(CCreature *pCreature, int SkillId){ for(int i=0;i<pCreature->vBuff.size();i++) { if(SkillId == pCreature->vBuff[i].pSkillInfo->skill_id) return true; } return false; } #include "Global.H" class CObject; class CCreature; class CSkillInfo; class COPCondition_have_debuff : public CBaseOperateCondition { int debuff; public: virtual bool CanUse(CCreature *pSkillUser, CObject *pTargetObject); virtual bool foundDebuff(CCreature *pTarget, int SkillId); virtual void Unknown1() { }; virtual void Unknown2() { }; /* Extended Methods */ COPCondition_have_debuff(); COPCondition_have_debuff(int arg1) { debuff = arg1; }; }; hopefully can help someone who wants to learn, angrax. PD: if someone find errors plis post the fix. Версия форума 2009–2010. Восстановлено из публичного снимка Wayback Machine. Тема могла сохраниться частично. Время показано по часам снимка; часовой пояс не установлен. Дата в снимке: 06-29-2009, 08:49 PM. Открыть источник. |
|
|