• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[JASS] Get unit that other comes in range... lol?

Status
Not open for further replies.
Level 12
Joined
Mar 23, 2008
Messages
942
How do I get the unit that is on "": Unit comes within range of "unit"
The unit that comes within range is triggering unit, and the other?

Edit: For my trigger, also works if I find a way to call my trigger setting a variable at start.

JASS:
function Trig_Sense_Inuyasha_Actions takes nothing returns nothing
    local unit tu = udg_tempunit[0]
    set location tp = GetUnitLoc(GetTriggerUnit())
    set force tf = GetForceOfPlayer(GetOwningPlayer(tu))
    call PingMinimapLocForForce( tf, tp, 1 )
    call DestroyForce(tf)
endfunction
Edit: I got a syntax error at set location tp, someone can help-me?
So, I have other trigger:

  • Sense Inuyasha On
    • Events
      • Unit - A unit enters (Playable map area)
    • Conditions
      • (Unit-type of (Entering unit)) Equal to Half Yõkai
    • Actions
      • Set tempunit[0] = (Entering unit)
      • Trigger - Add to Sense Inuyasha <gen> the event (Unit - A unit comes within 1500.00 of tempunit[0])
      • Trigger - Turn on Sense Inuyasha <gen>
If I could call Sense Inuyasha setting local tu I would solve this.
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
For example, using vJass

JASS:
struct UnitData //some generic struct
    trigger dynamicTrig //for this
    //if you need to store anything else about units, you could just make this struct attached to everyone
endstruct

function blah takes nothing returns nothing
    //assuming UnitData exists as the unit's UserData
    //assuming you want to use the triggering unit
    local UnitData dat = GetUnitUserData(GetTriggerUnit())
    set dat.dynamicTrig = CreateTrigger()
    call TriggerRegisterUnitInRange(dat.dynamicTrig,GetTriggerUnit(),<range>,<filter, if any>)
    call TriggerAddCondition(dat.dynamicTrig,Condition(function <actionFunc>))
    //conditions for dynamic triggers are better than actions in several ways, just make sure your action func returns true or false at the end of its body, to prevent desynchs on macs
    //other stuff
endfunction

//somewhere when you want to get rid of it
call DestroyTrigger(dat.dynamicTrigger)
 
Level 12
Joined
Mar 23, 2008
Messages
942
Well, udg_tempunit is a global that often changes value, so when the gui trigger run the first time the jass one, its correct the local tu takes Inuyasha. but if the jass trigger run again, that will mess the function.

How can I make a way where "tu" will have a fix value?
I thought I could make a way where the gui trigger run the jass trigger putting a value on "tu", so because gui trigger only runs one tim,e "tu" will have a fix value.
 
Level 12
Joined
Mar 23, 2008
Messages
942
Here is what I wanna to do.

The unit Inuyasha have a sense ability, when someone enter a 1500 range of him, it pinged to the owner of the Inuyasha.

You just say me stuffs that I can't understand. like "Attach the trigger to the unit" "
Can't you just say me how can I do that? I can't believe this will gonna be the hardest skill in my map ¬¬
 
Status
Not open for further replies.
Top