Linux multi-monitor fullscreen support
[ryzomcore.git] / ryzom / client / src / client_sheets / item_sheet.h
blobdc6c0a658550a711ef0c9972d60c0b64fbbfae9e
1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010-2019 Winch Gate Property Limited
3 //
4 // This source file has been modified by the following contributors:
5 // Copyright (C) 2020 Jan BOON (Kaetemi) <jan.boon@kaetemi.be>
6 //
7 // This program is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU Affero General Public License as
9 // published by the Free Software Foundation, either version 3 of the
10 // License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU Affero General Public License for more details.
17 // You should have received a copy of the GNU Affero General Public License
18 // along with this program. If not, see <http://www.gnu.org/licenses/>.
23 #ifndef CL_ITEM_SHEET_H
24 #define CL_ITEM_SHEET_H
27 /////////////
28 // INCLUDE //
29 /////////////
30 #include "client_sheets.h"
31 // misc
32 #include "nel/misc/types_nl.h"
33 // client
34 #include "entity_sheet.h"
35 #include "item_fx_sheet.h"
36 // Game share
37 #include "game_share/slot_types.h"
38 #include "game_share/item_family.h"
39 #include "game_share/item_type.h"
40 #include "game_share/skills.h"
41 #include "game_share/armor_types.h"
42 #include "game_share/weapon_types.h"
43 #include "game_share/damage_types.h"
44 #include "game_share/ecosystem.h"
45 #include "game_share/mp_category.h"
46 #include "game_share/item_origin.h"
47 #include "game_share/shield_types.h"
48 #include "game_share/crafting_tool_type.h"
49 #include "game_share/rm_family.h"
50 #include "game_share/range_weapon_type.h"
51 #include "game_share/characteristics.h"
52 #include "game_share/teleport_types.h"
53 #include "game_share/gender.h"
54 #include "game_share/characteristics.h"
55 // std
56 #include <string>
59 ///////////
60 // USING //
61 ///////////
64 ///////////
65 // CLASS //
66 ///////////
67 namespace NLGEORGES
69 class UFormElm;
70 class UFormLoader;
74 // ***************************************************************************
75 /**
76 * Class to manage an item sheet.
77 * \author Stephane Coutelas
78 * \author Nevrax France
79 * \date 2001
81 class CItemSheet : public CEntitySheet
83 public:
84 struct CCosmetic
86 uint32 VPValue;
87 GSGENDER::EGender Gender;
89 void serial(NLMISC::IStream &f)
91 f.serial(VPValue);
92 f.serialEnum(Gender);
95 struct CArmor
97 ARMORTYPE::EArmorType ArmorType;
99 void serial(NLMISC::IStream &f)
101 f.serialEnum(ArmorType);
104 struct CMeleeWeapon
106 WEAPONTYPE::EWeaponType WeaponType;
107 SKILLS::ESkills Skill;
108 DMGTYPE::EDamageType DamageType;
109 sint32 MeleeRange;
111 void serial(NLMISC::IStream &f)
113 f.serialEnum(WeaponType);
114 f.serialEnum(Skill);
115 f.serialEnum(DamageType);
116 f.serial(MeleeRange);
119 struct CRangeWeapon
121 WEAPONTYPE::EWeaponType WeaponType;
122 RANGE_WEAPON_TYPE::TRangeWeaponType RangeWeaponType;
123 SKILLS::ESkills Skill;
125 void serial(NLMISC::IStream &f)
127 f.serialEnum(WeaponType);
128 f.serialEnum(Skill);
129 f.serialEnum(RangeWeaponType);
132 struct CAmmo
134 SKILLS::ESkills Skill;
135 DMGTYPE::EDamageType DamageType;
136 sint32 Magazine;
138 void serial(NLMISC::IStream &f)
140 f.serialEnum(Skill);
141 f.serialEnum(DamageType);
142 f.serial(Magazine);
145 // Info on a itemPart which can be build by this MP
146 struct CMpItemPart
148 // The origin filter. It is actually a ITEM_ORIGIN::EItemOrigin
149 uint8 OriginFilter;
151 // The differents stats for this itemPart
152 uint8 Stats[RM_FABER_STAT_TYPE::NumRMStatType];
154 CMpItemPart()
156 OriginFilter = 0;
157 std::fill( Stats, Stats + RM_FABER_STAT_TYPE::NumRMStatType, 0 );
160 void serial(NLMISC::IStream &f)
162 f.serial(OriginFilter);
163 // must change sheet version
164 nlctassert(RM_FABER_STAT_TYPE::NumRMStatType==34);
165 for(uint i=0;i<RM_FABER_STAT_TYPE::NumRMStatType;i++)
167 f.serial(Stats[i]);
171 struct CMp
173 public:
174 ECOSYSTEM::EECosystem Ecosystem;
175 MP_CATEGORY::TMPCategory MpCategory;
176 SKILLS::ESkills HarvestSkill;
177 // The MP Family
178 RM_FAMILY::TRMFamily Family;
179 // If the MP is used as a special Craft Component requirement
180 bool UsedAsCraftRequirement;
181 // The Mp color
182 sint8 MpColor;
183 // The mean Stat Energy of this MP
184 uint16 StatEnergy;
185 // The ItemParts this MP can craft
186 uint64 ItemPartBF;
188 public:
189 void serial(NLMISC::IStream &f)
191 f.serialEnum(Ecosystem);
192 f.serialEnum(MpCategory);
193 f.serialEnum(HarvestSkill);
194 f.serialEnum(Family);
195 f.serial(ItemPartBF);
196 f.serial(UsedAsCraftRequirement);
197 f.serial(MpColor);
198 f.serial(StatEnergy);
201 struct CShield
203 SHIELDTYPE::EShieldType ShieldType;
205 void serial(NLMISC::IStream &f)
207 f.serialEnum(ShieldType);
210 struct CTool
212 SKILLS::ESkills Skill; // Used by HARVEST, TAMING, TRAINING tools
213 TOOL_TYPE::TCraftingToolType CraftingToolType; // Used by CRAFTING tool
214 sint32 CommandRange; // Used by TAMING tool
215 sint32 MaxDonkey; // Used by TAMING tool
217 void serial(NLMISC::IStream &f)
219 f.serialEnum(Skill);
220 f.serialEnum(CraftingToolType);
221 f.serial(CommandRange);
222 f.serial(MaxDonkey);
226 struct CGuildOption
228 uint32 MoneyCost;
229 sint32 XPCost;
231 void serial(NLMISC::IStream &f)
233 f.serial(MoneyCost);
234 f.serial(XPCost);
238 struct CPet
240 sint32 Slot;
242 void serial(NLMISC::IStream &f)
244 f.serial(Slot);
248 struct CTeleport
250 TELEPORT_TYPES::TTeleportType Type;
252 void serial(NLMISC::IStream &f)
254 f.serialEnum(Type);
258 struct CScroll
260 std::string Texture;
261 std::string LuaCommand;
262 std::string WebCommand;
263 std::string Label;
265 void serial(NLMISC::IStream &f)
267 f.serial(Texture);
268 f.serial(LuaCommand);
269 f.serial(WebCommand);
270 f.serial(Label);
274 struct CConsumable
276 uint16 OverdoseTimer;
277 uint16 ConsumptionTime;
279 CConsumable()
281 OverdoseTimer = 0;
282 ConsumptionTime = 0;
285 std::vector<std::string> Properties;
287 void serial(NLMISC::IStream &f)
289 f.serial(OverdoseTimer);
290 f.serial(ConsumptionTime);
291 f.serialCont(Properties);
295 public:
296 /// shape file name
297 NLMISC::TSStringId IdShape;
298 /// Female shape file name
299 NLMISC::TSStringId IdShapeFemale;
300 /// shape file name for fyros
301 NLMISC::TSStringId IdShapeFyros;
302 /// Female shape file name for fyros
303 NLMISC::TSStringId IdShapeFyrosFemale;
304 /// shape file name for matis
305 NLMISC::TSStringId IdShapeMatis;
306 /// Female shape file name for matis
307 NLMISC::TSStringId IdShapeMatisFemale;
308 /// shape file name for tryker
309 NLMISC::TSStringId IdShapeTryker;
310 /// Female shape file name for tryker
311 NLMISC::TSStringId IdShapeTrykerFemale;
312 /// shape file name for zorai
313 NLMISC::TSStringId IdShapeZorai;
314 /// Female shape file name for zorai
315 NLMISC::TSStringId IdShapeZoraiFemale;
316 /// Equipment slot. This is a bitField matching each bit to SLOTTYPE::TSlotType
317 uint64 SlotBF;
318 /// texture variant.
319 uint32 MapVariant;
320 /// Item Family
321 ITEMFAMILY::EItemFamily Family;
322 /// Item Type
323 ITEM_TYPE::TItemType ItemType;
324 /// icon file name for race type
325 NLMISC::TSStringId IdIconBack;
326 /// icon file name for main icon type
327 NLMISC::TSStringId IdIconMain;
328 /// icon file name for overlay
329 NLMISC::TSStringId IdIconOver;
330 /// icon file name for overlay2
331 NLMISC::TSStringId IdIconOver2;
332 // Special Color to modulate with
333 NLMISC::CRGBA IconColor;
334 NLMISC::CRGBA IconBackColor;
335 NLMISC::CRGBA IconOverColor;
336 NLMISC::CRGBA IconOver2Color;
337 /// icon Special Text (raw materials)
338 NLMISC::TSStringId IdIconText;
339 /// Part of the animation set ot use with this item.
340 NLMISC::TSStringId IdAnimSet;
341 /// Item Color. Special Enum for armours
342 sint8 Color;
343 /// has fx
344 bool HasFx;
345 // Does the player can sell the item ?
346 bool DropOrSell;
347 // Item is not persistent to a disconnection ?
348 bool IsItemNoRent;
349 /// item max stack size
350 uint32 Stackable;
351 /// is item consumable
352 bool IsConsumable;
353 /// Bulk.
354 float Bulk;
355 /// Equip Time
356 uint32 EquipTime;
357 /// true if this item can be hidden when equipped
358 bool NeverHideWhenEquipped;
360 // FX
361 CItemFXSheet FX;
363 // item special effects
364 NLMISC::TSStringId IdEffect1;
365 NLMISC::TSStringId IdEffect2;
366 NLMISC::TSStringId IdEffect3;
367 NLMISC::TSStringId IdEffect4;
369 // Only used for Mp
370 std::vector<CMpItemPart> MpItemParts;
372 // item requirements
373 CHARACTERISTICS::TCharacteristics RequiredCharac;
374 uint16 RequiredCharacLevel;
375 SKILLS::ESkills RequiredSkill;
376 uint16 RequiredSkillLevel;
378 /// if craftable, the craft plan
379 NLMISC::CSheetId CraftPlan;
381 /// \name Help Infos
382 // @{
383 // Basics
384 ITEM_ORIGIN::EItemOrigin ItemOrigin;
385 // Different according to Family
386 union
388 CCosmetic Cosmetic;
389 CArmor Armor;
390 CMeleeWeapon MeleeWeapon;
391 CRangeWeapon RangeWeapon;
392 CAmmo Ammo;
393 CMp Mp;
394 CShield Shield;
395 CTool Tool;
396 CGuildOption GuildOption;
397 CPet Pet;
398 CTeleport Teleport;
401 CScroll Scroll;
402 CConsumable Consumable;
403 // @}
407 * Constructor
409 CItemSheet();
411 std::string getShape() const { return ClientSheetsStrings.get(IdShape); }
412 std::string getShapeFemale() const { return ClientSheetsStrings.get(IdShapeFemale); }
413 std::string getShapeFyros() const { return ClientSheetsStrings.get(IdShapeFyros); }
414 std::string getShapeFyrosFemale() const { return ClientSheetsStrings.get(IdShapeFyrosFemale); }
415 std::string getShapeMatis() const { return ClientSheetsStrings.get(IdShapeMatis); }
416 std::string getShapeMatisFemale() const { return ClientSheetsStrings.get(IdShapeMatisFemale); }
417 std::string getShapeTryker() const { return ClientSheetsStrings.get(IdShapeTryker); }
418 std::string getShapeTrykerFemale() const { return ClientSheetsStrings.get(IdShapeTrykerFemale); }
419 std::string getShapeZorai() const { return ClientSheetsStrings.get(IdShapeZorai); }
420 std::string getShapeZoraiFemale() const { return ClientSheetsStrings.get(IdShapeZoraiFemale); }
421 std::string getIconBack() const { return ClientSheetsStrings.get(IdIconBack); }
422 std::string getIconMain() const { return ClientSheetsStrings.get(IdIconMain); }
423 std::string getIconOver() const { return ClientSheetsStrings.get(IdIconOver); }
424 std::string getIconOver2() const { return ClientSheetsStrings.get(IdIconOver2); }
425 std::string getIconText() const { return ClientSheetsStrings.get(IdIconText); }
426 std::string getAnimSet() const { return ClientSheetsStrings.get(IdAnimSet); }
428 std::string getEffect1() const { return ClientSheetsStrings.get(IdEffect1); }
429 std::string getEffect2() const { return ClientSheetsStrings.get(IdEffect2); }
430 std::string getEffect3() const { return ClientSheetsStrings.get(IdEffect3); }
431 std::string getEffect4() const { return ClientSheetsStrings.get(IdEffect4); }
433 /// Build the sheet from an external script.
434 virtual void build(const NLGEORGES::UFormElm &item);
436 /// Serialize character sheet into binary data file.
437 virtual void serial(NLMISC::IStream &f);
439 /// true if the item can put in the slot e
440 bool hasSlot(SLOTTYPE::TSlotType e) const {return (SlotBF&(SINT64_CONSTANT(1)<<e))!=0;}
442 /// true if the item is faberisable according to family
443 bool isFaberisable() const;
445 // Get the skill required by the item depending on its type (or unknown_skill_type if no specific skill is required)
446 SKILLS::ESkills getRequiredSkill() const;
448 // MP only. true if durability ok
449 bool canBuildItemPart(RM_FABER_TYPE::TRMFType e) const;
451 // MP only. true if durability ok, and if origin ok
452 bool canBuildItemPart(RM_FABER_TYPE::TRMFType e, ITEM_ORIGIN::EItemOrigin origin) const;
454 // MP only. get a ref on the item part. assert if cannot build for any race
455 const CMpItemPart &getItemPart(RM_FABER_TYPE::TRMFType e) const;
457 // true if this is an MP that can build some item part
458 bool canBuildSomeItemPart() const;
460 // true if this is an MP that is required for some special item crafting
461 bool isUsedAsCraftRequirement() const;
463 // Weapon/Armor/Buckler only: check if some requirement on this item.
464 // if true, caracType/caracValue is filled according to itemType and itemLevel
465 // the current carac must be >= caracValue
466 bool hasCharacRequirement(uint itemLevel, CHARACTERISTICS::TCharacteristics &caracType, float &caracValue) const;
468 // return if canDrop (player exchange or BotChat Gift)
469 bool canExchangeOrGive(bool botChatGift) const;
471 // MP only. return translated text of all item part this MP can build. empty, if can't build anything
472 void getItemPartListAsText(std::string &ipList) const;
474 // get craft plan
475 const NLMISC::CSheetId &getCraftPlan() const { return CraftPlan; }
479 #endif // CL_ITEM_SHEET_H
481 /* End of item_sheet.h */