Advertisement
dcomicboy

spawning

Mar 19th, 2014
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.18 KB | None | 0 0
  1. //H File
  2. // ----------------------------------------------------------------------- //
  3. //
  4. // MODULE : Spawner.h
  5. //
  6. // PURPOSE : Spawner class - implementation
  7. //
  8. // CREATED : 1/9/98
  9. //
  10. // ----------------------------------------------------------------------- //
  11.  
  12. #ifndef __SPAWNER_H__
  13. #define __SPAWNER_H__
  14.  
  15. #include "ltengineobjects.h"
  16. #include "GameBase.h"
  17. #include "CommandMgr.h"
  18.  
  19. LINKTO_MODULE( Spawner );
  20.  
  21. BaseClass *SpawnObject( char const* pszSpawn, const LTVector& vPos, const LTRotation& rRot );
  22.  
  23. class Spawner : public GameBase
  24. {
  25. public :
  26.  
  27. Spawner();
  28. virtual ~Spawner();
  29.  
  30. void Setup( );
  31.  
  32. protected :
  33.  
  34. virtual uint32 EngineMessageFn(uint32 messageID, void *pData, LTFLOAT lData);
  35. virtual bool OnTrigger(HOBJECT hSender, const CParsedMsg &cMsg);
  36.  
  37. private :
  38.  
  39. LTBOOL ReadProp(ObjectCreateStruct *pData);
  40. LTBOOL PostPropRead(ObjectCreateStruct* pData);
  41. LTBOOL InitialUpdate();
  42.  
  43. void Save(ILTMessage_Write *pMsg, uint32 dwSaveFlags);
  44. void Load(ILTMessage_Read *pMsg, uint32 dwSaveFlags);
  45.  
  46. std::string m_sDefaultSpawn;
  47. std::string m_sTarget;
  48. std::string m_sSpawnSound;
  49. std::string m_sInitialCommand;
  50. LTFLOAT m_fSoundRadius;
  51. };
  52.  
  53. class CSpawnerPlugin : public IObjectPlugin
  54. {
  55. public :
  56.  
  57. virtual LTRESULT PreHook_PropChanged(
  58. const char *szObjName,
  59. const char *szPropName,
  60. const int nPropType,
  61. const GenericProp &gpPropValue,
  62. ILTPreInterface *pInterface,
  63. const char *szModifiers );
  64.  
  65. protected :
  66.  
  67. CCommandMgrPlugin m_CommandMgrPlugin;
  68. };
  69.  
  70.  
  71. #endif // __SPAWNER_H__
  72.  
  73. //CPP file
  74. void CCharacter::SpawnItem(char* pItem, LTVector & vPos, LTRotation & rRot)
  75. {
  76. if (!pItem) return;
  77.  
  78. LPBASECLASS pObj = SpawnObject(pItem, vPos, rRot);
  79.  
  80. if (pObj && pObj->m_hObject)
  81. {
  82. LTVector vAccel;
  83. VEC_SET(vAccel, GetRandom(0.0f, 300.0f), GetRandom(100.0f, 200.0f), GetRandom(0.0f, 300.0f));
  84. g_pPhysicsLT->SetAcceleration(pObj->m_hObject, &vAccel);
  85.  
  86. LTVector vVel;
  87. vVel.Init(GetRandom(0.0f, 100.0f), GetRandom(200.0f, 400.0f), GetRandom(0.0f, 100.0f));
  88. g_pPhysicsLT->SetVelocity(pObj->m_hObject, &vVel);
  89. }
  90. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement