Instantly Move

T

Tubba

Guest
Code:
Custom script:   call SetUnitX(udg_tempPickedUnit(),(GetUnitX(udg_tempPickedUnit()+Cos(bj_DEGTORAD*AngleBetweenPoints(GetUnitLoc(udg_tempPickedUnit()),udg_tempCasterPos)))*0.2)

This gives me "Expected a ' "

Where to put that? >_>
 
T

Tubba

Guest
Code:
Custom script:   call SetUnitX(udg_tempPickedUnit),(GetUnitX(udg_tempPickedUnit)+Cos(bj_DEGTORAD*AngleBetweenPoints(GetUnitLoc(udg_tempPickedUnit),(udg_tempCasterPos)))*0.2)

This is getting pretty ridiculous. Gives me "Expected end of line". Tried both with and without parenthesis. Any final ideas?
 
T

Tubba

Guest
I didn't write it, the guy a page back did... I only added my variables, and they're all correct.

Should I have parentheses around udg_tempPickedUnit though?
 

Somatic

You can change this now in User CP.
Reaction score
84
No, Those are for function, not for Variables.

Post your trigger here.
 
T

Tubba

Guest
Nah, the trigger worked fine with "Move unit instantly to location...", was just thinking I could reduce workload with these.

So, let me get you right, if I extract something from a variable using a function, I should have parentheses around the variable, right? Like in GetUnitLoc(udg_UnitVar)? But not when I reference to the variable.

Code:
Custom script:   call SetUnitX(udg_tempPickedUnit),(GetUnitX(udg_tempPickedUnit)+Cos(bj_DEGTORAD*AngleBetweenPoints(udg_tempPickedUnitPos),udg_tempCasterPos)))*0.2)

Tried a slight change at the end, still doesn't work... Hmmm...
 

Somatic

You can change this now in User CP.
Reaction score
84
Yes, function(target) is how it is like when using the parentheses.
 
T

Tubba

Guest
I see... What about cases, if you check the last function, I have two targets. Should I parenthese both or only the first?
 

cleeezzz

The Undead Ranger.
Reaction score
268
not understanding o_o

Code:
Wind Copy
    Events
        Time - Every 0.05 seconds of game time
    Conditions
    Actions
        Set Archer_Group = (Units of type Archer Goddess)
        Unit Group - Pick every unit in Archer_Group and do (Actions)
            Loop - Actions
                Set Archer_Loc = (Position of (Picked unit))
                Set Temp_Point6 = (Archer_Loc offset by (Wind_Speed / 20.00) towards Wind_Degree degrees)
                Custom script:   call SetUnitX(GetEnumUnit(),(GetUnitX(GetEnumUnit()+Cos(bj_DEGTORAD*AngleBetweenPoints(GetUnitLoc(GetEnumUnit()),udg_Temp_Point6)))*2)
                Custom script:   call SetUnitY(GetEnumUnit(),(GetUnitY(GetEnumUnit()+Sin(bj_DEGTORAD*AngleBetweenPoints(GetUnitLoc(GetEnumUnit()),udg_Temp_Point6)))*(udg_Wind_Speed))
                Custom script:   call RemoveLocation(udg_Archer_Loc)
                Custom script:   call RemoveLocation(udg_Temp_Point6)
        Custom script:   call DestroyGroup(udg_Archer_Group)
 

Somatic

You can change this now in User CP.
Reaction score
84
Cases? There are no cases in Wc3, only Nested If/else. and for a function with 2 targets, its like this Function(Target1, Target 2) and when declaring the function its like this
JASS:

function Test_Test takes Type1 Name1, Type2 Name2 returns Type
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,495
> GetUnitX(GetEnumUnit()+Cos(

X of "unit + cos"? ...


As for the problem on the last 10 posts here... people, please, just think where and when you put those ( and )... currently, you're just guessing!
 
T

Tubba

Guest
Code:
Custom script:    call SetUnitX(GetEnumUnit(),(GetUnitX(GetEnumUnit()+Cos(bj_DEGTORAD*AngleBetweenPoints(GetUnitLoc(GetEnumUnit()),L)))*K)
Custom script:    call SetUnitY(GetEnumUnit(),(GetUnitY(GetEnumUnit()+Sin(bj_DEGTORAD*AngleBetweenPoints(GetUnitLoc(GetEnumUnit()),


I think I should start over.

Let's see. I replace L with the location of wherever I want the unit to be dragged towards, yes? I replace all the GetEnumUnit() with the unit I want to be dragged, yes? I replace K with a real, yes?
 

Builder Bob

Live free or don't
Reaction score
249
You are calling a number of functions in that custom script. Some functions requires input to work, others don't.

When calling a function the syntax is always functionName(inputVariable1, inputVariable2, inputVariable3). Examples: GetUnitX(whichUnit) or SetUnitX(whichUnit, newX)

functionName() for functions that don't require input. Example: GetEnumUnit()


You are currently feeding GetUnitX with the variable GetEnumUnit()+Cos(bj_DEGTORAD*AngleBetweenPoints(GetUnitLoc(GetEnumUnit()),L))

Since that isn't a unit you will get errors.

Try GetUnitX(GetEnumUnit())
 
T

Tubba

Guest
Holy crap.


Holy fucking crap.


It worked.

...Not.

Well, kinda.


Check these triggers out.

Code:
castFA
    Events
        Unit - A unit Starts the effect of an ability
    Conditions
        (Ability being cast) Equal to Super Pull 
    Actions
        Game - Display to (All players) the text: Casting
        Set tempCaster = (Casting unit)
        Set tempCasterPos = (Position of (Casting unit))
        Unit Group - Pick every unit in (Units within 512.00 of tempCasterPos) and do (Actions)
            Loop - Actions
                Set tempPickedUnit = (Picked unit)
                Set tempDistanceBetweenPoints = (Distance between tempCasterPos and (Position of (Picked unit)))
        Trigger - Turn on castFA Attract <gen>

=================================================================

castFA Attract
    Events
        Time - Every 0.02 seconds of game time
    Conditions
    Actions
        Set Repeats = (Repeats + 1)
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                tempDistanceBetweenPoints Greater than 100.00
            Then - Actions
                Set tempUnitGroup = (Units within 512.00 of tempCasterPos matching (((Owner of tempCaster) is an enemy of (Owner of (Matching unit))) Equal to True))
                Unit Group - Pick every unit in tempUnitGroup and do (Actions)
                    Loop - Actions
                        Set tempPickedUnit = (Picked unit)
                        Set tempPickedUnitPos = (Position of (Picked unit))
                        Set tempAngleBetweenUnits = (Angle from tempPickedUnitPos to tempCasterPos)
                        Set tempDistanceBetweenPoints = (Distance between tempCasterPos and tempPickedUnitPos)
                        Custom script:   call SetUnitX(GetEnumUnit(),(GetUnitX(GetEnumUnit())+Cos(bj_DEGTORAD*AngleBetweenPoints(GetUnitLoc(GetEnumUnit()),udg_tempCasterPos)))*2)
                        Custom script:   call SetUnitY(GetEnumUnit(),(GetUnitY(GetEnumUnit())+Sin(bj_DEGTORAD*AngleBetweenPoints(GetUnitLoc(GetEnumUnit()),udg_tempCasterPos)))*2)
            Else - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                Repeats Equal to 750
            Then - Actions
                Set Repeats = 0
                Custom script:   call RemoveLocation( udg_tempCasterPos)
                Custom script:   call RemoveLocation( udg_tempPickedUnitPos)
                Custom script:   call DestroyGroup( udg_tempUnitGroup)
                Trigger - Turn off (This trigger)
            Else - Actions

They worked just fine. Until I implemented said custom scripts instead of "Move unit instantly", for the reason to reduce lag.

When I cast the ability, the units nearby just dissappear. Then, the game clogs up. No FATAL ERROR, nothing. It just freezes up. Can't even CTRL+F4 my way out of it.

So yeah. What do you think the reason for this is? I theorize that it has to do with GetEnumUnit (What unit is that, anyway?), but I dunno.
 

Somatic

You can change this now in User CP.
Reaction score
84
GetEnumUnit gets the "Picked unit" From a
Code:
Unit Group - Pick all units from Temp_Unit_Group and do Actions

So unless ur custom script is inside there, else it will not work
 

Builder Bob

Live free or don't
Reaction score
249
JASS:
Custom script:   call SetUnitX(GetEnumUnit(),(GetUnitX(GetEnumUnit())+2*Cos(bj_DEGTORAD*AngleBetweenPoints(GetUnitLoc(GetEnumUnit()),udg_tempCasterPos))))
Custom script:   call SetUnitY(GetEnumUnit(),(GetUnitY(GetEnumUnit())+2*Sin(bj_DEGTORAD*AngleBetweenPoints(GetUnitLoc(GetEnumUnit()),udg_tempCasterPos))))


this should work. (UnitX + 2 * cos(...)) instead of 2 * (UnitX + cos(...))

The game probably froze because you threw a unit outside of the map bounds. I don't know though, since I have never tried what happens when you do that.
 
T

Tubba

Guest
Oh. I had no idea what to try, so I just threw something out. I'll try that, though.


Worked like a charm. The only problem is the units end up on top of the tower. Oh well, another day, another problem to solve. Thanks for all the help, guys.
 
K

Kerberos

Guest
Gah. Note to self: sleepy + code = compiling errors.

Here's a version that I'm very sure has parentheses in the right places.
Code:
Melee Initialization
    Events
        Time - Every 0.05 seconds of game time
    Conditions
    Actions
        Set LeakGroup = (Units in (Playable map area))
        Unit Group - Pick every unit in LeakGroup and do (Actions)
            Loop - Actions
                Custom script:   call SetUnitX(  GetEnumUnit()  ,  GetUnitX(GetEnumUnit())+Cos(bj_DEGTORAD * AngleBetweenPoints(GetUnitLoc(GetEnumUnit()),[b][u]GetRectCenter(GetPlayableMapRect())[/b][/u]))*2)
                Custom script:   call SetUnitY(  GetEnumUnit()  ,  GetUnitY(GetEnumUnit())+Sin(bj_DEGTORAD * AngleBetweenPoints(GetUnitLoc(GetEnumUnit()),[b][u]GetRectCenter(GetPlayableMapRect())[/b][/u]))*2)
        Custom script:   call DestroyGroup(udg_LeakGroup)

Tested, approved. As before, you replace the bold, underlined stuff with "udg_PointVariableName" or "udg_UnitVariableName", and the "2" at the end of each line controls the speed of the sucking-in.
 
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