1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
4 // This source file has been modified by the following contributors:
5 // Copyright (C) 2020 Jan BOON (Kaetemi) <jan.boon@kaetemi.be>
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/>.
26 #include "stdpch.h" // First include for pre-compiled headers.
28 #include "nel/georges/u_form_elm.h"
30 #include "player_sheet.h"
32 #include "game_share/skills.h"
33 #include "game_share/skills_build.h"
39 using namespace NLGEORGES
;
46 //-----------------------------------------------
49 //-----------------------------------------------
50 CPlayerSheet::CPlayerSheet()
54 // Initialize the type.
55 Type
= CEntitySheet::CHAR
;
58 //-----------------------------------------------
60 // Build the sheet from an external script.
61 //-----------------------------------------------
62 void CPlayerSheet::build(const NLGEORGES::UFormElm
&item
)
64 // Initialize the scale.
68 if(!item
.getValueByName(Gender
, "Gender"))
69 debug("Key 'Gender' not found.");
72 if(!item
.getValueByName(SkelFilename
, "Skel"))
73 debug("Key 'Skel' not found.");
75 // Load the Animation Set Base Name.
76 if(!item
.getValueByName(AnimSetBaseName
, "AnimSetBaseName"))
77 debug("Key 'AnimSetBaseName' not found.");
78 // Force the CASE in UPPER to not be CASE SENSITIVE.
80 AnimSetBaseName
= NLMISC::toLowerAscii(AnimSetBaseName
);
82 // Load Lod character name
83 if(!item
.getValueByName(LodCharacterName
, "LodCharacterName"))
84 debug("Key 'LodCharacterName' not found.");
86 // Load Lod character apparition distance
87 if(!item
.getValueByName(LodCharacterDistance
, "LodCharacterDistance"))
88 debug("Key 'LodCharacterDistance' not found.");
90 // Get the people of the player.
92 if(!item
.getValueByName(people
, "Peuple"))
94 debug("Key 'Peuple' not found.");
95 People
= EGSPD::CPeople::EndPeople
;
98 People
= EGSPD::CPeople::fromString(people
);
100 // Get the Default Player Face filename.
101 if(!item
.getValueByName(DefaultFace
, "DefaultFace"))
102 debug("Key 'DefaultFace' not found.");
103 // Get the Default Player Chest filename.
104 if(!item
.getValueByName(DefaultChest
, "DefaultChest"))
105 debug("Key 'DefaultChest' not found.");
106 // Get the Default Player Legs filename.
107 if(!item
.getValueByName(DefaultLegs
, "DefaultLegs"))
108 debug("Key 'DefaultLegs' not found.");
109 // Get the Default Player Arms filename.
110 if(!item
.getValueByName(DefaultArms
, "DefaultArms"))
111 debug("Key 'DefaultArms' not found.");
112 // Get the Default Player Hands filename.
113 if(!item
.getValueByName(DefaultHands
, "DefaultHands"))
114 debug("Key 'DefaultHands' not found.");
115 // Get the Default Player Feet filename.
116 if(!item
.getValueByName(DefaultFeet
, "DefaultFeet"))
117 debug("Key 'DefaultFeet' not found.");
118 // Get the Default Player Hair filename.
119 if(!item
.getValueByName(DefaultHair
, "DefaultHair"))
120 debug("Key 'DefaultHair' not found.");
123 if(!item
.getValueByName(DefaultHair
, "DefaultHair"))
124 debug("Key 'DefaultHair' not found.");
127 // NB: lod colors are given with panoply colors for players
130 // value to scale the "pos" channel of the animation of the player.
131 if(!item
.getValueByName(CharacterScalePos
, "CharacterScalePos"))
132 debug("Key 'CharacterScalePos' not found.");
134 #define PLAYER_SHEET_EQUIP "Basics.Equipment."
135 Body
.build(PLAYER_SHEET_EQUIP
"Body", item
);
136 Legs
.build(PLAYER_SHEET_EQUIP
"Legs", item
);
137 Arms
.build(PLAYER_SHEET_EQUIP
"Arms", item
);
138 Hands
.build(PLAYER_SHEET_EQUIP
"Hands", item
);
139 Feet
.build(PLAYER_SHEET_EQUIP
"Feet", item
);
140 Head
.build(PLAYER_SHEET_EQUIP
"Head", item
);
141 Face
.build(PLAYER_SHEET_EQUIP
"Face", item
);
142 ObjectInRightHand
.build(PLAYER_SHEET_EQUIP
"ObjectInRightHand", item
);
143 ObjectInLeftHand
.build(PLAYER_SHEET_EQUIP
"ObjectInLeftHand", item
);
144 Headdress
.build(PLAYER_SHEET_EQUIP
"Headdress", item
);
145 EarL
.build(PLAYER_SHEET_EQUIP
"EarL", item
);
146 EarR
.build(PLAYER_SHEET_EQUIP
"EarR", item
);
147 Neck
.build(PLAYER_SHEET_EQUIP
"Neck", item
);
148 Shoulders
.build(PLAYER_SHEET_EQUIP
"Shoulders", item
);
149 Back
.build(PLAYER_SHEET_EQUIP
"Back", item
);
150 WristL
.build(PLAYER_SHEET_EQUIP
"WristL", item
);
151 WristR
.build(PLAYER_SHEET_EQUIP
"WristR", item
);
152 FingerL
.build(PLAYER_SHEET_EQUIP
"FingerL", item
);
153 FingerR
.build(PLAYER_SHEET_EQUIP
"FingerR", item
);
154 AnkleR
.build(PLAYER_SHEET_EQUIP
"AnkleR", item
);
155 AnkleL
.build(PLAYER_SHEET_EQUIP
"AnkleL", item
);
156 Ammo
.build(PLAYER_SHEET_EQUIP
"Ammo", item
);
162 loadSkillsSummaryFromSheet(item
, "Basics.", Skills
);
166 //-----------------------------------------------
167 void CPlayerSheet::buildCharac(const NLGEORGES::UFormElm
&item
)
169 static const char characsBasePath
[] = "Basics.Characteristics.";
170 for(uint k
= 0; k
< CHARACTERISTICS::NUM_CHARACTERISTICS
; ++k
)
172 const std::string
&characName
= CHARACTERISTICS::toString((CHARACTERISTICS::TCharacteristics
)k
);
173 std::string characPath
= characsBasePath
+ characName
;
174 if(!item
.getValueByName(Characteristics
[k
], characPath
.c_str()))
176 debug("Key " + characName
+ "not found.");
177 Characteristics
[k
] = 0;
183 //-----------------------------------------------
185 // Serialize player sheet into binary data file.
186 //-----------------------------------------------
187 void CPlayerSheet::serial(NLMISC::IStream
&f
)
189 // Serialize class components.
190 f
.serial(SkelFilename
);
191 f
.serial(AnimSetBaseName
);
193 f
.serial(LodCharacterName
);
194 f
.serial(LodCharacterDistance
);
195 f
.serial(CharacterScalePos
);
196 f
.serialEnum(People
);
197 f
.serial(DefaultFace
);
198 f
.serial(DefaultChest
);
199 f
.serial(DefaultLegs
);
200 f
.serial(DefaultArms
);
201 f
.serial(DefaultHands
);
202 f
.serial(DefaultFeet
);
203 f
.serial(DefaultHair
);
213 f
.serial(ObjectInRightHand
);
214 f
.serial(ObjectInLeftHand
);
229 for(uint k
= 0; k
< CHARACTERISTICS::NUM_CHARACTERISTICS
; ++k
)
231 f
.serial(Characteristics
[k
]);
234 f
.serialCont(Skills
);
238 //=========================================================================================
239 void CPlayerSheet::CEquipment::build(const std::string
&key
,const NLGEORGES::UFormElm
&item
)
241 // Get the item (or shape) name.
243 if(!item
.getValueByName(itemName
, string(key
+ ".Item").c_str() ))
244 debug(NLMISC::toString("Key '%s.Item' not found.", key
.c_str()));
246 Item
= NLMISC::toLowerAscii(itemName
);
249 if(!item
.getValueByName(Color
, string(key
+ ".Color").c_str() ))
250 debug(NLMISC::toString("Key '%s.Color' not found.", key
.c_str()));