Warcraft III: MapsModelsSkinsIconsSpellsToolsTutorials
WC3 JASS: Code SnippetsJASS and vJASS Spells and SystemsJass Tutorials
Chat @Discord

Author Topic: [Snippet] GetWidgetMeasures  (Read 9243 times)

  • Site Owner
  • Administrator
  • Starter - level 4
  • *
  • Posts: 981
  • WC3 Models: 5
  • WC3 Tutorials: 11
  • WC3 Tools: 10
  • WC3 Maps: 11
  • WC3 Skins: 6
  • WC3 Icons: 2
  • WC3 Spells: 5
  • Reputation: 1153
  • Site Admin - I love fix things
    • View Profile
    • Blizzard Modding Information Center
[Snippet] GetWidgetMeasures
« on: October 01, 2012, 09:31:36 PM »
Description

This library provides a set of functions to get distance and angles between widgets (units, destructibles, items). Here you can get any of these measures no matter the type of the widget, like measuring the distance between unit-unit, unit-destructable, unit-item, item-unit, etc.

Requirements

 - Geometry Lib Base

Actual Code

Code: jass  [Select]
  1. /******************************************************************
  2. *                     GEOMETRY MEASURES V1.1                      *
  3. *                           By moyack                             *
  4. *                              2012                               *
  5. *              ===================================                *
  6. *              Exclusive resource from wc3jass.com                *
  7. *              ===================================                *
  8. ******************************************************************/
  9.  
  10. library GetWidgetMeasures requires GeometryLibBase
  11. /*This is the first of a set of libraries focused in the usage of
  12. proper geometry functions.
  13.  
  14. Here we'll aim to make the code as modular as possible so we can
  15. reduce the code amount in map but offering the neccesary tools
  16. for modders
  17.  
  18. Here we offer some basic functions realated to widgets (units,
  19. destructables and items):
  20.  
  21. GetWidgetsDistance: allows to calculate the distance between 2 widgets.
  22.                     Here you can have any combination: unit-unit, unit-
  23.                     destructable, item unit, etc.
  24.        
  25. GetWidgetsAngle: Gets the angle between 2 widgets. Like the previus
  26.                  function, it allows to compare between units, unit-item,
  27.                  unit-destructable, etc.
  28.                  
  29. GetUnitsDistanceZ: Get the distance between 2 units, taking into account
  30.                    their respectives locations and flyheights.
  31.  
  32. GetUnitsZAngle: Returns the elevation angle between unit a and unit b.
  33.  
  34. IMPORTANT NOTE: GetWidgetsAngle and GetUnitsZAngle returns angles in RADIANS.
  35. */
  36. function GetWidgetsDistance takes widget a, widget b returns real
  37.     return GetDistance(GetWidgetX(a), GetWidgetY(a), GetWidgetX(b), GetWidgetY(b))
  38. endfunction
  39.  
  40. function GetWidgetsAngle takes widget a, widget b returns real
  41.     return Atan3(GetWidgetX(a), GetWidgetY(a), GetWidgetX(b), GetWidgetY(b))
  42. endfunction
  43.  
  44. function GetUnitsDistanceZ takes unit a, unit b returns real
  45.     local real z = GetUnitZ(b) - GetUnitZ(a)
  46.     local real d = GetWidgetsDistance(a, b)
  47.     return SquareRoot(d * d + z * z)
  48. endfunction
  49.  
  50. function GetUnitsZAngle takes unit a, unit b returns real
  51.     return Acos(GetWidgetsDistance(a, b) / GetUnitsDistanceZ(a, b))
  52. endfunction
  53.  
  54. endlibrary

Changelog:
v1.0: Initial release
v1.1: Added new functions that match with the library dependencies
« Last Edit: December 17, 2012, 09:03:01 AM by moyack »

We can give you full hosting for your projects, a complete page!!

A custom altered melee map where you can play Naga and Demons. Check it out!!
Use Dropbox...

  • Site Owner
  • Administrator
  • Starter - level 4
  • *
  • Posts: 981
  • WC3 Models: 5
  • WC3 Tutorials: 11
  • WC3 Tools: 10
  • WC3 Maps: 11
  • WC3 Skins: 6
  • WC3 Icons: 2
  • WC3 Spells: 5
  • Reputation: 1153
  • Site Admin - I love fix things
    • View Profile
    • Blizzard Modding Information Center
Re: GetWidgetMeasures
« Reply #1 on: October 11, 2012, 09:17:09 PM »
Snippet updated. Please check first post.

We can give you full hosting for your projects, a complete page!!

A custom altered melee map where you can play Naga and Demons. Check it out!!
Use Dropbox...

  • Site Owner
  • Administrator
  • Starter - level 4
  • *
  • Posts: 981
  • WC3 Models: 5
  • WC3 Tutorials: 11
  • WC3 Tools: 10
  • WC3 Maps: 11
  • WC3 Skins: 6
  • WC3 Icons: 2
  • WC3 Spells: 5
  • Reputation: 1153
  • Site Admin - I love fix things
    • View Profile
    • Blizzard Modding Information Center
Re: GetWidgetMeasures
« Reply #2 on: December 11, 2012, 12:53:51 AM »
BUMP of glory!!!

We can give you full hosting for your projects, a complete page!!

A custom altered melee map where you can play Naga and Demons. Check it out!!
Use Dropbox...

  • Awesome Global Code Moderator
  • Recognized User
  • Rookie - level 2
  • *
  • Posts: 83
  • WC3 Models: 0
  • WC3 Tutorials: 0
  • WC3 Tools: 0
  • WC3 Maps: 0
  • WC3 Skins: 0
  • WC3 Icons: 0
  • WC3 Spells: 0
  • Reputation: 516
  • vJass Incarnate
    • View Profile
Re: [snippet] GetWidgetMeasures
« Reply #3 on: December 12, 2012, 09:48:09 AM »
This is a nice utility.
Approved.

  • Site Owner
  • Administrator
  • Starter - level 4
  • *
  • Posts: 981
  • WC3 Models: 5
  • WC3 Tutorials: 11
  • WC3 Tools: 10
  • WC3 Maps: 11
  • WC3 Skins: 6
  • WC3 Icons: 2
  • WC3 Spells: 5
  • Reputation: 1153
  • Site Admin - I love fix things
    • View Profile
    • Blizzard Modding Information Center
Re: [Snippet] GetWidgetMeasures
« Reply #4 on: December 12, 2012, 10:07:43 AM »
Thanks man!!!

We can give you full hosting for your projects, a complete page!!

A custom altered melee map where you can play Naga and Demons. Check it out!!
Use Dropbox...

 

[Snippet] Group Units in line, with distance and optional spread-value

Started by rvonsonsnadtzBoard Codes & Snippets

Replies: 5
Views: 11447
Last post March 13, 2013, 06:52:16 PM
by rvonsonsnadtz
[Snippet] Single Player Detector

Started by moyackBoard Codes & Snippets

Replies: 12
Views: 21008
Last post March 13, 2013, 12:48:49 PM
by Magtheridon96
[Snippet] Simple Unit Indexer

Started by moyackBoard Codes & Snippets

Replies: 17
Views: 25829
Last post September 30, 2013, 08:07:19 AM
by moyack
[Snippet] Disable Transmission Skip

Started by PurgeandfireBoard Codes & Snippets

Replies: 2
Views: 8730
Last post July 02, 2013, 01:34:55 PM
by Purgeandfire
[Snippet] Timed Effects

Started by moyackBoard Codes & Snippets

Replies: 0
Views: 7398
Last post January 09, 2012, 07:03:32 PM
by moyack
Blizzard Modding Information Center Starcraft II Modding Information Center Wacraft III Modding Information Center WC3JASS.com - The JASS Vault Chronicles of Darkness - A Warcraft III mod Jetcraft - A Starcraft II mod Troll Smash - A Warcraft III Arena
  Mod DB - Change the Game Power of Corruption - A Warcraft III altered melee map Chaos Realm - The world of Game modders and wc3 addicts Follow us on Facebook!!