]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Also let the first target of func_train be random
authorFreddy <schro.sb@gmail.com>
Tue, 1 Nov 2016 15:03:40 +0000 (16:03 +0100)
committerFreddy <schro.sb@gmail.com>
Tue, 1 Nov 2016 15:03:40 +0000 (16:03 +0100)
For this to work, the func_train entity needs to have .target_random set
initially

qcsrc/common/triggers/func/train.qc

index b7407c3ec883a6ba87db7bf3c8953a9fc7738ebf..161c033747ebac93afbfc9b15f892803dd45dc72 100644 (file)
@@ -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 == "")