Results 1 to 3 of 3

Thread: Weird behaviour when trying to get the .entnum from the last spawned entity

  1. #1

    Default Weird behaviour when trying to get the .entnum from the last spawned entity

    I was testing the method to get the entnum from the last spawned entity mentioned by Purple here: Anti-Door Block, which is used to iterate through all the entities
    and I noticed that sometimes it works fine and sometimes it does not.


    I tested this script in obj/obj_team2 with freeze-tag and a weapon mod with no players


    level waittill spawn;
    wait 10; // Tested with and without the wait

    local.max = spawn script_model model "models/fx/dummy.tik" origin ( 0 0 -5000 ) targetname "max0";
    println $max0.entnum;
    local.max = spawn script_model model "models/fx/dummy.tik" origin ( 0 0 -5000 ) targetname "max1";
    println $max1.entnum;
    local.max = spawn script_model model "models/fx/dummy.tik" origin ( 0 0 -5000 ) targetname "max2";
    println $max2.entnum;
    local.max = spawn script_model model "models/fx/dummy.tik" origin ( 0 0 -5000 ) targetname "max3";
    println $max3.entnum;
    local.max = spawn script_model model "models/fx/dummy.tik" origin ( 0 0 -5000 ) targetname "max4";
    println $max4.entnum;
    local.max = spawn script_model model "models/fx/dummy.tik" origin ( 0 0 -5000 ) targetname "max5";
    println $max5.entnum;
    local.max = spawn script_model model "models/fx/dummy.tik" origin ( 0 0 -5000 ) targetname "max6";
    println $max6.entnum;
    local.max = spawn script_model model "models/fx/dummy.tik" origin ( 0 0 -5000 ) targetname "max7";
    println $max7.entnum;
    local.max = spawn script_model model "models/fx/dummy.tik" origin ( 0 0 -5000 ) targetname "max8";
    println $max8.entnum;
    local.max = spawn script_model model "models/fx/dummy.tik" origin ( 0 0 -5000 ) targetname "max9";
    println $max9.entnum;


    And this is the output:

    57
    58
    80
    81
    158
    159
    160
    161
    162
    163


    I suppose this happens when using the 'remove', 'immediateremove', 'take', 'takeall' and probably other commands, to temove entities from the game, (or when they are automatically removed by the game)
    And then when you spawn a new entity, that new entity will get a previously used entnum to "fill the gaps" of the list.

    The thing is: This method is inconsistent. Sometimes it returns the expected output and sometimes it doesn't, depending on what mods the server is running. So, heads up with that.

  2. #2
    Purple Developer Purple Elephant1au's Avatar
    Join Date
    Feb 2012
    Location
    Australia
    Posts
    1,269

    Default

    I think this would all depends on when the script is executed in the pipeline so to speak. If you move the execution of the script to level waittill playerspawn or something, you might find that it produces higher but more consistent ent nums, as things might of finished spawning etc.

    Interesting about the "fill the gaps" theory, have you tested this and confirm that is the case?
    The max.entnum in the door script was just for optimisation, and you could just iterate up to the maximum number of entities that can be created.

    Purple's Playground
    OBJ :
    103.29.85.127:12203
    xfire: purpleelephant1au
    email: purpleelephant1au@gmail.com
    skydrive: PurpleElephantSkydrive




  3. #3

    Default

    Quote Originally Posted by Purple Elephant1au View Post
    Interesting about the "fill the gaps" theory, have you tested this and confirm that is the case?
    I just tested it in a clean server without mods, and I got this output
    Code:
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    Then after installing mefy-extgametypes and running freeze-tag I got this
    Code:
    57
    58
    80
    81
    158
    159
    160
    161
    162
    163
    It happens that the "fill the gaps" theory is correct

    This is the code that causes this behaviour in the V2rocket map

    if (level.mef_gametype != "obj" && level.mef_gametype != "ftobj")
    {
    // remove the bombs in a non-objective game
    $v2_bomb remove
    $v2_explode remove
    $ctrlroom_bomb remove
    $ctrlroom_explode remove
    }


    Which is executed from the map script, before "level waittill prespawn"

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •