HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Being paranoid a little...

11-03-2007, 06:16 PM#1
cohadar
What is wrong here?

Collapse JASS:
scope ForbidAllyAttack

private function Conditions takes nothing returns boolean
    local player attacker = GetOwningPlayer(GetAttacker())
    if IsUnitAlly(GetTriggerUnit(), attacker) then
        call IssueImmediateOrderById(GetAttacker(), OID_stop)
        call SimError(attacker, "attacking allies is forbidden!")
    endif
    return false
endfunction

//===========================================================================
public function InitTrig takes nothing returns nothing
    local trigger trig = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( trig, EVENT_PLAYER_UNIT_ATTACKED )
    call TriggerAddCondition( trig, Condition( function Conditions ) )
endfunction

endscope
11-03-2007, 06:20 PM#2
MaD[Lion]
is there something wrong?

all i see is tat the inittrig wont work well cus of the public suffix.. or prefix?
11-03-2007, 06:25 PM#3
Captain Griffen
IsUnitAlly may be somewhat iffy.
11-03-2007, 06:46 PM#4
Vexorian
I take it you get to see the SimError message? In that case you need to stop the unit after a 0 seconds timer...
11-03-2007, 06:53 PM#5
cohadar
Quote:
Originally Posted by MaD[Lion]
is there something wrong?

all i see is tat the inittrig wont work well cus of the public suffix.. or prefix?

No actually MaD[Lion] it works, it is one of the features of jasshelper. (prefix)

@Griffen
iffy? why?

@Vex
no I want to see the message, that is fine.

Well I guess I was simply paranoid.
11-03-2007, 07:45 PM#6
Ammorth
I believe it is better to order the unit to move to its current position as the stop order was reported to be slower than the move order (units with fast attack speeds could hit allies).
11-03-2007, 08:52 PM#7
cohadar
I just tested that claim about the move order and it turned out to be false,
ordering unit to stop is faster.
11-03-2007, 09:07 PM#8
Vexorian
Perhaps you want not IsUnitEnemy() ?

have an else clause to verify the condition is actually called.
11-04-2007, 12:42 AM#9
Toadcop
Quote:
Perhaps you want not IsUnitEnemy() ?
will also disallow attack neutrals =\ but well it will work much better. cause they may be some problems directly with IsUnitAlly.