Detecting If Player Clicked Inside An Area

From Valve Developer Community
< Dota 2 Workshop Tools‎ | Scripting
Revision as of 11:25, 16 June 2019 by Soer4769 (talk | contribs) (Added category to the page, added shortpagetitle template)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
  • Step 1: In Hammer, create a brush with the brush tool ( Shift+B). Make sure you have the "toolstrigger.vmat" material selected. It should cover the area you want to be tested.
  • Step 2: Select the brush you just and go to Tools > Tie To Entity (Ctrl+T). This will create a trigger entity that is tied to your box.
  • Step 3: Select the trigger and change its class to "trigger_multiple".
  • Step 4: Give the trigger a targetname, for the sake of this example, let's call it "trigger_no_ward".

Now in npc_items_custom.txt:

		"BaseClass"					"item_datadriven"
		"AbilityTextureName"				"item_ward_sentry"
		"AbilityBehavior"				"DOTA_ABILITY_BEHAVIOR_POINT"
				"ScriptFile"			"scripts/vscripts/custom_ward.lua"
				"Function"		        "spawn"
			        "Target"                        "POINT"

And in custom_ward.lua:

function spawn(keys)
  local inTrigger = false

    for _,thing in pairs(Entities:FindAllInSphere(GetGroundPosition(keys.target_points[1], nil), CHECKINGRADIUS) )  do

        if (thing:GetName() == "trigger_no_ward") then
            --In no_ward trigger. Set flag.
            inTrigger = true

    if (inTrigger == True)
       --Used onto specified area. Do stuff...