Yet Another Script "Confusingly" NOT Working

WarLuvr3393

Hmmm...too many things to play (WoW, COD4, WC3)
Reaction score
54
JASS:
function checkone takes nothing returns boolean
  return IsUnitAlly(GetAttacker(), GetOwningPlayer(GetOrderTargetUnit()))
endfunction

function checktwo takes nothing returns boolean
  return IsUnitType(GetOrderTargetUnit(), UNIT_TYPE_GROUND)
endfunction

function allycheck takes nothing returns boolean
  if GetBooleanAnd(checkone(),checktwo()) then 
      return true
  endif
  return false  
endfunction

function Trig_Prevent_Attack_Actions takes nothing returns nothing
  call IssueImmediateOrder(GetAttacker(), "stop")  
endfunction

//===========================================================================
function InitTrig_Prevent_Attack takes nothing returns nothing
local integer i
    set gg_trg_Prevent_Attack = CreateTrigger(  )
    set i=0
    loop
      exitwhen i>13
      call TriggerRegisterPlayerUnitEventSimple(gg_trg_Prevent_Attack, Player(i), EVENT_PLAYER_UNIT_ATTACKED)  
      set i=i+1
    endloop
   call TriggerAddCondition(gg_trg_Prevent_Attack, Condition(function allycheck))
   call TriggerAddAction( gg_trg_Prevent_Attack, function Trig_Prevent_Attack_Actions )
endfunction


I've been trying to fix this script for about an hour now. I still couldn't do this. Please help.

EDIT: This is supposed to prevent players from attacking any units but they're allowed to attack buildings. This is for my Tauren Tag.
 

Steel

Software Engineer
Reaction score
109
It will not work because

Has no reference to anything. There is no unit that is being ordered. To properly use GetOrderTargetUnit() you would have to have your event be EVENT_UNIT_ISSUED_ORDER
EVENT_UNIT_ISSUED_POINT_ORDER
EVENT_UNIT_ISSUED_TARGET_ORDER

In the event you are using there is
GetTriggerUnit() //Unit being attacked
GetAttacker() //Unit attacking

So the condition should be
JASS:
function allycheck takes nothing returns boolean
    return IsUnitAlly(GetAttacker(),GetOwningPlayer(GetTriggerUnit()))
endfunction
 

Pyrogasm

There are some who would use any excuse to ban me.
Reaction score
134
When you use "IsUnitType(...)" you must always compare it to true or false, else it may bug out.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top