| 02-21-2007, 09:59 PM | #1 |
Hi all, I have a problem with one of my spells and I can't find a valid solution: I have an ability that issues to an enemy unit to move to a certain location, but I want that the player owning the target unit can't issue any another order to his unit for some seconds (he can click but the unit will continue moving toward that location). In few words I want that a player can't issue orders to a unit for a short time, as if it was lag! Any ideas? Thanks! |
| 02-21-2007, 11:51 PM | #2 |
This should do it (though it's somewhat inaccurate): JASS:function Trig_Move_Constant_Conditons takes nothing returns boolean return GetSpellAbilityId() == 'A001' //Or whatever your spell's Id is endfunction function Trig_Move_Constant_Actions takes nothing returns nothing local unit U = GetSpellTargetUnit() //Or however you get your unit local real X1 = GetLocationX(GetSpellTargetLoc()) local real Y1 = GetLocationX(GetSpellTargetLoc()) local real X2 local real Y2 local real D loop exitwhen D <= 100.00 set X2 = GetUnitX(U) set Y2 = GetUnitY(U) set D = SquareRoot((X2-X1)*(X2-X1)+(Y2-Y1)*(Y2-Y1)) call IssuePointOrder(U, "move", X1, Y1) call TriggerSleepAction(0.00) //Not exactly accurate, but it'll get things done endloop set U = null endfunction //=========================================================================== function InitTrig_Move_Constant takes nothing returns nothing set gg_trg_Move_Constant = CreateTrigger( ) call TriggerRegisterAnyUnitEventBJ( gg_trg_Move_Constant, EVENT_PLAYER_UNIT_SPELL_EFFECT ) call TriggerAddCondition( gg_trg_Move_Constant, Condition(function Trig_Move_Constant_Conditons) ) call TriggerAddAction( gg_trg_Move_Constant, function Trig_Move_Constant_Actions ) endfunction |
| 02-22-2007, 02:01 AM | #3 |
Thanks for your help Pyrogasm, but I already have a function exactly like this that uses a looping timer. Actually I was looking for a easier workaround (for example I tried changing the unit's owner to Neutral Passive for some seconds, but it is not very beautiful). Any other idea to prevent a player from issuing orders to a unit (just like the lag effect)? Thanks BTW! |
| 02-22-2007, 07:59 AM | #4 |
I had a similar problem in my AoS type map when I had NPC spawned units that were on the same team as actual players (I wanted to have 6v6 capability, I have since moved the spawned units to players Neutral Hostile and Neutral Extra). I developed a system worked flawlessly I think. When the unit was given a destination to move to I attached that location as a "handle variable" to the unit then whenever the unit was ordered to do anything else I had a trigger to pause the unit, re-order it to move the the destination attached to itself and unpause it. The one thing you gotta watch out for with that is that getting stunned counts as an order and unpausing a stunned unit unstuns them. So the effect would be that if a unit had your "Run Away" ability or whatever cast on them and then they were stunned, they would ignore it and keep running even though the still have the stun buff on them. So you need to make an exception for the stun order (851973). Oh, and that will crash the game because of an infinite loop because you are ordering the unit and the trigger fires when you order a unit so you will need to prevent that by temporarily having the trigger turn itself of or moving the unit into a special unit group and having a condition to ignore units in that group or something like that. Here is an example. |
