// ------------------------------------------------------------------------------------------------ void SCharacter3DSetup::setupDefault (EGSPD::CPeople::TPeople eRace, bool bMale) { People = eRace; Male = bMale; CGenderInfo *pGI = getGenderInfo(eRace, bMale); if (pGI == NULL) return; Skeleton = pGI->Skelfilename; // Read all the default equipement for (sint32 i = 0; i < SLOTTYPE::NB_SLOT; ++i) { string ISstr = pGI->Items[i]; // All the strings are items if (!ISstr.empty()) { CItemSheet *pIS = dynamic_cast<CItemSheet*>(SheetMngr.get(CSheetId(ISstr))); if (pIS != NULL) { sint32 cpIndex = convert_VisualSlot_To_Char3DPart ((SLOTTYPE::EVisualSlot)i); if (cpIndex != Char3DPart_INVALID) { Parts[cpIndex].Quality = pIS->MapVariant; if (Male) Parts[cpIndex].Name = pIS->getShape(); else Parts[cpIndex].Name = pIS->getShapeFemale(); } } } } }
// ------------------------------------------------------------------------------------------------ void SCharacter3DSetup::setupFromCS_ModelCol (SLOTTYPE::EVisualSlot s, sint32 model, sint32 col) { TChar3DPart part = convert_VisualSlot_To_Char3DPart (s); if (part == Char3DPart_INVALID) return; CItemSheet *item = SheetMngr.getItem (s, model); if (item != NULL) { // magician gloves are a weapon but displayed in hands slot(armor gloves) if( (s == SLOTTYPE::RIGHT_HAND_SLOT) && (item->ItemType == ITEM_TYPE::MAGICIAN_STAFF) ) { Parts[part].Name = "none.shape"; part = convert_VisualSlot_To_Char3DPart (SLOTTYPE::HANDS_SLOT); } Parts[part].Quality = item->MapVariant; if (Male) Parts[part].Name = item->getShape(); else Parts[part].Name = item->getShapeFemale(); // FX { Parts[part].AdvFx = item->FX.getAdvantageFX(); Parts[part].StatFxNames.clear(); Parts[part].StatFxBones.clear(); Parts[part].StatFxOffss.clear(); for (uint32 fx = 0; fx < item->FX.getNumStaticFX(); ++fx) { Parts[part].StatFxNames.push_back(item->FX.getStaticFXName(fx)); Parts[part].StatFxBones.push_back(item->FX.getStaticFXBone(fx)); Parts[part].StatFxOffss.push_back(item->FX.getStaticFXOffset(fx)); } } if (part == Char3DPart_HandLeftItem) { if ((item->ItemType == ITEM_TYPE::SHIELD) || (item->ItemType == ITEM_TYPE::BUCKLER)) LeftHandItemIsShield = true; else LeftHandItemIsShield = false; } } else { if ((part == Char3DPart_HandLeftItem) || (part == Char3DPart_HandRightItem)) Parts[part].Name = "none.shape"; } Parts[part].Color = col; }
//----------------------------------------------- // updateVisualPropertyVpa : // Update the Visual Property A. // \todo GUIGUI : utiliser l'enum gender. //----------------------------------------------- void CPlayerR2CL::updateVisualPropertyVpa(const NLMISC::TGameCycle &/* gameCycle */, const sint64 &prop) { CInterfaceManager *IM = CInterfaceManager::getInstance (); // Player will now have enough informations to display the character. _WaitForAppearance = false; // Get the property. SPropVisualA visualA = *(SPropVisualA *)(&prop); // GENDER _Gender = (GSGENDER::EGender)_Sheet->Gender; if(_Gender!=GSGENDER::male && _Gender!=GSGENDER::female) { nlwarning("PL::updateVPVpa:%d: neither a male nor a female -> male selected.", _Slot); _Gender = GSGENDER::male; } // update title when gender changed const ucstring replacement(STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(_TitleRaw,_Gender == GSGENDER::female)); if (!replacement.empty()) { // Get extended name _NameEx = replacement; _Title = replacement; // rebuild in scene interface buildInSceneInterface(); } // Setup _CharacterScalePos _CharacterScalePos = _Sheet->CharacterScalePos; // Check if skeleton has changed if (_CacheSkeletonShapeName != _Sheet->getSkelFilename()) { _CacheSkeletonShapeName = _Sheet->getSkelFilename(); // Clean the playlist. if(_PlayList) _PlayList->resetAllChannels(); // We can now build the skeleton so do it now. skeleton(_CacheSkeletonShapeName); // Invalidate instances cache for (uint i = 0; i < _Instances.size(); ++i) _Instances[i].CurrentName = _Instances[i].LoadingName = ""; _Face.CurrentName = _Face.LoadingName = ""; } // Check the skeleton. if(skeleton() && !ClientCfg.Light) { // To re-link the skeleton to the mount if needed. parent(parent()); // Set the skeleton scale. // \todo GUIGUI: mettre le scale aussi dans race_stats. // Setup Lod Character skeleton, if skeleton exist // Get Lod Character Id from the sheet. sint clodId= getLodCharacterId(*Scene, _Sheet->getLodCharacterName()); if(clodId>=0) { // Setup Lod Character shape and distance skeleton()->setLodCharacterShape(clodId); skeleton()->setLodCharacterDistance(_Sheet->LodCharacterDistance); } // Compute the computeSomeBoneId(); // CHEST equip(SLOTTYPE::CHEST_SLOT, visualA.PropertySubData.JacketModel, visualA.PropertySubData.JacketColor); // LEGS equip(SLOTTYPE::LEGS_SLOT, visualA.PropertySubData.TrouserModel, visualA.PropertySubData.TrouserColor); // ARMS equip(SLOTTYPE::ARMS_SLOT, visualA.PropertySubData.ArmModel, visualA.PropertySubData.ArmColor); // HAT equip(SLOTTYPE::HEAD_SLOT, visualA.PropertySubData.HatModel, visualA.PropertySubData.HatColor); // OBJECT in the RIGHT HAND bool changeWeapon = false; const CItemSheet * oldRightSheet = _Items[SLOTTYPE::RIGHT_HAND_SLOT].Sheet; const CItemSheet * newRightSheet = SheetMngr.getItem(SLOTTYPE::RIGHT_HAND_SLOT, visualA.PropertySubData.WeaponRightHand); if((oldRightSheet && newRightSheet && oldRightSheet->Id!=newRightSheet->Id) || (!oldRightSheet && newRightSheet)) { changeWeapon = true; } _Items[SLOTTYPE::RIGHT_HAND_SLOT].Sheet = SheetMngr.getItem(SLOTTYPE::RIGHT_HAND_SLOT, visualA.PropertySubData.WeaponRightHand); // Equip the weapon(object/tool). if(_Items[SLOTTYPE::RIGHT_HAND_SLOT].Sheet) { if(_Gender == GSGENDER::female) equip(SLOTTYPE::RIGHT_HAND_SLOT, _Items[SLOTTYPE::RIGHT_HAND_SLOT].Sheet->getShapeFemale(), _Items[SLOTTYPE::RIGHT_HAND_SLOT].Sheet); else equip(SLOTTYPE::RIGHT_HAND_SLOT, _Items[SLOTTYPE::RIGHT_HAND_SLOT].Sheet->getShape(), _Items[SLOTTYPE::RIGHT_HAND_SLOT].Sheet); NL3D::UInstance itemInstance = (!_Instances[SLOTTYPE::RIGHT_HAND_SLOT].Loading.empty()) ? _Instances[SLOTTYPE::RIGHT_HAND_SLOT].Loading : _Instances[SLOTTYPE::RIGHT_HAND_SLOT].Current; if (!itemInstance.empty()) { // update fxs _Items[SLOTTYPE::RIGHT_HAND_SLOT].enableAdvantageFX(itemInstance); if ( _CurrentBehaviour.Behaviour != MBEHAV::EXTRACTING ) _Items[SLOTTYPE::RIGHT_HAND_SLOT].setTrailSize(0); //_Items[SLOTTYPE::RIGHT_HAND_SLOT].setTrailSize(visualA.PropertySubData.RTrail); } } else { // No Valid item in the right hand. equip(SLOTTYPE::RIGHT_HAND_SLOT, ""); } // OBJECT in the LEFT HAND const CItemSheet * oldLeftSheet = _Items[SLOTTYPE::LEFT_HAND_SLOT].Sheet; const CItemSheet * newLeftSheet = SheetMngr.getItem(SLOTTYPE::LEFT_HAND_SLOT, visualA.PropertySubData.WeaponLeftHand); if((oldLeftSheet && newLeftSheet && oldLeftSheet->Id!=newLeftSheet->Id) || (!oldLeftSheet && newLeftSheet)) { changeWeapon = true; } _Items[SLOTTYPE::LEFT_HAND_SLOT].Sheet = SheetMngr.getItem(SLOTTYPE::LEFT_HAND_SLOT, visualA.PropertySubData.WeaponLeftHand); // Equip the weapon(object/tool). if(_Items[SLOTTYPE::LEFT_HAND_SLOT].Sheet) { equip(SLOTTYPE::LEFT_HAND_SLOT, _Items[SLOTTYPE::LEFT_HAND_SLOT].Sheet->getShape(), _Items[SLOTTYPE::LEFT_HAND_SLOT].Sheet); NL3D::UInstance itemInstance = (!_Instances[SLOTTYPE::LEFT_HAND_SLOT].Loading.empty()) ? _Instances[SLOTTYPE::LEFT_HAND_SLOT].Loading : _Instances[SLOTTYPE::LEFT_HAND_SLOT].Current; if (!itemInstance.empty()) { // update fxs _Items[SLOTTYPE::LEFT_HAND_SLOT].enableAdvantageFX(itemInstance); _Items[SLOTTYPE::LEFT_HAND_SLOT].setTrailSize(0); //_Items[SLOTTYPE::LEFT_HAND_SLOT].setTrailSize(2 * (uint) visualA.PropertySubData.LTrail); } } else { // No Valid item in the left hand. equip(SLOTTYPE::LEFT_HAND_SLOT, ""); } // Create face // Only create a face when there is no Helmet if(_Items[SLOTTYPE::HEAD_SLOT].Sheet == 0 || _Items[SLOTTYPE::HEAD_SLOT].Sheet->Family != ITEMFAMILY::ARMOR) { CItemSheet *faceItem = getItem(*getGenderInfo(), SLOTTYPE::FACE_SLOT); if (faceItem) { string sFaceName; if(_Gender == GSGENDER::female) sFaceName = faceItem->getShapeFemale(); else sFaceName = faceItem->getShape(); if (((!_Face.Loading.empty()) && (_Face.LoadingName != sFaceName)) || ((!_Face.Current.empty()) && (_Face.CurrentName != sFaceName)) || (_Face.Current.empty())) { if (!_Face.Loading.empty()) { Scene->deleteInstance(_Face.Loading); _Face.Loading = NULL; _Face.LoadingName = sFaceName; } _Face.Loading = Scene->createInstance(sFaceName); if (!_Face.Loading.empty()) { _Face.LoadingName = sFaceName; if(!skeleton()->bindSkin(_Face.Loading)) nlwarning("PL::updateVPVpa:%d: Cannot bind the face.", _Slot); _Face.Loading.hide(); // set it async for texture _Face.Loading.enableAsyncTextureMode(true); } else nlwarning("PL::updateVPVpa:%d: Cannot create the face.", _Slot); } _Face.TextureSet = faceItem->MapVariant; applyColorSlot(_Face, skin(), 0, visualA.PropertySubData.HatColor, 0); // Set a default ruflaket color. } else nlwarning("PL::updateVPVpa:%d: Face Item '%s' does not exist.", _Slot, getGenderInfo()->Items[SLOTTYPE::FACE_SLOT].c_str()); } else { // There is a helmet ! if (!_Face.Loading.empty()) Scene->deleteInstance(_Face.Loading); _Face.Loading = NULL; _Face.LoadingName = ""; if (!_Face.Current.empty()) Scene->deleteInstance(_Face.Current); _Face.Current = NULL; _Face.CurrentName = ""; } // Now we have a skeleton, we can update VpB and VpC. sint64 vB, vC; string propName; propName = toString("SERVER:Entities:E%d:P%d", _Slot, CLFECOMMON::PROPERTY_VPB); vB = IM->getDbProp(propName)->getValue64(); propName = toString("SERVER:Entities:E%d:P%d", _Slot, CLFECOMMON::PROPERTY_VPC); vC = IM->getDbProp(propName)->getValue64(); updateVisualPropertyVpb(0, vB); updateVisualPropertyVpc(0, vC); // Attach The Light if there is one. if(!_Light.empty() && _NameBoneId!=-1) _Skeleton.stickObject(_Light, _NameBoneId); if(changeWeapon) { // Compute the new animation set to use (due to weapons). computeAnimSet(); // Set the animation to idle. setAnim(CAnimationStateSheet::Idle); } } // No skeleton else nlwarning("PL::updateVPVpa:%d: Skeleton not allocated.", _Slot); }// updateVisualPropertyVpa //