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.
  • Monovertex Monovertex:
    How are you all? :D
    +1
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top