|
|
#31 |
|
Lackadaisically Absent.
Respected User
|
Here's some progress, though I haven't syntax checked or test this, it should work.
__________________ JASS:library MinimapIcons initializer Init requires TimedLoop //================================================================================= // MinimapIcons Library, by Pyrogasm - V1.00 (August 23, 2009) // [A library to treat minimap unit icons as objects] // //================================================================================= globals private constant integer UNIT_ICON_ID = 'Uicn' private constant integer HERO_ICON_ID = 'Hicn' private constant real UPDATE_PERIOD = 0.04 private constant player DEFAULT_PLAYER = Player(15) private constant real DEFAULT_X = 0.00 private constant real DEFAULT_Y = 0.00 private constant integer ICON_TYPE_UNIT = 0 private constant integer ICON_TYPE_HERO = 1 endglobals globals private timer T private integer N = 0 private keyword MinimapIcon private MinimapIcon array MIArray private boolean B endglobals struct MinimapIcon private unit I = null private integer IType private real IX = 0.00 private real IY = 0.00 private unit ITarget = null private player IPlayer private integer Index = -1 static method create takes integer iconType returns MinimapIcon local MinimapIcon M = MinimapIcon.allocate() local integer Id = UNIT_ICON_ID if iconType == ICON_TYPE_HERO then set Id = HERO_ICON_ID endif set M.I = CreateUnit(DEFAULT_PLAYER, Id, DEFAULT_X, DEFAULT_Y, 0.00) set M.IType = iconType call ShowUnit(M.I, false) return M endmethod method operator X takes nothing returns real return .IX endmethod method operator X= takes real v returns nothing set .IX = v call SetUnitX(.I, .IX) if .ITarget != null then call .StopFollowing() endif endmethod method operator Y takes nothing returns real return .IY endmethod method operator Y= takes real v returns nothing set .IY = v call SetUnitY(.I, .IY) if .ITarget != null then call .FollowTarget(false) endif endmethod method operator Target takes nothing returns unit return .ITarget endmethod method operator Target= takes unit v returns nothing set .ITarget = v endmethod method operator IconType takes nothing returns integer return IType endmethod method operator IconType= takes integer v returns nothing local integer Id = UNIT_ICON_ID if iconType == ICON_TYPE_HERO then set Id = HERO_ICON_ID endif call ShowUnit(.I, true) call RemoveUnit(.I) set .I = CreateUnit(.IPlayer, Id, .IX, .IY, 0.00) call ShowUnit(.I, false) endmethod method operator OwningPlayer takes nothing returns player return .IPlayer endmethod method operator OwningPlayer= takes player v returns nothing set .IPlayer = v call SetUnitOwner(.I, v, true) endmethod method ShowForPlayer takes player whichPlayer, boolean flag returns nothing if flag and GetLocalPlayer() == whichPlayer then call ShowUnit(.I, true) elseif not(flag) and GetLocalPlayer() == whichPlayer then call ShowUnit(.I, false) endif endmethod private static method ForceEnum takes nothing returns nothing if B and GetLocalPlayer() == GetEnumPlayer() then call ShowUnit(.I, true) elseif not(B) and GetLocalPlayer() == GetEnumPlayer() then call ShowUnit(.I, false) endif endmethod method ShowForForce takes force whichForce, boolean flag returns nothing set B = flag call ForForce(whichForce, MinimapIcon.ForceEnum) endmethod private static method Periodic takes nothing returns nothing local integer J = 0 local MinimapIcon M loop set M = MIArray[J] set M.IX = GetUnitX(M.Target) set M.IY = GetUnitY(M.Target) call SetUnitX(M.I, M.IX) call SetUnitY(M.I, M.IY) set J = J+1 exitwhen J >= N endloop endmethod method FollowTarget takes boolean flag returns nothing if flag then set MIArray[N] = this set .Index = N set N = N+1 if N == 1 then call TimerStart(T, UPDATE_PERIOD, MinimapIcon.Periodic, true) endif elseif .Index > -1 then set N = N-1 if N > 0 then set MIArray[.Index] = MIArray[N] else set .Index = -1 call PauseTimer(T) endif else debug call BJDebugMsg("|cffffcc00MinimapIcon Warning: called .FollowTarget(false) on an instance that was not following!") endif endmethod method onDestroy takes nothing returns nothing if .Index > -1 then set N = N-1 if N > 0 then set MIArray[.Index] = MIArray[N] else call PauseTimer(T) endif endif endmethod endstruct private function Init takes nothing returns nothing set T = CreateTimer() endfunction endlibrary |
|
|
|
| Sponsored Links - Login to hide this ad! |
|
|
|
|
#32 |
|
User
Join Date: Mar 2008
Posts: 93
|
hummm.. looks you have done some work there
__________________ But (iam really sorry for this) as im a jass illiterate, im gonna have to ask you if you could implement it on a map :/. Coz i have no idea when to call anything ![]() it needs timedloop which i found (think so) but still got this error call .StopFollowing() it says it is not a member of minimapicons__minimapicon Last edited by Darkrider : 08-24-2009 at 04:29 AM. |
|
|
|
|
|
#33 |
|
User
|
JASS:method operator X= takes real v returns nothing set .IX = v call SetUnitX(.I, .IX) if .ITarget != null then call .StopFollowing() endif endmethod method operator Y takes nothing returns real return .IY endmethod method operator Y= takes real v returns nothing set .IY = v call SetUnitY(.I, .IY) if .ITarget != null then call .FollowTarget(false) endif endmethod replace "call .StopFollowing()" with "call .FollowTarget(false)" |
|
|
|
|
|
#34 |
|
Lackadaisically Absent.
Respected User
|
Ah, whoops. It doesn't need TimedLoop; I forgot to remove that.
__________________And no guarantees on it working yet, either. I haven't had a chance to test. If you want to go ahead and see if it works, make 2 new units on your map: one regular unit and one hero unit. Do whatever you'd normally do to make dummy units except don't turn their minimap display off, and then update the library's rawcodes. JASS:library MinimapIcons initializer Init //================================================================================= // MinimapIcons Library, by Pyrogasm - V1.01 (August 24, 2009) // [A library to treat minimap unit icons as objects] // //================================================================================= globals private constant integer UNIT_ICON_ID = 'Uicn' private constant integer HERO_ICON_ID = 'Hicn' private constant real UPDATE_PERIOD = 0.04 private constant player DEFAULT_PLAYER = Player(15) private constant real DEFAULT_X = 0.00 private constant real DEFAULT_Y = 0.00 private constant integer ICON_TYPE_UNIT = 0 private constant integer ICON_TYPE_HERO = 1 endglobals globals private timer T private integer N = 0 private keyword MinimapIcon private MinimapIcon array MIArray private boolean B endglobals struct MinimapIcon private unit I = null private integer IType private real IX = 0.00 private real IY = 0.00 private unit ITarget = null private player IPlayer private integer Index = -1 static method create takes integer iconType returns MinimapIcon local MinimapIcon M = MinimapIcon.allocate() local integer Id = UNIT_ICON_ID if iconType == ICON_TYPE_HERO then set Id = HERO_ICON_ID endif set M.I = CreateUnit(DEFAULT_PLAYER, Id, DEFAULT_X, DEFAULT_Y, 0.00) set M.IType = iconType call ShowUnit(M.I, false) return M endmethod method operator X takes nothing returns real return .IX endmethod method operator X= takes real v returns nothing set .IX = v call SetUnitX(.I, .IX) if .ITarget != null then call .FollowTarget(false) endif endmethod method operator Y takes nothing returns real return .IY endmethod method operator Y= takes real v returns nothing set .IY = v call SetUnitY(.I, .IY) if .ITarget != null then call .FollowTarget(false) endif endmethod method operator Target takes nothing returns unit return .ITarget endmethod method operator Target= takes unit v returns nothing set .ITarget = v endmethod method operator IconType takes nothing returns integer return IType endmethod method operator IconType= takes integer v returns nothing local integer Id = UNIT_ICON_ID if iconType == ICON_TYPE_HERO then set Id = HERO_ICON_ID endif call ShowUnit(.I, true) call RemoveUnit(.I) set .I = CreateUnit(.IPlayer, Id, .IX, .IY, 0.00) call ShowUnit(.I, false) endmethod method operator OwningPlayer takes nothing returns player return .IPlayer endmethod method operator OwningPlayer= takes player v returns nothing set .IPlayer = v call SetUnitOwner(.I, v, true) endmethod method ShowForPlayer takes player whichPlayer, boolean flag returns nothing if flag and GetLocalPlayer() == whichPlayer then call ShowUnit(.I, true) elseif not(flag) and GetLocalPlayer() == whichPlayer then call ShowUnit(.I, false) endif endmethod private static method ForceEnum takes nothing returns nothing if B and GetLocalPlayer() == GetEnumPlayer() then call ShowUnit(.I, true) elseif not(B) and GetLocalPlayer() == GetEnumPlayer() then call ShowUnit(.I, false) endif endmethod method ShowForForce takes force whichForce, boolean flag returns nothing set B = flag call ForForce(whichForce, MinimapIcon.ForceEnum) endmethod private static method Periodic takes nothing returns nothing local integer J = 0 local MinimapIcon M loop set M = MIArray[J] set M.IX = GetUnitX(M.Target) set M.IY = GetUnitY(M.Target) call SetUnitX(M.I, M.IX) call SetUnitY(M.I, M.IY) set J = J+1 exitwhen J >= N endloop endmethod method FollowTarget takes boolean flag returns nothing if flag then set MIArray[N] = this set .Index = N set N = N+1 if N == 1 then call TimerStart(T, UPDATE_PERIOD, MinimapIcon.Periodic, true) endif elseif .Index > -1 then set N = N-1 if N > 0 then set MIArray[.Index] = MIArray[N] else set .Index = -1 call PauseTimer(T) endif else debug call BJDebugMsg("|cffffcc00MinimapIcon Warning: called .FollowTarget(false) on an instance that was not following!") endif endmethod method onDestroy takes nothing returns nothing if .Index > -1 then set N = N-1 if N > 0 then set MIArray[.Index] = MIArray[N] else call PauseTimer(T) endif endif endmethod endstruct private function Init takes nothing returns nothing set T = CreateTimer() endfunction endlibrary |
|
|
|
|
|
#35 |
|
User
Join Date: Mar 2008
Posts: 93
|
:P
__________________ok i'll try what you said as soon as i get home. EDIT: Please let me know when you can test it, because im getting a lot of compiling errors regarding undeclared variable types and things like that :P Last edited by Darkrider : 08-25-2009 at 03:49 AM. |
|
|
|
|
|
#36 |
|
Lackadaisically Absent.
Respected User
|
Whenever I boot into Windows, which hasn't been for a while.
__________________ |
|
|
|
|
|
#37 |
|
User
Join Date: Mar 2008
Posts: 93
|
or else, if you want, i can post the errors i get :P
__________________ |
|
|
|
|
|
#38 |
|
User
Join Date: Mar 2008
Posts: 93
|
this are the errors i get. Can you help me ?
__________________![]() ![]() Last edited by Darkrider : 08-31-2009 at 04:33 AM. |
|
|
|
|
|
#39 |
|
User
Join Date: Mar 2008
Posts: 93
|
Pyrogasm can you help me here :(
__________________ |
|
|
|
|
|
#40 |
|
Lackadaisically Absent.
Respected User
|
It's been a while, but I've been on vacation. This should work:
__________________ JASS:library MinimapIcons initializer Init //========================================================================================== // MinimapIcons Library, by Pyrogasm - V1.03 (September 7th, 2009) // [A library to treat minimap unit icons as objects] // // The outset of this system is very simple: there may be some instances in which // a mapmaper wishes to display a unit or hero icon on the minimap for specific // players, for whatever reason. Currently there is no API to support this, thus // this library was written. // // // ============== // The most relevant part of this library is a new object, the MinimapIcon // local MinimapIcon M = MinimapIcon.create(ICON_TYPE_UNIT) // - Allocates a new MinimapIcon object with a unit icon // // local MinimapIcon M = MinimapIcon.createXY(ICON_TYPE_UNIT, SomeX, SomeY, Player(0)) // - The same as above but creates it at (SomeX, SomeY) for Player(0) // // local MinimapIcon M = MinimapIcon.createTarget(ICON_TYPE_UNIT, Targ, Player(0), flag) // - The same, but creates it at Targ's coordinates, and will .FollowTarget(flag) // // M.IconUnit - Returns the unit being used to display the icon (Read Only) // set M.X = 3.00 - Sets the icon's X coordinate to 3.00 // set M.Y = 5.00 - Sets the icon's Y coordinate to 5.00 // M.X - Would return 3.00 (the icon's X coordinate) // M.Y - Would return 5.00 (the icon's Y coordinate) // set M.Target = U - Sets the icon's target to U // M.Target - Would return U // set M.IconType = - Sets the current IconType to ICON_TYPE_UNIT or ICON_TYPE_HERO // (When called, this resets the current Display options and // will hide the MinimapIcon for all players) // M.IconType - Returns the current IconType // set M.OwningPlayer = - Sets the owning player for the icon, thus changing the display // color on the minimap // M.OwningPlayer - Returns the current owning player // // call M.ShowForPlayer(P, Bool) - Shows the icon for player P if Bool is true; if Bool // is false, the icon will be hidden for P // call M.ShowForForce(F, Bool) - The same as the above, but will show/hide for the // specified force // // ============== // There are also a few constants you might want to modify: // UNIT_ICON_ID - The rawcode of the unit icon unit // HERO_ICON_ID - The rawcode of the hero icon unit // UPDATE_PERIOD - The timeout of the timer that moves target-following icons // DEFAULT_PLAYER - When .create is called, the icon will be created for this player // DEFAULT_X - When .create is called, the icon will be created at this X coordinate // DEFAULT_Y - When .create is called, the icon will be created at this Y coordinate // ICON_TYPE_UNIT - For use with unit icons // ICON_TYPE_HERO - For use with hero icons // // // ============== // Units: // This system uses two dummy units to display the icons, and they are created with // external ObjectMerger calls. After saving this script in your map the first time, // simply find the two lines that start with "//! external ObjectMerger" and put a space // between the // and the ! // // // ============== // Credit where it's due: // Vexorian, for JASSHelper // Pitzermike, for PJass and Grimoire // Pipedream, Zoxc, and MindWorx, for the JassNewGen Pack // grim001, for a little help with static method callbacks // _, for the inspiration to create this system // //========================================================================================== globals private constant integer UNIT_ICON_ID = 'uicn' private constant integer HERO_ICON_ID = 'Hicn' private constant real UPDATE_PERIOD = 0.04 private constant player DEFAULT_PLAYER = Player(15) private constant real DEFAULT_X = 0.00 private constant real DEFAULT_Y = 0.00 constant key ICON_TYPE_UNIT constant key ICON_TYPE_HERO endglobals globals private timer T private integer N = 0 private MinimapIcon array MIArray private boolean B private MinimapIcon Hold endglobals //! external ObjectMerger w3u ewsp uicn uabi Aloc umdl none.mdl ussc -1.00 uspa 0 umvs 0 ucol 0.00 ufoo 0 urac Commoner usid 0 usin 0 utyp 0 ubui 0 upgr 0 unam "Unit Icon" //! external ObjectMerger w3u ewsp Hicn uabi Aloc umdl none.mdl ussc -1.00 uspa 0 umvs 0 ucol 0.00 ufoo 0 urac Commoner usid 0 usin 0 utyp 0 ubui 0 upgr 0 unam "Hero Icon" struct MinimapIcon private unit I = null private integer IType private real IX = 0.00 private real IY = 0.00 private unit ITarget = null private player IPlayer private integer Index = -1 method operator IconUnit takes nothing returns unit return .I endmethod method operator X takes nothing returns real return .IX endmethod method operator X= takes real v returns nothing set .IX = v call SetUnitX(.I, .IX) if .ITarget != null then call .FollowTarget(false) endif endmethod method operator Y takes nothing returns real return .IY endmethod method operator Y= takes real v returns nothing set .IY = v call SetUnitY(.I, .IY) if .ITarget != null then call .FollowTarget(false) endif endmethod method operator Target takes nothing returns unit return .ITarget endmethod method operator Target= takes unit v returns nothing set .ITarget = v endmethod method operator IconType takes nothing returns integer return .IType endmethod method operator IconType= takes integer v returns nothing local integer Id = UNIT_ICON_ID if v == ICON_TYPE_HERO then set Id = HERO_ICON_ID endif if v != .IType then call ShowUnit(.I, true) call RemoveUnit(.I) set .I = CreateUnit(.IPlayer, Id, .IX, .IY, 0.00) call ShowUnit(.I, false) set .IType = v endif endmethod method operator OwningPlayer takes nothing returns player return .IPlayer endmethod method operator OwningPlayer= takes player v returns nothing set .IPlayer = v call SetUnitOwner(.I, v, true) endmethod method ShowForPlayer takes player whichPlayer, boolean flag returns nothing if flag and GetLocalPlayer() == whichPlayer then call ShowUnit(.I, true) elseif not(flag) and GetLocalPlayer() == whichPlayer then call ShowUnit(.I, false) endif endmethod private static method ForceEnum takes nothing returns nothing if B and GetLocalPlayer() == GetEnumPlayer() then call ShowUnit(Hold.I, true) elseif not(B) and GetLocalPlayer() == GetEnumPlayer() then call ShowUnit(Hold.I, false) endif endmethod method ShowForForce takes force whichForce, boolean flag returns nothing set B = flag set Hold = this call ForForce(whichForce, function MinimapIcon.ForceEnum) endmethod private static method Periodic takes nothing returns nothing local integer J = 0 local MinimapIcon M loop set M = MIArray[J] set M.IX = GetUnitX(M.Target) set M.IY = GetUnitY(M.Target) call SetUnitX(M.I, M.IX) call SetUnitY(M.I, M.IY) set J = J+1 exitwhen J >= N endloop endmethod method FollowTarget takes boolean flag returns nothing if flag then set MIArray[N] = this set .Index = N set N = N+1 if N == 1 then call TimerStart(T, UPDATE_PERIOD, true, function MinimapIcon.Periodic) endif elseif .Index > -1 then set N = N-1 if N > 0 then set MIArray[.Index] = MIArray[N] else set .Index = -1 call PauseTimer(T) endif else debug call BJDebugMsg("|cffffcc00MinimapIcon Warning: called .FollowTarget(false) on an instance that was not following!") endif endmethod static method create takes integer iconType returns MinimapIcon local MinimapIcon M = MinimapIcon.allocate() local integer Id = UNIT_ICON_ID if iconType == ICON_TYPE_HERO then set Id = HERO_ICON_ID endif set M.I = CreateUnit(DEFAULT_PLAYER, Id, DEFAULT_X, DEFAULT_Y, 0.00) set M.IType = iconType call ShowUnit(M.I, false) return M endmethod static method createXY takes integer iconType, real X, real Y, player P returns MinimapIcon local MinimapIcon M = MinimapIcon.allocate() local integer Id = UNIT_ICON_ID if iconType == ICON_TYPE_HERO then set Id = HERO_ICON_ID endif set M.I = CreateUnit(DEFAULT_PLAYER, Id, DEFAULT_X, DEFAULT_Y, 0.00) set M.IType = iconType set M.X = X set M.Y = Y set M.OwningPlayer = P call ShowUnit(M.I, false) return M endmethod static method createTarget takes integer iconType, unit T, player P, boolean Follow returns MinimapIcon local MinimapIcon M = MinimapIcon.allocate() local integer Id = UNIT_ICON_ID if iconType == ICON_TYPE_HERO then set Id = HERO_ICON_ID endif set M.I = CreateUnit(DEFAULT_PLAYER, Id, DEFAULT_X, DEFAULT_Y, 0.00) set M.IType = iconType set M.Target = T set M.OwningPlayer = P if Follow then call M.FollowTarget(true) endif call ShowUnit(M.I, false) return M endmethod method onDestroy takes nothing returns nothing call RemoveUnit(.I) if .Index > -1 then set N = N-1 if N > 0 then set MIArray[.Index] = MIArray[N] else call PauseTimer(T) endif endif endmethod endstruct /* function OnX takes unit U, real X returns nothing call BJDebugMsg(GetUnitName(U)) endfunction hook SetUnitX OnX private function Init takes nothing returns nothing set T = CreateTimer() endfunction */ endlibrary |
|
|
|
|
|
#41 |
|
User
Join Date: Mar 2008
Posts: 93
|
Ok im gonna try this ASAP and bring some feedback
__________________Thx a lot for it ^^ (and sorry if i've been too repetitive) EDIT: I get this error and as iam a noob i cant solve it, i know this is something stupid... but i dont know where to put the return nothing thing :( ![]() |
|
|
|
|
|
#42 |
|
Lackadaisically Absent.
Respected User
|
That's just a NewGen thing. You should be able to just click 'Accept' and it will enable the trigger anyway.
__________________ |
|
|
|
|
|
#43 |
|
User
Join Date: Mar 2009
Posts: 1,079
![]()
|
I doubt he has JNGP...
__________________Edit: Or he disabled "Disable editor error messages" Last edited by Anachron : 09-09-2009 at 07:28 AM. |
|
|
|
|
|
#44 |
|
User
Join Date: Mar 2008
Posts: 93
|
i have JNGP and i have disabled editor error messages
__________________else i would also get an error with artificial's recype system or other jass script i used to have like Pandamine's AMHS (now i only have it's replay detect engine) and i dont :P Yes, the trigger remains enabled but i cant test it from WE, so i'll have to try to load it from wc3 EDIT: Im having this problem ![]() i have jass helper version 0.9.K.0 and JNGP for 1.24, i have disabled WE syntax checker and all those things... what can i do? Btw i cant play the map on warcraft (players do not appear in lobby) EDIT: WoW... i wrote this inside the library (before structs) and it saved the map o.O JASS:function Init takes nothing returns nothing endfunction but i still cant make it work (the minimap icons are not displayed) Last edited by Darkrider : 09-10-2009 at 05:19 AM. |
|
|
|
|
|
#45 |
|
Lackadaisically Absent.
Respected User
|
I don't know what's up with you, but it saves/works just fine for me without errors at all. Try downloading .K.0 again and overwriting the old jasshelper.exe, clijasshelper.exe, and the .conf files.
At any rate, try opening the attached map and saving it. Press escape in-game to show an icon for all the riflemen. Last edited by Pyrogasm : 09-10-2009 at 02:49 PM. |
|
|
|
![]() |
| Thread Tools | Search this Thread |
|
|
|
Donate |