1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #include "nel/net/message.h"
24 #include "nel/misc/bit_mem_stream.h"
26 #include "game_share/generic_xml_msg_mngr.h"
28 #include "combat_action_stun.h"
29 #include "phrase_utilities_functions.h"
32 using namespace NLMISC
;
33 using namespace NLNET
;
36 extern CGenericXmlMsgHeaderManager GenericMsgManager
;
39 //--------------------------------------------------------------
41 //--------------------------------------------------------------
42 bool CCombatActionStun::build( const TDataSetRow
& actorRowId
, const std::vector
< const CStaticBrick
* >& bricks
, uint
&brickIndex
, CCombatPhrase
* phrase
)
44 if (!phrase
) return false;
46 _CombatPhrase
= phrase
;
47 _ActorRowId
= actorRowId
;
53 //--------------------------------------------------------------
55 //--------------------------------------------------------------
56 void CCombatActionStun::apply(CCombatPhrase
*phrase
)
58 CEntityBase
*entity
= CEntityBaseManager::getEntityBasePtr(_TargetRowId
);
62 TGameCycle endDate
= _StunDuration
+ CTickEventHandler::getGameCycle();
64 _StunEffect
= new CCombatStunEffect( _ActorRowId
, _TargetRowId
, EFFECT_FAMILIES::CombatStun
, _StunLevel
, endDate
);
67 nlwarning("<CCombatActionStun::apply> Failed to allocate new CCombatStunEffect object !");
71 _StunEffect
->stunnedEntity(entity
);
73 entity
->addSabrinaEffect(_StunEffect
);
75 // send stun impulsion to the IOS
76 CMessage
msgout( "IMPULSION_ID" );
77 msgout
.serial( const_cast<CEntityId
&> (entity
->getId()) );
79 GenericMsgManager
.pushNameToStream( "STUN:STUN", bms
);
80 uint16 tickCount
= _StunDuration
;
81 bms
.serial( tickCount
);
82 msgout
.serialMemStream( bms
);
83 CUnifiedNetwork::getInstance()->send( entity
->getId().getDynamicId(), msgout
);
86 PHRASE_UTILITIES::sendSimpleMessage( _TargetRowId
, "OPS_EFFECT_STUN_BEGIN" );
87 PHRASE_UTILITIES::sendMessage( _ActorRowId
, "OPS_EFFECT_STUN_BEGIN_E", _TargetRowId
);
89 /// todo : send to spectators