• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[Spell] IssuePointOrder works based on which day of the week it is

Status
Not open for further replies.
Hello,

I am pretty sure at this point that the problem with regards to this issue isn't sitting in front of the computer, but located in the top-right corner of the main menu, but maybe someone can still offer advice or has experienced something similar.

I have a system in my map wherein spells have infinite range, but if the hero is out of a range set in the script, a trigger will cancel the spell cast, save the order and the location, move the hero towards the location, and once in range of the spell, will give the order to cast it. This is necessary because of the custom movement system in the map.

Now I noticed that the system is sometimes failing. Sometimes the hero moves to the location, but then doesn't do anything. I have not been able to reliably reproduce it. On some map tests, it will always work, and occasionally it will never work on exactly one spell.

So I put in debug messages, created hooks for IssueImmediateOrder, IssueTargetOrder, and IssuePointOrder (anything that could intercept the command (accidental "stop" trigger?)), but nothing. The code executes, there's a message that the hero has been given the correct order, but it just doesn't do anything. There are no additional orders detected.

If the hero is ordered by me to cast the same spell in range (so the cast range system doesn't jump in), it will cast it without issues. When I was able to get a map launch where the bug occured, I tried to get more info. The bug also happens for another spell of a different hero that has the same order id ("acidbomb", ability based on Channel). This is so bizzare...

I think (about 50% sure) that the bug only occurs once you hear that main menu chains sound that you shouldn't hear in-game. I am almost certain that the IssueOrder functions are the problem because I've experienced unexpected behavior with regards to units ignoring orders in other areas, but where I couldn't exclude the possibility yet that I caused the bug.

Thanks for any help!
 
Level 21
Joined
Dec 4, 2007
Messages
1,483
How does the unit in question know when to cast the real spell? Are you overusing entering unit events?
Does it always work, right after going into testing, or does it fail sometimes even instantly after map init (thus before the chain sound bug)?

Well you concluded that it always works if your workaround system isn't involved, so i'd try to reduce the triggers down step by step to find the culprit - or at least find the moment when it fails.
 
How does the unit in question know when to cast the real spell? Are you overusing entering unit events?
With a distance check on a periodic trigger.
Code:
			if T_H.outOfRangeAbility != 0 then
				if SHORT_RANGE_SPELL_TARGET_TYPE[T_H.outOfRangeAbility] == "point" then
					set T_dx = T_H.outOfRangeOrderX - T_H.x
					set T_dy = T_H.outOfRangeOrderY - T_H.y
					set T_dist2 = T_dx*T_dx + T_dy*T_dy
					if T_dist2 < SHORT_RANGE_SPELL_CAST_RANGE[T_H.outOfRangeAbility]*SHORT_RANGE_SPELL_CAST_RANGE[T_H.outOfRangeAbility] then
						call IssuePointOrder( T_H.avatar , SHORT_RANGE_SPELL_ORDER_STRING[T_H.outOfRangeAbility] , T_H.outOfRangeOrderX , T_H.outOfRangeOrderY )
						set T_H.outOfRangeAbility = 0
					endif
				else
					set T_H.orderX = GetUnitX(T_H.outOfRangeOrderUnit)
					set T_H.orderY = GetUnitY(T_H.outOfRangeOrderUnit)
					set T_dx = T_H.orderX - T_H.x
					set T_dy = T_H.orderY - T_H.y
					set T_dist2 = T_dx*T_dx + T_dy*T_dy
					if T_dist2 < SHORT_RANGE_SPELL_CAST_RANGE[T_H.outOfRangeAbility]*SHORT_RANGE_SPELL_CAST_RANGE[T_H.outOfRangeAbility] then
						call IssueTargetOrder( T_H.avatar , SHORT_RANGE_SPELL_ORDER_STRING[T_H.outOfRangeAbility] , T_H.outOfRangeOrderUnit )
						set T_H.outOfRangeAbility = 0
					endif
				endif
			endif
Does it always work, right after going into testing, or does it fail sometimes even instantly after map init (thus before the chain sound bug)?
When I started the map, it always took me some time to find the specific spell for which it isn't working this time, which could just be bad luck so can't say for certain either way.

Well you concluded that it always works if your workaround system isn't involved, so i'd try to reduce the triggers down step by step to find the culprit - or at least find the moment when it fails.
I have done that by creating hooks and debug messages. The line with the IssuePointOrder call is reached, outOfRangeAbility is set to 0, the correct order string is displayed as a debug message, and there are no other commands given to the hero detected by the hooks.

Another clue that the IssueOrder function is broken: I create a unit with a spell and give it a command to move towards the spell target location. This should be recognized by the movement system, but it isn't.

Code:
	local real x = GetSpellTargetX()
	local real y = GetSpellTargetY()
	local unit master = GetSpellAbilityUnit()
	local real x2 = GetUnitX(master)
	local real y2 = GetUnitY(master)
	local real dist = SquareRoot((x-x2)*(x-x2) + (y-y2)*(y-y2))
	local hoverdisc newHoverdisc = hoverdisc.CreateSpecial( A, 'H00B', x2+250*(x-x2)/dist, y2+250*(y-y2)/dist, 5, AVATAR_RADIUS, 0.6*HOVERDISC_RADIUS, 0.75, true )
	local unit pet = newHoverdisc.avatar
	call IssueImmediateOrder( pet , "berserk" )
	call IssuePointOrder( pet , "move" , x , y )

This has always worked. It now has stopped working on older versions of the map, for which I know it has worked. Now I have to update the order location manually to achieve the same behavior.
Code:
	set newHoverdisc.orderX = x
	set newHoverdisc.orderY = y
If I order the unit directly, everything works as it always has.
 
I just realized that all spells for which I observed this behavior are based on Channel, while the other spells always worked (only spells with an area of effect cursor are not based on Channel, so it wasn't that obvious). So, the bug might be that the game doesn't recognize that the hero has a Channel ability with the issued order id and just ignores it.
 

Uncle

Warcraft Moderator
Level 65
Joined
Aug 10, 2018
Messages
6,647

The cast type channel uses must match the cast type of the ability that the order string comes from. If it does not match then AI and trigger issued orders will not work to cast both the channelled ability and any ability derived from the ability the order string comes from. This will not affect player casting of the abilities, only AI and trigger casting.

As an example, if you base a channel ability on the order string for thunderclap and then turn it into a unit target ability then this will break trigger issued orders for both the channel ability and any ability derived from thunderclap. Thunderclap is an instant cast ability so channel has mutated its target type breaking it internally.
 
Status
Not open for further replies.
Top