Thread: [Replace Items] Dropped items after map start.

Results 1 to 5 of 5
  1. #1
    Silencer Lt.JC's Avatar  
    Tester
    Join Date
    Dec 2003
    Location
    Germany
    Posts
    1,249

    [Replace Items] Dropped items after map start.

    Is there a way to have a script or plugin replace items in the map that are getting dropped by NPC's or func_breakables?

    Because I got a working script now which replaces items that are already in place but the dropped ones which get "spawned" afterward are not affected.

    Another question would be how to replace the weapons the player spawns with when using the plugin.
    Born to Fight,
    Trained to Kill,
    Taught to Survive,
    and told to take no Prisoners.
    Visit http://www.youtube.com/NostalgicGames

  2. #2
    func_vehicle enthusiaist w00tguy123's Avatar
    Join Date
    Dec 2006
    Location
    U.S. West
    Posts
    1,598

    Re: [Replace Items] Dropped items after map start.

    I think you just have to scan the entire entity list for new "weaponbox" entities or weapon_X/ammo_X every so often. Scripts aren't notified when new entities are created.

    To replace weapons players start with, I would just do this:
    1) Check which weapons they have on spawn, then make a list of replacements
    2) Strip the player
    3) Give them the list of replacement weapons
    Love,
    w00tguy

  3. #3
    Silencer Lt.JC's Avatar  
    Tester
    Join Date
    Dec 2003
    Location
    Germany
    Posts
    1,249

    Re: [Replace Items] Dropped items after map start.

    But what about the weapons that get spawned in the map from NPC's or crates?

    I mean if for example npc_dropweapons is 1 then grunts would drop mp5's and such but it would always be the svencoop default one.

    The same happens if there is a crate in the map which you can break and it spawns a weapon. Those aren't affected by my plugin script although the script bascially is told to replace the weapon_ entity.
    Born to Fight,
    Trained to Kill,
    Taught to Survive,
    and told to take no Prisoners.
    Visit http://www.youtube.com/NostalgicGames

  4. #4
    func_vehicle enthusiaist w00tguy123's Avatar
    Join Date
    Dec 2006
    Location
    U.S. West
    Posts
    1,598

    Re: [Replace Items] Dropped items after map start.

    Weapons spawned from NPCs and crates aren't easy to track with plugins (we don't have the EntityCreated hook yet). The naive way to handle this would be to iterate the entity list of the map every frame:

    Code:
    CBaseEntity@ ent = null;
    do {
        @ent = g_EntityFuncs.FindEntityByClassname(ent, "*"); 
    
        if (ent !is null)
        {
            if (ent.pev.classname == "weapon_mp5")
            {
                // replace the weapon
            }
            else if (ent.pev.classname == "weapon_shotgun")
            {
                // replace the weapon
            }
        }
    } while (ent !is null);
    Since doing that kills performance, you should at least spread out the workload over several frames (break the loop after X iterations, then resume by using the same "ent" var).

    An improvement to that would be if you created an array of monsters/breakables and monitored for deaths. Then you would do the expensive check above only once after they die. That array would have to be updated every second or so to account for squadmakers/trigger_createentity/etc.
    Love,
    w00tguy

  5. #5
    Silencer Lt.JC's Avatar  
    Tester
    Join Date
    Dec 2003
    Location
    Germany
    Posts
    1,249

    Re: [Replace Items] Dropped items after map start.

    Hmm sounds like I would have to wait for that "hook" to be implemented cause otherwise this won't really help me with what I'm doing.

    Anyway thanks for your help and the explanation ^^
    Born to Fight,
    Trained to Kill,
    Taught to Survive,
    and told to take no Prisoners.
    Visit http://www.youtube.com/NostalgicGames

Posting Permissions

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