[Log in / Register]
| News | Chat | Pastebin | Donations | Tutorials | Rules | Forums |
| Maps | Skins | Icons | Models | Spells | Tools | Jass | Packs | Hosted Projects | Starcraft II Modding | Starcraft II Resources | Galaxy Wiki |
(Keeps Hive Alive)
Go Back   The Hive Workshop > Warcraft III Modding > World Editor Help Zone


World Editor Help Zone Ask general questions about World Editor features and use in this forum. If you need help fixing a trigger, please post it in Triggers & Scripts. Please review the forum rules before posting.

Closed Thread
 
Thread Tools
Old 04-11-2012, 05:10 PM   #1 (permalink)
Registered User Spartipilo
User
 
Join Date: Jul 2011
Posts: 2,643
Spartipilo is just really nice (311)Spartipilo is just really nice (311)
How to find the highest value

Hi!

I started this thread as a "Multiboard data update" but I noticed the title isn't appropiate.

I save all my tower kills and damage dealt so far during lifetime in a Hashtable under the towers handle. I need to find which tower has the highest number of kills or damage dealt, and know who owns it. How can I do that?
Spartipilo is online now  
Old 04-11-2012, 05:29 PM   #2 (permalink)
Registered User Dr Super Good
Imperial Good
 
Dr Super Good's Avatar
 
Join Date: Jan 2005
Posts: 15,278
Dr Super Good has been here far too long (2650)Dr Super Good has been here far too long (2650)Dr Super Good has been here far too long (2650)Dr Super Good has been here far too long (2650)Dr Super Good has been here far too long (2650)Dr Super Good has been here far too long (2650)
Merit Badge - Level 0: This user has proven to be extremely valuable to the Warcraft III Modding Community. User of the Year: 2010 
Unless you use some kind of cleaver updating tree or pre-sorted data structure to hold the towers, you will have to perform a linear search through all towers.

Wikipedia provides you with the pseudo code for linear search.
Dr Super Good is online now  
Old 04-11-2012, 07:12 PM   #3 (permalink)
Registered User Spartipilo
User
 
Join Date: Jul 2011
Posts: 2,643
Spartipilo is just really nice (311)Spartipilo is just really nice (311)
Like this? I know it's a mix of jass and GUI, I just need to know if the general idea works and it's easy + efficient.

Jass:
Set i = 0
Set MaxDamage = 0.00

Unit - Pick Every Unit in TowerGroup and do:
   Set i = i +1
   Set Tower[i] = (Picked Unit)

For each Integer A from 1 to (Number of Units in TowersGroup) do (Actions)
   Custom Script: Set int = GetHandleId(Towers[GetForLoopIndexA()])
   Set r = Load 1 of int in Hash
   If r > MaxDamage then
      Set MaxDamage = r
      Set MaxTower = Towers[Integer A]
      Set Owner = Player number of (Owner of MaxTower)
   endif
Spartipilo is online now  
Old 04-11-2012, 09:35 PM   #4 (permalink)
Registered User Dr Super Good
Imperial Good
 
Dr Super Good's Avatar
 
Join Date: Jan 2005
Posts: 15,278
Dr Super Good has been here far too long (2650)Dr Super Good has been here far too long (2650)Dr Super Good has been here far too long (2650)Dr Super Good has been here far too long (2650)Dr Super Good has been here far too long (2650)Dr Super Good has been here far too long (2650)
Merit Badge - Level 0: This user has proven to be extremely valuable to the Warcraft III Modding Community. User of the Year: 2010 
I think that would work as it looks about right.
Dr Super Good is online now  
Old 04-12-2012, 02:21 AM   #5 (permalink)
Registered User mckill2009
SSJ99999 Pinoy!
 
mckill2009's Avatar
 
Join Date: Mar 2009
Posts: 4,471
mckill2009 is a splendid one to behold (872)mckill2009 is a splendid one to behold (872)mckill2009 is a splendid one to behold (872)mckill2009 is a splendid one to behold (872)mckill2009 is a splendid one to behold (872)mckill2009 is a splendid one to behold (872)
Filter all the towers and try using IMaxBJ ...I use this in my [Snippet] [Needs fix] AuraLevel
__________________
My Resources:
My Maps
My Systems/Spells

Your ideas tend to result in unnecessary violence so shut the F*** up!
mckill2009 is online now  
Closed Thread

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


All times are GMT. The time now is 11:32 PM.





Powered by vBulletin
Copyright 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.5.1 PL2
Copyright © Ralle