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/>.
20 #include "magic_action.h"
21 #include "magic_phrase.h"
23 #include "character.h"
24 #include "game_share/entity_structure/statistic.h"
25 #include "s_link_effect_debuff_skill.h"
27 using namespace NLNET
;
28 using namespace NLMISC
;
29 using namespace RY_GAME_SHARE
;
33 class CMagicActionDebuffSkill
: public IMagicAction
36 CMagicActionDebuffSkill()
37 :_TargetSkill(SKILLS::unknown
),_DebuffValue(0){}
39 virtual bool addBrick( const CStaticBrick
& brick
, CMagicPhrase
* phrase
)
41 for ( uint i
=0 ; i
<brick
.Params
.size() ; ++i
)
43 switch(brick
.Params
[i
]->id())
46 case TBrickParam::MA_DEBUFF
:
47 INFOLOG("MA_DEBUFF: %u",((CSBrickParamMagicDebuff
*)brick
.Params
[i
])->Debuff
);
48 _DebuffValue
= ((CSBrickParamMagicDebuff
*)brick
.Params
[i
])->Debuff
;
51 case TBrickParam::MA_LINK_COST
:
52 INFOLOG("MA_LINK_COST: %u",((CSBrickParamMagicLinkCost
*)brick
.Params
[i
])->Cost
);
53 _CostPerUpdate
= ((CSBrickParamMagicLinkCost
*)brick
.Params
[i
])->Cost
;
56 case TBrickParam::SKILL
:
58 INFOLOG("SKILL: %s",((CSBrickParamSkill
*)brick
.Params
[i
])->Skill
.c_str());
59 _Skill
= SKILLS::toSkill( ((CSBrickParamSkill
*)brick
.Params
[i
])->Skill
);
60 if ( _Skill
== SKILLS::unknown
)
62 nlwarning( "<CMagicActionDebuffSkill addBrick> invalid skill type %s", ((CSBrickParamSkill
*)brick
.Params
[i
])->Skill
.c_str() );
68 // unused param, can be useful in the phrase
69 phrase
->applyBrickParam( brick
.Params
[i
] );
73 ///\todo nico: check if everything is set
76 virtual bool validate(CMagicPhrase
* phrase
)
78 return PHRASE_UTILITIES::validateSpellTarget(phrase
->getActor(),phrase
->getTargets()[0],ACTNATURE::OFFENSIVE
);
80 virtual void apply( CMagicPhrase
* phrase
, float successFactor
,MBEHAV::CBehaviour
& behav
)
85 // - player damages + on armor
86 // - behaviour + chat messages
90 if ( successFactor
< 0.0f
)
96 /// apply success factor
97 _DebuffValue
= uint32( _DebuffValue
* successFactor
);
99 const std::vector
< TDataSetRow
> & targets
= phrase
->getTargets();
100 CEntityBase
* actor
= CEntityBaseManager::getEntityBasePtr( phrase
->getActor() );
104 SCORES::EScores linkEnergy
;
105 if ( phrase
->getSapCost() > 0 )
107 linkEnergy
= SCORES::sap
;
110 linkEnergy
= SCORES::hit_points
;;
111 for ( uint i
= 0; i
< targets
.size(); i
++ )
114 CEntityBase
* target
= CEntityBaseManager::getEntityBasePtr( targets
[i
] );
118 if ( PHRASE_UTILITIES::validateSpellTarget(actor
,target
,ACTNATURE::OFFENSIVE
) )
120 CSLinkEffectDebuffSkill
* debuff
= new CSLinkEffectDebuffSkill( phrase
->getActor(),
128 actor
->addLink( debuff
);
129 target
->addSabrinaEffect( debuff
);
134 SKILLS::ESkills _TargetSkill
;
138 MAGIC_ACTION_FACTORY( CMagicActionDebuffSkill
,BRICK_FAMILIES::MADebuffSkill
)