Difference between revisions of "Lua:nogrens"
Mulchman MM (talk | contribs) |
|||
(3 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
+ | {{Infobox manual/Header}} | ||
==No Grenade Areas - "nogrens"== | ==No Grenade Areas - "nogrens"== | ||
Line 5: | Line 6: | ||
<pre>-- Map's LUA file | <pre>-- Map's LUA file | ||
− | -- Include | + | -- Include nogrens functionality |
IncludeScript( "base_teamplay" )</pre> | IncludeScript( "base_teamplay" )</pre> | ||
Line 35: | Line 36: | ||
end</pre> | end</pre> | ||
− | [[Category: | + | [[Category:Lua]] |
+ | {{Infobox manual/Footer}} |
Latest revision as of 16:16, 31 December 2007
No Grenade Areas - "nogrens"A "nogrens" area is defined as an area where grenades will not explode - hence "nogrens". To create a "nogrens" area in your map all you need to do is create a brush, click "tie to entity", choose trigger_ff_script, and then name it "nogrens". Then, in your map's .LUA file be sure to include base_teamplay.lua as such: -- Map's LUA file -- Include nogrens functionality IncludeScript( "base_teamplay" ) How It WorksThe way a "nogrens" area works is that before the grenade goes to explode it checks to see just exactly what entities it is touching. It then asks those entity if it can explode. If any of the entities respond back with "false" then the grenade can not explode. The LUA function that answers the question if the grenade can explode is "canexplode" (as seen in the example) so if you want to override default "nogrens" behavior then your custom "nogrens" lua object will need to have a "canexplode" function. ExampleIf you wanted red team to be able to throw grenades in an area (and have them explode) but blue team not be allowed to do that then you can do that. There are really only two changes you would need to make. First, name your "nogrens" area (in hammer) to something else - like "blue_nogrens". Then, modify your map's lua file thusly: -- Map's LUA file -- Define "blue_nogrens" blue_nogrens = trigger_ff_script({}) -- Let red team's grenades explode but not blue team's -- here we define the "canexplode" function function blue_nogrens:canexplode( ent_id ) if IsGrenade( ent_id ) then -- Allow red team if ( GetObjectsTeam( ent_id ) == RED_TEAM ) then return true else -- Disallow every other team return false end end -- Return normally for anything not a grenade return true end |