DDWORD ObjectiveTrigger::EngineMessageFn(DDWORD messageID, void *pData, DFLOAT fData) { CServerDE* pServerDE = GetServerDE(); if (!pServerDE) return DFALSE; switch (messageID) { case MID_INITIALUPDATE: { if (fData != INITIALUPDATE_SAVEGAME) { pServerDE->SetObjectDims(m_hObject, &m_vDims); pServerDE->SetObjectFlags(m_hObject, FLAG_TOUCH_NOTIFY); pServerDE->SetObjectUserFlags(m_hObject, USRFLG_IGNORE_PROJECTILES); pServerDE->SetNextUpdate(m_hObject, 0.0f); } } break; case MID_TOUCHNOTIFY: { if (!m_bTriggered) ObjectTouch((HOBJECT)pData); } break; case MID_PRECREATE: { ObjectCreateStruct* pStruct = (ObjectCreateStruct*)pData; if (!pStruct) return 0; if (fData == PRECREATE_WORLDFILE) { ReadProp(pStruct); } } break; case MID_SAVEOBJECT: { Save((HMESSAGEWRITE)pData, (DDWORD)fData); } break; case MID_LOADOBJECT: { Load((HMESSAGEREAD)pData, (DDWORD)fData); } break; default : break; } return BaseClass::EngineMessageFn(messageID, pData, fData); }
bool PickupItem::OnTrigger(HOBJECT hSender, const CParsedMsg &cMsg) { static CParsedMsg::CToken s_cTok_Activate("ACTIVATE"); static CParsedMsg::CToken s_cTok_Team( "TEAM" ); if( cMsg.GetArg(0) == s_cTok_Activate ) { // Can't activate before we've respawned. if( m_bWasPickedUp ) return true; // If the object is dead, it can't pick up stuff... if (IsPlayer(hSender)) { CPlayerObj* pPlayer = (CPlayerObj*)g_pLTServer->HandleToObject(hSender); if (!pPlayer || pPlayer->IsDead()) return true; SetPlayerObj(hSender); ObjectTouch(hSender); } else { SetPlayerObj(LTNULL); return true; } } else if (cMsg.GetArg(0) == s_cTok_Team) { if( cMsg.GetArgCount( ) > 1 ) { uint32 nTeamId = atoi( cMsg.GetArg( 1 )); if( nTeamId < MAX_TEAMS ) { SetTeamId( nTeamId ); } else { SetTeamId( INVALID_TEAM ); } return true; } } else return GameBase::OnTrigger(hSender, cMsg); return true; }
DDWORD DefenseGlobeLegs::EngineMessageFn(DDWORD messageID, void *pData, DFLOAT fData) { switch(messageID) { case MID_UPDATE: { if (!Update((DVector *)pData) ) { CServerDE* pServerDE = GetServerDE(); if (!pServerDE) break; pServerDE->RemoveObject(m_hObject); } } break; case MID_TOUCHNOTIFY: { ObjectTouch((HOBJECT)pData); } break; case MID_PRECREATE: { // Need to call base class to have the object name read in before // we call PostPropRead() DDWORD dwRet = B2BaseClass::EngineMessageFn(messageID, pData, fData); PostPropRead((ObjectCreateStruct*)pData); return dwRet; } case MID_INITIALUPDATE: { InitialUpdate((DVector *)pData); } break; default : break; } return B2BaseClass::EngineMessageFn(messageID, pData, fData); }
uint32 PickupItem::EngineMessageFn(uint32 messageID, void *pData, LTFLOAT fData) { switch(messageID) { case MID_UPDATE: { Update(); } break; case MID_TOUCHNOTIFY: { if( !m_bTouchPickup ) break; HOBJECT hObj = (HOBJECT)pData; // If this is a character hit box, use its object... CCharacterHitBox* pHitBox = LTNULL; if (IsCharacterHitBox(hObj)) { pHitBox = (CCharacterHitBox*)g_pLTServer->HandleToObject(hObj); if (pHitBox) { hObj = pHitBox->GetModelObject(); } } // If the object is dead, it can't pick up stuff... if (IsPlayer(hObj)) { CPlayerObj* pPlayer = (CPlayerObj*)g_pLTServer->HandleToObject(hObj); if (!pPlayer || pPlayer->IsDead()) break; SetPlayerObj(hObj); } else { SetPlayerObj(LTNULL); break; } ObjectTouch(hObj); } break; case MID_PRECREATE: { ObjectCreateStruct* pInfo = (ObjectCreateStruct*)pData; if (fData == PRECREATE_WORLDFILE) { ReadProp(pInfo); } else if (fData == PRECREATE_STRINGPROP) { ReadProp(pInfo); // Show ourself... pInfo->m_Flags |= FLAG_VISIBLE; } PostPropRead(pInfo); } break; case MID_INITIALUPDATE: { if (fData != INITIALUPDATE_SAVEGAME) { InitialUpdate(); } } break; case MID_SAVEOBJECT: { Save((ILTMessage_Write*)pData, (uint32)fData); } break; case MID_LOADOBJECT: { Load((ILTMessage_Read*)pData, (uint32)fData); uint32 dwRet = GameBase::EngineMessageFn(messageID, pData, fData); // We need to reset our sfx message since values // could have changed across save versions. CreateSpecialFX( ); return dwRet; } break; default : break; } return GameBase::EngineMessageFn(messageID, pData, fData); }
DDWORD Trigger::EngineMessageFn(DDWORD messageID, void *pData, DFLOAT fData) { switch(messageID) { case MID_UPDATE: { if (!Update()) { CServerDE* pServerDE = BaseClass::GetServerDE(); if (!pServerDE) return 0; pServerDE->RemoveObject(m_hObject); } } break; case MID_TOUCHNOTIFY: { ObjectTouch((HOBJECT)pData); } break; case MID_PRECREATE: { ObjectCreateStruct *pStruct = (ObjectCreateStruct *)pData; if (!pStruct) return 0; if (fData == PRECREATE_WORLDFILE) { ReadProp(pStruct); } pStruct->m_UserData = USRFLG_IGNORE_PROJECTILES; pStruct->m_fDeactivationTime = TRIGGER_DEACTIVATION_TIME; } break; case MID_INITIALUPDATE: { if (fData != INITIALUPDATE_SAVEGAME) { InitialUpdate(); } CacheFiles(); } break; case MID_LINKBROKEN : { HOBJECT hLink = (HOBJECT)pData; if (hLink == m_hTouchObject) { m_hTouchObject = DNULL; } } break; case MID_SAVEOBJECT: { Save((HMESSAGEWRITE)pData, (DDWORD)fData); } break; case MID_LOADOBJECT: { Load((HMESSAGEREAD)pData, (DDWORD)fData); } break; case MID_PARENTATTACHMENTREMOVED : { // Go away if our parent is removed... CServerDE* pServerDE = BaseClass::GetServerDE(); if (pServerDE) { pServerDE->RemoveObject(m_hObject); } } break; default : break; } return BaseClass::EngineMessageFn(messageID, pData, fData); }
DDWORD PickupObject::EngineMessageFn(DDWORD messageID, void *pData, DFLOAT fData) { if( g_pServerDE ) { switch(messageID) { case MID_UPDATE: { Update((DVector *)pData); break; } case MID_TOUCHNOTIFY: { ObjectTouch((HOBJECT)pData); break; } case MID_PRECREATE: { DDWORD dwRet = B2BaseClass::EngineMessageFn(messageID, pData, fData); if (fData == PRECREATE_WORLDFILE ) ReadProp((ObjectCreateStruct*)pData); if( fData == PRECREATE_STRINGPROP) { ReadProp((ObjectCreateStruct*)pData); } PostPropRead((ObjectCreateStruct*)pData); return dwRet; } case MID_INITIALUPDATE: { if (fData != INITIALUPDATE_SAVEGAME) { InitialUpdate((DVector *)pData); } if (fData == INITIALUPDATE_WORLDFILE) { MoveObjectToGround(m_hObject); } else if( fData == PRECREATE_STRINGPROP) { DVector vPos; g_pServerDE->GetObjectPos(m_hObject, &vPos); SpawnItem( &vPos ); } CacheFiles(); break; } case MID_SAVEOBJECT: { Save((HMESSAGEWRITE)pData, (DDWORD)fData); break; } case MID_LOADOBJECT: { Load((HMESSAGEREAD)pData, (DDWORD)fData); break; } default : break; } } return B2BaseClass::EngineMessageFn(messageID, pData, fData); }