void Trigger::AttachToObject() { CServerDE* pServerDE = GetServerDE(); if (!pServerDE || !m_hstrAttachToObject) return; char* pObjName = pServerDE->GetStringData(m_hstrAttachToObject); if (!pObjName) return; // Find object to attach to... HOBJECT hObj = DNULL; ObjectList* pList = pServerDE->FindNamedObjects(pObjName); if (!pList) return; if (pList->m_pFirstLink) { hObj = pList->m_pFirstLink->m_hObject; } if (!hObj) return; DVector vOffset; VEC_INIT(vOffset); DRotation rOffset; ROT_INIT(rOffset); HATTACHMENT hAttachment; pServerDE->CreateAttachment(hObj, m_hObject, DNULL, &vOffset, &rOffset, &hAttachment); }
void Explosion::AddShockwave(DVector *pvPoint) { if (!g_pServerDE) return; ObjectCreateStruct ocStruct; INIT_OBJECTCREATESTRUCT(ocStruct); DRotation rRot; ROT_INIT(rRot); g_pServerDE->SetupEuler(&rRot, MATH_HALFPI, 0.0f, 0.0f); ROT_COPY(ocStruct.m_Rotation, rRot); VEC_COPY(ocStruct.m_Pos, *pvPoint); ocStruct.m_Flags = FLAG_VISIBLE | FLAG_ROTATEABLESPRITE; CImpact* pShockwave = CreateImpact(ocStruct, m_hstrShockwaveSprite); if (!pShockwave) return; if (pShockwave) { DVector vNormal; VEC_SET(vNormal, 0.0f, 1.0f, 0.0f); pShockwave->Setup(vNormal, m_vShockwaveScaleMin, m_vShockwaveScaleMax, DNULL, 0, m_fShockwaveDuration, DTRUE, DFALSE); m_hShockwave = g_pServerDE->ObjectToHandle(pShockwave); g_pServerDE->CreateInterObjectLink(m_hObject, m_hShockwave); } }
CPlayerCamera::CPlayerCamera() { m_hTarget = DNULL; m_pClientDE = DNULL; ROT_INIT(m_rRotation); VEC_INIT(m_vPos); VEC_INIT(m_vLastTargetPos); VEC_INIT(m_vLastOptPos); ROT_INIT(m_rLastTargetRot); // m_eOrientation = SOUTH; // m_eSaveOrientation = SOUTH; m_CameraDistBack = DEFAULT_CAMERA_DIST_BACK; m_CameraDistUp = DEFAULT_CAMERA_DIST_UP; m_CameraDistDiag = DEFAULT_CAMERA_DIST_DIAG; m_OptX = 0.0f; // m_OptY = 0.0f; // m_OptZ = 0.0f; m_OptY = m_CameraDistUp; m_OptZ = -m_CameraDistBack; m_CircleStartTime = 0.0f; m_SaveAnglesY = 0.0f; m_bSlide = DTRUE; m_bStartCircle = DFALSE; m_CircleHeightOffset = 0.0f; m_CircleRadius = 75.0f; m_CircleTime = 3.0f; m_bRestoreFirstPerson = DFALSE; m_fTransitionStart = 0.0f; m_fTransitionTime = 1.0f; m_eCameraMode = FIRSTPERSON; m_eSaveCameraMode = FIRSTPERSON; VEC_INIT(m_TargetFirstPersonOffset); VEC_INIT(m_TargetChaseOffset); VEC_INIT(m_TargetPointAtOffset); VEC_INIT(m_TargetDeathOffset); }
CShellCasingFX::CShellCasingFX() { ROT_INIT(m_rRot); VEC_INIT(m_vStartPos); m_fExpireTime = 0.0f; m_bInVisible = DTRUE; m_bResting = DFALSE; m_nBounceCount = 2; // Set maximum bounces m_bLeftHanded = DFALSE; }
DBOOL CBaseParticleSystemFX::CreateObject(CClientDE *pClientDE) { if (!CSpecialFX::CreateObject(pClientDE)) return DFALSE; DVector vPos; DRotation rRot; ROT_INIT(rRot); // Use server object position if a position wasn't specified... if (m_vPos.x == 0.0f && m_vPos.y == 0.0f && m_vPos.z == 0.0f) { if (m_hServerObject) { pClientDE->GetObjectPos(m_hServerObject, &vPos); } } else { VEC_COPY(vPos, m_vPos); } // Use the specified rotation if applicable if (m_rRot.m_Vec.x != 0.0f || m_rRot.m_Vec.y != 0.0f || m_rRot.m_Vec.z != 0.0f || m_rRot.m_Spin != 1.0f) { ROT_COPY(rRot, m_rRot); } // Setup the ParticleSystem... ObjectCreateStruct createStruct; INIT_OBJECTCREATESTRUCT(createStruct); createStruct.m_ObjectType = OT_PARTICLESYSTEM; createStruct.m_Flags = FLAG_VISIBLE | FLAG_UPDATEUNSEEN; VEC_COPY(createStruct.m_Pos, vPos); ROT_COPY(createStruct.m_Rotation, rRot); m_hObject = m_pClientDE->CreateObject(&createStruct); m_pClientDE->SetupParticleSystem(m_hObject, m_pTextureName, m_fGravity, m_dwFlags, m_fRadius / 640.0f); VEC_SET(m_vColorRange, m_vColor2.x - m_vColor1.x, m_vColor2.y - m_vColor1.y, m_vColor2.z - m_vColor1.z); if (m_vColorRange.x < 0.0f) m_vColorRange.x = 0.0f; if (m_vColorRange.y < 0.0f) m_vColorRange.y = 0.0f; if (m_vColorRange.z < 0.0f) m_vColorRange.z = 0.0f; return DTRUE; }
DBOOL CBaseParticleSystemFX::Init(SFXCREATESTRUCT* psfxCreateStruct) { if (!CSpecialFX::Init(psfxCreateStruct)) return DFALSE; m_fGravity = PSFX_DEFAULT_GRAVITY; m_fRadius = PSFX_DEFAULT_RADIUS; m_dwFlags = 0; m_pTextureName = "SpecialFX\\ParticleTextures\\particle.dtx"; VEC_INIT(m_vPos); ROT_INIT(m_rRot); return DTRUE; }
void Gabriel::CreateShield() { CServerDE* pServerDE = GetServerDE(); if (!pServerDE || m_hShield) return; ObjectCreateStruct theStruct; INIT_OBJECTCREATESTRUCT(theStruct); DVector vPos; pServerDE->GetObjectPos(m_hObject, &vPos); VEC_COPY(theStruct.m_Pos, vPos); SAFE_STRCPY(theStruct.m_Filename, "Models\\PV_Weapons\\SpiderExplosionCore.abc"); SAFE_STRCPY(theStruct.m_SkinName, "SpecialFX\\Explosions\\SpiderCore.dtx"); theStruct.m_ObjectType = OT_MODEL; theStruct.m_Flags = FLAG_VISIBLE | FLAG_GOTHRUWORLD; HCLASS hClass = pServerDE->GetClass("BaseClass"); LPBASECLASS pModel = pServerDE->CreateObject(hClass, &theStruct); if (!pModel) return; m_hShield = pModel->m_hObject; DVector vScale; VEC_SET(vScale, 150.0f, 300.0f, 150.0f); pServerDE->ScaleObject(m_hShield, &vScale); pServerDE->SetObjectColor(m_hShield, 1.0f, 0.5f, 0.0f, 0.5f); // Attach the sheild model to Gabriel... DVector vOffset; VEC_INIT(vOffset); DRotation rOffset; ROT_INIT(rOffset); HATTACHMENT hAttachment; DRESULT dRes = pServerDE->CreateAttachment(m_hObject, m_hShield, DNULL, &vOffset, &rOffset, &hAttachment); if (dRes != DE_OK) { pServerDE->RemoveObject(m_hShield); m_hShield = DNULL; } }
DBOOL GameStartPoint::ReadProp() { CServerDE* pServerDE = GetServerDE(); if (!pServerDE) return DFALSE; GenericProp genProp; if (pServerDE->GetPropGeneric("Multiplayer", &genProp) == DE_OK) m_bMultiplayer = genProp.m_Bool; if (pServerDE->GetPropGeneric("Name", &genProp) == DE_OK) { if (genProp.m_String[0]) m_hstrName = pServerDE->CreateString(genProp.m_String); } if (g_pServerDE->GetPropGeneric("TeamID", &genProp) == DE_OK) { m_nTeamID = (int)genProp.m_Long; } DRotation rRot; ROT_INIT(rRot); if (pServerDE->GetPropGeneric("Rotation", &genProp) == DE_OK) { m_vPitchYawRoll.x = genProp.m_Vec.x; m_vPitchYawRoll.y = genProp.m_Vec.y; m_vPitchYawRoll.z = genProp.m_Vec.z; } if (pServerDE->GetPropGeneric("TriggerTarget", &genProp) == DE_OK) { if (genProp.m_String[0]) m_hstrTriggerTarget = pServerDE->CreateString(genProp.m_String); } if (pServerDE->GetPropGeneric("TriggerMessage", &genProp) == DE_OK) { if (genProp.m_String[0]) m_hstrTriggerMessage = pServerDE->CreateString(genProp.m_String); } return DTRUE; }
void DropShip::CreateThrusterSprites() { CServerDE* pServerDE = GetServerDE(); if (!pServerDE) return; // Create the first thruster... ObjectCreateStruct theStruct; INIT_OBJECTCREATESTRUCT(theStruct); DVector vPos; pServerDE->GetObjectPos(m_hObject, &vPos); VEC_COPY(theStruct.m_Pos, vPos); char* pFilename = m_hstrThrusterFilename ? pServerDE->GetStringData(m_hstrThrusterFilename) : DEFAULT_THRUSTER_SPRITE; pFilename = pFilename ? pFilename : DEFAULT_THRUSTER_SPRITE; SAFE_STRCPY(theStruct.m_Filename, pFilename); theStruct.m_Flags = FLAG_VISIBLE | FLAG_GLOWSPRITE | FLAG_GOTHRUWORLD; theStruct.m_ObjectType = OT_SPRITE; // Okay, this is weird so listen up. If we're creating a smoke trail // we're going to attach a TOW special fx. This special fx will create // a rocket flare, so we don't need (to see) the thruster sprite // (however we still need to create it to give us something to add // the special fx message to). //if (m_bSmokeTrail) //{ // theStruct.m_Flags &= ~FLAG_VISIBLE; // theStruct.m_Flags |= FLAG_FORCECLIENTUPDATE; //} HCLASS hClass = pServerDE->GetClass("BaseClass"); LPBASECLASS pSprite = pServerDE->CreateObject(hClass, &theStruct); if (!pSprite) return; m_hThruster1 = pSprite->m_hObject; pServerDE->ScaleObject(m_hThruster1, &m_vThrusterScale); // Attach the sprite to the model... DVector vOffset; VEC_INIT(vOffset); DRotation rOffset; ROT_INIT(rOffset); HATTACHMENT hAttachment; DRESULT dRes = pServerDE->CreateAttachment(m_hObject, m_hThruster1, "thruster_1", &vOffset, &rOffset, &hAttachment); if (dRes != DE_OK) { pServerDE->RemoveObject(m_hThruster1); m_hThruster1 = DNULL; } if (m_bSmokeTrail) { // Create the special fx message for the object... HMESSAGEWRITE hMessage = pServerDE->StartSpecialEffectMessage(pSprite); pServerDE->WriteToMessageByte(hMessage, SFX_PROJECTILE_ID); pServerDE->WriteToMessageByte(hMessage, GUN_TOW_ID); pServerDE->EndMessage(hMessage); } // Create the second thruster... pSprite = pServerDE->CreateObject(hClass, &theStruct); if (!pSprite) return; m_hThruster2 = pSprite->m_hObject; pServerDE->ScaleObject(m_hThruster2, &m_vThrusterScale); dRes = pServerDE->CreateAttachment(m_hObject, m_hThruster2, "thruster_2", &vOffset, &rOffset, &hAttachment); if (dRes != DE_OK) { pServerDE->RemoveObject(m_hThruster2); m_hThruster2 = DNULL; } if (m_bSmokeTrail) { // Create the special fx message for the object... HMESSAGEWRITE hMessage = pServerDE->StartSpecialEffectMessage(pSprite); pServerDE->WriteToMessageByte(hMessage, SFX_PROJECTILE_ID); pServerDE->WriteToMessageByte(hMessage, GUN_TOW_ID); pServerDE->EndMessage(hMessage); } }