Use the targets. (target and killtarget) The global "activator" should be set to the entity that initiated the firing. If self.delay is set, a DelayedUse entity will be created that will actually do the SUB_UseTargets after that many seconds have passed. Centerprints any self.message to the activ
(SubgameEntity ent, SubgameEntity activator, GameExportsImpl gameExports)
| 48 | * (string)self.target and call their .use function |
| 49 | */ |
| 50 | public static void G_UseTargets(SubgameEntity ent, SubgameEntity activator, GameExportsImpl gameExports) { |
| 51 | |
| 52 | if (ent.classname == null) { |
| 53 | gameExports.gameImports.dprintf("edict with classname = null: " + ent.index); |
| 54 | } |
| 55 | |
| 56 | // check for a delay |
| 57 | SubgameEntity t; |
| 58 | if (ent.delay != 0) { |
| 59 | // create a temp object to fire at a later time |
| 60 | t = gameExports.G_Spawn(); |
| 61 | t.classname = "DelayedUse"; |
| 62 | t.think.nextTime = gameExports.level.time + ent.delay; |
| 63 | t.think.action = Think_Delay; |
| 64 | t.activator = activator; |
| 65 | if (activator == null) |
| 66 | gameExports.gameImports.dprintf("Think_Delay with no activator\n"); |
| 67 | t.message = ent.message; |
| 68 | t.target = ent.target; |
| 69 | t.killtarget = ent.killtarget; |
| 70 | return; |
| 71 | } |
| 72 | |
| 73 | |
| 74 | // print the message |
| 75 | if ((ent.message != null) |
| 76 | && (activator.svflags & Defines.SVF_MONSTER) == 0) { |
| 77 | gameExports.gameImports.centerprintf(activator, "" + ent.message); |
| 78 | if (ent.noise_index != 0) |
| 79 | gameExports.gameImports.sound(activator, Defines.CHAN_AUTO, |
| 80 | ent.noise_index, 1, Defines.ATTN_NORM, 0); |
| 81 | else |
| 82 | gameExports.gameImports.sound(activator, Defines.CHAN_AUTO, gameExports.gameImports |
| 83 | .soundindex("misc/talk1.wav"), 1, Defines.ATTN_NORM, 0); |
| 84 | } |
| 85 | |
| 86 | // kill killtargets |
| 87 | EdictIterator edit = null; |
| 88 | |
| 89 | if (ent.killtarget != null) { |
| 90 | while ((edit = GameBase.G_Find(edit, GameBase.findByTargetName, ent.killtarget, gameExports)) != null) { |
| 91 | t = edit.o; |
| 92 | gameExports.freeEntity(t); |
| 93 | if (!ent.inuse) { |
| 94 | gameExports.gameImports.dprintf("entity was removed while using killtargets\n"); |
| 95 | return; |
| 96 | } |
| 97 | } |
| 98 | } |
| 99 | |
| 100 | // fire (use) targets |
| 101 | if (ent.target != null) { |
| 102 | edit = null; |
| 103 | while ((edit = GameBase.G_Find(edit, GameBase.findByTargetName, ent.target, gameExports)) != null) { |
| 104 | t = edit.o; |
| 105 | // doors fire area portals in a specific way |
| 106 | if (Lib.Q_stricmp("func_areaportal", t.classname) == 0 |
| 107 | && (Lib.Q_stricmp("func_door", ent.classname) == 0 || Lib |
no test coverage detected