From 5a2b6d85ab21c27bd9f0e501de25ab2d007bff67 Mon Sep 17 00:00:00 2001 From: Freddy Date: Tue, 1 Nov 2016 16:03:40 +0100 Subject: [PATCH] Also let the first target of func_train be random For this to work, the func_train entity needs to have .target_random set initially --- qcsrc/common/triggers/func/train.qc | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/qcsrc/common/triggers/func/train.qc b/qcsrc/common/triggers/func/train.qc index b7407c3ec..161c03374 100644 --- a/qcsrc/common/triggers/func/train.qc +++ b/qcsrc/common/triggers/func/train.qc @@ -62,11 +62,8 @@ void train_wait(entity this) } } -void train_next(entity this) +entity train_next_find(entity this) { - entity targ = NULL, cp = NULL; - vector cp_org = '0 0 0'; - if(this.target_random) { RandomSelection_Init(); @@ -74,12 +71,20 @@ void train_next(entity this) { RandomSelection_AddEnt(t, 1, 0); } - targ = RandomSelection_chosen_ent; + return = RandomSelection_chosen_ent; } else { - targ = find(NULL, targetname, this.target); + return find(NULL, targetname, this.target); } +} + +void train_next(entity this) +{ + entity targ = NULL, cp = NULL; + vector cp_org = '0 0 0'; + + targ = train_next_find(this); this.target = targ.target; this.target_random = targ.target_random; @@ -201,8 +206,7 @@ void train_use(entity this, entity actor, entity trigger) void func_train_find(entity this) { - entity targ; - targ = find(NULL, targetname, this.target); + entity targ = train_next_find(this); this.target = targ.target; this.target_random = targ.target_random; if (this.target == "") -- 2.39.2