示例#1
0
//-----------------------------------------------
// CFaberPhrase execute
//-----------------------------------------------
void  CFaberPhrase::execute()
{
	H_AUTO(CFaberPhrase_execute);

	CCharacter* player = PlayerManager.getChar(_ActorRowId);
	if (!player)
		return;

	const CStaticBrick * plan = CSheets::getSBrickForm( player->getCraftPlan() );
	if( plan == 0 )
	{
		nlwarning("<CFaberPhrase::execute> Can't found static form of craft plan %s", player->getCraftPlan().toString().c_str() );
		return;
	}

	/// set Faber time if not set (default is 2 sec)
	if ( !_FaberTime)
	{
		_FaberTime = (NLMISC::TGameCycle)(plan->CraftingDuration * 10);
	}
	nldebug("CFaberPhrase::execute> _FaberTime = %d",_FaberTime);

	const NLMISC::TGameCycle time = CTickEventHandler::getGameCycle();

	_ExecutionEndDate  = time + _FaberTime ;

	player->setCurrentAction(CLIENT_ACTION_TYPE::Faber,_ExecutionEndDate);
	player->staticActionInProgress(true);

	// set behaviour
	PHRASE_UTILITIES::sendUpdateBehaviour( _ActorRowId, MBEHAV::FABER );
}// CFaberPhrase execute
//--------------------------------------------------------------
//		CChgCharacEffect::update()
//--------------------------------------------------------------
bool CChgCharacEffect::update(CTimerEvent * event, bool applyEffect)
{
	if (!TheDataset.isAccessible(_TargetRowId))
	{
		_EndTimer.setRemaining(1, new CEndEffectTimerEvent(this));
		return true;
	}

	CCharacter *player = PlayerManager.getChar(_TargetRowId);
	if (!player)
	{
		_EndTimer.setRemaining(1, new CEndEffectTimerEvent(this));
		return true;
	}
		
	//player->getScores()._PhysicalScores[_AffectedScore].RegenerateModifier += _RegenModifier;
	string var = "Modifier" + _AffectedCharac;
	
	string currentValueStr;
	player->getValue(var,currentValueStr);
	sint32 currentValue;
	NLMISC::fromString(currentValueStr, currentValue);
	string newValueStr = toString(currentValue + _Modifier1 + _Modifier2);
	player->setValue(var,newValueStr);
	
	// now only one update is needed, but the end methos must reset the modifier !
	// must update this every ticks NO !!!!
	//_UpdateTimer.setRemaining(1, event);

	return false;
} // update //
//--------------------------------------------------------------
//		CModDefenseEffect::removed()
//--------------------------------------------------------------
void CModDefenseEffect::removed()
{
	// reset modifier to it's old value
	CCharacter *player = PlayerManager.getChar(_TargetRowId);
	if (!player)
	{
		nlwarning("Cannot find target entity %s", _TargetRowId.toString().c_str());
		return;
	}
	
	switch( _Family )
	{
		case EFFECT_FAMILIES::PowerModDodgeSkill:
			player->incDodgeModifier( -(sint32)(_Modifier1 + _Modifier2) );
			player->dodgeSuccessModifier( 0 );
			break;
		case EFFECT_FAMILIES::PowerModParrySkill:
			player->incParryModifier( -(sint32)(_Modifier1 + _Modifier2) );
			player->parrySuccessModifier( 0 );
			break;
		case EFFECT_FAMILIES::PowerModDefenseSkill:
			player->incDodgeModifier( -(sint32)(_Modifier1 + _Modifier2) );
			player->incParryModifier( -(sint32)(_Modifier1 + _Modifier2) );
			player->dodgeSuccessModifier( 0 );
			player->parrySuccessModifier( 0 );
			break;
		default:
			break;
	}
}
示例#4
0
//-----------------------------------------------
// CTimedActionPhrase execute
//-----------------------------------------------
void  CTimedActionPhrase::execute()
{
    _ExecutionEndDate = CTickEventHandler::getGameCycle() + _ExecutionDuration;

    CCharacter* player = PlayerManager.getChar(_ActorRowId);
    if (player)
    {
        if (_IsStatic)
        {
            switch( _ActionType )
            {
            case CLIENT_ACTION_TYPE::Mount :
                player->staticActionInProgress(true, STATIC_ACT_TYPES::Mount);
                break;
            default:
                player->staticActionInProgress(true, STATIC_ACT_TYPES::Teleport);
            }
        }
        else
            player->cancelStaticActionInProgress();

        player->setCurrentAction(_ActionType, _ExecutionEndDate);
        if (_RootSheetId != CSheetId::Unknown)
        {
//			player->_PropertyDatabase.setProp( "EXECUTE_PHRASE:SHEET", _RootSheetId.asInt() );
            CBankAccessor_PLR::getEXECUTE_PHRASE().setSHEET(player->_PropertyDatabase, _RootSheetId);
//			player->_PropertyDatabase.setProp( "EXECUTE_PHRASE:PHRASE", 0 );
            CBankAccessor_PLR::getEXECUTE_PHRASE().setPHRASE(player->_PropertyDatabase, 0);
        }
    }
}// CTimedActionPhrase execute
//-----------------------------------------------
// CHarvestPhrase end
//-----------------------------------------------
void CHarvestPhrase::end()
{
	H_AUTO(CHarvestPhrase_end);
	
	CCharacter* player = PlayerManager.getChar(_ActorRowId);
	if (player)
	{
		player->clearCurrentAction();
	}

	vector<uint16> qualities;

	// set behaviour no! -> set it when closing interface
//	PHRASE_UTILITIES::sendUpdateBehaviour( _ActorRowId, MBEHAV::LOOT_END );

	/*if (_Deposit) // obsolete (now done by the foraging actions)
	{
		//player->harvestResultDeposit( _MinQuality, false);
		//player->harvestDepositResult( max(_MinQuality,uint16(1)) );
		player->harvestDepositResult( max( (uint16)( rand() * ( _MaxQuality * 10  - _MinQuality * 10) / RAND_MAX + _MinQuality * 10 ), uint16(1)) );
	}
	else*/
		//harvestCorpseResult();
		player->harvestCorpseResult( qualities );

} // end //
示例#6
0
//-----------------------------------------------
// CTimedActionPhrase end
//-----------------------------------------------
void CTimedActionPhrase::end()
{
    CCharacter* player = PlayerManager.getChar(_ActorRowId);
    if (player)
    {
        player->clearCurrentAction();
    }
} // end //
示例#7
0
//-----------------------------------------------
// CTimedActionPhrase stop
//-----------------------------------------------
void CTimedActionPhrase::stop()
{
    CCharacter* player = PlayerManager.getChar(_ActorRowId);
    if (player)
    {
        player->clearCurrentAction();
        if (_TimedAction != NULL)
            _TimedAction->stopAction(this, player);
    }
} // stop //
//--------------------------------------------------------------
//					apply()  
//--------------------------------------------------------------
void CSpecialPowerBasic::apply()
{
	if (!_Phrase)
		return;

	CCharacter *actor = PlayerManager.getChar(_ActorRowId);
	if (!actor)
	{
		nlwarning("<CSpecialPowerBasic::apply> Cannot find actor entity or not a player");
		return;
	}

	// disable power
	actor->forbidPower(_PowerType, _Phrase->getConsumableFamilyId(), CTickEventHandler::getGameCycle() + _DisablePowerTime + _Duration);

	// create effect and apply it on actor
	const TGameCycle endDate = _Duration + CTickEventHandler::getGameCycle();
	
	CSTimedEffect *effect = IEffectFactory::buildEffect(_EffectFamily);
	if (effect)
	{
		effect->setCreatorRowId(_ActorRowId);
		effect->setFamily(_EffectFamily);
		effect->setTargetRowId(_ActorRowId);
		effect->setParamValue(_ParamValue);
		effect->setEndDate(endDate);
		
		actor->addSabrinaEffect(effect);
	}
	else
		return;

	// send messages
//	TVectorParamCheck params;
	// for actor
	if (actor->getId().getType() == RYZOMID::player)
	{
		SM_STATIC_PARAMS_1(params, STRING_MANAGER::power_type);
		params[0].Enum = _PowerType;
		PHRASE_UTILITIES::sendDynamicSystemMessage(_ActorRowId, "POWER_USE", params);
	}

	// for spectators
//	{
//		vector<CEntityId> excluded;
//		excluded.push_back(actor->getId());
//
//		params.resize(2);
//		params[0].Type = STRING_MANAGER::entity;
//		params[0].EId = actor->getId();
//		params[1].Type = STRING_MANAGER::power_type;
//		params[1].Enum = _PowerType;
//		PHRASE_UTILITIES::sendDynamicGroupSystemMessage(_ActorRowId, excluded, "POWER_USE_SPECTATORS", params);
//	}
} // apply //
//--------------------------------------------------------------
void CModMagicProtectionEffect::removed()
{
	// reset modifier to it's old value
	CCharacter *player = PlayerManager.getChar(_TargetRowId);
	if (!player)
	{
		nlwarning("Cannot find target entity %s", _TargetRowId.toString().c_str());
		return;
	}
	player->setUnclampedMagicProtection( _AffectedProtection, player->getUnclampedMagicProtection(_AffectedProtection) - _Modifier1 - _Modifier2 );
}
示例#10
0
//--------------------------------------------------------------
//		removed
//--------------------------------------------------------------
void CModCraftSuccessEffect::removed()
{
	// reset modifier to it's old value
	CCharacter *player = PlayerManager.getChar(_TargetRowId);
	if (!player)
	{
		nlwarning("Cannot find target entity %s", _TargetRowId.toString().c_str());
		return;
	}

	player->craftSuccessModifier( 0 );
}
示例#11
0
//-----------------------------------------------
// CFaberPhrase end
//-----------------------------------------------
void CFaberPhrase::end()
{
	H_AUTO(CFaberPhrase_end);

	CCharacter* player = PlayerManager.getChar(_ActorRowId);
	if (!player)
		return;

	player->unlockFaberRms();
	player->clearCurrentAction();
	player->staticActionInProgress(false);
	//player->sendCloseTempInventoryImpulsion();

	// set behaviour
	PHRASE_UTILITIES::sendUpdateBehaviour( _ActorRowId, MBEHAV::FABER_END );
} // end //
//--------------------------------------------------------------
bool CModMagicProtectionEffect::update(CTimerEvent * event, bool applyEffect)
{
	if (!TheDataset.isAccessible(_TargetRowId))
	{
		_EndTimer.setRemaining(1, new CEndEffectTimerEvent(this));
		return true;
	}

	CCharacter *player = PlayerManager.getChar(_TargetRowId);
	if (!player)
	{
		_EndTimer.setRemaining(1, new CEndEffectTimerEvent(this));
		return true;
	}
	player->setUnclampedMagicProtection( _AffectedProtection, player->getUnclampedMagicProtection(_AffectedProtection) + _Modifier1 + _Modifier2 );
	return false;
} // update //
//-----------------------------------------------
// CHarvestPhrase stop
//-----------------------------------------------
void CHarvestPhrase::stop()
{
	H_AUTO(CHarvestPhrase_stop);
	
	CCharacter* player = PlayerManager.getChar(_ActorRowId);
	if (player)
	{
		player->clearCurrentAction();
		/*if (_Deposit)
			PHRASE_UTILITIES::sendSimpleMessage( _ActorRowId, "EGS_FORAGE_INTERRUPTED");
		else*/
			PHRASE_UTILITIES::sendSimpleMessage( _ActorRowId, "EGS_QUARTER_INTERRUPTED");
	}

	// set behaviour
	PHRASE_UTILITIES::sendUpdateBehaviour( _ActorRowId, MBEHAV::LOOT_END );
} // stop //
示例#14
0
//--------------------------------------------------------------
//		update
//--------------------------------------------------------------
bool CModCraftSuccessEffect::update(CTimerEvent * event, bool applyEffect)
{
	if (!TheDataset.isAccessible(_TargetRowId))
	{
		_EndTimer.setRemaining(1, new CEndEffectTimerEvent(this));
		return true;
	}

	CCharacter *player = PlayerManager.getChar(_TargetRowId);
	if (!player)
	{
		_EndTimer.setRemaining(1, new CEndEffectTimerEvent(this));
		return true;
	}

	player->craftSuccessModifier( (sint32)(_Modifier1 + _Modifier2) );
	
	return false;
} // update //
示例#15
0
//-----------------------------------------------
// CFaberPhrase stop
//-----------------------------------------------
void CFaberPhrase::stop()
{
	H_AUTO(CFaberPhrase_stop);

	CCharacter* player = PlayerManager.getChar(_ActorRowId);
	if (!player)
		return;

	player->unlockFaberRms();
	player->clearCurrentAction();
	player->staticActionInProgress(false);
	player->sendCloseTempInventoryImpulsion();

	// set behaviour
	PHRASE_UTILITIES::sendUpdateBehaviour( _ActorRowId, MBEHAV::FABER_END );

	// send message
	PHRASE_UTILITIES::sendDynamicSystemMessage(_ActorRowId, "FABER_CANCEL");
} // stop //
//--------------------------------------------------------------
//		CChgCharacEffect::removed()
//--------------------------------------------------------------
void CChgCharacEffect::removed()
{
	// reset modifier to it's old value
	CCharacter *player = PlayerManager.getChar(_TargetRowId);
	if (!player)
	{
		nlwarning("Cannot find target entity %s", _TargetRowId.toString().c_str());
		return;
	}
	
	//player->getScores()._PhysicalScores[_AffectedScore].RegenerateModifier -= _RegenModifier;
	string var = "Modifier" + _AffectedCharac;

	string currentValueStr;
	player->getValue(var,currentValueStr);
	sint32 currentValue;
	NLMISC::fromString(currentValueStr, currentValue);
	string newValueStr = toString(currentValue - _Modifier1 - _Modifier2);
	player->setValue(var,newValueStr);
}
//-----------------------------------------------
// CHarvestPhrase execute
//-----------------------------------------------
void  CHarvestPhrase::execute()
{
	H_AUTO(CHarvestPhrase_execute);
	
	const NLMISC::TGameCycle time = CTickEventHandler::getGameCycle();

	_ExecutionEndDate  = time + _HarvestTime ;

// TODO
#if 0
	CCharacter* player = PlayerManager.getChar(_ActorRowId);
	if (player)
	{
		player->setCurrentAction(CLIENT_ACTION_TYPE::Harvest,_ExecutionEndDate);

		player->_PropertyDatabase.setProp( "EXECUTE_PHRASE:SHEET", _RootSheetId.asInt() );
		player->_PropertyDatabase.setProp( "EXECUTE_PHRASE:PHRASE", 0);
	}
#endif
	// set behaviour
	PHRASE_UTILITIES::sendUpdateBehaviour( _ActorRowId, MBEHAV::LOOT_INIT );
}// CHarvestPhrase execute
示例#18
0
//--------------------------------------------------------------
//		activate
//--------------------------------------------------------------
void CModCraftSuccessEffect::activate()
{
	CCharacter *actor = PlayerManager.getChar(_CreatorEntityId);
	if (!actor)
	{
		nlwarning("<CModCraftSuccessEffect::activate> Cannot find actor entity or not a player");
		return;
	}
	
	CModCraftSuccessEffect *effect = new CModCraftSuccessEffect(actor->getEntityRowId(), 
		getEndDate()+CTickEventHandler::getGameCycle(), 
		EFFECT_FAMILIES::PowerModCraftSkill,
		_Modifier1,
		_Modifier2);
	
	if (!effect)
	{
		nlwarning("<CModCraftSuccessEffect::activate> Failed to allocate new CModCraftSuccessEffect");
		return;
	}
	actor->addSabrinaEffect(effect);
}
//--------------------------------------------------------------
//		activate
//--------------------------------------------------------------
void CModDefenseEffect::activate()
{
	CCharacter *actor = PlayerManager.getChar(_CreatorEntityId);
	if (!actor)
	{
		nlwarning("<CModDefenseEffect::activate> Cannot find actor entity or not a player");
		return;
	}
	
	CModDefenseEffect *effect = new CModDefenseEffect(actor->getEntityRowId(), 
		getEndDate()+CTickEventHandler::getGameCycle(), 
		_Family,
		_DefenseMode,
		_Modifier1,
		_Modifier2);
	
	if (!effect)
	{
		nlwarning("<CModDefenseEffect::activate> Failed to allocate new CModDefenseEffect");
		return;
	}
	actor->addSabrinaEffect(effect);
}
//--------------------------------------------------------------
//		CModDefenseEffect::update()
//--------------------------------------------------------------
bool CModDefenseEffect::update(CTimerEvent * event, bool applyEffect)
{
	if (!TheDataset.isAccessible(_TargetRowId))
	{
		_EndTimer.setRemaining(1, new CEndEffectTimerEvent(this));
		return true;
	}

	CCharacter *player = PlayerManager.getChar(_TargetRowId);
	if (!player)
	{
		_EndTimer.setRemaining(1, new CEndEffectTimerEvent(this));
		return true;
	}
	
	switch( _Family )
	{
		case EFFECT_FAMILIES::PowerModDodgeSkill:
			player->incDodgeModifier( (sint32)(_Modifier1 + _Modifier2) );
			player->dodgeSuccessModifier( (sint32)(_Modifier1 + _Modifier2) );
			break;
		case EFFECT_FAMILIES::PowerModParrySkill:
			player->incParryModifier( (sint32)(_Modifier1 + _Modifier2) );
			player->parrySuccessModifier( (sint32)(_Modifier1 + _Modifier2) );
			break;
		case EFFECT_FAMILIES::PowerModDefenseSkill:
			player->incDodgeModifier( (sint32)(_Modifier1 + _Modifier2) );
			player->incParryModifier( (sint32)(_Modifier1 + _Modifier2) );
			player->dodgeSuccessModifier( (sint32)(_Modifier1 + _Modifier2) );
			player->parrySuccessModifier( (sint32)(_Modifier1 + _Modifier2) );
			break;
		default:
			break;
	}
	
	return false;
} // update //
//--------------------------------------------------------------
//					apply()  
//--------------------------------------------------------------
void CSpecialPowerBasicAura::apply()
{
	if (!_Phrase)
		return;

	CCharacter *actor = PlayerManager.getChar(_ActorRowId);
	if (!actor)
	{
		nlwarning("<CSpecialPowerBasicAura::apply> Cannot find actor entity or not a player");
		return;
	}

	// disable auras
	actor->setForbidAuraUseDates(CTickEventHandler::getGameCycle(), CTickEventHandler::getGameCycle() + _DisablePowerTime);

	const TGameCycle endDate = _Duration + CTickEventHandler::getGameCycle();

	// create effect and apply it on target
	CAuraRootEffect *effect = new CAuraRootEffect(_ActorRowId, endDate, _RootEffectFamily, _CreatedEffectFamily, _PowerType, _ParamValue, _AffectGuild);
	if (!effect)
	{		
		nlwarning("<CSpecialPowerBasicAura::apply> Failed to allocate new CShieldingEffect");
		return;
	}
	effect->setRadius(_AuraRadius);
	effect->setTargetDisableTime(_TargetsDisableAuraTime);
	actor->addSabrinaEffect(effect);

	// add aura FX on the actor
	CMirrorPropValue<TYPE_VISUAL_FX> visualFx( TheDataset, _ActorRowId, DSPropertyVISUAL_FX );
	CVisualFX fx;
	fx.unpack(visualFx.getValue());
	
	switch(_PowerType)
	{
	case POWERS::LifeAura:
		fx.Aura = MAGICFX::AuraHp;
		break;
	case POWERS::StaminaAura:
		fx.Aura = MAGICFX::AuraSta;
		break;
	case POWERS::SapAura:
		fx.Aura = MAGICFX::AuraSap;
		break;
	case POWERS::MeleeProtection:
		fx.Aura = MAGICFX::ProtectionMelee;
		break;
	case POWERS::Umbrella:
		fx.Aura = MAGICFX::ProtectionRange;
		break;
	case POWERS::AntiMagicShield:
		fx.Aura = MAGICFX::ProtectionMagic;
		break;
	case POWERS::WarCry:
		fx.Aura = MAGICFX::WarCry;
		break;
	case POWERS::FireWall:
		fx.Aura = MAGICFX::FireWall;
		break;
	case POWERS::ThornWall:
		fx.Aura = MAGICFX::ThornWall;
		break;
	case POWERS::WaterWall:
		fx.Aura = MAGICFX::WaterWall;
		break;
	case POWERS::LightningWall:
		fx.Aura = MAGICFX::LightningWall;
		break;
	default:
		return;
	};
	
	sint64 prop;
	fx.pack(prop);
	visualFx = (sint16)prop;
} // apply //
//--------------------------------------------------------------
//					apply()  
//--------------------------------------------------------------
void CSpecialPowerModForageSuccess::apply()
{
	if (!_Phrase)
		return;

	CCharacter *actor = PlayerManager.getChar(_ActorRowId);
	if (!actor)
	{
		nlwarning("<CSpecialPowerModForageSuccess::apply> Cannot find actor entity or not a player");
		return;
	}

	// disable power
	actor->forbidPower(_PowerType, _Phrase->getConsumableFamilyId(), CTickEventHandler::getGameCycle() + _DisablePowerTime);

	const TGameCycle endDate = _Duration + CTickEventHandler::getGameCycle();

	// create effect and apply it on target
	EFFECT_FAMILIES::TEffectFamily effectFamily;
	ECOSYSTEM::EECosystem eco = ECOSYSTEM::stringToEcosystem(_Ecosystem);
	switch( eco )
	{
		case ECOSYSTEM::common_ecosystem:
			effectFamily = EFFECT_FAMILIES::PowerModForageSkill;
			break;
		case ECOSYSTEM::desert:
			effectFamily = EFFECT_FAMILIES::PowerModDesertForageSkill;
			break;
		case ECOSYSTEM::forest:
			effectFamily = EFFECT_FAMILIES::PowerModForestForageSkill;
			break;
		case ECOSYSTEM::lacustre:
			effectFamily = EFFECT_FAMILIES::PowerModLacustreForageSkill;
			break;
		case ECOSYSTEM::jungle:
			effectFamily = EFFECT_FAMILIES::PowerModJungleForageSkill;
			break;
		case ECOSYSTEM::primary_root:
			effectFamily = EFFECT_FAMILIES::PowerModPrimaryRootForageSkill;
			break;
		default:
			nldebug("<CSpecialPowerModForageSuccess::apply> The ecosystem '%s' is not managed by this special power",_Ecosystem.c_str());
			return;
	}

	CModForageSuccessEffect *effect = new CModForageSuccessEffect(_ActorRowId, 
													endDate, 
													effectFamily,
													_Ecosystem,
													_Modifier1,
													_Modifier2);
	if (!effect)
	{
		nlwarning("<CSpecialPowerModForageSuccess::apply> Failed to allocate new CModForageSuccessEffect");
		return;
	}

	actor->addSabrinaEffect(effect);

	// send messages
	SM_STATIC_PARAMS_1(params, STRING_MANAGER::power_type);
//	TVectorParamCheck params;
	// for actor
	if (actor->getId().getType() == RYZOMID::player)
	{
		params[0].Enum = _PowerType;
		PHRASE_UTILITIES::sendDynamicSystemMessage(_ActorRowId, "POWER_USE", params);
	}
} // apply //
//-----------------------------------------------
// CHarvestPhrase harvestCorpseResult
//-----------------------------------------------
void CHarvestPhrase::harvestCorpseResult()
{
	H_AUTO(CHarvestPhrase_harvestCorpseResult);
	
	// get harvester character
	CCharacter *character = PlayerManager.getChar( _ActorRowId );
	if (character == NULL)
	{
		//nlwarning("<cbHarvestResult> Invalid player Id %s", playerId.toString().c_str() );
		return;
	}

	// get harvested corpse
	const CEntityId &harvestedEntity = character->harvestedEntity();

	CCreature *creature = CreatureManager.getCreature( harvestedEntity );
	if (creature == NULL)
	{
		nlwarning("<cbHarvestResult> Invalid creature Id %s", harvestedEntity.toString().c_str() );
		// reset harvest info
		character->resetHarvestInfos();
		character->endHarvest();
		return;
	}

	const vector< CCreatureRawMaterial> &mps = creature->getMps();
	if ( character->harvestedMpIndex() >= mps.size() || character->harvestedMpQuantity() > mps[character->harvestedMpIndex()].Quantity )
	{
		// reset harvest info
		character->resetHarvestInfos();
		return;
	}

	uint16 quality = _MaxQuality;

	// create the mp items if any
	if (quality > 0)
	{
		if ( !character->createItemInInventory(INVENTORIES::bag, quality, character->harvestedMpQuantity(), _RawMaterialId, character->getId()) )
		{
	//		CMissionEventItem event(CMissionEvent::Harvest,playerId,harvestedEntity,_RawMaterialId,quality,character->harvestedMpQuantity());
	//		character->processMissionEvent(event);
			// error creating the object, hand probably not empty
		//	character->resetHarvestInfos();
		//	return;
		}
		else
		{
			const CStaticItem *item = CSheets::getForm(_RawMaterialId);
			if (item)
			{
				///\todo nico: check if this event exists
//				CMissionEventHarvest event(_RawMaterialId ,character->harvestedMpQuantity(),quality);
//				character->processMissionEvent( event );

				SM_STATIC_PARAMS_3(params, STRING_MANAGER::integer, STRING_MANAGER::item, STRING_MANAGER::integer);
				params[0].Int = (sint32)character->harvestedMpQuantity();
				params[1].SheetId = _RawMaterialId;
				params[2].Int = (sint32)quality;

				STRING_MANAGER::sendStringToClient( character->getEntityRowId(), "HARVEST_SUCCESS", params );
			}
		}
	}
	// the mp have been destroyed -> do nothing
	else
	{
	}

	// remove the quantity of mp harvested from the ressource
	creature->removeMp( character->harvestedMpIndex(), character->harvestedMpQuantity() );
		
	// reset harvest info
	character->resetHarvestInfos();
} // harvestCorpseResult //
//-----------------------------------------------
// CHarvestPhrase validate
//-----------------------------------------------
bool CHarvestPhrase::validate()
{
	H_AUTO(CHarvestPhrase_validate);
	
	_BeingProcessed = true;

	// entities cant harvest if in combat
	TDataSetRow entityRowId = CPhraseManager::getInstance().getEntityEngagedMeleeBy( _ActorRowId );
	if (TheDataset.isAccessible(entityRowId))
	{
		///\todo david : send message
		_BeingProcessed = false;
		return false;
	}
	entityRowId = CPhraseManager::getInstance().getEntityEngagedRangeBy( _ActorRowId );
	if (TheDataset.isAccessible(entityRowId))
	{
		///\todo david : send message
		_BeingProcessed = false;
		return false;
	}
	
	CCharacter * player = PlayerManager.getChar(_ActorRowId);
	if (!player)
	{
		_BeingProcessed = false;
		return false;
	}

	const sint32 hp = player->currentHp();
	if ( hp < _HPCost  )
	{
		///\todo david : send message
		_BeingProcessed = false;
		return false;
	}
	const sint32 sta = player->getScores()._PhysicalScores[ SCORES::stamina ].Current;
	if ( sta < _StaminaCost  )
	{
		///\todo david : send message
		_BeingProcessed = false;
		return false;
	}
	if (hp <= 0	|| player->isDead())
	{
		///\todo david : send message
		_BeingProcessed = false;
		return false;
	}	

	/// todo david : test if on mount

	// on first validate, get the harvested item and check it's validity
	if ( state() == Evaluated)
	{
	// TEMPORARY CHANGE THIS WHEN THE BRICK WILL HAVE THE RIGHT PARAMS-------
		if (_RootSheetId == CSheetId("bhf01.sbrick"))
		{
			// this is the forage action
			// end harvest but doesn't close the interface
			/*player->endHarvest(false);

			// begin harvest
			player->staticActionInProgress( true );
			player->harvestDeposit(true);	
			player->depositSearchSkill(SKILLS::SH);
			player->openHarvest();
			player->tempInventoryMode(TEMP_INV_MODE::HarvestDeposit);
			CZoneManager::getInstance().harvestDeposit(player);

			if (player->getHarvestInfos().Sheet != CSheetId::Unknown)
			{
				//player->harvestAsked(0);
				_Deposit = true;
				_RawMaterialId = player->getHarvestInfos().Sheet;
				_MinQuality = player->getHarvestInfos().MinQuality;
				_MaxQuality = player->getHarvestInfos().MaxQuality;
				_Quantity = player->getHarvestInfos().Quantity;
				player->harvestedMpQuantity((uint8)_Quantity);	
			}
			else
			{
				player->sendMessageToClient( player->getId(), "WOS_HARVEST_FOUND_NOTHING");
				player->sendCloseTempInventoryImpulsion();
				player->getHarvestInfos().Sheet = CSheetId::Unknown;
				player->endHarvest();
				_BeingProcessed = false;
				return false;
			}*/
		}
	// TEMPORARY ---------------------------------------------
		const CStaticItem *item = CSheets::getForm(_RawMaterialId);
		if (item != 0)
		{
			CCharacter::sendDynamicSystemMessage(player->getId(), "WOS_HARVEST_SEARCHING");
/*				string msgName = "WOS_HARVEST_SEARCHING";
			CMessage msg("STATIC_STRING");
			msg.serial( const_cast<CEntityId&> (player->getId()) );
			set<CEntityId> excluded;
			msg.serialCont( excluded );
			msg.serial( msgName );
			sendMessageViaMirror ("IOS", msg);
*/			}
		else
		{
			nlwarning("HARVEST : Cannot find form for raw material %s, cancel harvest", _RawMaterialId.toString().c_str());
			CCharacter::sendDynamicSystemMessage(player->getId(), "WOS_HARVEST_FOUND_NOTHING");
//				player->sendMessageToClient( player->getId(), "WOS_HARVEST_FOUND_NOTHING");
			player->sendCloseTempInventoryImpulsion();
			player->getHarvestInfos().Sheet = CSheetId::Unknown;
			player->endHarvest();
			_BeingProcessed = false;
			return false;
		}
	}

	return true;
}// CHarvestPhrase validate
//--------------------------------------------------------------
//					apply()  
//--------------------------------------------------------------
void CSpecialPowerEnchantWeapon::apply()
{
	if (!_Phrase)
		return;
	
	CCharacter* actor = PlayerManager.getChar(_ActorRowId);
	if (!actor)
	{
		nlwarning("<CSpecialPowerEnchantWeapon::apply> Cannot find actor entity or not a player");
		return;
	}
	
	CInventoryPtr inv = actor->getInventory(INVENTORIES::handling);
	nlassert(inv != NULL);
	
	// Test some cases that should be avoided on client (so don't bother adding an error message)
	
	// If we have no equipped item
	if (inv->getSlotCount()<=0)
		return;
	
	// If equipped item is invalid
	CGameItemPtr item = inv->getItem(0);
	if (item == NULL)
		return;
	
	// If item sheet is unknown
	CSheetId itemSheet = item->getSheetId();
	if (itemSheet==CSheetId::Unknown)
		return;
	
	// If item sheet is invalid
	const CStaticItem * form = item->getStaticForm();
	if (!form)
		return;
	
	// If item is not a melee weapon
	ITEMFAMILY::EItemFamily family = form->Family;
	if (family!=ITEMFAMILY::MELEE_WEAPON)
		return;
	
	// Here equipped item is valid. Enchant removal will be done on unequip.
	
	// disable power
	actor->forbidPower(_PowerType, _Phrase->getConsumableFamilyId(), CTickEventHandler::getGameCycle() + _DisablePowerTime + _Duration);
	
	// create effect and apply it on actor
	TGameCycle const endDate = _Duration + CTickEventHandler::getGameCycle();
	float damageBonus = _DpsBonus * 10.f / item->hitRate();
	
	CEnchantWeaponEffect* effect = new CEnchantWeaponEffect(_ActorRowId, _ActorRowId, _EffectFamily, _ParamValue, endDate, _DamageType, SCORES::hit_points, damageBonus, DMGTYPE::UNDEFINED);
	if (effect)
	{
		effect->endsAtCasterDeath(true);
		effect->stackable(true);
		actor->addSabrinaEffect(effect);
	}
	else
		return;
	// send messages
//	TVectorParamCheck params;
	// for actor
	if (actor->getId().getType() == RYZOMID::player)
	{
		SM_STATIC_PARAMS_1(params, STRING_MANAGER::power_type);
		params[0].Enum = _PowerType;
		PHRASE_UTILITIES::sendDynamicSystemMessage(_ActorRowId, "POWER_USE", params);
	}
	
	// for spectators
//	{
//		vector<CEntityId> excluded;
//		excluded.push_back(actor->getId());
//
//		params.resize(2);
//		params[0].Type = STRING_MANAGER::entity;
//		params[0].EId = actor->getId();
//		params[1].Type = STRING_MANAGER::power_type;
//		params[1].Enum = _PowerType;
//		PHRASE_UTILITIES::sendDynamicGroupSystemMessage(_ActorRowId, excluded, "POWER_USE_SPECTATORS", params);
//	}
}
示例#26
0
//-----------------------------------------------
// CTimedActionPhrase stopBeforeExecution
//-----------------------------------------------
void CTimedActionPhrase::stopBeforeExecution()
{
    CCharacter* player = PlayerManager.getChar(_ActorRowId);
    if ( player != NULL && _TimedAction != NULL)
        _TimedAction->stopBeforeExecution(this, player);
} // stopBeforeExecution //
示例#27
0
//-----------------------------------------------
// CTimedActionPhrase build
//-----------------------------------------------
bool CTimedActionPhrase::build( const TDataSetRow & actorRowId, const std::vector< const CStaticBrick* >& bricks, bool buildToExecute )
{
    _ActorRowId = actorRowId;

    for (uint i = 0 ; i < bricks.size() ; ++i)
    {
        const CStaticBrick *brick = bricks[i];
        nlassert(brick != NULL);

        if (i==0)
            _RootSheetId = brick->SheetId;

        // process params
        for ( uint j = 0 ; j < brick->Params.size() ; ++j)
        {
            TBrickParam::IId	*param = brick->Params[j];
            if (!param) continue;

            switch(param->id())
            {
            case TBrickParam::TA_TELEPORT:
            {
                _TimedAction = new CTPTimedAction();
                if (_TimedAction == NULL)
                {
                    nlwarning("Error allocating new CTPTimedAction object");
                    return false;
                }
                _ExecutionDuration = DelayBeforeItemTP;
                _ActionType = CLIENT_ACTION_TYPE::Teleport;
            }
            break;

            case TBrickParam::TA_DISCONNECT:
            {
                _TimedAction = new CDisconnectTimedAction();
                if (_TimedAction == NULL)
                {
                    nlwarning("Error allocating new CTPTimedAction object");
                    return false;
                }

                _ExecutionDuration = TimeBeforeDisconnection;
                if (IsRingShard)
                {
                    // Find out how much time to wait depending on the role of the character
                    CCharacter* player = PlayerManager.getChar(_ActorRowId);
                    if (player)
                    {
                        // In Ring edition and animation mode, take a short cut when Far Teleporting
                        R2::TUserRole role = player->sessionUserRole();
                        if ((role == R2::TUserRole::ur_editor) || (role == R2::TUserRole::ur_animator))
                            _ExecutionDuration = 1;
                    }
                }
                _ActionType = CLIENT_ACTION_TYPE::Disconnect;
            }
            break;

            case TBrickParam::TA_MOUNT:
            {
                _TimedAction = new CMountTimedAction();
                if (_TimedAction == NULL)
                {
                    nlwarning("Error allocating new CTPTimedAction object");
                    return false;
                }
                _ExecutionDuration = MountDuration;
                _ActionType = CLIENT_ACTION_TYPE::Mount;
            }
            break;

            case TBrickParam::TA_UNMOUNT:
            {
                _TimedAction = new CUnmountTimedAction();
                if (_TimedAction == NULL)
                {
                    nlwarning("Error allocating new CTPTimedAction object");
                    return false;
                }
                _ExecutionDuration = UnmountDuration;
                _ActionType = CLIENT_ACTION_TYPE::Unmount;
            }
            break;

            case TBrickParam::TA_CONSUME:
            {
                _TimedAction = new CConsumeItemTimedAction();
                if (_TimedAction == NULL)
                {
                    nlwarning("Error allocating new CConsumeItemTimedAction object");
                    return false;
                }
                // get item to consume to init consumption time
                CCharacter *player = PlayerManager.getChar(actorRowId);
                if (player)
                {
                    CGameItemPtr item =player->getConsumedItem();
                    if (item != NULL)
                    {
                        const CStaticItem *form = item->getStaticForm();
                        if (form && form->ConsumableItem)
                        {
                            _ExecutionDuration = TGameCycle(form->ConsumableItem->ConsumptionTime / CTickEventHandler::getGameTimeStep());
                        }
                    }
                }
                _ActionType = CLIENT_ACTION_TYPE::ConsumeItem;
            }
            break;

            default:
                ;
            };
        }
    }

    return true;
}// CTimedActionPhrase build