• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • Create a faction for Warcraft 3 and enter Hive's 19th Techtree Contest: Co-Op Commanders! Click here to enter!
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 21st Texturing Contest: Upgrade is now concluded, time to vote for your favourite set of icons! Click here to vote!

Unable to attack allied units...

Status
Not open for further replies.
Level 12
Joined
Apr 16, 2010
Messages
584
So i need the system, like in DotA, thats makes your hero unattackable for your allies, well i can do this system myself, but i need to know hot it's made that i cannot attack allied, i know it doesn't uses action Force UI key. I can't remember but i guess a read somewhere that when you attack allied unit a wall is spawned between you and attacked unit, and you unit cannot reach it. For now I'm using ability Hardened Skin, i add to my creeps, but i still can kill them when i attack them 4 or 5 times per second. So i need to know what is the concept of this "allied" system. Anyone knows??
 
Level 16
Joined
May 1, 2008
Messages
1,605
Moin moin =)

You mean something like that:
JASS:
function AntiAttack takes nothing returns nothing
    if IsUnitAlly(GetTriggerUnit(),GetOwningPlayer(GetAttacker())) == true then
        if GetUnitState(GetTriggerUnit(),UNIT_STATE_LIFE) > (GetUnitState(GetTriggerUnit(),UNIT_STATE_MAX_LIFE) * 0.05) then
            call IssueImmediateOrder(GetAttacker(),"stop")
        endif
    endif
endfunction

function InitTrig_AntiAttack takes nothing returns nothing
    local integer i = 0
    set gg_trg_AntiAttack = CreateTrigger(  )
    loop
        exitwhen i == bj_MAX_PLAYER_SLOTS
        call TriggerRegisterPlayerUnitEvent(gg_trg_AntiAttack,Player(i),EVENT_PLAYER_UNIT_ATTACKED,null)
        set i = i + 1
    endloop
    call TriggerAddAction(gg_trg_AntiAttack,function AntiAttack)
endfunction

Greetings and Peace
Dr. Boom
 
Level 2
Joined
May 1, 2010
Messages
13
Create a new trigger, name it 'AntiAttack' and switch it to custom text (Edit->Convert to text...or so) and paste the code there; Done.

hope that helped
 
Level 12
Joined
Apr 16, 2010
Messages
584
Actually i already mentioned that i used those kinds of staff, such as Force UI key. And it doesn't work properly, i need just like in DotA, but i don't know how it was made.
Edit: gormed i know that i should name trigger AntiAttack and i of cousre know hot to convert i'm just wondering if i need just code? +rep and to Dr.Boom if can))
 
Level 2
Joined
May 1, 2010
Messages
13
Just wanted to help ;) sry if i underestimated your skill!

Here is how i tried it:

JASS:
function Trig_PreventTeamkills_Conditions takes nothing returns boolean
    if ( not ( GetIssuedOrderIdBJ() == String2OrderIdBJ("attack") ) ) then
        return false
    endif
    
    if not ( IsUnitAlly(GetOrderedUnit(), GetOwningPlayer(GetOrderTargetUnit())) == true ) then
        return false
    endif
    
    if (GetUnitLifePercent(GetOrderTargetUnit()) < 10) then
        return false
    endif

    return true
endfunction

function Trig_PreventTeamkills_Actions takes nothing returns nothing
    call IssueTargetOrderBJ( GetOrderedUnit(), "move", GetOrderTargetUnit() )
endfunction

//===========================================================================
function InitTrig_PreventTeamkills takes nothing returns nothing
    set gg_trg_PreventTeamkills = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_PreventTeamkills, EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER )
    call TriggerAddCondition( gg_trg_PreventTeamkills, Condition( function Trig_PreventTeamkills_Conditions ) )
    call TriggerAddAction( gg_trg_PreventTeamkills, function Trig_PreventTeamkills_Actions )
endfunction

well, register it for every player, this is the lazy version^^

EDIT: tested and works, you can deny a player under 10 percent HP (like in dota, i think)
 
Last edited:
Level 16
Joined
May 1, 2008
Messages
1,605
Moin moin =)

For real @ gormed: I don't would use that, because it's just converted to Jass and it has to many leaks. And for fixing all that, your trigger is longer then mine^^

@Stanley: You just need to create a trigger named AntiAttack and copy my Jass Trigger into it ( after you convert the GUI to Jass
( Edit > Convert to Custom Text ))

@-Kobas-: Attacked Unit = Triggering Unit and with your trigger, you can't deny the creeps, if he want the same system like dota, but at all this is the base AntiAttack trigger =)

Hmm longer time ago, that I created a trigger in GUI, I hope that this is correct:
  • AntiAttack
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • ((Attacking unit) belongs to an ally of (Owner of (Triggering unit))) Equal to True
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Life of (Triggering unit)) Greater than or equal to ((Max life of (Triggering unit)) x 0.05)
        • Then - Actions
          • Unit - Order (Attacking unit) to Stop
        • Else - Actions
Edit: Ok I use 5% I don't know the rate of dota 5% or 10% or whatever, but shit dota, make your own way =P

Greetings and Peace
Dr. Boom
 
Level 12
Joined
Apr 16, 2010
Messages
584
Well, thank you guys. Testing now...
Edit:
JASS:
function AntiAttack takes nothing returns nothing
    if IsUnitAlly(GetTriggerUnit(),GetOwningPlayer(GetAttacker())) == true then
        if GetUnitState(GetTriggerUnit(),UNIT_STATE_LIFE) > (GetUnitState(GetTriggerUnit(),UNIT_STATE_MAX_LIFE) * 0.05) then
            call IssueImmediateOrder(GetAttacker(),"stop")
        endif
    endif
endfunction

function InitTrig_AntiAttack takes nothing returns nothing
    local integer i = 0
    set gg_trg_AntiAttack = CreateTrigger(  )
    loop
        exitwhen i == bj_MAX_PLAYER_SLOTS
        call TriggerRegisterPlayerUnitEvent(gg_trg_AntiAttack,Player(i),EVENT_PLAYER_UNIT_ATTACKED,null)
        set i = i + 1
    endloop
    call TriggerAddAction(gg_trg_AntiAttack,function AntiAttack)
endfunction
This code worked well, +rep to Dr. Boom, but later now i can't)
 
Status
Not open for further replies.
Top