void CScreenTeam::UpdateChar() { HOBJECT hChar = m_CharSFX.GetObject(); if (hChar) { if (m_nCurrentModel >= g_pModelButeMgr->GetNumTeamModels()) { m_nCurrentModel = 0; } ModelId id = g_pModelButeMgr->GetTeamModel(m_nCurrentModel); ObjectCreateStruct createStruct; INIT_OBJECTCREATESTRUCT(createStruct); SAFE_STRCPY(createStruct.m_Filename, g_pModelButeMgr->GetModelFilename(id)); if(g_pModelButeMgr->GetSkinReader(id)) { g_pModelButeMgr->GetSkinReader(id)->CopyList(0, createStruct.m_SkinNames[0], MAX_CS_FILENAME_LEN+1); } g_pModelButeMgr->CopyRenderStyleFilenames( id, &createStruct ); g_pLTClient->SetModelAnimation(hChar, 0); g_pCommonLT->SetObjectFilenames(hChar, &createStruct); uint32 dwAni = g_pLTClient->GetAnimIndex(hChar, "Interface"); if (dwAni != INVALID_ANI) { g_pLTClient->SetModelAnimation(hChar, dwAni); } // Remove old attachments... ClearAttachFX(); // Create the required attachments for this model... INT_CHAR *pChar = g_pLayoutMgr->GetScreenCharacter((eScreenID)m_nScreenID); uint8 nDefaultAttachments = g_pModelButeMgr->GetNumDefaultAttachments( id ); const char *pszAttachmentPos; const char *pszAttachment; for( uint8 i = 0; i < nDefaultAttachments; ++i ) { INT_ATTACH acs; g_pModelButeMgr->GetDefaultAttachment( id, i, pszAttachmentPos, pszAttachment ); acs.nAttachmentID = g_pAttachButeMgr->GetAttachmentIDByName( pszAttachment ); acs.fScale = pChar->fScale; LTStrCpy( acs.szSocket, pszAttachmentPos, ARRAY_LEN( acs.szSocket )); CreateAttachFX( &acs ); } } }
LTBOOL CFolderPlayer::CreatePlayerModel(LTBOOL bNewSkin /* = LTTRUE */) { HOBJECT hCamera = g_pGameClientShell->GetInterfaceCamera(); if (!hCamera) return LTFALSE; if (!strlen(m_szPlayerModel)) return LTFALSE; char temp[128]; strcpy(temp,m_szPlayerModel); char *pTemp = strtok(temp,","); strcpy(m_szModName,pTemp); pTemp = strtok(NULL,","); if (pTemp) strcpy(m_szStyleName,pTemp); if ( bNewSkin ) { uint32 cSkins = 0; uint32 cHeads = 0; char szTag[128]; char szValue[128]; sprintf(szTag, "%s_%s", temp, m_szStyleName); _strlwr(szTag); m_pSkinCtrl->RemoveAll(); m_pHeadCtrl->RemoveAll(); char szRestoreSkin[256]; char szRestoreHead[256]; strcpy(szRestoreSkin, m_szPlayerSkin); *strchr(szRestoreSkin, ',') = 0; strcpy(szRestoreHead, m_szPlayerHead); *strchr(szRestoreHead, ',') = 0; if (g_pModelButeMgr->GetButeMgr()->Exist(szTag)) { sprintf(szValue, "Skin%d", cSkins); while ( g_pModelButeMgr->GetButeMgr()->Exist(szTag, szValue) ) { char szName[256]; strcpy(szName, (const char*)g_pModelButeMgr->GetButeMgr()->GetString(szTag, szValue)); char* pch = strchr(szName, ','); *pch++ = 0; strcpy(m_aszSkins[cSkins], pch); HSTRING hstr = g_pLTClient->CreateString(szName); m_pSkinCtrl->AddString(hstr); g_pLTClient->FreeString(hstr); if ( m_bRestoreSkinHead ) { if ( !strcmp(szName, szRestoreSkin) ) { m_nSkinNum = cSkins; m_pSkinCtrl->UpdateData(LTFALSE); } } cSkins++; sprintf(szValue, "Skin%d", cSkins); } sprintf(szValue, "Head%d", cHeads); while ( g_pModelButeMgr->GetButeMgr()->Exist(szTag, szValue) ) { char szName[256]; strcpy(szName, (const char*)g_pModelButeMgr->GetButeMgr()->GetString(szTag, szValue)); char* pch = strchr(szName, ','); *pch++ = 0; strcpy(m_aszHeads[cHeads], pch); HSTRING hstr = g_pLTClient->CreateString(szName); m_pHeadCtrl->AddString(hstr); g_pLTClient->FreeString(hstr); if ( m_bRestoreSkinHead ) { if ( !strcmp(szName, szRestoreHead) ) { m_nHeadNum = cHeads; m_pHeadCtrl->UpdateData(LTFALSE); } } cHeads++; sprintf(szValue, "Head%d", cHeads); } } ASSERT(cSkins != 0 && cHeads != 0); } m_bRestoreSkinHead = LTFALSE; BSCREATESTRUCT bcs; LTVector vPos, vU, vR, vF, vTemp, vScale(1.0f,1.0f,1.0f); LTRotation rRot; char modName[128]; char animName[128]; char skinName[128]; char skin2Name[128]; if ( bNewSkin ) { sprintf(m_szPlayerSkin, "%s,%s", g_pLTClient->GetStringData(m_pSkinCtrl->GetString(m_nSkinNum)), m_aszSkins[m_nSkinNum]); sprintf(m_szPlayerHead, "%s,%s", g_pLTClient->GetStringData(m_pHeadCtrl->GetString(m_nHeadNum)), m_aszHeads[m_nHeadNum]); } g_pLayoutMgr->GetFolderCustomString((eFolderID)m_nFolderID,"CharAnim",animName,sizeof(animName)); ModelId eModelId = g_pModelButeMgr->GetModelId(m_szModName); ModelStyle eModelStyle = g_pModelButeMgr->GetStyle(m_szStyleName); const char* pFilename = g_pModelButeMgr->GetMultiModelFilename(eModelId, eModelStyle); SAFE_STRCPY(modName, pFilename); const char* pSkin = strchr(m_szPlayerSkin, ',')+1; SAFE_STRCPY(skinName, pSkin); const char* pSkin2 = strchr(m_szPlayerHead, ',')+1; SAFE_STRCPY(skin2Name, pSkin2); g_pLTClient->GetObjectPos(hCamera, &vPos); g_pLTClient->GetObjectRotation(hCamera, &rRot); g_pLTClient->GetRotationVectors(&rRot, &vU, &vR, &vF); VEC_SET(vScale,1.0f,1.0f,1.0f); VEC_MULSCALAR(vScale, vScale, g_pLayoutMgr->GetFolderCustomFloat((eFolderID)m_nFolderID,"CharScale")); LTVector vModPos = g_pLayoutMgr->GetFolderCustomVector((eFolderID)m_nFolderID,"CharPos"); LTFLOAT fRot = g_pLayoutMgr->GetFolderCustomFloat((eFolderID)m_nFolderID,"CharRotation"); fRot = MATH_PI + DEG2RAD(fRot); g_pLTClient->RotateAroundAxis(&rRot, &vU, fRot); VEC_MULSCALAR(vTemp, vF, vModPos.z); VEC_MULSCALAR(vTemp, vTemp, g_pInterfaceResMgr->GetXRatio()); VEC_ADD(vPos, vPos, vTemp); VEC_MULSCALAR(vTemp, vR, vModPos.x); VEC_ADD(vPos, vPos, vTemp); VEC_MULSCALAR(vTemp, vU, vModPos.y); VEC_ADD(vPos, vPos, vTemp); VEC_COPY(bcs.vPos, vPos); bcs.rRot = rRot; VEC_COPY(bcs.vInitialScale, vScale); VEC_COPY(bcs.vFinalScale, vScale); VEC_SET(bcs.vInitialColor, 1.0f, 1.0f, 1.0f); VEC_SET(bcs.vFinalColor, 1.0f, 1.0f, 1.0f); bcs.bUseUserColors = LTTRUE; bcs.pFilename = modName; bcs.pSkin = skinName; bcs.pSkin2 = skin2Name; bcs.dwFlags = FLAG_VISIBLE | FLAG_FOGDISABLE | FLAG_NOLIGHT; bcs.nType = OT_MODEL; bcs.fInitialAlpha = 1.0f; bcs.fFinalAlpha = 1.0f; bcs.fLifeTime = 1000000.0f; bcs.bLoop = LTTRUE; if (m_CharSFX.Init(&bcs)) { m_CharSFX.CreateObject(g_pLTClient); g_pInterfaceMgr->AddInterfaceSFX(&m_CharSFX, IFX_WORLD); if (m_CharSFX.GetObject()) { HMODELANIM hAnim = g_pLTClient->GetAnimIndex(m_CharSFX.GetObject(),animName); if (hAnim != -1) g_pLTClient->SetModelAnimation(m_CharSFX.GetObject(),hAnim); ClearAttachFX(); int reqID[MAX_INT_ATTACHMENTS]; int numReq = g_pAttachButeMgr->GetRequirementIDs(m_szModName,m_szStyleName,reqID,MAX_INT_ATTACHMENTS); for (int i = 0; i < numReq; i++) { INT_ATTACH acs; acs.fScale = g_pLayoutMgr->GetFolderCustomFloat((eFolderID)m_nFolderID,"CharScale"); acs.nAttachmentID = g_pAttachButeMgr->GetRequirementAttachment(reqID[i]); CString socket = g_pAttachButeMgr->GetRequirementSocket(reqID[i]); acs.pszSocket = (char *)(LPCTSTR)socket; CreateAttachFX(&acs); } int numAtt = g_pLayoutMgr->GetFolderNumAttachments((eFolderID)m_nFolderID); for (i = 0; i < numAtt; i++) { char szTemp[128]; char *pName = LTNULL; char *pSocket = LTNULL; g_pLayoutMgr->GetFolderAttachment( (eFolderID)m_nFolderID, i, szTemp, 128); pName = strtok(szTemp,";"); pSocket = strtok(NULL,";"); INT_ATTACH acs; acs.fScale = g_pLayoutMgr->GetFolderCustomFloat((eFolderID)m_nFolderID,"CharScale"); acs.nAttachmentID = g_pAttachButeMgr->GetAttachmentIDByName(pName); acs.pszSocket = pSocket; CreateAttachFX(&acs); } } return LTTRUE; } return LTFALSE; }