g_xatrix_target.cpp 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. // Copyright (c) ZeniMax Media Inc.
  2. // Licensed under the GNU General Public License 2.0.
  3. #include "../g_local.h"
  4. /*QUAKED target_mal_laser (1 0 0) (-4 -4 -4) (4 4 4) START_ON RED GREEN BLUE YELLOW ORANGE FAT
  5. Mal's laser
  6. */
  7. void target_mal_laser_on(edict_t *self)
  8. {
  9. if (!self->activator)
  10. self->activator = self;
  11. self->spawnflags |= SPAWNFLAG_LASER_ZAP | SPAWNFLAG_LASER_ON;
  12. self->svflags &= ~SVF_NOCLIENT;
  13. self->flags |= FL_TRAP;
  14. // target_laser_think (self);
  15. self->nextthink = level.time + gtime_t::from_sec(self->wait + self->delay);
  16. }
  17. USE(target_mal_laser_use) (edict_t *self, edict_t *other, edict_t *activator) -> void
  18. {
  19. self->activator = activator;
  20. if (self->spawnflags.has(SPAWNFLAG_LASER_ON))
  21. target_laser_off(self);
  22. else
  23. target_mal_laser_on(self);
  24. }
  25. void mal_laser_think(edict_t *self);
  26. THINK(mal_laser_think2) (edict_t *self) -> void
  27. {
  28. self->svflags |= SVF_NOCLIENT;
  29. self->think = mal_laser_think;
  30. self->nextthink = level.time + gtime_t::from_sec(self->wait);
  31. self->spawnflags |= SPAWNFLAG_LASER_ZAP;
  32. }
  33. THINK(mal_laser_think) (edict_t *self) -> void
  34. {
  35. self->svflags &= ~SVF_NOCLIENT;
  36. target_laser_think(self);
  37. self->think = mal_laser_think2;
  38. self->nextthink = level.time + 100_ms;
  39. }
  40. void SP_target_mal_laser(edict_t *self)
  41. {
  42. self->movetype = MOVETYPE_NONE;
  43. self->solid = SOLID_NOT;
  44. self->s.renderfx |= RF_BEAM;
  45. self->s.modelindex = MODELINDEX_WORLD; // must be non-zero
  46. self->flags |= FL_TRAP_LASER_FIELD;
  47. // set the beam diameter
  48. if (self->spawnflags.has(SPAWNFLAG_LASER_FAT))
  49. self->s.frame = 16;
  50. else
  51. self->s.frame = 4;
  52. // set the color
  53. if (self->spawnflags.has(SPAWNFLAG_LASER_RED))
  54. self->s.skinnum = 0xf2f2f0f0;
  55. else if (self->spawnflags.has(SPAWNFLAG_LASER_GREEN))
  56. self->s.skinnum = 0xd0d1d2d3;
  57. else if (self->spawnflags.has(SPAWNFLAG_LASER_BLUE))
  58. self->s.skinnum = 0xf3f3f1f1;
  59. else if (self->spawnflags.has(SPAWNFLAG_LASER_YELLOW))
  60. self->s.skinnum = 0xdcdddedf;
  61. else if (self->spawnflags.has(SPAWNFLAG_LASER_ORANGE))
  62. self->s.skinnum = 0xe0e1e2e3;
  63. G_SetMovedir(self->s.angles, self->movedir);
  64. if (!self->delay)
  65. self->delay = 0.1f;
  66. if (!self->wait)
  67. self->wait = 0.1f;
  68. if (!self->dmg)
  69. self->dmg = 5;
  70. self->mins = { -8, -8, -8 };
  71. self->maxs = { 8, 8, 8 };
  72. self->nextthink = level.time + gtime_t::from_sec(self->delay);
  73. self->think = mal_laser_think;
  74. self->use = target_mal_laser_use;
  75. gi.linkentity(self);
  76. if (self->spawnflags.has(SPAWNFLAG_LASER_ON))
  77. target_mal_laser_on(self);
  78. else
  79. target_laser_off(self);
  80. }
  81. // END 15-APR-98