• 🏆 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!

request, monster lure spell

Status
Not open for further replies.
Level 4
Joined
Oct 9, 2013
Messages
84
Hello guys, Im making a hunter character in a map and I need a monster lure, I got a ward, but how do I make that ward to attract nearby monsters to attack it to drive away their attention from the hunter?
 

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,183
I created this really quick. You need JNGP for it to work. It works nicely, however there are two flaws as of now.

1. it orders all units to attack the ward, no mater the owner.
2. the order can be changed. So this wont work properly is the unit is controlled by a player.

JASS:
//! zinc
	library WardTaunt
	{
		private hashtable hash = InitHashtable();
		
		function death()
		{
			unit u = GetEnumUnit();
			integer h = GetHandleId(u);
			FlushChildHashtable(hash, h);
			DestroyTrigger(LoadTriggerHandle(hash, h, 1));
		}
		
		private function actions()
		{
			unit u = GetTriggerUnit();
			unit ward = LoadUnitHandle(hash, GetHandleId(GetTriggeringTrigger()), 1);
			IssueTargetOrder(u, "attack", ward);
		}
		
		public function addWardTaunt(unit u)
		{
			trigger t = CreateTrigger();
			TriggerRegisterUnitInRangeSimple(t, 500, u);
			TriggerAddAction(t, function actions);
			SaveUnitHandle(hash, GetHandleId(t), 1, u);
			SaveTriggerHandle(hash, GetHandleId(u), 1, t);
		}
		
		function onInit()
		{
			trigger t = CreateTrigger();
			TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_DEATH);
			TriggerAddAction(t, function death);
		}
	}
//! endzinc
  • demo
    • Events
      • Player - Player 1 (Red) skips a cinematic sequence
    • Conditions
    • Actions
      • Set u = Footman 0001 <gen>
      • Custom script: call addWardTaunt(udg_u)
 

Attachments

  • WardTaunt.w3x
    10.8 KB · Views: 57
Status
Not open for further replies.
Top