emp_vehicle_spawner

Discussion in 'Bug Reports' started by Xyaminou, Mar 6, 2018.

  1. Xyaminou

    Xyaminou Member

    Messages:
    1,369
    Likes Received:
    156
    Trophy Points:
    0
    When "autorespawn" is set to 1 in emp_vehicle_spawner it will only spawn a new vehicle once the full "emp_sv_vehicle_fadeout_time" for the previous vehicle's carcass has run out. Even if you recycle the carcass.

    It should be changed to either have a new vehicle respawn when the previous one has been destroyed OR spawn a new vehicle if the carcass has been recycled. Even better would be to have both choices.
     
    D.D.D. Destroyer likes this.
  2. Misfire

    Misfire Always Lost

    Messages:
    311
    Likes Received:
    44
    Trophy Points:
    0
    My code kung fu is weak but growing, so I'm going to take a stab at this one.
    Real coders chime in please.

    emp_vehicle_spawner.cpp Line 204 CEmpVehicleSpawner::Think

    It doesn't seem to take carcass recycle in to account at all, just tags on a future recycle time based on fadeout_time.

    Code:
       // Check for death
        if (!m_flRespawnTime && m_pLastVehicle->m_flDestroyTime != 0)
    -->     m_flRespawnTime = gpGlobals->curtime + emp_sv_vehicle_fadeout_time.GetInt();
    
        // Death detected, try to respawn
        if (m_flRespawnTime && gpGlobals->curtime >= m_flRespawnTime && BuildVehicle(NULL))
            m_flRespawnTime = 0;
    

    Maybe adding additional info to the BE and NF engy recycle code could correct this

    Emp_weapon_nf_engineer_kit.cpp Line 717

    Code:
        if (finalHealth == 0)
        {
            // This carcass has been completely recycled.
    -->     pTank->m_flRespawnTime = 1; // New Line. Carcass gone so skip "Check for Death"
            pTank->RemoveVehicle();
            pOldTank = NULL;
            m_irecycledresources = 0;
            m_fRecycledResourcesForTankRemainder = 0.0f;
        }
      
    If RespawnTime = 1, then "check for death" is skipped
    In "Death detected", each of the three checks are now satisfied and RespawnTime gets set to zero.
     
  3. Thexa4

    Thexa4 Developer Staff Member Moderator

    Messages:
    304
    Likes Received:
    98
    Trophy Points:
    0
    Shouldn't you set m_flDestroyTime instead of m_flRespawnTime in the engineer kit code? Btw, fl...Time fields are supposed to be assigned 0 or gpGlobals->curtime, 1 is not really a useful time.
     
  4. Misfire

    Misfire Always Lost

    Messages:
    311
    Likes Received:
    44
    Trophy Points:
    0
    Setting DestroyTime to zero in engie code does achieve the correct result for "Death Check".
    But doesn't satisfy the check for "try to respawn" if RespawnTime is at default 0.

    Instead of "= 1", then maybe a more elegant line could be....

    pTank->m_flRespawnTime = gpGlobals->curtime - RESPAWNABLE_PROP_DEFAULT_TIME; // ?

    This would subtract the default value of 60 from current time allowing a respawn immediately after recyle. Or that's my hope anyway.
    "Death Check" time extension should be bypassed, and then the true result of "try respawn" resets RespawnTime back to zero.

    In all cases I could find, DestroyTime is simply float being used as true/false condition, not as a real time stamp value. So that's why "1" seemed and easy option. (though hackish I can now see)
     
  5. Thexa4

    Thexa4 Developer Staff Member Moderator

    Messages:
    304
    Likes Received:
    98
    Trophy Points:
    0
    If you want it to respawn right now, it would be right to set it to gpGlobals->curtime, if you want it to respawn RESPAWNABLE_PROP_DEFAULT_TIME seconds from now you could set it to gpGlobals->curtime + RESPAWNABLE_PROP_DEFAULT_TIME.

    You are probably right that it doesn't change the behavior but it makes the code follow the same conventions as the rest of the codebase.
     
  6. Misfire

    Misfire Always Lost

    Messages:
    311
    Likes Received:
    44
    Trophy Points:
    0
    pTank->m_flRespawnTime = gpGlobals->curtime - RESPAWNABLE_PROP_DEFAULT_TIME

    My thinking here is that if the code has a chance to set RespawnTime to a future time, before the engie recycle happens...
    m_flRespawnTime = gpGlobals->curtime + emp_sv_vehicle_fadeout_time.GetInt();

    ... then just setting to curtime might not be far enough ahead for an instant respawn.
    So setting it to curtime minus a bit in the past would take care of that case.
     
  7. Thexa4

    Thexa4 Developer Staff Member Moderator

    Messages:
    304
    Likes Received:
    98
    Trophy Points:
    0
    Times are supposed to be checked by comparing greater than or equal to curtime but that might not be applied everywhere. If you want to be sure you can subtract one tick, you can find the amount of time of one tick in the gpGlobals object, not sure which field.
     
  8. Misfire

    Misfire Always Lost

    Messages:
    311
    Likes Received:
    44
    Trophy Points:
    0
    I'll have a look. Or maybe another option would be to simply reverse any possible time addition with...
    pTank->m_flRespawnTime = gpGlobals->curtime - emp_sv_vehicle_fadeout_time.GetInt(); //??
     
  9. Thexa4

    Thexa4 Developer Staff Member Moderator

    Messages:
    304
    Likes Received:
    98
    Trophy Points:
    0
    Just make sure you document why you're adding it.
     
  10. Misfire

    Misfire Always Lost

    Messages:
    311
    Likes Received:
    44
    Trophy Points:
    0
    When is this autorespawn feature used exactly?
    I've worked out a change that would allow respawn after a recycle.
     
  11. Xyaminou

    Xyaminou Member

    Messages:
    1,369
    Likes Received:
    156
    Trophy Points:
    0
    On certain Infantry Maps such as Havoc or Atomic.
     
  12. Misfire

    Misfire Always Lost

    Messages:
    311
    Likes Received:
    44
    Trophy Points:
    0
    So maps without normal VF's that spawn their own replacement vehicles periodically.
    I'm guessing this reaches a max vehicle problem where you server doesn't use the default carcass fade-out time?
     
  13. Xyaminou

    Xyaminou Member

    Messages:
    1,369
    Likes Received:
    156
    Trophy Points:
    0
    No, havoc and atomic only ever spawn one vehicle per spawner. Which is why it's important to have it respawn as soon as the carcass has been recycled.

    But really there should also be an option for it to ignore the carcass entirely, and just spawn a new vehicle as soon as the old one dies.
     
  14. Not Kidpaler

    Not Kidpaler Member

    Messages:
    50
    Likes Received:
    9
    Trophy Points:
    0
    I always took it as a punishment for losing the vehicle in the first place like every other game. It gives time for the other team to advance instead of just instantly having your tank back.
     
  15. Misfire

    Misfire Always Lost

    Messages:
    311
    Likes Received:
    44
    Trophy Points:
    0
    As with player spawns some small time penalty seems appropriate. "Insta-spawn at recycle" sounds like something easily turned in to at least a mini-sploit on v-spawner maps.
    Rush a tank, loose it, 2 engie recycle, rush another ... rinse and repeat.

    I don't know how v-spawner maps work. I'm guessing they periodically check for an available vehicle, if none available then wait a period before checking again?
    Depending on the mechanics, a patch of the code may still leave long delays which might need map updates to improve.
    The patch would put the carcass on the queue sooner, but what is the v-spawner doing about it?
     

Share This Page