(SubgameEntity self, GameExportsImpl gameExports)
| 63 | private static EntThinkAdapter target_laser_think = new EntThinkAdapter() { |
| 64 | public String getID() { return "target_laser_think"; } |
| 65 | public boolean think(SubgameEntity self, GameExportsImpl gameExports) { |
| 66 | |
| 67 | edict_t ignore; |
| 68 | float[] start = { 0, 0, 0 }; |
| 69 | float[] end = { 0, 0, 0 }; |
| 70 | trace_t tr; |
| 71 | float[] point = { 0, 0, 0 }; |
| 72 | float[] last_movedir = { 0, 0, 0 }; |
| 73 | int count; |
| 74 | |
| 75 | if ((self.spawnflags & 0x80000000) != 0) |
| 76 | count = 8; |
| 77 | else |
| 78 | count = 4; |
| 79 | |
| 80 | if (self.enemy != null) { |
| 81 | Math3D.VectorCopy(self.movedir, last_movedir); |
| 82 | Math3D.VectorMA(self.enemy.absmin, 0.5f, self.enemy.size, point); |
| 83 | Math3D.VectorSubtract(point, self.s.origin, self.movedir); |
| 84 | Math3D.VectorNormalize(self.movedir); |
| 85 | if (!Math3D.VectorEquals(self.movedir, last_movedir)) |
| 86 | self.spawnflags |= 0x80000000; |
| 87 | } |
| 88 | |
| 89 | ignore = self; |
| 90 | Math3D.VectorCopy(self.s.origin, start); |
| 91 | Math3D.VectorMA(start, 2048, self.movedir, end); |
| 92 | while (true) { |
| 93 | tr = gameExports.gameImports.trace(start, null, null, end, ignore, |
| 94 | Defines.CONTENTS_SOLID | Defines.CONTENTS_MONSTER |
| 95 | | Defines.CONTENTS_DEADMONSTER); |
| 96 | |
| 97 | SubgameEntity target = (SubgameEntity) tr.ent; |
| 98 | if (target == null) |
| 99 | break; |
| 100 | |
| 101 | // hurt it if we can |
| 102 | if ((target.takedamage != 0) |
| 103 | && 0 == (target.flags & GameDefines.FL_IMMUNE_LASER)) |
| 104 | GameCombat.T_Damage((SubgameEntity) target, self, self.activator, |
| 105 | self.movedir, tr.endpos, Globals.vec3_origin, |
| 106 | self.dmg, 1, DamageFlags.DAMAGE_ENERGY, |
| 107 | GameDefines.MOD_TARGET_LASER, gameExports); |
| 108 | |
| 109 | // if we hit something that's not a monster or player or is |
| 110 | // immune to lasers, we're done |
| 111 | if (0 == (target.svflags & Defines.SVF_MONSTER) |
| 112 | && (null == target.getClient())) { |
| 113 | if ((self.spawnflags & 0x80000000) != 0) { |
| 114 | self.spawnflags &= ~0x80000000; |
| 115 | gameExports.gameImports.multicastMessage(tr.endpos, new SplashTEMessage(Defines.TE_LASER_SPARKS, count, tr.endpos, tr.plane.normal, self.s.skinnum), MulticastTypes.MULTICAST_PVS); |
| 116 | } |
| 117 | break; |
| 118 | } |
| 119 | |
| 120 | ignore = target; |
| 121 | Math3D.VectorCopy(tr.endpos, start); |
| 122 | } |
no test coverage detected