MCPcopy Create free account
hub / github.com/demoth/jake2 / G_PickTarget

Method G_PickTarget

game/src/main/java/jake2/game/GameBase.java:154–178  ·  view source on GitHub ↗
(String targetname, GameExportsImpl gameExports)

Source from the content-addressed store, hash-verified

152 */
153
154 public static SubgameEntity G_PickTarget(String targetname, GameExportsImpl gameExports) {
155 int num_choices = 0;
156 int MAXCHOICES = 8;
157 SubgameEntity[] choice = new SubgameEntity[MAXCHOICES];
158
159 if (targetname == null) {
160 gameExports.gameImports.dprintf("G_PickTarget called with null targetname\n");
161 return null;
162 }
163
164 EdictIterator es = null;
165
166 while ((es = G_Find(es, findByTargetName, targetname, gameExports)) != null) {
167 choice[num_choices++] = es.o;
168 if (num_choices == MAXCHOICES)
169 break;
170 }
171
172 if (num_choices == 0) {
173 gameExports.gameImports.dprintf("G_PickTarget: target " + targetname + " not found\n");
174 return null;
175 }
176
177 return choice[Lib.rand() % num_choices];
178 }
179
180 private static final float[] VEC_UP = { 0, -1, 0 };
181

Callers 5

thinkMethod · 0.95
monster_start_goMethod · 0.95
touchMethod · 0.95
FoundTargetMethod · 0.95
train.ktFile · 0.80

Calls 3

G_FindMethod · 0.95
randMethod · 0.95
dprintfMethod · 0.65

Tested by

no test coverage detected