Some struct help needed

Nexor

...
Reaction score
74
So I wanted to make a cooldown system, which got no help, so I tried to recreate it after my idea.
I got it to some part, like setting the value of each ability on each level.
But I wanted to make a struct to each unit and to be able to refer to their abilities' cooldown.

Here's the idea:

Code:
a[<Ability ID>].cd[<Level>] = X
X will be the value of <Ability ID> on level <Level>.

Now the other one:

Code:
h[<Unit ID>].id[<Ability ID>] = Y
Y will be the <Unit ID>'s <Ability ID>'s value. (<Unit ID> will be it's custom value created by PUI)
This value will exist locally, and unit-specific. (This is because it shall be able to get modified)


I made so far the first part. But I can't make the other part. Please help me if you could write something clever! :)
Thanks
 

Viikuna

No Marlo no game.
Reaction score
265
Id make it like this:


JASS:
struct ability
  
   // this has cooldown stuff
   real cooldown
   
    
endstruct

struct abilityunit 
   
   unit unit
   ability array abilities  [5 /* or 7 or something */ ]


   // this should probably have some method like this:

   private abilityunit array array
   
   static method getFromUnit takes unit u returns abilityunit
         return .array[GetUnitId(u)]
    endmethod

endstruct
 

Nexor

...
Reaction score
74
I don't get it, will this compile?
There are 2 arrays and a struct ability?

If this works then how do I set and get the values from it?
Something like:

Code:
set x = abilityunit.array[GetTriggerUnit()]

Please write some more information about it, and could you write it in vJASS, I don't get used to Zinc or cJASS.

Anyway thanks for the reply, I think I'll get it after your seconds post :)
 

Viikuna

No Marlo no game.
Reaction score
265
Well, Modifying first abilitys cooldown would go like this:

JASS:


local abilityunit au=abilityunit.getFromUnit( whichunit ) // here we get units ability data

local ability a=au.abilities[ 1 ]  // unit has some amount of abilities in its ability array
set a.cooldown = duration // here we modify cooldown

set a=au.abilities[ 2 ] // here we do something else for second ability
set a.cooldown = a.cooldown / 2
 

Frozenhelfir

set Gwypaas = Guhveepaws
Reaction score
56
He used a generic name for that, I think it is supposed to refer to the global array declared up at the top.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top