]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Random entity selection only for the target field for func_train
authorFreddy <schro.sb@gmail.com>
Tue, 1 Nov 2016 14:48:34 +0000 (15:48 +0100)
committerFreddy <schro.sb@gmail.com>
Tue, 1 Nov 2016 14:48:34 +0000 (15:48 +0100)
qcsrc/common/triggers/func/train.qc

index bb7b540e435fb6cf9bba726951aa43b1ef2ab656..b7407c3ec883a6ba87db7bf3c8953a9fc7738ebf 100644 (file)
@@ -64,44 +64,26 @@ void train_wait(entity this)
 
 void train_next(entity this)
 {
-       entity targ, cp = NULL;
+       entity targ = NULL, cp = NULL;
        vector cp_org = '0 0 0';
-       string next_target = "";
 
-       targ = find(NULL, targetname, this.target);
-       if(targ.target_random)
+       if(this.target_random)
        {
                RandomSelection_Init();
-               for(int i = 0; i < 4; ++i)
+               for(entity t = NULL; (t = find(t, targetname, this.target));)
                {
-                       switch(i)
-                       {
-                               case 0:
-                                       next_target = targ.target;
-                                       break;
-                               case 1:
-                                       next_target = targ.target2;
-                                       break;
-                               case 2:
-                                       next_target = targ.target3;
-                                       break;
-                               case 3:
-                                       next_target = targ.target4;
-                                       break;
-                       }
-                       if (next_target != "")
-                       {
-                               RandomSelection_AddString(next_target, 1, 1);
-                       }
+                       RandomSelection_AddEnt(t, 1, 0);
                }
-               next_target = RandomSelection_chosen_string;
+               targ = RandomSelection_chosen_ent;
        }
        else
        {
-               next_target = targ.target;
+               targ = find(NULL, targetname, this.target);
        }
 
-       this.target = next_target;
+       this.target = targ.target;
+       this.target_random = targ.target_random;
+
        if (this.spawnflags & 1)
        {
                if(targ.curvetarget)
@@ -222,6 +204,7 @@ void func_train_find(entity this)
        entity targ;
        targ = find(NULL, targetname, this.target);
        this.target = targ.target;
+       this.target_random = targ.target_random;
        if (this.target == "")
                objerror(this, "func_train_find: no next target");
        SUB_SETORIGIN(this, targ.origin - this.view_ofs);