• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

units attack automatically. what event?

Status
Not open for further replies.
Level 2
Joined
Oct 17, 2009
Messages
7
hey guys,

imagine: u have a unit and a building. the unit is owned by players red and the building is neutral aggressive.
so if the unit stands next to the building it attacks the building.

how can i ask for that event?
looks like "EVENT_PLAYER_UNIT_ATTACKED" doesnt work for that. or maybe my script just doesnt work....

i have to say that i want the script JUST to trigger when the attacking units id = npn2 , but you can see that in the script^^

here's the script:

JASS:
function Trig_AdminAttack_Conditions takes nothing returns boolean
	return(not(IsUnitAlly(GetTriggerUnit(),GetOwningPlayer(GetAttacker()))))
endfunction

function Trig_AdminAttack_Actions takes nothing returns nothing

	if (GetUnitTypeId(GetAttacker())=='npn2') then
		call DisplayTimedTextToForce(GetPlayersAll(),30,"blablabla")
	endif

endfunction

...


	call TriggerRegisterAnyUnitEventBJ(udg_trigger99,EVENT_PLAYER_UNIT_ATTACKED)
	call TriggerAddCondition(udg_trigger99,Condition(function Trig_AdminAttack_Conditions))
	call TriggerAddAction(udg_trigger99,function Trig_AdminAttack_Actions)

...

	set udg_trigger99=CreateTrigger()

i think this should work, but it doesnt...
everyone who helps me gets +rep =)
 
Status
Not open for further replies.
Top