TargetPoints.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664
  1. #include "TargetPoints.h"
  2. #include "ships\ship.h"
  3. #include "..\Common_h\ICharactersArbiter.h"
  4. #include "..\Common_h\IExplosionPatch.h"
  5. #include "..\Common_h\IShooter.h"
  6. #include "SeaMissionParams.h"
  7. //============================================================================================
  8. array<TargetPoints*> TargetPoints::g_targObjectsList(_FL_);
  9. long TargetPoints::g_nTargObjIndex = 0;
  10. float TargetPoints::g_fCooldawn = 0.f;
  11. TargetPoints* TargetPoints::g_pLastTargetPoints = NULL;
  12. TargetPoints::TargetPoints() :
  13. m_points(_FL_)
  14. {
  15. m_renderParams.pointradius = 1.f;
  16. m_renderParams.scalePeriod = 1.f;
  17. m_renderParams.scaleAmplitude = 1.2f;
  18. m_renderParams.colPrepare = 0xC060FF60;
  19. m_renderParams.startSize = 0.5f;
  20. m_renderParams.startColor = 0x55FFFFFF;
  21. m_renderParams.finishColor = 0xCCFFFFFF;
  22. m_renderParams.pTexture = NULL;
  23. m_renderParams.pVertex = NULL;
  24. m_renderParams.pIndex = NULL;
  25. m_renderParams.pShVarTexture = NULL;
  26. m_renderParams.pShVarCol = NULL;
  27. m_logicParams.minShowDelay = 0.f;
  28. m_logicParams.maxShowDelay = 1.f;
  29. m_logicParams.activeRadius = 5.f;
  30. m_logicParams.minFlyTime = 1.f;
  31. m_logicParams.maxFlyTime = 3.f;
  32. m_logicParams.minFlyHeight = 10.f;
  33. m_logicParams.maxFlyHeight = 40.f;
  34. m_hitParams.explodeRadius = 2.f;
  35. m_hitParams.explodeDamage = 100.f;
  36. m_hitParams.explodePower = 1.f;
  37. m_hitParams.hitSFXScale = 1.f;
  38. g_nTargObjIndex = 0;
  39. g_targObjectsList.Add(this);
  40. g_fCooldawn = 0.f;
  41. g_pLastTargetPoints = NULL;
  42. m_arbiter.Reset();
  43. m_ExplosionPatch = NULL;
  44. m_HitGroupIndex = -1;
  45. m_bWaitKickOut = false;
  46. m_bWaitKickOutPrepair = false;
  47. }
  48. TargetPoints::~TargetPoints()
  49. {
  50. RELEASE(m_renderParams.pTexture);
  51. RELEASE(m_renderParams.pVertex);
  52. RELEASE(m_renderParams.pIndex);
  53. g_nTargObjIndex = 0;
  54. g_targObjectsList.Del(this);
  55. g_fCooldawn = 0.f;
  56. g_pLastTargetPoints = NULL;
  57. m_ExplosionPatch = NULL;
  58. }
  59. //============================================================================================
  60. //Инициализировать объект
  61. bool TargetPoints::Create(MOPReader & reader)
  62. {
  63. // shader
  64. Render().GetShaderId("TargetPoints",m_renderParams.idShader);
  65. // shader variables
  66. m_renderParams.pShVarTexture = Render().GetTechniqueGlobalVariable("TargPntTexture",_FL_);
  67. Assert(m_renderParams.pShVarTexture);
  68. m_renderParams.pShVarCol = Render().GetTechniqueGlobalVariable("TargPntColor",_FL_);
  69. Assert(m_renderParams.pShVarCol);
  70. // read mission params
  71. ReadMOPs(reader);
  72. // for edit mode:
  73. if( EditMode_IsOn() )
  74. {
  75. SetUpdate(&TargetPoints::WorkEdit, ML_PARTICLES1);
  76. // set all points into prepare state
  77. for( dword n=0; n<m_points.Size(); n++ )
  78. {
  79. m_points[n].state = tps_prepare;
  80. m_points[n].maxFlyTime = 0.f;
  81. m_points[n].curFlyTime = 0.f;
  82. }
  83. UpdatePointsVertex(0.f);
  84. }
  85. return true;
  86. }
  87. void TargetPoints::PostCreate()
  88. {
  89. static const ConstString arbiterId("CharactersArbiter");
  90. MissionObject::FindObject(arbiterId, m_arbiter);
  91. static const ConstString seaMisParamsId("SeaMissionParams");
  92. MissionObject::FindObject(seaMisParamsId, m_seaMisParams);
  93. if( !FindObject( m_logicParams.watchObjectID, m_logicParams.watchObject ) )
  94. {
  95. LogicDebug("Target points array: can`t find watched object");
  96. }
  97. m_ExplosionPatch = IExplosionPatch::GetExplosionPatch(Mission());
  98. if( m_ExplosionPatch )
  99. {
  100. m_HitGroupIndex = m_ExplosionPatch->GetHitGroup("ShipCannon");
  101. if( m_HitGroupIndex < 0 )
  102. {
  103. LogicDebug("Target point create: warning - Can`t find explosion patch geometry group 'ShipCannon'");
  104. m_HitGroupIndex = m_ExplosionPatch->GetHitGroup("bomb");
  105. }
  106. }
  107. static const ConstString strShooterKickOut = ConstString("ShooterKickOut");
  108. if (!FindObject(strShooterKickOut, m_ShooterKickOut))
  109. api->Error("ERROR: TargetPoints: Can't find KickOut object ShooterKickOut");
  110. }
  111. // редактировать объект
  112. bool TargetPoints::EditMode_Update(MOPReader & reader)
  113. {
  114. ReadMOPs(reader);
  115. // set all points into prepare state
  116. for( dword n=0; n<m_points.Size(); n++ )
  117. {
  118. m_points[n].state = tps_prepare;
  119. m_points[n].maxFlyTime = 0.f;
  120. m_points[n].curFlyTime = 0.f;
  121. }
  122. UpdatePointsVertex(0.f);
  123. return true;
  124. }
  125. //Активировать
  126. void TargetPoints::Activate(bool isActive)
  127. {
  128. MissionObject::Activate(isActive);
  129. if(!EditMode_IsOn())
  130. {
  131. if(IsActive() )
  132. {
  133. LogicDebug("Activate");
  134. SetUpdate(&TargetPoints::WorkGame, ML_PARTICLES1);
  135. }else{
  136. LogicDebug("Deactivate");
  137. DelUpdate(&TargetPoints::WorkGame);
  138. }
  139. }
  140. }
  141. long TargetPoints::GetPointsArray(long shootQuantity, array<long>& points)
  142. {
  143. long leftQnt = shootQuantity;
  144. long chooseQnt = 0;
  145. // дистанция в квадрате
  146. float dist2pow = m_logicParams.activeRadius * m_logicParams.activeRadius;
  147. // позиция источника (игрока)
  148. Vector cpos = 0.f;
  149. if( m_logicParams.watchObject.Validate() )
  150. {
  151. Matrix mtx(true);
  152. m_logicParams.watchObject.Ptr()->GetMatrix(mtx);
  153. cpos = mtx.pos;
  154. }
  155. // массив дистанций
  156. array<float> aPowDist(_FL_);
  157. points.DelAll();
  158. for(dword n=0; n<m_points.Size() && leftQnt>0; n++)
  159. {
  160. // пропускаем уже выбранные точки
  161. if( m_points[n].state == tps_prepare ) continue;
  162. // дистанция до точки
  163. float curDist = ~(m_points[n].pos - cpos);
  164. // пропускаем точки которые далеко от нас
  165. if( curDist > dist2pow ) continue;
  166. points.Add( n );
  167. aPowDist.Add( curDist );
  168. chooseQnt++;
  169. leftQnt--;
  170. }
  171. // лимит на количество
  172. while(chooseQnt > m_logicParams.pointsLimit)
  173. {
  174. dword imax = 0;
  175. for(n=1; n<aPowDist.Size(); n++)
  176. if( aPowDist[n] > aPowDist[imax] )
  177. imax = n;
  178. aPowDist.DelIndex(imax);
  179. points.DelIndex(imax);
  180. chooseQnt--;
  181. }
  182. return chooseQnt;
  183. }
  184. const Vector & TargetPoints::GetPointPos(long n)
  185. {
  186. return m_points[n].pos;
  187. }
  188. void TargetPoints::ResetPoint(long n)
  189. {
  190. if( n < m_points )
  191. {
  192. m_points[n].state = tps_disable;
  193. }
  194. }
  195. void TargetPoints::BorrowPoint(long n, float flyTime)
  196. {
  197. m_points[n].state = tps_showdelay;
  198. m_points[n].maxFlyTime = flyTime;
  199. m_points[n].curFlyTime = 0.f;
  200. // подготавливаем выбиватель из шутера
  201. if( !m_bWaitKickOutPrepair && !m_bWaitKickOut )
  202. {
  203. m_bWaitKickOutPrepair = true;
  204. m_bWaitKickOut = false;
  205. }
  206. }
  207. void TargetPoints::BorrowTargetPoints(TargetPoints* pTargPoints, MissionObject* pObj)
  208. {
  209. if( g_pLastTargetPoints != NULL ) return;
  210. if( g_fCooldawn > 0.f ) return;
  211. if( pTargPoints == NULL ) return;
  212. g_pLastTargetPoints = pTargPoints;
  213. g_fCooldawn = pTargPoints->GetCooldawn();
  214. // в следующий раз берем другой набор точек
  215. g_nTargObjIndex++;
  216. // поставим позицию для стреляющего
  217. if( pObj )
  218. {
  219. Matrix mtx(true);
  220. pObj->GetMatrix(mtx);
  221. pTargPoints->SetSrcPosition(mtx.pos);
  222. }
  223. }
  224. void TargetPoints::GetTimeHeightLimit(float & fTimeLimit, float & fHeightLimit)
  225. {
  226. fTimeLimit = m_logicParams.minFlyTime + FRAND( m_logicParams.maxFlyTime - m_logicParams.minFlyTime );
  227. fHeightLimit = m_logicParams.minFlyHeight + FRAND( m_logicParams.maxFlyHeight - m_logicParams.minFlyHeight );
  228. }
  229. void TargetPoints::MakePointDamage(long n)
  230. {
  231. Vector vPos = m_points[n].pos;
  232. Matrix mPos;
  233. mPos.BuildPosition(vPos);
  234. // particle
  235. if( !m_hitParams.hitSFX.IsEmpty() )
  236. {
  237. IParticleSystem* pParticle = Particles().CreateParticleSystemEx2( m_hitParams.hitSFX.c_str(), mPos, false, _FL_ );
  238. if( pParticle )
  239. {
  240. pParticle->SetScale( m_hitParams.hitSFXScale );
  241. pParticle->AutoDelete(true);
  242. }
  243. }
  244. // sound
  245. if( !m_hitParams.hitSound.IsEmpty() )
  246. Sound().Create3D( m_hitParams.hitSound.c_str(), vPos, _FL_ );
  247. // boom
  248. if(m_arbiter.Validate())
  249. {
  250. ((ICharactersArbiter *)m_arbiter.Ptr())->Boom(this, DamageReceiver::ds_cannon, vPos, m_hitParams.explodeRadius, m_hitParams.explodeDamage, m_hitParams.explodePower);
  251. }
  252. // попытка выкинуть из шутера
  253. if( m_bWaitKickOut )
  254. {
  255. if( m_ShooterKickOut.Validate() )
  256. m_bWaitKickOut = !((IShooterKickOut*)m_ShooterKickOut.Ptr())->KickOut(m_vSrcPosition, vPos);
  257. }
  258. // рождаем модель для взрыва
  259. // if( m_ExplosionPatch && m_HitGroupIndex >= 0 )
  260. // m_ExplosionPatch->MakeExplosion( vPos, m_HitGroupIndex );
  261. }
  262. TargetPoints* TargetPoints::GetNextTargetPoint(IMission* pMission)
  263. {
  264. if( g_pLastTargetPoints != NULL ) return NULL;
  265. if( g_fCooldawn > 0.f ) return NULL;
  266. TargetPoints* pFirstFinded = NULL;
  267. TargetPoints* pLastFinded = NULL;
  268. long nFindCount = 0;
  269. for( long n=0; n<g_targObjectsList; n++ )
  270. {
  271. // текущий обхект принадлежит данной миссии?
  272. if( pMission == &g_targObjectsList[n]->Mission() )
  273. {
  274. // нашли искомое
  275. if( nFindCount == g_nTargObjIndex )
  276. {
  277. pLastFinded = g_targObjectsList[n];
  278. break;
  279. }
  280. nFindCount++;
  281. // это будет первая находка
  282. if( !pFirstFinded )
  283. pFirstFinded = g_targObjectsList[n];
  284. }
  285. }
  286. // не нашли?
  287. if( pLastFinded == NULL )
  288. {
  289. // никого нет?
  290. if( pFirstFinded == NULL )
  291. return NULL;
  292. // берем первого попавшегося и правим индекс на 0
  293. pLastFinded = pFirstFinded;
  294. g_nTargObjIndex = 0;
  295. }
  296. if( !pLastFinded )
  297. return NULL;
  298. // в следубщий раз берем другого
  299. //g_nTargObjIndex++;
  300. return pLastFinded;
  301. }
  302. //============================================================================================
  303. void _cdecl TargetPoints::WorkGame(float dltTime, long level)
  304. {
  305. // draw points
  306. UpdatePointsVertex(dltTime);
  307. DrawPoints();
  308. // включаем предупреждение кикера из шутера
  309. if( m_renderParams.pointQPrepare > 0 && m_bWaitKickOutPrepair )
  310. {
  311. m_bWaitKickOutPrepair = false;
  312. m_bWaitKickOut = true;
  313. if( m_ShooterKickOut.Validate() )
  314. ((IShooterKickOut*)m_ShooterKickOut.Ptr())->KickOutPrepair();
  315. }
  316. // обновление кулдауна на выстрелы
  317. if( this == g_pLastTargetPoints )
  318. {
  319. g_fCooldawn -= dltTime;
  320. if( g_fCooldawn <= 0.f )
  321. g_pLastTargetPoints = NULL;
  322. }
  323. }
  324. void _cdecl TargetPoints::WorkEdit(float dltTime, long level)
  325. {
  326. // draw points
  327. if( m_editorParams.isShowPoints )
  328. {
  329. DrawPoints();
  330. }
  331. }
  332. void TargetPoints::ReadMOPs(MOPReader & reader)
  333. {
  334. dword n;
  335. // render params
  336. m_renderParams.texturename = reader.String();
  337. m_renderParams.pointradius = reader.Float();
  338. m_renderParams.scalePeriod = reader.Float();
  339. m_renderParams.scaleAmplitude = 1.f + reader.Float();
  340. m_renderParams.colPrepare = reader.Colors();
  341. m_renderParams.startSize = reader.Float();
  342. m_renderParams.startColor = reader.Colors();
  343. m_renderParams.finishColor = reader.Colors();
  344. // logic params
  345. m_logicParams.minShowDelay = reader.Float();
  346. m_logicParams.maxShowDelay = reader.Float();
  347. m_logicParams.activeRadius = reader.Float();
  348. m_logicParams.watchObjectID = reader.String();
  349. m_logicParams.cooldawn = reader.Float();
  350. m_logicParams.pointsLimit = reader.Long();
  351. m_logicParams.minFlyTime = reader.Float();
  352. m_logicParams.maxFlyTime = reader.Float();
  353. m_logicParams.minFlyHeight = reader.Float();
  354. m_logicParams.maxFlyHeight = reader.Float();
  355. // hit params
  356. m_hitParams.explodeRadius = reader.Float();
  357. m_hitParams.explodeDamage = reader.Float();
  358. m_hitParams.explodePower = reader.Float();
  359. m_hitParams.hitSFX = reader.String();
  360. m_hitParams.hitSFXScale = reader.Float();
  361. m_hitParams.hitSound = reader.String();
  362. // target points
  363. m_points.DelAll();
  364. dword q = reader.Array();
  365. m_points.AddElements(q);
  366. for( n=0; n<q; n++ )
  367. {
  368. m_points[n].pos = reader.Position();
  369. m_points[n].state = tps_disable;
  370. m_points[n].maxFlyTime = 0.f;
  371. m_points[n].curFlyTime = 0.f;
  372. }
  373. // editor params
  374. m_editorParams.isShowPoints = reader.Bool();
  375. // activate state
  376. Activate( reader.Bool() );
  377. // create depended params:
  378. // texture
  379. RELEASE( m_renderParams.pTexture );
  380. m_renderParams.pTexture = Render().CreateTexture( _FL_, "%s", m_renderParams.texturename.c_str() );
  381. // vertex buffer
  382. RELEASE( m_renderParams.pVertex );
  383. m_renderParams.pointQMax = m_points.Size();
  384. m_renderParams.pointQPrepare = m_renderParams.pointQMax;
  385. m_renderParams.pVertex = Render().CreateVertexBuffer( m_renderParams.pointQMax * 4 * sizeof(TargetPointVertex), sizeof(TargetPointVertex), _FL_ );
  386. // index buffer
  387. RELEASE( m_renderParams.pIndex );
  388. m_renderParams.pIndex = Render().CreateIndexBuffer( m_renderParams.pointQMax * 6 * sizeof(unsigned short), _FL_ );
  389. // watch object
  390. FindObject( m_logicParams.watchObjectID, m_logicParams.watchObject );
  391. // fill index buffer
  392. Assert( m_renderParams.pIndex );
  393. unsigned short* pI = (unsigned short*)m_renderParams.pIndex->Lock();
  394. Assert( pI );
  395. for( n=0; n<m_renderParams.pointQMax; n++ )
  396. {
  397. pI[n*6] = n*4;
  398. pI[n*6+1] = n*4 + 1;
  399. pI[n*6+2] = n*4 + 2;
  400. pI[n*6+3] = n*4 + 2;
  401. pI[n*6+4] = n*4 + 1;
  402. pI[n*6+5] = n*4 + 3;
  403. }
  404. m_renderParams.pIndex->Unlock();
  405. }
  406. void TargetPoints::InitShowDelay()
  407. {
  408. // поиск минимального и максимального времени полета ядра
  409. float minFlyTime = 10000.f;
  410. float maxFlyTime = 0.f;
  411. for( dword n=0; n<m_points.Size(); n++ )
  412. {
  413. if( m_points[n].state == tps_showdelay )
  414. {
  415. minFlyTime = Min(minFlyTime, m_points[n].maxFlyTime);
  416. maxFlyTime = Max(maxFlyTime, m_points[n].maxFlyTime);
  417. }
  418. }
  419. float delay = m_logicParams.maxShowDelay - m_logicParams.minShowDelay;
  420. float fMinDelay = m_logicParams.minShowDelay;
  421. if( fMinDelay > maxFlyTime * 0.9f )
  422. fMinDelay = maxFlyTime * 0.9f;
  423. // если задержка больше половины времени полета ядра, то уменьшаем задержку
  424. if( fMinDelay + delay > maxFlyTime * 0.98f )
  425. delay = maxFlyTime * 0.98f - fMinDelay;
  426. // коеффициент для расчета времени задержки
  427. float kTime = (maxFlyTime - minFlyTime > 0.01f) ? (delay / (maxFlyTime - minFlyTime)) : 0.f;
  428. for( n=0; n<m_points.Size(); n++ )
  429. {
  430. if( m_points[n].state == tps_showdelay )
  431. {
  432. float time = fMinDelay + kTime * (m_points[n].maxFlyTime - minFlyTime);
  433. m_points[n].curFlyTime = -time;
  434. m_points[n].maxFlyTime -= time;
  435. m_points[n].state = tps_prepare;
  436. }
  437. }
  438. }
  439. void TargetPoints::UpdatePointsVertex(float dltTime)
  440. {
  441. Assert(m_renderParams.pVertex);
  442. m_renderParams.pointQPrepare = 0;
  443. // массив вертексов
  444. TargetPointVertex* pV = (TargetPointVertex*)m_renderParams.pVertex->Lock();
  445. float sz = m_renderParams.pointradius;
  446. // текущий номер вертекса
  447. dword q = 0;
  448. for( dword n=0; n<m_points.Size(); n++ )
  449. {
  450. // если попалась новая точка, то было обновление: ставим время задержки для них
  451. if( m_points[n].state == tps_showdelay )
  452. InitShowDelay();
  453. if( m_points[n].state == tps_prepare )
  454. {
  455. // до начала времени ничего не показываем
  456. if( m_points[n].curFlyTime < 0.f )
  457. {
  458. m_points[n].curFlyTime += dltTime;
  459. if( m_points[n].curFlyTime < 0.f )
  460. continue;
  461. }
  462. float x = m_points[n].pos.x;
  463. float y = m_points[n].pos.y;
  464. float z = m_points[n].pos.z;
  465. float fScaleK = Clamp( m_points[n].curFlyTime / m_points[n].maxFlyTime );
  466. dword dwCol = Color().LerpA( Color(m_renderParams.startColor), Color(m_renderParams.finishColor), fScaleK ).GetDword();
  467. float uvScale = 1.f / (m_renderParams.startSize + (1.f - m_renderParams.startSize) * fScaleK);
  468. if( m_points[n].curFlyTime < m_points[n].maxFlyTime )
  469. m_points[n].curFlyTime += dltTime;
  470. pV[q].pos = Vector(x-sz,y,z+sz);
  471. pV[q].col = dwCol;
  472. pV[q].u = 0.f;
  473. pV[q].v = 0.f;
  474. pV[q].u2 = 0.75f - uvScale*.25f;
  475. pV[q].v2 = 0.5f - uvScale*.5f;
  476. pV[q+1].pos = Vector(x+sz,y,z+sz);
  477. pV[q+1].col = dwCol;
  478. pV[q+1].u = 0.5f;
  479. pV[q+1].v = 0.f;
  480. pV[q+1].u2 = 0.75f + uvScale*.25f;
  481. pV[q+1].v2 = 0.5f - uvScale*.5f;
  482. pV[q+2].pos = Vector(x-sz,y,z-sz);
  483. pV[q+2].col = dwCol;
  484. pV[q+2].u = 0.f;
  485. pV[q+2].v = 1.f;
  486. pV[q+2].u2 = 0.75f - uvScale*.25f;
  487. pV[q+2].v2 = 0.5f + uvScale*.5f;
  488. pV[q+3].pos = Vector(x+sz,y,z-sz);
  489. pV[q+3].col = dwCol;
  490. pV[q+3].u = 0.5f;
  491. pV[q+3].v = 1.f;
  492. pV[q+3].u2 = 0.75f + uvScale*.25f;
  493. pV[q+3].v2 = 0.5f + uvScale*.5f;
  494. q += 4;
  495. m_renderParams.pointQPrepare++;
  496. }
  497. }
  498. m_renderParams.pVertex->Unlock();
  499. }
  500. void TargetPoints::DrawPoints()
  501. {
  502. // get quantity of squares
  503. dword squareQantity = m_renderParams.pointQPrepare;
  504. if( squareQantity == 0 ) return;
  505. // set texture
  506. if( m_renderParams.pTexture )
  507. m_renderParams.pShVarTexture->SetTexture(m_renderParams.pTexture);
  508. else
  509. m_renderParams.pShVarTexture->ResetTexture();
  510. // set color
  511. m_renderParams.pShVarCol->SetVector4( Color(m_renderParams.colPrepare).v4 );
  512. // stream sources
  513. Render().SetStreamSource(0, m_renderParams.pVertex);
  514. Render().SetIndices(m_renderParams.pIndex);
  515. Render().SetWorld(Matrix());
  516. // draw squares
  517. Render().DrawIndexedPrimitive( m_renderParams.idShader, PT_TRIANGLELIST, 0, squareQantity*4, 0, squareQantity*2 );
  518. }
  519. //============================================================================================
  520. //Параметры инициализации
  521. //============================================================================================
  522. MOP_BEGINLISTCG(TargetPoints, "Target points array", '1.00', 100, "Target point set for enemy sea ship", "Arcade Sea")
  523. MOP_GROUPBEG("Render params")
  524. MOP_STRING("Texture name", "")
  525. MOP_FLOATC("Point radius", 1.0f, "Size of target point")
  526. MOP_FLOATC("Blinding period", 1.0f, "Time period for blinding of the target points (sec)")
  527. MOP_FLOATC("Blinding amplutude", 0.2f, "Amplutude change while blinding (relative value: 0.5 = half of radius")
  528. MOP_COLORC("Prepare color",Color(0xC060FF60),"Color of target point wait for ship cannon shoot")
  529. MOP_FLOATEXC("Start size", 0.2f, 0.1f, 1.f, "Start point size (grow to 1.0 until cannon ball fly)")
  530. MOP_COLORC("Start color",Color((dword)0x55FFFFFF),"Start color of target point")
  531. MOP_COLORC("Finish color",Color(0xCCFFFFFF),"Final color of target point")
  532. MOP_GROUPEND()
  533. MOP_GROUPBEG("Logic params")
  534. MOP_FLOATC("Min show delay", 1.0f, "Time delay for show target point min(sec)")
  535. MOP_FLOATC("Max show delay", 1.0f, "Time delay for show target point max(sec)")
  536. MOP_FLOATC("Active radius", 5.0f, "Maximum distance from player to choosed points")
  537. MOP_STRINGC("Watch object", "Player", "Mission object which activated target points group by enter into area box")
  538. MOP_FLOATC("Cooldown", 5.0f, "Time until ship cant shoot by target points")
  539. MOP_LONGC("Points limit", 15, "Limit of simultaneous target points for shoot")
  540. MOP_FLOATC("Min fly time", 1.0f, "Minimal time of cannonball flying")
  541. MOP_FLOATC("Max fly time", 3.0f, "Maximal time of cannonball flying")
  542. MOP_FLOATC("Min fly height", 10.0f, "Minimal height of cannonball flying")
  543. MOP_FLOATC("Max fly height", 40.0f, "Maximal height of cannonball flying")
  544. MOP_GROUPEND()
  545. MOP_GROUPBEG("Hit params")
  546. MOP_FLOATEX("Explode Radius", 2.0f, 0.1f, 1000000.0f)
  547. MOP_FLOAT("Explode Damage", 100.0f)
  548. MOP_FLOATEX("Explode Power", 1.0f,0.1f,100.0f)
  549. MOP_STRING("HitSFX","")
  550. MOP_FLOAT("HitSFXScale",1.f)
  551. MOP_STRING("HitSound","")
  552. MOP_GROUPEND()
  553. MOP_ARRAYBEG( "Points", 1, 100 )
  554. MOP_POSITION( "pos", Vector(0.f) )
  555. MOP_ARRAYEND
  556. MOP_GROUPBEG("Editor params")
  557. MOP_BOOL("Show points", false)
  558. MOP_GROUPEND()
  559. MOP_BOOL("Active",true)
  560. MOP_ENDLIST(TargetPoints)