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] Events and Mapadd I/O's  (Read 3071 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] Events and Mapadd I/O's
« on: October 12, 2009, 05:15:53 AM »
Lets take a quick look at basic Inputs and Outputs (I/O's) and how they are handled in SMOD's mapadd system! This is the bread and butter of the source engine. If you have no idea what inputs and outputs are I would suggest that you do some reading here:
http://developer.valvesoftware.com/wiki/Inputs_and_Outputs

Get a basic feel for them because I am just going to jump right into the SMOD mapadd system, but keep in mind we will mainly be dealing with outputs.

Created - 10.07.09



EVENTS & MAPADD I/O's

I. EVENTS

The SMOD author was nice enough to give us a softball with the "event" entity. This entity basically sends a one time output to an entity. It also will help us set up a basic template of how an Output should look. Here is an example event

   
Code: [Select]
"event" {
    "targetname" "reinforcement_spawner"
    "action" "SetMaxLiveChildren"
    "value" "5"
    "delaytime" "2"
    }

Ok now lets take a quick look at what each value in our example does.

targetname - This is our target entity, or the entity we are sending the output to. In the example it is an npc_template_maker.
action - This is what we are telling the target entity to do, or what we are changing about it.
value - Some arguements require a value. In this example we are setting the maximum number of living NPC's to 5.
delaytime - How many seconds after this output is sent should it take effect.

II. OUTPUTS AS KEYVALUES

Another way to send an output is through another entity. In this case we will look at sending an output from a NPC. Basically we use all the same values and arguments from the "event" entity and just stick them under the entities keyvalues. The nice thing about doing it this way is that we have more control over when the output is fired because we can set the Event that triggers the output instead of just using the one off entity the author provided. Here is the format we will use:

Code: [Select]
    "event" "targetname,action,value,delaytime,fireonce"
Breaking it down again. Note that when outputs are expressed as keyvalues, each arguement is separated by a comma.

event - This is what tells the entity to send the output. Keep in mind that each entity has it's own unique events.
targetname - Again , this declares which entity we are targeting (sending the output to).
action - What we are telling the target entity to do.
value - May not need to be set in all cases.
delaytime - sets a delay in seconds from the time we send the output, to the time it takes effect.
fireonce - Use this to set whether the output can be triggered more than once. -1=infinite, 1=fire only once.

Alright so finally, a quick example output for you. In this example we will use a combine soldier. When he dies, we will send an output that removes his weapon from the game so the player can not pick it up.

   
Code: [Select]
"npc_combine_s" {
    "origin" "234 -1642 28"
    "keyvalues" {
    "targetname" "combine_soldier1"
    "additionalequipment" "weapon_smg1"
    "OnDeath" "combine_soldier1_weapon,Kill,,0,1"
    }
    }

A quick note about this example: In some cases, you won't need to include a value arguement. In those cases just leave it blank as shown above.

One last time just to drill it into your head, color coded this time...

"event" "targetname,action,value,delaytime,fireonce"

"OnDeath" "combine_soldier1_weapon,Kill,,0,1"


III. OUTPUTS FROM AN INSTANT_TRIG

Lastly...We can also fire outputs directly from the "instant_trig" entity the SMOD author included in the game. Now I haven't experimented too much with this but, for now, the only confirmed event for an instant_trig is "OnHitTrigger". Again, our output will be expressed as a keyvalue so use the same format as above.

Here is an example (from d3_c17_10b):

Code: [Select]
    "instant_trig" {
    "keyvalues" {
    "timer" "0.1"
    "label" "init"
    "OnHitTrigger" "n_room_trapdoor_2a,Close,,5,-1"
    }
}

IV. FINAL NOTES, ETC...

Just for shits and giggles, here is an example output with a value arguement:

Code: [Select]
    "OnTrigger" "switches_counter,Add,1,0,-1"
You can have more than one output under an entity's keyvalues. As far as I know, you can have an unlimited amount of them. Here is an example from one of my OUTBREAK mapadds:

   
Code: [Select]
"logic_relay" {
    "origin" "2644 -1880 576"
    "keyvalues" {
    "targetname" "s_room_off_relay"
    "StartDisabled" "0"
    "OnTrigger" "s_laser27,TurnOff,,0,-1"
    "OnTrigger" "s_laser23,TurnOff,,0,-1"
    "OnTrigger" "s_laser24,TurnOff,,0,-1"
    "OnTrigger" "s_laser26,TurnOff,,0,-1"
    "OnTrigger" "s_room_nodelink_brush,Kill,,0,-1"
    "OnTrigger" "barney_laseroom_assault,Kill,,0.5,-1"
    "OnTrigger" "barney_laseroom_assault,Deactivate,,0,-1"
    "OnTrigger" "barney_laseroom_seq_trigger,Kill,,0,-1"
    "OnTrigger" "s_room_nodelink_1,TurnOn,,0,-1"
    "OnTrigger" "s_laser22,TurnOff,,0,-1"
    "OnTrigger" "s_laser21,TurnOff,,0,-1"
    "OnTrigger" "s_laser18,TurnOff,,0,-1"
    "OnTrigger" "s_laser17,TurnOff,,0,-1"
    "OnTrigger" "s_laser16,TurnOff,,0,-1"
    "OnTrigger" "s_laser15,TurnOff,,0,-1"
    "OnTrigger" "s_laser14,TurnOff,,0,-1"
    "OnTrigger" "s_laser13,TurnOff,,0,-1"
    "OnTrigger" "s_laser12,TurnOff,,0,-1"
    "OnTrigger" "s_laser11,TurnOff,,0,-1"
    "OnTrigger" "s_laser10,TurnOff,,0,-1"
    "OnTrigger" "s_laser9,TurnOff,,0,-1"
    "OnTrigger" "s_laser8,TurnOff,,0,-1"
    "OnTrigger" "s_laser7,TurnOff,,0,-1"
    "OnTrigger" "s_laser6,TurnOff,,0,-1"
    "OnTrigger" "s_laser5,TurnOff,,0,-1"
    "OnTrigger" "s_laser4,TurnOff,,0,-1"
    "OnTrigger" "s_laser3,TurnOff,,0,-1"
    "OnTrigger" "s_laser2,TurnOff,,0,-1"
    "OnTrigger" "s_laser1,TurnOff,,0,-1"
    "OnTrigger" "laser_off_sound,PlaySound,,0,-1"
    "OnTrigger" "s_laser25,TurnOff,,0,-1"
    "OnTrigger" "npc_citizen,SetSquad,player_squad,0,-1"
    "OnTrigger" "s_room_off_follow,Activate,,0.2,-1"
    "OnTrigger" "laserroom_mines,Disarm,,0,-1"
    "OnTrigger" "laserroom_tripmines,Kill,,0,-1"
    "OnTrigger" "game_s_cmd,command,instant_trig_run sasha,0,1"
    }
    }

Wondering what the fireonce arguement is useful for? Lets say you have an unarmed citizen. You want to give the citizen a gun when they join the players squad. However, if the citizen then leaves the players squad and re-joins again later on, you wouldn't want the citizen to get the same gun again (since they are already carrying one from before). This is when we would use a fire once.

Code: [Select]
    "npc_citizen" {
    "origin" "-24 -6541 240"
    "keyvalues" {
    "targetname" "unarmed_citizen"
    "OnJoinedPlayerSquad" "unarmed_citizen, GiveWeapon,weapon_smg1,2,1"
    }
    }

Now lets do a quick example of an infinite firing output. Lets say we have a citizen that is neutral to combine soldiers. However when the citizen joins the players squad, we want them to start attacking the combine. And finally if they leave the players squad again, we want them to revert back to being neutral to the combine.

 
Code: [Select]
   "npc_citizen" {
    "origin" "-24 -6541 240"
    "keyvalues" {
    "targetname" "timid_citizen"
    "OnJoinedPlayerSquad" "timid_citizen, SetRelationship,npc_combine_s D_HT 999,0.1,-1"
    "OnLeftPlayerSquad" "timid_citizen, SetRelationship,npc_combine_s D_NU 999,0.1,-1"
    }
    }

Since we want this output to happen EVERY time the event occurs, we set it to -1, making it fire infinitely.
« Last Edit: July 21, 2011, 12:49:37 AM by BIZ »

Offline BIZ

  • 32-Bit Hobo
  • *
  • *
  • +0% chance to make useful post
  • BIZ hides in shadows.
    • BSNOOCH.COM
Re: Events and Mapadd I/O's
« Reply #1 on: November 01, 2009, 08:08:15 PM »
V. EXAMPLES

1.) Patrolling NPC's

Lets create a bunch of combine and then make them patrol the nearby area.

Code: [Select]
"npc_metropolice" {
"origin" "25 -403 256"
"angle" "0 -90 0"
"keyvalues" {
"targetname" "walkers"
"squadname" "enemy_squad1"
"additionalequipment" "weapon_pistol"
}
}

"npc_combine_s" {
"origin" "50 -287 256"
"angle" "0 -90 0"
"keyvalues" {
"targetname" "walkers"
"squadname" "enemy_squad1"
"additionalequipment" "weapon_smg1"
}
}

"npc_combine_e" {
"origin" "-2 -426 256"
"angle" "0 -90 0"
"keyvalues" {
"targetname" "walkers"
"squadname" "enemy_squad1"
"additionalequipment" "weapon_ar2"
}
}

"event" {
"targetname" "walkers"
"action" "startpatrolling"
}

Ok, as you can see we are spawning 3 different NPC's, one metrocop, one combine soldier, and one elite soldier. The important part here is that they all share the same targetname.

Now after we spawn our three NPC's we are firing an input to them with the "event" entity. In this case we are sending the action (input) of "startpatrolling" to any entity with the targetname "walkers".

Offline veteran_gamer

  • *
  • *
  • +5% chance to make useful post
  • veteran_gamer barely matters.veteran_gamer barely matters.
Re: Events and Mapadd I/O's
« Reply #2 on: November 01, 2009, 08:18:12 PM »
yanni is strong with this one!!!!!!!