Welcome, Guest. Please login or register. Did you miss your activation email?

* TUTORIAL SECTION RULES

This section is for SMOD TUTORIALS & GUIDES ONLY.
You may create a new topic in the appropriate area to share your tutorial. If you post anything off-topic here you will be temp-banned. This is so we don't hassle the moderators too much, they are volunteers.

If you need help with a tutorial, post a reply in its thread . Do not start a new topic for help here!

Author Topic: [SMOD] Mapadd Sample - Zombie Ambush  (Read 6610 times)

0 Members and 1 Guest are viewing this topic.

Offline BIZ

  • 32-Bit Hobo
  • *
  • *
  • +0% chance to make useful post
  • BIZ hides in shadows.
    • BSNOOCH.COM
[SMOD] Mapadd Sample - Zombie Ambush
« on: October 12, 2009, 05:07:51 AM »
Here is a mapadd I threw together that was inspired by a video that veteran_gamer made for his mod SMOD Outbreak. Everything is here for your taking. Hopefully this can help you with designing mapadds.

Created - Monday, March 16, 2009, 1:10:50 PM



Zombie Ambush Mapadd Sample


Ok, first off this was inspired by a neat video veterangamer had uploaded of combine fighting off zombie2's from atop a house on d2_coast_03. He has since removed the video so I figured I would re-create it, expand upon it a little, and show you some mappadd stuff at the same time.

I. THE IDEA

Okay so in the map d2_coast_03, you drive your buggy along the coast to the rebel camp. If you have played HL2 before, you know that you can pretty much bypass all the abandoned homes and just head straight for the camp.

But why not give players a treat for taking the time to clear out the combine soldiers spying on the rebel camp huh?

I give you the zombie ambush:

[youtube]http://www.youtube.com/watch?v=unUwSIEVGlk#[/youtube]


Basically, after the combine are disposed of the player finds a combine floor turret. They barely have time to pick it up before a massive group of zombies attack. The player is then barricaded inside the house with only the turret and their current firepower to battle the fast zombies and zombie2's entering through the blown out roof!

 

II. GETTING STARTED

OK, so you need a few things for this to work correctly like it does in my video:

1.) You need to node the house! This can be a real pain in the grass, so I am providing my very unprofessional SNL file. You will need to download this file and then place it in your mapadd\nodes folder.

**RIGHTCLICK->SAVE LINK AS**

2.) You will need veterangamers zombie2 models. They are able to climb up walls and stuff. You can get these from his SMOD Outbreak mod (I have no DL for it sorry.)

Not sure if these climb walls but you could try this too - http://www.smod-tactical.com/forums/viewtopic.php?id=1384

3.) You need the actual mapadd text file. Place it in your mapadd folder.

**RIGHTCLICK->SAVE LINK AS**



   
Code: [Select]
// MAP ARRANGE DATA
    // LOCATION: d2_coast_03
    // ZOMBIE AMBUSH SAMPLE BY BUSINESS
    // Last updated 03.16.09

    "precache" {
    // Precache loads the entities into memory before the map begins. Prevents pauses during gameplay.
    "entity" "npc_zombie"
    "entity" "npc_fastzombie"
    "entity" "npc_f_turret_floor"
    }

    "entities" {
    // Entities are spawned when the map starts.

    "instant_trig" {
    //This type of entity instantly triggers something. In this case another group of entities.

    "origin" "-4263 3791 496"
    // This is the location where the center of the trigger is.

    "keyvalues" {
    // Keyvalues help define an entity. They open a new section, so watch your braces!

    "radius" "50"
    // This defines how large a trigger is. If the player walks within 50 units of the origin, he will activate the trigger.

    "label" "zambush"
    // This calls or spawns another group of entities.
    }
    }

    "instant_trig" {
    "origin" "-4141 3830 510"
    "keyvalues" {
    "radius" "50"
    "label" "tspawn"
    }
    }
    }

    "entities:tspawn" {
    // This is a new group of entities. These entities do not exist until we call them.

    "npc_f_turret_floor" {
    // A friendly floor turret.

    "origin" "-4218.4 3739.4 468.7" "angle" "0 0 0"
    // Where it will be spawned and which way it will face.

    "keyvalues" {
    "model" "models/combine_turrets/floor_turret.mdl"
    // Tells the game which model to use for this entity.
    }
    }
    }

    "entities:zambush" {

    "prop_physics" {
    // This spawns a physics prop. It can be pushed and moved around.

    "origin" "-4049.2 3576.6 501.1" "angle" "0 88 -0"
    "keyvalues" {
    "model" "models/props_c17/FurnitureCouch001a.mdl"
    }
    }

    "npc_zombie2" {
    // This spawns a zombie2 NPC

    "origin" "-3857.8 3178.6 456.7" "angle" "0 151 0"
    "keyvalues" {
    "squadname" "zucki01"
    // Enemies with the same squad name share info about target location.

    "sleepstate" "0"
    // Makes the NPC start active.

    "wakeradius" "2000"
    // How close the player must get to wake the zombie.

    "wakesquad" "1"
    // Alerts squad when zombie is woken.
    }
    }

    "npc_zombie2" {
    "origin" "-4425.9 3027.7 457.5" "angle" "0 0 0"
    "keyvalues" {
    "squadname" "zucki01"
    "sleepstate" "0"
    "wakeradius" "2000"
    "wakesquad" "1"
    }
    }

    "npc_zombie2" {
    "origin" "-4602.0 3110.8 477.9" "angle" "0 20 0"
    "keyvalues" {
    "squadname" "zucki01"
    "sleepstate" "0"
    "wakeradius" "2000"
    "wakesquad" "1"
    }
    }

    "npc_fastzombie" {
    "origin" "-4428.5 3498.7 456.0" "angle" "0 0 0"
    "keyvalues" {
    "squadname" "zucki01"
    "sleepstate" "0"
    "wakeradius" "2000"
    "wakesquad" "1"
    }
    }

    "instant_trig" {
    // Another trigger

    "keyvalues" {
    "timer" "15"
    // This trigger is on a timer and only activates when time runs out.

    "label" "fzambush"
    }
    }
    }

    "entities:fzambush" {

    "npc_fastzombie" {
    "origin" "-5300.1 4219.8 252.8" "angle" "0 244 0"
    "keyvalues" {
    "targetname" "fzact1"
    "squadname" "zucki01"
    "sleepstate" "0"
    "wakeradius" "5500"
    "wakesquad" "1"
    }
    }

    "npc_fastzombie" {
    "origin" "-5321.4 4361.2 252.2" "angle" "0 262 0"
    "keyvalues" {
    "targetname" "fzact1"
    "squadname" "zucki01"
    "sleepstate" "0"
    "wakeradius" "5500"
    "wakesquad" "1"
    }
    }

    "npc_fastzombie" {
    "origin" "-5395.6 4214.1 252.4" "angle" "0 0 0"
    "keyvalues" {
    "targetname" "fzact1"
    "squadname" "zucki01"
    "sleepstate" "0"
    "wakeradius" "5500"
    "wakesquad" "1"
    }
    }

    "npc_fastzombie" {
    "origin" "-5495.8 4382.1 230.6" "angle" "0 280 0"
    "keyvalues" {
    "targetname" "fzact1"
    "squadname" "zucki01"
    "sleepstate" "0"
    "wakeradius" "5500"
    "wakesquad" "1"
    }
    }

    "npc_fastzombie" {
    "origin" "-5702.8 4260.8 229.1" "angle" "0 338 0"
    "keyvalues" {
    "targetname" "fzact1"
    "squadname" "zucki01"
    "sleepstate" "0"
    "wakeradius" "5500"
    "wakesquad" "1"
    }
    }

    "npc_fastzombie" {
    "origin" "-5665.0 4656.8 89.2" "angle" "0 0 0"
    "keyvalues" {
    "targetname" "fzact1"
    "squadname" "zucki01"
    "sleepstate" "0"
    "wakeradius" "5500"
    "wakesquad" "1"
    }
    }

    "npc_fastzombie" {
    "origin" "-5898.4 4827.5 71.0" "angle" "0 0 0"
    "keyvalues" {
    "targetname" "fzact1"
    "squadname" "zucki01"
    "sleepstate" "0"
    "wakeradius" "5500"
    "wakesquad" "1"
    }
    }

    "npc_fastzombie" {
    "origin" "-5120 3622 325" "angle" "0 0 0"
    "keyvalues" {
    "targetname" "fzact1"
    "squadname" "zucki01"
    "sleepstate" "0"
    "wakeradius" "5500"
    "wakesquad" "1"
    }
    }

    "info_target" {
    // This creates a point of interest.

    "origin" "-3903 3738 512"
    "keyvalues" {
    "targetname" "fzgoal"
    // This gives the point a name.

    }
    }

    "ai_goal_follow" {
    // This will direct the AI of one or more NPCs

    "keyvalues" {
    "startactive" "1"
    // Active when spawned?

    "searchtype" "0"
    "MaximumState" "2"

    "actor" "fzact1"
    // Which NPC should this affect?

    "goal" "fzgoal"
    // Where should the NPC move to?
    }
    }
    }

Lets begin.


III. PRECACHE AND ENTITIES GROUP

1.) Time to start going through the code. First we will look at the precache group.

   
Code: [Select]
"precache" {
    // Precache loads the entities into memory before the map begins. Prevents pauses during gameplay.
    "entity" "npc_zombie"
    "entity" "npc_fastzombie"
    "entity" "npc_f_turret_floor"
    }

This is a very useful section. This tells the game to load these entities before the map starts. This can help to reduce load times during gameplay. If you notice in my video, there is a small hiccup when I pick up the turret? That is the game loading a bunch of different zombie models. I think you may also be able to precache individual models, but I have not tested this myself.

2.) Lets examine the entities group.

   
Code: [Select]
"entities" {
    // Entities are spawned when the map starts.

    "instant_trig" {
    //This type of entity instantly triggers something. In this case another group of entities.

    "origin" "-4263 3791 496"
    // This is the location where the center of the trigger is.

    "keyvalues" {
    // Keyvalues help define an entity. They open a new section, so watch your braces!

    "radius" "50"
    // This defines how large a trigger is. If the player walks within 50 units of the origin, he will activate the trigger.

    "label" "zambush"
    // This calls or spawns another group of entities.
    }
    }

    "instant_trig" {
    "origin" "-4141 3830 510"
    "keyvalues" {
    "radius" "50"
    "label" "tspawn"
    }
    }
    }

First thing to note - anything under the "entities" group is spawned when the map starts. No two ways about it. If you put a 10 second timer under the entities group it starts counting down as soon as the map loads.

You can see I have placed two instant triggers here on the map. Both of them are in the abandoned house. (click pic for bigger view)



Using the console command cl_showpos 1 will help greatly in finding the origin for your triggers. I also have noticed that ducking gives better coordinates for triggers.

These triggers are one time use only.

There are two types of mapadd triggers that I know of, radius and timed. You can tell the game which type of trigger you want by adding the keyvalue "radius" or the keyvalue "timer".

Radius triggers activate when the player touches them. Timed triggers activate when they finish counting down.

One very useful aspect of these triggers is that you can use them to spawn more entities. This is done through the "label" keyvalue. Using this we can tell a new entity group to spawn. More on that ahead.

IV. SPAWNING THE TURRET

1.) Ok now we are going to look at how I have spawned the turret, and why I did it this way. Here is the relevant code:

   
Code: [Select]
"entities:tspawn" {
    // This is a new group of entities. These entities do not exist until we call them.

    "npc_f_turret_floor" {
    // A friendly floor turret.

    "origin" "-4218.4 3739.4 468.7" "angle" "0 0 0"
    // Where it will be spawned and which way it will face.

    "keyvalues" {
    "model" "models/combine_turrets/floor_turret.mdl"
    // Tells the game which model to use for this entity.
    }
    }
    }
First thing to notice is the name of this entity group. It is "entities:tspawn". This is a labeled entity group. Anytime you label an entity group it will NOT be spawned when the map is loaded. The only way to spawn this stuff is to activate it (usually through a trigger).

Just to make sure you get the idea:

   
Code: [Select]
"instant_trig" {
    "keyvalues" {
    "label" "tspawn"

    ** Spawns the entity group **

    "entities:tspawn"

2.) Next thing to think about -- why didn't I just spawn the turret under the "entities" section, at the start of the map? The answer to that is because of Valve :P

If we take a look at the combine that occupy the abandoned house, you can see one of them is spawned in the area where my turret spawns.



The problem with spawning the turret at the start of the map is that when the combine spawn in the house, the turret immediately begins attacking the combine soldier in the same room, and since all three combine are in the same squad they all rush over to take out the turret and get mowed down. This results in a bunch of dead combine by the time the player gets to the house, which is confusing and not very fun.

So the fix is to place the turret under a labeled entity group. I place the trigger that spawns the turret right at the doorway to the room. This ensures that the player has most likely dealt with the combine. Another thing this does is that it allows the turret to spawn while the player is not looking at it, giving the illusion that it was there the whole time.

V. ZOMBIES COMMENCE

1.) Time to look at the next entity group, "entities:zambush".

   
Code: [Select]
"entities:zambush" {

    "prop_physics" {
    // This spawns a physics prop. It can be pushed and moved around.

    "origin" "-4049.2 3576.6 501.1" "angle" "0 88 -0"
    "keyvalues" {
    "model" "models/props_c17/FurnitureCouch001a.mdl"
    }
    }

    "npc_zombie2" {
    // This spawns a zombie2 NPC

    "origin" "-3857.8 3178.6 456.7" "angle" "0 151 0"
    "keyvalues" {
    "squadname" "zucki01"
    // Enemies with the same squad name share info about target location.

    "sleepstate" "0"
    // Makes the NPC start active.

    "wakeradius" "2000"
    // How close the player must get to wake the zombie.

    "wakesquad" "1"
    // Alerts squad when zombie is woken.
    }
    }

    "npc_zombie2" {
    "origin" "-4425.9 3027.7 457.5" "angle" "0 0 0"
    "keyvalues" {
    "squadname" "zucki01"
    "sleepstate" "0"
    "wakeradius" "2000"
    "wakesquad" "1"
    }
    }

    "npc_zombie2" {
    "origin" "-4602.0 3110.8 477.9" "angle" "0 20 0"
    "keyvalues" {
    "squadname" "zucki01"
    "sleepstate" "0"
    "wakeradius" "2000"
    "wakesquad" "1"
    }
    }

    "npc_fastzombie" {
    "origin" "-4428.5 3498.7 456.0" "angle" "0 0 0"
    "keyvalues" {
    "squadname" "zucki01"
    "sleepstate" "0"
    "wakeradius" "2000"
    "wakesquad" "1"
    }
    }

    "instant_trig" {
    // Another trigger

    "keyvalues" {
    "timer" "15"
    // This trigger is on a timer and only activates when time runs out.

    "label" "fzambush"
    }
    }
    }

Notice first thing I do is spawn a physics prop. This is the big couch that blocks the doorway. I wanted to force the zombies to enter from the roof, so blocking the shortest route (the door) was necessary.

2.) Next I spawn a bunch of zombie NPC's. Nothing real special about them. They spawn outside the house and begin to attack. I put descriptions under the keyvalues so you can see what they do, but the important one is probably the "squadname".

Since all these zombies are in the same squad, their AI shares information about targets and stuff. This helps increase the odds that they begin attacking the player.

3.) Lastly I spawn a trigger. It is on a 15 second timer, which starts counting down. When the timer runs out, I call another labeled entity group which spawns even more zombies. I wanted a lot of zombies, but didn't want to bog down the players PC by spawning a whole bunch at once. You can use this technique several times to make it seem like a constant stream of zombies.

VI. MORE ZOMBIES

Relevant code:

   
Code: [Select]
"entities:fzambush" {

    "npc_fastzombie" {
    "origin" "-5300.1 4219.8 252.8" "angle" "0 244 0"
    "keyvalues" {
    "targetname" "fzact1"
    "squadname" "zucki01"
    "sleepstate" "0"
    "wakeradius" "5500"
    "wakesquad" "1"
    }
    }

    "npc_fastzombie" {
    "origin" "-5321.4 4361.2 252.2" "angle" "0 262 0"
    "keyvalues" {
    "targetname" "fzact1"
    "squadname" "zucki01"
    "sleepstate" "0"
    "wakeradius" "5500"
    "wakesquad" "1"
    }
    }

    "npc_fastzombie" {
    "origin" "-5395.6 4214.1 252.4" "angle" "0 0 0"
    "keyvalues" {
    "targetname" "fzact1"
    "squadname" "zucki01"
    "sleepstate" "0"
    "wakeradius" "5500"
    "wakesquad" "1"
    }
    }

    "npc_fastzombie" {
    "origin" "-5495.8 4382.1 230.6" "angle" "0 280 0"
    "keyvalues" {
    "targetname" "fzact1"
    "squadname" "zucki01"
    "sleepstate" "0"
    "wakeradius" "5500"
    "wakesquad" "1"
    }
    }

    "npc_fastzombie" {
    "origin" "-5702.8 4260.8 229.1" "angle" "0 338 0"
    "keyvalues" {
    "targetname" "fzact1"
    "squadname" "zucki01"
    "sleepstate" "0"
    "wakeradius" "5500"
    "wakesquad" "1"
    }
    }

    "npc_fastzombie" {
    "origin" "-5665.0 4656.8 89.2" "angle" "0 0 0"
    "keyvalues" {
    "targetname" "fzact1"
    "squadname" "zucki01"
    "sleepstate" "0"
    "wakeradius" "5500"
    "wakesquad" "1"
    }
    }

    "npc_fastzombie" {
    "origin" "-5898.4 4827.5 71.0" "angle" "0 0 0"
    "keyvalues" {
    "targetname" "fzact1"
    "squadname" "zucki01"
    "sleepstate" "0"
    "wakeradius" "5500"
    "wakesquad" "1"
    }
    }

    "npc_fastzombie" {
    "origin" "-5120 3622 325" "angle" "0 0 0"
    "keyvalues" {
    "targetname" "fzact1"
    "squadname" "zucki01"
    "sleepstate" "0"
    "wakeradius" "5500"
    "wakesquad" "1"
    }
    }

    "info_target" {
    // This creates a point of interest.

    "origin" "-3903 3738 512"
    "keyvalues" {
    "targetname" "fzgoal"
    // This gives the point a name.

    }
    }

    "ai_goal_follow" {
    // This will direct the AI of one or more NPCs

    "keyvalues" {
    "startactive" "1"
    // Active when spawned?

    "searchtype" "0"
    "MaximumState" "2"

    "actor" "fzact1"
    // Which NPC should this affect?

    "goal" "fzgoal"
    // Where should the NPC move to?
    }
    }
    }

1.) So when the timer runs down another entity group is triggered, "entities:fzambush". This spawns even more fast zombies, but this time I put them farther away from the house so the player has time to wipe out a few from the first wave.

One thing to note is that I gave all the zombies the same "targetname". This way I can give them commands.

2.) I also included an example of an "ai_goal_follow" setup here. Credit for this system goes to the_author. The system consists of two entities, an "ai_goal_follow" and an "info_target"

Code: [Select]
    "info_target" {
    // This creates a point of interest.

    "origin" "-3903 3738 512"
    "keyvalues" {
    "targetname" "fzgoal"
    // This gives the point a name.

    }
    }

    "ai_goal_follow" {
    // This will direct the AI of one or more NPCs

    "keyvalues" {
    "startactive" "1"
    // Active when spawned?

    "searchtype" "0"
    "MaximumState" "2"

    "actor" "fzact1"
    // Which NPC should this affect?

    "goal" "fzgoal"
    // Where should the NPC move to?
    }
    }

Basically the "ai_goal_follow" tells an NPC or NPCs to move to a point of interest. They will then pick the shortest route (usually) and move there. They will only stop moving to the point of interest to engage an enemy. Once they reach the point of interest they go back to behaving normally.

If you didn't already figure it out, the "info_target" is my point of interest. I placed it smack dead in the middle of the house, near floor level. You can see in the video the fast zombies do a pretty good job jumping onto the roof, and then down into the room.

I should mention that the point of having one of these systems is usually to spawn NPC's out of the players view and then direct them to the action.

Also note that the "ai_goal_follow" entity can be placed anywhere inside the map.

VII. CLOSING


Sorry I made this so long, wanted to make sure modders of all skill levels could grasp it. Feel free to leave questions, comments, whatever. I will post some more mapadds soon.

If anybody knows where to get the climbing zombie2s please post a link. I dunno if vg ever released them or if you can only find them in the Outbreak 45 version???
« Last Edit: January 20, 2015, 09:15:08 AM by Pepsifan04 »

Offline BIZ

  • 32-Bit Hobo
  • *
  • *
  • +0% chance to make useful post
  • BIZ hides in shadows.
    • BSNOOCH.COM
Re: Mapadd Sample - Zombie Ambush
« Reply #1 on: October 12, 2009, 05:09:09 AM »
This tutorial is outdated. I forgot that the turret can sometimes crash the game. I have a workaround for that now. Will update soon.

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal