Finding Unit Within Range Center Unit?

Squll2

je'ne sais pas
Reaction score
76
I actually have three queries, which I will explain in this post but first of all, is there an event response for finding the Unit Within Range Center Unit?

If you dont get what I mean, heres my code (uncompleted)

JASS:
function Trig_Forest_of_Alchemy_Start_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A00A'
endfunction

function Trig_Forest_of_Alchemy_Start_Actions takes nothing returns nothing

    local location l = GetSpellTargetLoc()
    local unit d
    local unit u = GetSpellAbilityUnit()
    local real x = GetLocationX(l)
    local real y = GetLocationY(l)
    local player p = GetOwningPlayer(u)
    
    set d = CreateUnit( p, 'h006', x, y, 0.00 )
    call TriggerRegisterUnitInRangeSimple( gg_trg_Forest_of_Alchemy, 600.00, d )
    
    call PolledWait(1.00)
    
    set p = null
    
endfunction

//===========================================================================
function InitTrig_Forest_of_Alchemy_Start takes nothing returns nothing
    set gg_trg_Forest_of_Alchemy_Start = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Forest_of_Alchemy_Start, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Forest_of_Alchemy_Start, Condition( function Trig_Forest_of_Alchemy_Start_Conditions ) )
    call TriggerAddAction( gg_trg_Forest_of_Alchemy_Start, function Trig_Forest_of_Alchemy_Start_Actions )
endfunction

Thats the intialization trigger, what im doing here as you can probably see it when a unit casts a spell it creates a unit, then adds that unit to a unit within range event to another trigger..

Heres the other trigger (incomplete)

JASS:
function Trig_Forest_of_Alchemy_Conditions takes nothing returns boolean

 local unit u = GetTriggerUnit()
 local unit e = GetEnteringUnit()
 
    if ( not ( IsUnitAliveBJ(e) == true ) ) then
        return false
    endif
    if ( not( IsUnitEnemy(e, GetOwningPlayer(u)) == true ) ) then
        return false
    endif
    return true
    
endfunction

function Trig_Forest_of_Alchemy_Actions takes nothing returns nothing

  local unit u    = GetTriggerUnit()
  local unit e    = GetEnteringUnit()
  local player p  = GetOwningPlayer(u)
  local integer I = GetRandomInt(0, 100)
  local real x    = GetUnitX(u)
  local real y    = GetUnitY(u)
  local unit d
  
  
 if I <= 20 then 
   set d = CreateUnit(p, 'h006', x, y, 0.00)
   call UnitAddAbility (d, 'A00B')
   call IssueTargetOrder(d, "entanglingroots", e)
   
 endif
 
 if I 
    
  
endfunction

//===========================================================================
function InitTrig_Forest_of_Alchemy takes nothing returns nothing
    set gg_trg_Forest_of_Alchemy = CreateTrigger(  )
    call TriggerAddCondition( gg_trg_Forest_of_Alchemy, Condition( function Trig_Forest_of_Alchemy_Conditions ) )
    call TriggerAddAction( gg_trg_Forest_of_Alchemy, function Trig_Forest_of_Alchemy_Actions )
endfunction

And here stems my other two problems, first off, how do I code something depending on the integer I equaling 20-40?

also, is there a way of cleaning up and simplizing the Conditions, surly there must be?

(The Conditions)
JASS:
function Trig_Forest_of_Alchemy_Conditions takes nothing returns boolean

 local unit u = GetTriggerUnit()
 local unit e = GetEnteringUnit()
 
    if ( not ( IsUnitAliveBJ(e) == true ) ) then
        return false
    endif
    if ( not( IsUnitEnemy(e, GetOwningPlayer(u)) == true ) ) then
        return false
    endif
    return true
    
endfunction


Thanks for all the help greatly appreciate it! +rep to anyone who can solve any of my problems!

PS: Where have the spoiler tags gone? :p :(
 

Darthfett

Aerospace/Cybersecurity Software Engineer
Reaction score
615
I actually have three queries, which I will explain in this post but first of all, is there an event response for finding the Unit Within Range Center Unit?

Take a look at my system: http://www.thehelper.net/forums/showthread.php?t=109299

It provides the "Center Unit" similar to the way you can get the Triggering Unit.

And here stems my other two problems, first off, how do I code something depending on the integer I equaling 20-40?

JASS:
if I >= 20 and I <= 40 then
 //Actions go here
endif


also, is there a way of cleaning up and simplizing the Conditions, surly there must be?

Yep. "or" and "and" are wonderful. :p

JASS:
function Trig_Forest_of_Alchemy_Conditions takes nothing returns boolean
 //local unit u = GetCenterUnit() //Perhaps you mean the Center unit?  This can be used through the system I linked above
 //local unit e = GetTriggerUnit() //This is the same as the Entering Unit.
    return IsUnitAliveBJ(GetCenterUnit()) and IsUnitEnemy(GetTriggerUnit(),GetOwningPlayer(GetCenterUnit()))
endfunction


PS: Where have the spoiler tags gone? :p :(

They aren't intended for these zones. They are intended to hide text that people aren't supposed to see until they know what they're going to see, not to hide a long code.
 

Squll2

je'ne sais pas
Reaction score
76
Thanks for all the help Darthfeet +rep

But is there any way to do that center unit A not in V jass and B without dling half a million programs ><?

Edit: I heard something about Vjass not wokring online or something? please explain and possibly link me to Vjass programs and tutorials I would be very greatful ^^ (I guess i should start learning it if it still works ^^)

Edit2: Anyone know whats wrong with this one.. its seriously irritatting me everything I do doesnt make it work -_-

JASS:
function Trig_Flask_of_Mind_Control_Conditions takes nothing returns boolean
  return GetSpellAbilityId() == &#039;A00G&#039; 
endfunction

function Trig_Moveit takes nothing returns nothing
    

    local location L = GetRectCenter(gg_rct_Player_Two_Unit_Sender)
    local real x = GetLocationX(L)
    local real y = GetLocationY(L)
    local location L2 = GetRectCenter(gg_rct_Player_9_Unit_Sender)
    local real x2 = GetLocationX(L2)
    local real y2 = GetLocationY(L2)
    local unit e
    
 if IsUnitType(GetEnumUnit(), UNIT_TYPE_STRUCTURE) == false and GetOwningPlayer(GetEnumUnit()) == Player(5) == true then
 
    set e = GetEnumUnit()
    set x = GetLocationX(L2)
    set y = GetLocationY(L2)   
     call SetUnitOwner( e, Player(11), true )
     call SetUnitPosition(e, x, y )

endif     

    
 if IsUnitType(GetEnumUnit(), UNIT_TYPE_STRUCTURE) == false and GetOwningPlayer(GetEnumUnit()) == Player(11) == true then
 
    set e = GetEnumUnit()
    set x = GetLocationX(L)
    set y = GetLocationY(L)   
     call SetUnitOwner( e, Player(5), true )
     call SetUnitPosition(e, x, y )

     
endif   
    
     
  call PolledWait(20.00)  
    set L = null
    set L2 = null

endfunction

function Trig_Flask_of_Mind_Control_Actions takes nothing returns nothing

    local real r = 450.00
    local location l = GetSpellTargetLoc()
    local real x = GetLocationX(l)
    local real y = GetLocationY(l)
    local group g
    local group g2

    
    call GroupEnumUnitsInRange(g, x, y, r, null)
    call PolledWait(0.30)
    call GroupAddGroup(g, g2)
    call PolledWait(0.30)
    call ForGroup(g2, function Trig_Moveit )
    call PolledWait(5.50)
    call DestroyGroup(g)
    set g  = null
    call DestroyGroup(g2)
    set g2 = null

endfunction

//==== Init Trigger NewTrigger ====
function InitTrig_Flask_of_Mind_Control takes nothing returns nothing
    set gg_trg_Flask_of_Mind_Control = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(gg_trg_Flask_of_Mind_Control, EVENT_PLAYER_UNIT_SPELL_CAST )
    call TriggerAddCondition(gg_trg_Flask_of_Mind_Control, Condition(function Trig_Flask_of_Mind_Control_Conditions))
    call TriggerAddAction(gg_trg_Flask_of_Mind_Control, function Trig_Flask_of_Mind_Control_Actions)
endfunction
 

Darthfett

Aerospace/Cybersecurity Software Engineer
Reaction score
615
But is there any way to do that center unit A not in V jass and B without dling half a million programs ><?

A. If you can find me a reliable attachment system for units and triggers. vJASS is now the standard for JASS programming..
B. All you need is JASS Newgen Pack, and the systems my script requires. If you don't want to get these, see A.

Edit: I heard something about Vjass not wokring online or something? please explain and possibly link me to Vjass programs and tutorials I would be very greatful ^^ (I guess i should start learning it if it still works ^^)

I have no idea where you got that one from. vJASS is fine for online games.

Jass Newgen Pack

You can find plenty of vJASS tutorials in our Tutorial Repository.
 
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