How to spawn jarate/milk/grenades... into your map?

Discussion in 'Tutorials & Resources' started by Benoist3012, Nov 14, 2016.

  1. Benoist3012

    Benoist3012 L3: Member

    Messages:
    147
    Positive Ratings:
    201
    After getting a request on how to spawn projectiles into a map I decided to write this guide.

    Before we get started here a list of recommended projectiles to spawn:
    Code:
    tf_projectile_jar
    tf_projectile_jar_milk
    tf_projectile_pipe
    tf_projectile_spellbats
    tf_projectile_spellmeteorshower
    tf_projectile_spellspawnzombie
    
    I think their classnames talk for them, you don't need me to figure out what they are. There are more projectiles, but those require custom angles to be shoot since they have no gravity, and doesn't behave like grenades, so until I figure out a "clean" way of doing so I don't recommend you to use other projectiles than those.

    1st Step

    Spawn any entities into your map and change their classname to one of the given list above.
    Then add a key named "targetname" and set in its value the name you want to give to it, "value".
    Optional: You can add a key named "TeamNum" and set as its value the team you want. Friendly reminder: 0-Unasigned (don't use it!) 1-Spectator, 2-Red, 3-Blue, 5-Doesn't exist but this what valve uses commonly to make an entity able to attack both team, I named that team Boss Team.


    2nd Step

    Our second step is to create our spawner (point_template)!
    Depending to what kind of spawner you want, I'll ask you to read the sub part that interest you.

    Sub-part 1 Normal spawner

    Put into every Template key, the name of the entity you want to spawn, and send the ForceSpawn input whenever you want to that point_template to spawn them, according to your map logic.

    Sub-part 2 Random spawner(Complex read it carefully!)

    To make a second spawner you are required to create another entity (logic_case), let's name it spawner_randomizer.
    You will then make the same number of OnCase ouputs that the number of projectile you made.
    If you need more than 12 outputs then make another logic_case.

    In each output, target your point_teamplate (your spawner), then send the input AddOutput with this parameter: "Template01 X", replace X with one of the name of your projectiles, each of your projectiles must be named differently or it won't work! Repeat this input operation with every name of your projectile.

    You should have something like this at the end:
    Code:
    My Output: OnCase01 Target Entity: myspawner  Target Input: AddOutput Parameter: Template01 myjarate1
    My Output: OnCase02 Target Entity: myspawner  Target Input: AddOutput Parameter: Template01 myjarate2
    My Output: OnCase03 Target Entity: myspawner  Target Input: AddOutput Parameter: Template01 myjarate3
    My Output: OnCase04 Target Entity: myspawner  Target Input: AddOutput Parameter: Template01 myjarate4
    My Output: OnCase05 Target Entity: myspawner  Target Input: AddOutput Parameter: Template01 myjarate5
    My Output: OnCase06 Target Entity: myspawner  Target Input: AddOutput Parameter: Template01 myjarate6
    
    Once this is done, go to your point_template target, add an output OnEntitySpawned and target your logic_case and send PickRandom input. This will actually change the next entity to spawn everytime you call ForceSpawn on it.

    And then make a logic_auto entity, and then target your logic_case and send PickRandom input to initialize your spawner, otherwise it won't spawn anything the 1st time you send ForceSpawn!

    Conclusion
    Thanks for reading, this is again a guide I wrote quickly, I will correct any weird infos soon, and link a prefab to this post for the random spawner, because it's really complex.
     
    • Thanks Thanks x 4
    • Like Like x 1
    Last edited: Nov 22, 2016
  2. mi2

    mi2 L1: Registered

    Messages:
    6
    Positive Ratings:
    2
    Again, most useful and informative! I have always wondered about the implementation of such entities into my maps.
     
  3. ics

    aa ics http://ics-base.net

    Messages:
    664
    Positive Ratings:
    412
    This is not exactly what i was looking for, since if using this method, it creates a lot of entities. I was thinking more of setting certain entity on the sky and this stuff would come out of it, something like the jarate rain in wheel of doom. It is a a func_brush at the sky, named spawn cloud and jarate rains down from it. Do you know if it is possible to spawn without the wheel itself?
     
  4. Three Million

    Three Million L5: Dapper Member

    Messages:
    201
    Positive Ratings:
    65
    How can I configure this to make the 2fort cow throw milk every time a player hits it?
     
    Last edited: Nov 14, 2016
  5. Viperi

    aa Viperi not actually a snek

    Messages:
    962
    Positive Ratings:
    533
    I'm not exactly sure, but probably with Input/Output
     
    • Respectfully Disagree Respectfully Disagree x 1
  6. ics

    aa ics http://ics-base.net

    Messages:
    664
    Positive Ratings:
    412
    I'd use env_shooter and just select the milkjar model for it. Though it wouldn't be real, just cosmetic feature. I use this when players enter hell in brimstone. Fire burning gibs will fly out from gargoyles and the skulls eyes when player enters underworld for the first time.
     
  7. Three Million

    Three Million L5: Dapper Member

    Messages:
    201
    Positive Ratings:
    65
    Obviously. I just need to know how to fire the point_template that will spawn the tf_projectile_jar_milk. Since prop_dynamics can't do cool things buttons can like OnPressed or PressIn I am trying to find another way.


    Yeah I am going to try this since im not really looking for effects, just cosmetics like you said.

    EDIT: So I tried it out, I just need to get the timing right. @ics (or anyone) could you take a look at this vmf and help with the timing? It should be pretty self explanatory on what I am trying to achieve by looking at the entities.
     
    Last edited: Nov 16, 2016
  8. Benoist3012

    Benoist3012 L3: Member

    Messages:
    147
    Positive Ratings:
    201
    Well if you count the number of alive entity you have only 3, any projectiles made and set into a spawner, are not spawned, so if you worry about reaching the ent limit, nope you won't.
     
    Last edited: Nov 15, 2016