Welcome to PlagueFest.com! Log in or Sign up to interact with the Plague Fest community.
  1. Welcome Guest! to interact with the community and gain access to all the site's features.

Tutorial Changing players' models on the fly. (Not server-OS dependant)

Discussion in Resources & Tutorials started by enviolinador, Apr 12, 2013

  1. May 31, 2012
    Posts
    A small note: you can find simpler version of this guide, written by Like a Bauxe on the DtK forums: http://www.dying2kill.com.au/showthread.php/21936-MAP-Changing-Player-Models (for if you'd rather read a simpler guide with less inane trash added to it).

    -----------------------

    As some of you might know, I am a pretty stubborn person when I want to get something working and I had been working on the modelindex thing Hannibal had discovered to change playermodels for a while. As a result of this, that -not so long, but people get woddledly woop over the name- slightly weird map that NY is was born. The problem with what I did (which was nothing more than a further analysis of what had made Hannibal stop) is that it was dependant of the target server's OS.

    After testing, we (I always rely on others to help me test this stupid things I do) found out that, for some reason, the dedicated server precaches differently when on Windows and Linux. This means that the modelprecache table changes from one to another and, furthermore, that you can't 'point' to an universal modelindex unless you're lucky and the index has landed in the same position.

    During that time there was something I also tried, precaching 'outside' the map; however, after looking at all the related /scripts (I thought), I couldn't find a way to do so. Yesterday, however, I saw ZombieFurbie's thread about using the soundescape's txt to precache sound and, while thinking that it's not much of a solution (aside from music and this being just my opinion), I remembered that Joris had had been a bit repetitive about his custom gibs for a while. I know that gibs are the first models loaded onto the precache table (and I guess there is a good reason behind it; I think playermodels would make more sense, though, but that's none of my business). I believed, then, I could do something with that.

    As I'm tired of this story (because it's terrible), I'll just explain how to do it.

    1. Go to /scripts and open propdata.txt
    2. Add a new scope in the last part of the file containing your models, named 'BREAKABLE DATA'
    -- 2'. Example (I forgot what Josh(I think?) told me to use the code thing, so the format is lost... just read it):

    PHP:
     "BreakableModels"
    {
    // Sorted in order of smallest to largest
     
    "WoodChunks"
    {
    "models\Gibs\wood_gib01e.mdl" "1"
    "models\Gibs\wood_gib01d.mdl" "1"
    "models\Gibs\wood_gib01c.mdl" "1"
    "models\Gibs\wood_gib01b.mdl" "1"
    "models\Gibs\wood_gib01a.mdl" "1"
    }
    "GlassChunks"
    {
    "models\Gibs\Glass_shard01.mdl" "1"
    "models\Gibs\Glass_shard02.mdl" "1"
    "models\Gibs\Glass_shard03.mdl" "1"
    "models\Gibs\Glass_shard04.mdl" "1"
    "models\Gibs\Glass_shard05.mdl" "1"
    "models\Gibs\Glass_shard06.mdl" "1"
    }
    "ConcreteChunks"
    {
    "models\props_debris\concrete_chunk08a.mdl" "1"
    "models\props_debris\concrete_chunk09a.mdl" "1"
    "models\props_debris\concrete_chunk03a.mdl" "1"
    "models\props_debris\concrete_chunk07a.mdl" "1"
    "models\props_debris\concrete_chunk09a.mdl" "1"
    "models\props_debris\concrete_chunk02a.mdl" "1"
    }
    "MetalChunks"
    {
    "models\Gibs\metal_gib1.mdl" "1"
    "models\Gibs\metal_gib2.mdl" "1"
    "models\Gibs\metal_gib3.mdl" "1"
    "models\Gibs\metal_gib4.mdl" "1"
    "models\Gibs\metal_gib5.mdl" "1"
    }
    "EnviModels"
    {
    "models\player\techknow\clownprince\clownprince.mdl" "1"
    }
    }
    3. Open CS:S and Hammer. In Hammer, place whatever the entity you want to detect whoever the player you wish and do 'OnWhateverTheThing -> !activator -> AddOutput -> modelindex ### -> 0.00'. The ### is obtained from looking at the cl_precacheinfo modelprecache table; look for your model (it should be right after the brush models which and the gibs, you can copypaste on notepad and look for it)
    4. Compile map.
    -- 4'. If release: Pack everything in map (propdata.txt included in /scripts, models in their holy land of bleblablehbleho).
    5. Test. Always test.

    Tell me if it works for you, although I don't see why it shouldn't. Yes, this method doesn't depend on the OS (because you can precache right after the brushes and avoid the gibs from being the first ones).

    RECOMENDATIONS:
    -----------------------
    If for ZE/ZM, leave models + zombies. In some servers (pF is an example of it, see?) there are zombies with a smaller/bigger hitbox, and hitboxes do NOT get recalculated. I've been trying to find a way to fix this, but I'm not cool enough for this.
    Do it at last. Dynamic brushes (brush entities) go before the gibs, so any brush entity related change will change the indexes (they'll go down one position for each brush entity, you can just take care of it yourself)
    Add the models as prop_static to the map for easier packing.
    If something blows up, please do tell me.
    • Like Like x 1
    • Wizard! Wizard! x 1
    • Informative Informative x 1
    • Mapping King Mapping King x 1
      enviolinador, Apr 12, 2013 Last edited by enviolinador, Apr 15, 2014
    • Apr 9, 2012
      Posts
      Wow, I said something useful for once.
      • Funny Funny x 1
      • Mapping King Mapping King x 1
      • Feb 19, 2012
        Posts
        I see how it is. Shit on my solution while saying it helped you! --shot-- I'm kidding!

        Anyway. Oh jesus, so we can actually define player models now and not have to worry about gandalf syndrome? (player models always in the running animation). This also can help with reducing entity count, yeah?

        As far as I know, the couple of issues with adapting this system is hitboxes and custom animations, yeah? Say your model has a custom attack animation for some special attack, it wouldn't quite work if your player model was constantly changing animations on its own, would it?

        From my testing, this method seems to work: [IMG]

        encountered no hitches
      • May 31, 2012
        Posts
        From what I've tested, those would just be playermodels, so custom anims are not possible. However, workarounds would be possible to some extent (for example, the knife animations are the special attacks, if they are based on a game_ui). I don't think it's quite much of a hassle, though, since particles and some visuals could just hide it well enough.

        Another solution would be a 'ghost' model (which would share textures with the normal one, so it wouldn't cause any problem in terms of size) with all the animations set to the special animation desired. As models themselves aren't that heavy (usually it's the textures), this would 'work' (given the little tedious work of having to rename all the anims).

        I've looked for solutions for the hitboxes but there seems to be none. If anyone experienced with Sourcemod could assist me (to understand how SM does it and try to find a workaround) I could try, but looking at commands (it should be done on the fly, unlike the precaching which is just a bleh trick) I don't think it's possible. Still, toying a bit with ZR classes could do (forcing a model X, for example, a default terrorist playermodel, and then using a logic_timer to force zombies to have the models we 'want').

        EDIT: Just for the matter, some servers might dislike this last option, that's why I say it's 'bleh' by now.
      • Apr 9, 2012
        Posts
        For SSBB I couldn't use this method, because it would make it unable for me to use the animations at correct timings. For the always same animations I had the workaround to have an idle standing animation and a running animation. So when you press forward/backward left or right the model will have the walking animation, and if you leave any of the buttons, aka stop moving, the idle kicks in.

        That was just for information, not really helpful to this thread anyways.

        Looks nice though, especially for the entity count.
      • Feb 19, 2012
        Posts
        does the custom model get retained when the person becomes a zombie, therefore needing to be switched back to a zombie model manually?
      • May 31, 2012
        Posts
        No, not at all. It would actually make little sense if it happened, because it'd mean it would be reassigning an index every once in a while.
      • Feb 19, 2012
        Posts
        I just realized this completely defeats one of the only real benefits Counter-Strike: Global Offensive had - map specific player models.

        put a trigger_multiple at your spawnpoints and you can override the player models in CS:S. Other than a neat looking fog entity, there is no real upgrade to CS:GO mapping, lol.