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/>.
21 #include "combat_attacker.h"
22 #include "phrase_utilities_functions.h"
25 using namespace NLMISC
;
27 bool UseWeaponDamageFactorModifier
= true;
29 NLMISC_COMMAND(UseWeaponDamageFactorModifier
,"toggle the use of the item damage factor (temporary patch item damage )","")
31 UseWeaponDamageFactorModifier
= !UseWeaponDamageFactorModifier
;
33 log
.displayNL("UseWeaponDamageFactorModifier is %s",UseWeaponDamageFactorModifier
?"used":"unused");
37 //--------------------------------------------------------------
38 // CCombatWeapon constructor
39 //--------------------------------------------------------------
40 CCombatWeapon::CCombatWeapon(CGameItemPtr itemPtr
)
42 if (itemPtr
== NULL
|| itemPtr
->getStaticForm() == NULL
)
45 Family
= itemPtr
->getStaticForm()->Family
;
49 case ITEMFAMILY::MELEE_WEAPON
:
50 if (!itemPtr
->getStaticForm()->MeleeWeapon
)
52 DmgType
= itemPtr
->getStaticForm()->MeleeWeapon
->DamageType
;
53 Skill
= itemPtr
->getStaticForm()->Skill
;
56 case ITEMFAMILY::RANGE_WEAPON
:
57 if (!itemPtr
->getStaticForm()->RangeWeapon
)
59 DmgType
= itemPtr
->getStaticForm()->RangeWeapon
->DamageType
;
60 Skill
= itemPtr
->getStaticForm()->Skill
;
61 Range
= itemPtr
->getRange();
64 case ITEMFAMILY::AMMO
:
65 if (!itemPtr
->getStaticForm()->Ammo
)
67 DmgType
= itemPtr
->getStaticForm()->Ammo
->DamageType
;
68 Range
= itemPtr
->getRange();
75 if (Skill
== SKILLS::unknown
)
77 nlwarning("<CCombatWeapon::CCombatWeapon> Error : item %s skill is Unknown", itemPtr
->getStaticForm()->Name
.c_str());
80 SpeedInTicks
= uint16(itemPtr
->getSpeed() / CTickEventHandler::getGameTimeStep());
81 Quality
= itemPtr
->quality();
83 if ( UseWeaponDamageFactorModifier
)
84 Damage
= itemPtr
->getDamage() * 260 / (10 + Quality
*10);
86 Damage
= itemPtr
->getDamage();
89 // SkillValue must be init in the calling class
94 //--------------------------------------------------------------
95 // CCombatAttackerPlayer::getItem
96 //--------------------------------------------------------------
97 bool CCombatAttackerPlayer::getItem( TAttackerItem item
, CCombatWeapon
&weaponItem
) const
102 if ( _RightHandItem
!= NULL
)
104 weaponItem
= CCombatWeapon(_RightHandItem
);
112 if ( _LeftHandItem
!= NULL
)
114 weaponItem
= CCombatWeapon(_LeftHandItem
);
124 weaponItem
= CCombatWeapon( _Ammos
);
134 } // CCombatAttackerPlayer::getItem //
137 //--------------------------------------------------------------
138 // CCombatAttackerPlayer::getItem
139 //--------------------------------------------------------------
140 bool CCombatAttackerPlayer::checkAmmoAmount( uint8 qty
) const
142 static const CSheetId
StackItem("stack.sitem");
147 if (_Ammos
->getSheetId() == StackItem
)
149 nbAmmo
= _Ammos
->getChildren().size(); //- _Ammos->getLockState();
153 nbAmmo
= 1 ;//- _Ammos->getLockState();
156 return (nbAmmo
>= (uint16
)qty
);
160 } // CCombatAttackerPlayer::checkAmmoAmount //
164 //--------------------------------------------------------------
165 // CCombatAttackerAI::CCombatAttackerAI
166 //--------------------------------------------------------------
167 CCombatAttackerAI::CCombatAttackerAI( const TDataSetRow
&rowId
) : CCombatAttacker(rowId
)
169 CEntityBase
*entity
= CEntityBaseManager::getEntityBasePtr(rowId
);
173 const CStaticCreatures
* form
= CSheets::getCreaturesForm( entity
->_SheetId
);
176 nlwarning( "<CCombatAttackerAI::CCombatAttackerAI> invalid creature form %s in entity %s", entity
->_SheetId
.toString().c_str(), entity
->getId().toString().c_str() );
180 _RightHandWeapon
.Quality
= form
->Level
;
181 _RightHandWeapon
.Damage
= form
->CreatureDamagePerHit
* 260/(10+10*form
->Level
);
183 _RightHandWeapon
.DmgType
= DMGTYPE::SLASHING
;
184 _RightHandWeapon
.SpeedInTicks
= 30;
185 _RightHandWeapon
.Family
= ITEMFAMILY::MELEE_WEAPON
;
186 _RightHandWeapon
.Skill
= SKILLS::SFM1H
;
188 INFOLOG("AttackerAi :_RightHandWeapon.Quality = %u, _RightHandWeapon.Damage = %u", _RightHandWeapon
.Quality
, _RightHandWeapon
.Damage
);
189 } // CCombatAttackerAI::CCombatAttackerAI //
192 //--------------------------------------------------------------
193 // CCombatAttackerAI::getItem
194 //--------------------------------------------------------------
195 bool CCombatAttackerAI::getItem( TAttackerItem item
, CCombatWeapon
&weaponItem
) const
200 if ( _RightHandWeapon
.Quality
!= 0)
202 weaponItem
= _RightHandWeapon
;
210 if ( _LeftHandWeapon
.Quality
!= 0)
212 weaponItem
= _LeftHandWeapon
;
220 if ( _Ammo
.Quality
!= 0)
232 } // CCombatAttackerAI::getItem //