BaseClass *SpawnObjectTemplate(const char *pszSpawn, const char *pName, const LTVector& vPos, const LTRotation& rRot) { if (!g_pLTServer || !pszSpawn) return NULL; // Pull the class name out of the spawn string... const ObjectCreateStruct *pOCS = g_pGameServerShell->GetObjectTemplates()->FindTemplate(pszSpawn); if (!pOCS) return NULL; ObjectCreateStruct theStruct = *pOCS; HCLASS hClass = theStruct.m_hClass; if (!hClass) return NULL; theStruct.m_Pos = vPos; theStruct.m_Rotation = rRot; // Change the name of the object, we're assuming that these already exist and more room // doesn't need to be allocated for them theStruct.SetName(pName); theStruct.m_cProperties.AddProp("Name", GenericProp(pName, LT_PT_STRING)); // Change the position and rotation theStruct.m_cProperties.AddProp("Pos", GenericProp(vPos, LT_PT_VECTOR)); theStruct.m_cProperties.AddProp("Rotation", GenericProp(rRot, LT_PT_ROTATION)); // Allocate an object... // Note : This has to use the CreateObjectProps function for purposes of backwards // compatibility. Most of the game code assumes that if it's getting a PRECREATE_NORMAL // message that it doesn't have any properties available. return (BaseClass *)g_pLTServer->CreateObjectProps(hClass, &theStruct, ""); }
static LTRESULT CreateStaticObjects(CClassMgr *pClassMgr) { int i; ObjectCreateStruct theStruct; LPBASECLASS pObject; ClassDef *pClass; LTRESULT dResult; for (i=0; i < pClassMgr->m_nClassDatas; i++) { theStruct.Clear(); pClass = pClassMgr->m_ClassDatas[i].m_pClass; if (pClass->m_ClassFlags & CF_STATIC) { pObject = sm_AllocateObjectOfClass(pClass); dResult = sm_AddObjectToWorld(pObject, pClass, &theStruct, INVALID_OBJECTID, OBJECTCREATED_NORMAL, &pClassMgr->m_ClassDatas[i].m_pStaticObject); } } return LT_OK; }
bool CTriggerFX::Init( HLOCALOBJ hServObj, ILTMessage_Read *pMsg ) { if( !hServObj ) return false; if( !CSpecialFX::Init( hServObj, pMsg )) return false; m_cs.hServerObj = hServObj; m_cs.Read( pMsg ); ObjectCreateStruct ocs; LTVector vPos; g_pLTClient->GetObjectPos( m_hServerObject, &vPos ); ocs.m_Pos = vPos; ocs.SetFileName(TRIGFX_DIMS_MODEL ); ocs.SetMaterial(0, TRIGFX_DIMS_MATERIAL ); ocs.m_ObjectType = OT_MODEL; ocs.m_Flags = FLAG_NOLIGHT | FLAG_GOTHRUWORLD; m_hDimsObject = g_pLTClient->CreateObject( &ocs ); if( !m_hDimsObject ) return false; LTVector vDims = m_cs.vDims; g_pPhysicsLT->SetObjectDims( m_hDimsObject, &vDims, 0 ); if( NULL != m_cs.hTriggerTypeRecord ) { m_hIcon.Load( TriggerTypeDB::Instance().GetIconTexture(m_cs.hTriggerTypeRecord) ); } return true; }
void Speaker::InitialUpdate() { if (!g_pLTServer || !m_hObject) return; ObjectCreateStruct createstruct; createstruct.Clear(); SAFE_STRCPY(createstruct.m_Filename, "Models\\1x1_square.abc"); SAFE_STRCPY(createstruct.m_SkinNames[0], "Models\\1x1_square.dtx"); g_pLTServer->Common()->SetObjectFilenames(m_hObject, &createstruct); }
void Prop::HandleDestroy(HOBJECT hDamager) { if( (!m_pDisturb) || (!m_pDisturb->pPD) ) { // Remove us since we don't have a destroyed model to switch to. g_pLTServer->RemoveObject( m_hObject ); return; } // Kill sound if touching. if( m_eState == kState_PropTouching ) { ClearTouchSoundIfDone( LTTRUE ); } else if( m_eState == kState_PropHit ) { ClearHitSoundIfDone( LTTRUE ); } // Remove us if we don't have a destroyed model to switch to. if( m_pDisturb->pPD->sDestroyFilename.empty( ) ) { g_pLTServer->RemoveObject( m_hObject ); return; } ObjectCreateStruct createstruct; createstruct.Clear(); SAFE_STRCPY(createstruct.m_Filename, m_pDisturb->pPD->sDestroyFilename.c_str( )); m_pDisturb->pPD->blrDestroySkinReader.CopyList(0, createstruct.m_SkinNames[0], MAX_CS_FILENAME_LEN+1); m_pDisturb->pPD->blrDestroyRenderStyleReader.CopyList(0, createstruct.m_RenderStyleNames[0], MAX_CS_FILENAME_LEN+1); g_pCommonLT->SetObjectFilenames(m_hObject, &createstruct); m_eState = kState_PropDestroyed; // Can't activate a destroyed prop. g_pCommonLT->SetObjectFlags(m_hObject, OFT_User, 0, USRFLG_CAN_ACTIVATE); m_damage.SetCanDamage(LTFALSE); }
// ----------------------------------------------------------------------- // // // ROUTINE: CDebugLineFX::Spawn // // PURPOSE: Creates a new debug line system. // // ----------------------------------------------------------------------- // DebugLineSystem * DebugLineSystem::Spawn(const char * name, bool bRelative) { const HCLASS hClass = g_pLTServer->GetClass("DebugLineSystem"); ObjectCreateStruct theStruct; theStruct.SetName(name); theStruct.m_Pos = LTVector(0.0f,0.0f,0.0f); theStruct.m_Flags = FLAG_FORCECLIENTUPDATE | FLAG_GOTHRUWORLD | FLAG_NOTINWORLDTREE; theStruct.m_ObjectType = OT_NORMAL; DebugLineSystem* pRV = (DebugLineSystem*)g_pLTServer->CreateObjectProps(hClass, &theStruct, ""); if(!pRV) return NULL; pRV->m_bRelative = bRelative; return pRV; }
void CProjectileFX::CreateFlare(const LTVector & vPos, const LTRotation & rRot) { if (!m_pClientDE || !m_hServerObject) return; ObjectCreateStruct createStruct; createStruct.Clear(); if (!m_pProjectileFX->szFlareSprite[0]) return; SAFE_STRCPY(createStruct.m_Filename, m_pProjectileFX->szFlareSprite); createStruct.m_ObjectType = OT_SPRITE; createStruct.m_Flags = FLAG_VISIBLE; VEC_COPY(createStruct.m_Pos, vPos); createStruct.m_Rotation = rRot; m_hFlare = m_pClientDE->CreateObject(&createStruct); if (!m_hFlare) return; LTFLOAT fScale = m_pProjectileFX->fFlareScale; m_pClientDE->SetObjectScale(m_hFlare, <Vector(fScale, fScale, 1.0f)); }
LTRESULT CLTCommonClient::SetObjectResource(HOBJECT pObj, EObjectResource eType, uint32 nIndex, const char* pszResource) { FN_NAME(CLTCommonClient::SetObjectResource); CHECK_PARAMS2(pObj && (pObj->m_ObjectType == OT_MODEL || pObj->m_ObjectType == OT_SPRITE)); ObjectCreateStruct ocs; ocs.Clear(); if(pObj->m_ObjectType == OT_MODEL) { if(eType == eObjectResource_ObjectFile) { LTStrCpy(ocs.m_Filename, pszResource, MAX_CS_FILENAME_LEN); } else if(eType == eObjectResource_Texture) { assert(nIndex < MAX_MODEL_TEXTURES); LTStrCpy(ocs.m_SkinNames[nIndex], pszResource, MAX_CS_FILENAME_LEN); } else if(eType == eObjectResource_RenderStyle) { assert(nIndex < MAX_MODEL_RENDERSTYLES); LTStrCpy(ocs.m_RenderStyleNames[nIndex], pszResource, MAX_CS_FILENAME_LEN); } return SetObjectFilenames(pObj, &ocs); } else { assert(eType == eObjectResource_ObjectFile); LTStrCpy(ocs.m_Filename, pszResource, MAX_CS_FILENAME_LEN); return SetObjectFilenames(pObj, &ocs); } //return the error code return LT_OK; }
void CProjectile::DoProjectile() { if (!m_pAmmoData || !m_pAmmoData->pProjectileFX) return; // Set up the model... ObjectCreateStruct createStruct; createStruct.Clear(); SAFE_STRCPY(createStruct.m_Filename, m_pAmmoData->pProjectileFX->szModel); SAFE_STRCPY(createStruct.m_SkinNames[0], m_pAmmoData->pProjectileFX->szSkin); g_pLTServer->Common()->SetObjectFilenames(m_hObject, &createStruct); g_pLTServer->ScaleObject(m_hObject, &(m_pAmmoData->pProjectileFX->vModelScale)); uint32 dwFlags = g_pLTServer->GetObjectFlags(m_hObject); g_pLTServer->SetObjectFlags(m_hObject, dwFlags | FLAG_VISIBLE); // Start your engines... m_fStartTime = g_pLTServer->GetTime(); // Make the flash position the same as the fire position... m_vFlashPos = m_vFirePos; // If we have a fired from object, make a link to it... if (m_hFiredFrom) { g_pLTServer->CreateInterObjectLink(m_hObject, m_hFiredFrom); } // Set our force ignore limit and mass... g_pLTServer->SetBlockingPriority(m_hObject, 0); g_pLTServer->SetForceIgnoreLimit(m_hObject, 0.0f); g_pLTServer->SetObjectMass(m_hObject, m_fMass); // Make sure we are pointing in the direction we are traveling... LTRotation rRot; g_pLTServer->AlignRotation(&rRot, &m_vDir, LTNULL); g_pLTServer->SetObjectRotation(m_hObject, &rRot); // Make sure we have the correct flags set... dwFlags = g_pLTServer->GetObjectFlags(m_hObject); dwFlags |= m_pAmmoData->pProjectileFX->dwObjectFlags; g_pLTServer->SetObjectFlags(m_hObject, dwFlags); // And away we go... LTVector vVel; vVel = m_vDir * m_fVelocity; g_pLTServer->SetVelocity(m_hObject, &vVel); // Special case of 0 life time... if (m_fLifeTime <= 0.0f) { Detonate(LTNULL); } else { AddSpecialFX(); } }
void CCharacterHitBox::CreateNodeRadiusModels() { AIASSERT( m_pHitBoxUser, m_hObject, "Called with NULL HitBoxUser" ); AIASSERT( m_hModel, m_hObject, "Called with NULL m_hModel" ); AIASSERT( m_hObject, m_hObject, "Called with NULL m_hObject" ); if (!m_hModel) { return; } ModelsDB::HSKELETON hModelSkeleton = m_pHitBoxUser->GetModelSkeleton(); int cNodes = g_pModelsDB->GetSkeletonNumNodes(hModelSkeleton); for (int iNode = 0; iNode < cNodes; iNode++) { ModelsDB::HNODE hCurNode = g_pModelsDB->GetSkeletonNode( hModelSkeleton, iNode ); const char* szNodeName = g_pModelsDB->GetNodeName( hCurNode ); float fNodeRadius = GetNodeRadius( hCurNode ); if (fNodeRadius <= 0.0f) { continue; } if (!szNodeName) { continue; } LTTransform transform; if ( GetNodeTransform(szNodeName, transform ) == false ) { continue; } // Create the radius model... ObjectCreateStruct theStruct; theStruct.m_Pos = transform.m_vPos; theStruct.SetFileName("Models\\sphere." RESEXT_MODEL_PACKED); theStruct.SetMaterial( 0,"Materials\\Grid." RESEXT_MATERIAL ); theStruct.m_Flags = FLAG_VISIBLE; theStruct.m_ObjectType = OT_MODEL; theStruct.m_eGroup = ePhysicsGroup_NonSolid; HCLASS hClass = g_pLTServer->GetClass("BaseClass"); LPBASECLASS pModel = g_pLTServer->CreateObject(hClass, &theStruct); LTASSERT( pModel, "Failed to create BaseClass" ); if (!pModel) { return; } // Don't eat ticks please... ::SetNextUpdate(pModel->m_hObject, UPDATE_NEVER); g_pLTServer->SetObjectScale(pModel->m_hObject, fNodeRadius); NodeRadiusStruct* pNRS = debug_new(NodeRadiusStruct); pNRS->hNode = hCurNode; pNRS->hModel = pModel->m_hObject; // Add the model to our list... m_NodeRadiusList.AddTail(pNRS); } }