Snippet OffsetUnitReals

Gtam

Lerning how to write and read!! Yeah.
Reaction score
164
OffsetUnitReals
By Gtam aka SharkBait87

I dont know if anyone will find this usefull but in any way i hope someone does.

This Requires NewGen


This snippet can Offset a Units Reals with a easy function call and get the offseted Real x with a function call and y aswell.
There are some other function calls that can be usefull.
To Import Just create a new trigger name RealsOffset and replace all the text with this.

Here is the code
JASS:
library RealsOffset

//=======================================================================================\\
//=======================================================================================\\
//=                     This is created by Gtam                                         =\\
//= This library makes offsetting reals alot easier                                     =\\
//= It can offset reals, move units to the offseted reals,                              =\\
//= damage the moved unit, create a effect at the moved unit and                        =\\
//= damage and created effects to the moved unit                                        =\\
//=                                                                                     =\\
//=  GetOffsetUnitRealX() takes unit, real1, real2 returns real                         =\\
//=    This is used to get the offseted reals X                                         =\\
//=                                                                                     =\\
//=  GetOffsetUnitRealY() takes unit, real1, real2 returns real                         =\\
//=    This is ised to get the offseted reals y                                         =\\
//=                                                                                     =\\
//=  OffsetUnitRealsMove() takes unit, real1, real2 returns nothing                     =\\
//=    This will offset unit reals by real and move him there                           =\\
//=                                                                                     =\\
//=  OffsetUnitRealsMoveDamage() takes unit1, unit2, real1, real2, attacktype,          =\\
//=    damagetype, weapontype returns nothing                                           =\\
//==   This will offset unit1 reals by real 1 and move him there then cause unit2       =\\
//=    to damage unit1 by real2                                                         =\\
//=                                                                                     =\\
//=  OffsetUnitRealsMoveEffect() takes unit, real, string returns nothing               =\\
//=    This will offset unit reals by real and move him there and create a effect at    =\\
//=    unit1 current position and his offseted position                                 =\\
//=                                                                                     =\\
//=  OffsetUnitRealsMoveDamageEffect() takes unit1, unit2, real1, real2, string,        =\\
//=    attacktype, damagetype, weapontype returns nothing                               =\\
//=    This will offset unit1 reals by real 1 and move him there then cause unit2       =\\
//=    to damage unit1 by real2 and create a effect at unit1 current position and his   =\\
//=    offseted position                                                                =\\
//=                                                                                     =\\
//=======================================================================================\\
//=======================================================================================\\

globals
    private real urx
    private real ury
endglobals
    
    function GetOffsetUnitRealX takes unit u, real r, real f returns real
        set urx = GetUnitX(u) + r * Cos (f * .0175)
        return urx
    endfunction
    
    function GetOffsetUnitRealY takes unit u, real r, real f returns real
        set ury = GetUnitY(u) + r * Sin (f * .0175)
        return ury
    endfunction
    
    function OffsetUnitRealsMove takes unit u, real r, real f returns nothing
        call SetUnitPosition( u, GetOffsetUnitRealX(u,r,f), GetOffsetUnitRealY(u,r,f))
    endfunction
    
    function OffsetUnitRealsMoveDamage takes unit u, unit t, real r, real f, real d, attacktype a, damagetype b, weapontype c  returns nothing
        call OffsetUnitRealsMove(u, r, f)
        call UnitDamageTarget( t, u, d, false, false, a, b, c )
    endfunction
    
    function OffsetUnitRealsMoveEffect takes unit u, real r, real f, string s returns nothing
        call DestroyEffect( AddSpecialEffect( s, GetUnitX(u), GetUnitY(u)))
        call OffsetUnitRealsMove( u, r, f)
        call DestroyEffect( AddSpecialEffect( s, urx, ury))
    endfunction
    
    function OffsetUnitRealsMoveDamageEffect takes unit u, unit t, real r, real f, real d, string s, attacktype a, damagetype b, weapontype c returns nothing
        call DestroyEffect( AddSpecialEffect( s, GetUnitX(u), GetUnitY(u)))
        call OffsetUnitRealsMove( u, r, f)
        call DestroyEffect( AddSpecialEffect( s, urx, ury))
        call UnitDamageTarget( t, u, d, false, false, a, b, c )
    endfunction
endlibrary

Btw. This is my first jass resource. Hope its usefull

Code:
ChangeLog
v1.00 Released
v1.01 Updated to Komations suggestions
v1.02 Bugs fix and should work properly now
 

Komaqtion

You can change this now in User CP.
Reaction score
469
Well, first.. Why use a struct there ? :S
It's better to use a private global :D

Also, this function:
JASS:
    function GetOffsetUnitRealY takes nothing returns real
        return RO.ury
    endfunction


Should look like this:
JASS:
    function GetOffsetUnitRealX takes unit t, real r returns real
        call OffsetUnitReals(t, r)
        return RO.ury
    endfunction


To start with :p

And, can't really see how tho last 3 functions would be useful :S
 

Gtam

Lerning how to write and read!! Yeah.
Reaction score
164
well ill do the private globals and thats to reduce the fumction calls since the x is always returned before the y and those last three can reduce function calls alot
 

Romek

Super Moderator
Reaction score
964
These are just a bunch of BJs, really.

It's about 100 lines of code, which in the end, does this:
JASS:
call SetUnitX(u, distance * Cos(angle) + GetUnitX(u))
call SetUnitY(u, distance * Sin(angle) + GetUnitY(u))


Ironically, the snippet is named after the only function that's inaccessible.
 

Komaqtion

You can change this now in User CP.
Reaction score
469
Well, you can simply remove the first function, and just do this:
JASS:
    function GetOffsetUnitRealX takes unit t, real r returns real        
        local real f = GetUnitFacing(u) - 180
        set RO.urx = GetUnitX(u) + r * Cos (f * .0175)
        return RO.urx
    endfunction
    
    function GetOffsetUnitRealY takes unit t, real r returns real        
        local real f = GetUnitFacing(u) - 180
        set RO.ury = GetUnitY(u) + r * Sin (f * .0175)
        return RO.ury
    endfunction
 

GetTriggerUnit-

DogEntrepreneur
Reaction score
129
:nuts:

So your parse is like a BJ in that case. Kinda useless Imo. I'm pretty sure you could have done something way more usefull ;)
 

Gtam

Lerning how to write and read!! Yeah.
Reaction score
164
okay komaqtion ill do that then thx for the helping too
 

Gtam

Lerning how to write and read!! Yeah.
Reaction score
164
Ok i updated the Snippet to komaqtions suggestions
Thx for the Feed back komaqtion
 

Komaqtion

You can change this now in User CP.
Reaction score
469
Sorry to say this but... I can't seem to understand what this is supposed to d o:S
I used this simple trigger to test it, and it gave the same result every time:
Trigger:
  • Offset Reals Test
    • Events
      • Time - Every 2.00 seconds of game time
    • Conditions
    • Actions
      • Custom script: call BJDebugMsg(R2S(GetOffsetUnitRealX(gg_unit_Hpal_0010, 100)))
      • Custom script: call BJDebugMsg(R2S(GetOffsetUnitRealX(gg_unit_Hpal_0006, 100)))


Result: -99.996

What is is supposed to do ? :S

Also, why not inline this a bit more ?
JASS:
    function OffsetUnitRealsMove takes unit u, real r returns nothing
        local real x = GetOffsetUnitRealX(u, r)
        local real y = GetOffsetUnitRealY(u, r)
        call SetUnitPosition( u, urx, ury)
    endfunction


To:
JASS:
    function OffsetUnitRealsMove takes unit u, real r returns nothing
        call SetUnitPosition( u, GetOffsetUnitRealX(u,r), GetOffsetUnitRealY(u,r))
    endfunction


And, also tested that function, and it didn't do anything :S
Trigger:
  • Offset Reals Test 2
    • Events
      • Time - Every 5.00 seconds of game time
    • Conditions
    • Actions
      • Custom script: call BJDebugMsg("Hello!")
      • Custom script: call OffsetUnitRealsMove(gg_unit_Hpal_0010, 100)
      • Custom script: call OffsetUnitRealsMove(gg_unit_Hpal_0006, 100)


The "Hello!" was displayed, but nothing happened :S

Again... What is this supposed to do ?
 

Gtam

Lerning how to write and read!! Yeah.
Reaction score
164
which function did you use for the move mine or your one and its suppose to do what the title says Offset a units reals. Ill work on it when i get home.
 

Romek

Super Moderator
Reaction score
964
"Offset a units reals" means nothing whatsoever.

As I said previously, these are just a bunch of BJs (that are actually less efficient than most BJs).

GY'd
 

Gtam

Lerning how to write and read!! Yeah.
Reaction score
164
offset location now this just uses reals and not a location and how are these bjs they are created by me not blizzard and i see no reason to graveyard this when its not even released properly yet
 

Larcenist

REP: Respect, Envy, Prosperity?
Reaction score
211
> ...how are these bjs they are created by me not blizzard...

And what exacly is it that makes these BJs exactly that, BJs?

> ...and i see no reason to graveyard this when its not even released properly yet


Ever heard of this little rule stating that you should not submit unfinished work?
 

Gtam

Lerning how to write and read!! Yeah.
Reaction score
164
its not unfinished but it still in the early versions
 

uberfoop

~=Admiral Stukov=~
Reaction score
177
The rule generally means something should be clean, polished, and more or less finalized by community final product standards before submission. If you aren't currently releasing something 'properly', it shouldn't be being released.
 

Gtam

Lerning how to write and read!! Yeah.
Reaction score
164
Ok but its updated in anyway and works properly thx to Komaqtion(Again)
 

Komaqtion

You can change this now in User CP.
Reaction score
469
Btw... You should probably give the "takes" variable more descriptive names, like angle, dmg, and such :D

Also, maybe a better description of what this system does, and what each function does :D
 

Gtam

Lerning how to write and read!! Yeah.
Reaction score
164
Do you mean the takes in the description or the functions them selves
 
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

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top