Exemplo n.º 1
0
void DestructionSpear::execute(Ousters* pOusters, ZoneCoord_t X, ZoneCoord_t Y, OustersSkillSlot* pOustersSkillSlot, CEffectID_t CEffectID)
	throw(Error)
{
	__BEGIN_TRY

	Zone* pZone = pOusters->getZone();
	Assert(pZone != NULL);

/*	Creature* pTargetCreature = pZone->getCreature(TargetObjectID);

	if (pTargetCreature==NULL
		|| !canAttack(pOusters, pTargetCreature )
		|| pTargetCreature->isNPC())
	{
		executeSkillFailException(pOusters, getSkillType());
		return;
	}*/

/*	if (pTargetCreature->isSlayer() )
	{
		Slayer* pSlayer = dynamic_cast<Slayer*>(pTargetCreature);
		targetLevel = pSlayer->getHighestSkillDomainLevel();
	}
	else
	{
		targetLevel = pTargetCreature->getLevel();
	}*/

	SkillInput input(pOusters, pOustersSkillSlot);
	SkillOutput output;
	computeOutput(input, output);

	Item* pWeapon = pOusters->getWearItem(Ousters::WEAR_RIGHTHAND);
	if (pWeapon == NULL )
	{
		executeSkillFailException(pOusters, getSkillType());
		return;
	}

	SIMPLE_SKILL_INPUT param;
	param.SkillType     = getSkillType();
	param.SkillDamage   = output.Damage;

	param.Delay         = output.Delay;
	param.ItemClass     = Item::ITEM_CLASS_OUSTERS_CHAKRAM;
	param.STRMultiplier = 0;
	param.DEXMultiplier = 0;
	param.INTMultiplier = 0;
	param.bMagicHitRoll = false;
	param.bMagicDamage  = false;
	param.bAdd = true;

	SIMPLE_SKILL_OUTPUT result;

	int offset = 0;

	OustersSkillSlot* pMastery = pOusters->hasSkill(SKILL_DESTRUCTION_SPEAR_MASTERY);
	if (pMastery != NULL )
	{
		offset = 1;
		if (pMastery->getExpLevel() <= 15 )
			param.SkillDamage = min(70,param.SkillDamage + 10 + pMastery->getExpLevel()/3);
		else
			param.SkillDamage = min(90,param.SkillDamage + 10 + pMastery->getExpLevel()/2);
		param.Grade=4;
	}

	for (int i=-offset; i<=offset; ++i )
	for (int j=-offset; j<=offset; ++j )
		param.addMask(i, j, 100);

	g_SimpleTileMissileSkill.execute(pOusters, X, Y, pOustersSkillSlot, param, result, CEffectID);

	list<Creature*>::iterator itr = result.targetCreatures.begin();
	for (; itr != result.targetCreatures.end() ; ++itr )
	{
		Creature* pTargetCreature = *itr;
		if (pTargetCreature->getX() == X && pTargetCreature->getY() == Y )
		{
			GCModifyInformation gcMI, gcAttackerMI;
			Damage_t damage = computeElementalCombatSkill(pOusters, pTargetCreature, gcAttackerMI);
			if (damage != 0 )
			{
				::setDamage(pTargetCreature, damage, pOusters, SKILL_DESTRUCTION_SPEAR, &gcMI, &gcAttackerMI);
				if (pTargetCreature->isPC() ) pTargetCreature->getPlayer()->sendPacket(&gcMI);

				if (pTargetCreature->isDead())
				{
					int exp = computeCreatureExp(pTargetCreature, 70, pOusters);
					shareOustersExp(pOusters, exp, gcAttackerMI);
				}

				pOusters->getPlayer()->sendPacket(&gcAttackerMI);
			}
		}

		if (!pTargetCreature->isFlag(Effect::EFFECT_CLASS_DESTRUCTION_SPEAR ) && result.bSuccess )
		{
			int targetLevel = pTargetCreature->getLevel();
			int ratio = 0;

			if (input.SkillLevel <= 15 )
			{
				ratio = max(20, min(80, (int)(pOusters->getLevel() + (input.SkillLevel * 8.0 / 3.0) - targetLevel ) ));
			}
			else
			{
				ratio = max(20, min(80, (int)(pOusters->getLevel() + 20.0 + (input.SkillLevel * 4.0 / 3.0) - targetLevel ) ));
			}

			if (rand() % 100 < ratio )
			{

				EffectDestructionSpear* pEffect = new EffectDestructionSpear(pTargetCreature);
				Assert(pEffect != NULL);

				pEffect->setDamage(2 + (input.SkillLevel/3 ));
				pEffect->setNextTime(20);
				pEffect->setCasterID(pOusters->getObjectID());
				pEffect->setDeadline(output.Duration);

				if (pTargetCreature->getX() == X && pTargetCreature->getY() == Y )
					pEffect->setSteal(true);

				pTargetCreature->setFlag(Effect::EFFECT_CLASS_DESTRUCTION_SPEAR);
				pTargetCreature->addEffect(pEffect);

				GCAddEffect gcAddEffect;
				gcAddEffect.setObjectID(pTargetCreature->getObjectID());
				gcAddEffect.setEffectID(pEffect->getSendEffectClass());
				gcAddEffect.setDuration(output.Duration);

				pZone->broadcastPacket(pTargetCreature->getX(), pTargetCreature->getY(), &gcAddEffect);
			}
		}
	}

	__END_CATCH
}
Exemplo n.º 2
0
//////////////////////////////////////////////////////////////////////////////
// 아우스터즈 오브젝트 핸들러
//////////////////////////////////////////////////////////////////////////////
void MagnumSpear::execute(Ousters* pOusters, ObjectID_t TargetObjectID, OustersSkillSlot* pOustersSkillSlot, CEffectID_t CEffectID)
	throw(Error)
{
	__BEGIN_TRY

	Assert(pOusters != NULL);
	Assert(pOustersSkillSlot != NULL);

	try 
	{
		Player* pPlayer = pOusters->getPlayer();
		Zone* pZone = pOusters->getZone();
		Assert(pPlayer != NULL);
		Assert(pZone != NULL);

		Item* pWeapon = pOusters->getWearItem(Ousters::WEAR_RIGHTHAND);
		if (pWeapon == NULL || pWeapon->getItemClass() != Item::ITEM_CLASS_OUSTERS_WRISTLET || !pOusters->isRealWearingEx(Ousters::WEAR_RIGHTHAND))
		{
			executeSkillFailException(pOusters, pOustersSkillSlot->getSkillType());
			return;
		}

		Creature* pTargetCreature = pZone->getCreature(TargetObjectID);
		SkillType_t SkillType = pOustersSkillSlot->getSkillType();

		// NPC는 공격할 수가 없다.
		if (pTargetCreature==NULL
			|| !canAttack(pOusters, pTargetCreature )
			|| pTargetCreature->isNPC())
		{
			executeSkillFailException(pOusters, SkillType);
			return;
		}

		GCSkillToObjectOK1 _GCSkillToObjectOK1;
		GCSkillToObjectOK2 _GCSkillToObjectOK2;
		GCSkillToObjectOK3 _GCSkillToObjectOK3;
		GCSkillToObjectOK4 _GCSkillToObjectOK4;
		GCSkillToObjectOK5 _GCSkillToObjectOK5;
		GCSkillToObjectOK6 _GCSkillToObjectOK6;

		SkillInfo* pSkillInfo = g_pSkillInfoManager->getSkillInfo(SkillType);

		
		int HitBonus = 0;
		/*
		if (pOusters->hasRankBonus(RankBonus::RANK_BONUS_KNOWLEDGE_OF_ACID ) )
		{
			RankBonus* pRankBonus = pOusters->getRankBonus(RankBonus::RANK_BONUS_KNOWLEDGE_OF_ACID);
			Assert(pRankBonus != NULL);

			HitBonus = pRankBonus->getPoint();
		}
		*/


		int  RequiredMP  = (int)(pSkillInfo->getConsumeMP() + pOustersSkillSlot->getExpLevel()/3);
		bool bManaCheck  = hasEnoughMana(pOusters, RequiredMP);
		bool bTimeCheck  = verifyRunTime(pOustersSkillSlot);
		bool bRangeCheck = verifyDistance(pOusters, pTargetCreature, pSkillInfo->getRange());
		bool bHitRoll    = HitRoll::isSuccessMagic(pOusters, pSkillInfo, pOustersSkillSlot, HitBonus);
		bool bCanHit     = canHit(pOusters, pTargetCreature, SkillType);
		bool bPK         = verifyPK(pOusters, pTargetCreature);
		bool bEffect	 = pTargetCreature->isFlag(Effect::EFFECT_CLASS_MAGNUM_SPEAR);

		if (bManaCheck && bTimeCheck && bRangeCheck && bHitRoll && bCanHit && bPK && !bEffect)
		{
			ZoneCoord_t oustX   = pOusters->getX();
			ZoneCoord_t oustY   = pOusters->getY();
			ZoneCoord_t targetX = pTargetCreature->getX();
			ZoneCoord_t targetY = pTargetCreature->getY();

			decreaseMana(pOusters, RequiredMP, _GCSkillToObjectOK1);
			bool bCanSeeCaster = canSee(pTargetCreature, pOusters);

			SkillInput input(pOusters, pOustersSkillSlot);
			SkillOutput output;
			computeOutput(input, output);

			Damage_t Damage = output.Damage;

			OustersSkillSlot* pMastery = pOusters->hasSkill(SKILL_MAGNUM_SPEAR_MASTERY);
			if (pMastery != NULL )
			{
				Damage += (pMastery->getExpLevel() * 5 / 3 ) + 15;
			}
			else
			{
				bool dummy;
				computeCriticalBonus(pOusters, getSkillType(), Damage, dummy);
			}

			EffectMagnumSpear* pEffect = new EffectMagnumSpear(pTargetCreature);
			pEffect->setDamage(computeOustersMagicDamage(pOusters, pTargetCreature, Damage, SKILL_MAGNUM_SPEAR ));

			int spearNum = 2;

			if (pOustersSkillSlot->getExpLevel() <= 15 )
				spearNum = 2;
			else if (pOustersSkillSlot->getExpLevel() < 30 )
				spearNum = 4;
			else if (pOustersSkillSlot->getExpLevel() == 30 )
				spearNum = 6;

			int Grade = spearNum/2 - 1;

			if (pMastery != NULL ) 
			{
				spearNum = 1;
				Grade = 4;
				output.Delay = 20;
			}

			pEffect->setTimes(spearNum);
			pEffect->setTick(5);
			pEffect->setNextTime(5);
			pEffect->setCasterOID(pOusters->getObjectID());

			pTargetCreature->addEffect(pEffect);
			pTargetCreature->setFlag(pEffect->getEffectClass());

			_GCSkillToObjectOK1.setSkillType(SkillType);
			_GCSkillToObjectOK1.setCEffectID(CEffectID);
			_GCSkillToObjectOK1.setTargetObjectID(TargetObjectID);
			_GCSkillToObjectOK1.setDuration(0);
			_GCSkillToObjectOK1.setGrade(Grade);
		
			_GCSkillToObjectOK2.setObjectID(pOusters->getObjectID());
			_GCSkillToObjectOK2.setSkillType(SkillType);
			_GCSkillToObjectOK2.setDuration(0);
			_GCSkillToObjectOK2.setGrade(Grade);
			
			_GCSkillToObjectOK3.setObjectID(pOusters->getObjectID());
			_GCSkillToObjectOK3.setSkillType(SkillType);
			_GCSkillToObjectOK3.setTargetXY(targetX, targetY);
			_GCSkillToObjectOK3.setGrade(Grade);
		
			_GCSkillToObjectOK4.setSkillType(SkillType);
			_GCSkillToObjectOK4.setTargetObjectID(TargetObjectID);
			_GCSkillToObjectOK4.setGrade(Grade);

			_GCSkillToObjectOK5.setObjectID(pOusters->getObjectID());
			_GCSkillToObjectOK5.setTargetObjectID(TargetObjectID);
			_GCSkillToObjectOK5.setSkillType(SkillType);
			_GCSkillToObjectOK5.setGrade(Grade);
			
			_GCSkillToObjectOK6.setXY(oustX, oustY);
			_GCSkillToObjectOK6.setSkillType(SkillType);
			_GCSkillToObjectOK6.setDuration(0);
			_GCSkillToObjectOK6.setGrade(Grade);

			pPlayer->sendPacket(&_GCSkillToObjectOK1);
		
			Player* pTargetPlayer = NULL;
			if (pTargetCreature->isPC()) 
			{
				pTargetPlayer = pTargetCreature->getPlayer();
				Assert(pTargetPlayer != NULL);
				if (bCanSeeCaster) pTargetPlayer->sendPacket(&_GCSkillToObjectOK2);
				else pTargetPlayer->sendPacket(&_GCSkillToObjectOK6);
			} 
			else 
			{
				Monster* pMonster = dynamic_cast<Monster*>(pTargetCreature);
				pMonster->addEnemy(pOusters);
			}

			list<Creature*> cList;
			cList.push_back(pOusters);
			cList.push_back(pTargetCreature);

			cList = pZone->broadcastSkillPacket(oustX, oustY, targetX, targetY, &_GCSkillToObjectOK5, cList);
			
			pZone->broadcastPacket(oustX, oustY,  &_GCSkillToObjectOK3 , cList);
			pZone->broadcastPacket(targetX, targetY,  &_GCSkillToObjectOK4 , cList);

			pOustersSkillSlot->setRunTime(output.Delay);

		}
		else 
		{
			executeSkillFailNormal(pOusters, getSkillType(), pTargetCreature);
		}
	} 
	catch (Throwable & t) 
	{
		executeSkillFailException(pOusters, getSkillType());
	}

	__END_CATCH
}
Exemplo n.º 3
0
void CGDownSkillHandler::execute (CGDownSkill* pPacket , Player* pPlayer)
throw(ProtocolException, Error)
{
    __BEGIN_TRY __BEGIN_DEBUG_EX

#ifdef __GAME_SERVER__

    Assert(pPacket != NULL);
    Assert(pPlayer != NULL);

    GamePlayer* pGamePlayer = dynamic_cast<GamePlayer*>(pPlayer);
    Assert(pGamePlayer != NULL);

    PlayerCreature* pPC = dynamic_cast<PlayerCreature*>(pGamePlayer->getCreature());
    Assert(pPC != NULL);

    SkillType_t targetSkillType = pPacket->getSkillType();

    GCDownSkillFailed failpkt;
    failpkt.setSkillType(targetSkillType);

    if (!pPC->isOusters() )
    {
        failpkt.setDesc(NOT_OUSTERS);
        pPlayer->sendPacket(&failpkt);

        return;
    }

    Ousters* pOusters = dynamic_cast<Ousters*>(pPC);
    Assert(pOusters != NULL);
    OustersSkillSlot* pTargetSkillSlot = pOusters->getSkill(targetSkillType);

    if (pTargetSkillSlot == NULL )
    {
        failpkt.setDesc(HAVE_NOT_SKILL);
        pPlayer->sendPacket(&failpkt);
        return;
    }

    SkillInfo* pTargetSkillInfo = NULL;

    try
    {
        pTargetSkillInfo = g_pSkillInfoManager->getSkillInfo(targetSkillType);
    }
    catch(Exception& e)
    {
        failpkt.setDesc(INVALID_SKILL);
        pPlayer->sendPacket(&failpkt);

        return;
    }

    if (pTargetSkillSlot->getExpLevel() <= 1 )
    {
        if (!pTargetSkillInfo->canDelete() )
        {
            failpkt.setDesc(TOO_LOW);
            pPlayer->sendPacket(&failpkt);
            return;
        }

        list<SkillType_t>& rRequiredSkills = pTargetSkillInfo->getRequiredSkills();
        list<SkillType_t>::iterator itr = rRequiredSkills.begin();

        for (; itr != rRequiredSkills.end(); ++itr )
        {
            if (pOusters->hasSkill(*itr) != NULL )
            {
                bool canDrop = false;
                SkillInfo* pFollowingSkillInfo = g_pSkillInfoManager->getSkillInfo(*itr);
                list<SkillType_t>& rRequireSkills = pFollowingSkillInfo->getRequireSkills();
                list<SkillType_t>::iterator itr2 = rRequireSkills.begin();
                for (; itr2 != rRequireSkills.end(); ++itr2 )
                {
                    if ((*itr2) != targetSkillType && pOusters->hasSkill(*itr2) != NULL )
                    {
                        SkillInfo* pAlternativeSkillInfo = g_pSkillInfoManager->getSkillInfo(*itr2);
                        if (getSkillMapID((ElementalDomain)pAlternativeSkillInfo->getElementalDomain()) == getSkillMapID((ElementalDomain)pTargetSkillInfo->getElementalDomain()) )
                            canDrop = true;
                    }
                }

                if (!canDrop )
                {
                    failpkt.setDesc(CANNOT_DROP_SKILL);
                    pPlayer->sendPacket(&failpkt);
                    return;
                }
            }
        }
    }

    /*	if (pTargetSkillSlot->getExpLevel() >= 30 )
    	{
    		failpkt.setDesc(TOO_HIGH);
    		pPlayer->sendPacket(&failpkt);
    		return;
    	}*/

    Assert(pTargetSkillInfo != NULL);

    int backPoint = pTargetSkillInfo->getLevelUpPoint();
    Price_t downPrice = (int)(backPoint * pow(pOusters->getLevel(),1.3) * 200);

    if (pTargetSkillSlot->getExpLevel() <= 1 )
    {
        downPrice *= 5;
        if (downPrice == 0 ) downPrice = 1000000;
    }

    if (pOusters->getGold() < downPrice )
    {
        failpkt.setDesc(NOT_ENOUGH_MONEY);
        pPlayer->sendPacket(&failpkt);

        return;
    }

    pOusters->decreaseGoldEx(downPrice);
    pTargetSkillSlot->setExpLevel(pTargetSkillSlot->getExpLevel() - 1);
    pTargetSkillSlot->save();
    if (pTargetSkillSlot->getExpLevel() <= 0 )
    {
        pTargetSkillSlot->destroy(pOusters->getName());
        backPoint = pTargetSkillInfo->getSkillPoint();
        pOusters->removeSkill(targetSkillType);
    }

    pOusters->setSkillBonus(pOusters->getSkillBonus() + backPoint);
    char query[50];
    sprintf(query, "SkillBonus=%d", pOusters->getSkillBonus());
    pOusters->tinysave(query);

    GCDownSkillOK okpkt;
    okpkt.setSkillType(targetSkillType);
    pPlayer->sendPacket(&okpkt);

    GCModifyInformation gcMI;
    gcMI.addLongData(MODIFY_GOLD, pOusters->getGold());
    gcMI.addShortData(MODIFY_SKILL_BONUS_POINT, pOusters->getSkillBonus());

    switch (targetSkillType )
    {
    case SKILL_HIDE_SIGHT:
    {
        OUSTERS_RECORD prev;
        pOusters->getOustersRecord(prev);
        pOusters->initAllStat();
        pOusters->sendRealWearingInfo();
        pOusters->addModifyInfo(prev, gcMI);
    }
    break;

    default :
        break;
    }

    pPlayer->sendPacket(&gcMI);

#endif	// __GAME_SERVER__

    __END_DEBUG_EX __END_CATCH
}