i have a map in my campaign where a castle will be attacked, but i want te melee attackers to run further if they r attacked by archers that stand on cliffs or some unreachable place, or else all attackers will try to move to the archer and it will get stuck when there r to many. is there a way to solve this? thnx
((Attacking unit) is A ranged attacker) Equal to True ((Triggering unit) is A melee attacker) Equal to True ((*whatever area includes your wall*) contains (Attacking unit)) Equal to True
Actions
Unit - Order (Triggering unit) to Move To ((Position of (Attacking unit)) offset by *how far you want the units to run* towards (Facing of (Attacking unit))
Basically, when a melee unit is attacked by a ranged unit that is located on your wall, this trigger orders the melee unit to run in the opposite direction of the ranged attacker for a specified distance. Now, if you want your melee units to run to a certain point on your map, you can change the Trigger Action so that it reads:
Unit - Order (Triggering unit) to Move To (Point(*X coordinate of point*, *Y coordinate of point*))
no its harder then this, cuz i want them only to ignore the ranged attackers and not the nearby melee enemies. now it ignores every unit when its attacked by a ranged attacker. i thought maybe there was some thing u could uncheck in object editor or anything. i alrdy looked at gameplay constants but nothing helpful there
Hmm, k, then try thissry, I don't know how to do it in GUI >>)
...
local group g = CreateGroup()
local unit u = GetAttackedUnit()
local integer target_index = 0
local unit first
local unit array target
call GroupEnumUnitsInRange(g,500.00,GetUnitX(u),GetUnitY(u), null) // to be tweaked, 500 is a proper range because you won't be that close to the archers
// Credits to PurplePoot for this cheat-function btw!! >_<
loop
set first = FirstOfGroup(g)
exitwhen (first == null)
if (IsUnitEnemy(first)) and (not GetUnitName(first)=="Archer") and (not GetUnitName(first)=="Sniper") then
// Change the String "Archer" if they are called differently, and put more "ands" if you have more than only Archers and Snipers
set target[target_index] = first
set target_index = target_index + 1
endif
call GroupRemoveUnit(g,first)
endloop
if (target[0]==null) then
call IssuePointOrder(u,"move",ATTACK_POINT)//attack_point is the attack point...it's a Location btw
else
call IssueTargetOrder(u,"attack",target[GetRandomInt(0,target_index)])
endif
Why dont u make the rangers have locust or inverible, this way the meleer wont even think about attacking them, or make the ranger a air unit and meleer only attacks ground.
dracula, i cant use those ways. they r only good for cinematics, cuz the archers r contoleable by me. and UnMi, i rly dont know how to use JASS. where do i put this, how do i change it so it works on my map?
I do not if it's possible but try and make the archers classified as wards and see if you can diasble the ability to attack wards by melee attackers, alternatively you could make them invulnerable and let any units you need be able to attack invulnerable units.
kinda does not work here, but GroupEnumUnitsInRangeOfLoc does... I don't know what I did wrong there... @Ramza, create a Trigger called "Ignore Rangers", and make it into custom text. Then, delete everyting there and just paste the following: (Don't forget to change the X / Y coordinates!)
function Trig_Ignore_Rangers_Conditions takes nothing returns boolean
return (IsUnitType(GetTriggerUnit(), UNIT_TYPE_MELEE_ATTACKER)) and (IsUnitType(GetAttacker(), UNIT_TYPE_RANGED_ATTACKER))
endfunction
function Trig_Ignore_Rangers_Actions takes nothing returns nothing
local group g = CreateGroup()
local unit u = GetTriggerUnit()
local location target_loc = GetUnitLoc(u)
local integer target_index = 0
local unit first
local unit array target
call GroupEnumUnitsInRangeOfLoc(g,target_loc,500.00,null)
loop
set first = FirstOfGroup(g)
exitwhen (first == null)
if (IsUnitEnemy(first,GetTriggerPlayer())) and (not IsUnitType(first,UNIT_TYPE_RANGED_ATTACKER)) then
set target[target_index] = first
set target_index = target_index + 1
endif
call GroupRemoveUnit(g,first)
endloop
if (target[0]==null) then
call IssuePointOrder(u,"move",1,2)
//those are X/Y coordinates, you have to change them to those you are using
else
call IssueTargetOrder(u,"attack",target[GetRandomInt(0,target_index)])
endif
endfunction
//===========================================================================
function InitTrig_Ignore_Rangers takes nothing returns nothing
set gg_trg_Ignore_Rangers = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Ignore_Rangers, EVENT_PLAYER_UNIT_ATTACKED )
call TriggerAddCondition( gg_trg_Ignore_Rangers, Condition( function Trig_Ignore_Rangers_Conditions ) )
call TriggerAddAction( gg_trg_Ignore_Rangers, function Trig_Ignore_Rangers_Actions )
endfunction
gerbal_warfareI do not if it's possible but try and make the archers classified as wards and see if you can diasble the ability to attack wards by melee attackers,
actually you can do that. make the archers targeted as wards. the field is Combat - Targeted as. it's the last field under Combat, right before the Editor fields. you can change that and change the allowed targets for melee around and get it to work. maybe target them as ancients and for melee attackers have non-ancients under the targets allowed.