| 07-24-2007, 07:45 PM | #1 |
I'm pretty sure it would, just want to make sure before I start changing shit up in my map Usually I do: JASS:function Whatever takes nothing returns nothing local unit u = GetTriggerUnit() local string udat = GetAttachmentTable(u) local herodata hd = GetTableInt(udat, "herodata") ... But I got to thinking... wouldn't it be faster to just do JASS:function HeroInit takes unit u, player p returns nothing set udg_herotables[GetPlayerId(p)] = GetAttachmentTable(u) endfunction function NewWhatever takes nothing returns nothing local unit u = GetTriggerUnit() local player p = GetTriggerPlayer() local herodata hd = GetTableInt(udg_herotables[GetPlayerId(p)], "herodata") endfunction |
| 07-24-2007, 08:36 PM | #2 |
Huh? I don't exactly understand what you are saying but I don't think your code makes much sense. JASS:function HeroInit takes unit u, player p returns nothing set udg_herotables[GetPlayerId(p)] = GetAttachmentTable(u) endfunction Why even have this if you aren't going to use it?? Well, I think you're aiming for: JASS:function HeroInit takes unit u, player p returns nothing set udg_herotables[GetPlayerId(p)] = GetAttachmentTable(u) endfunction function NewWhatever takes nothing returns nothing local unit u = GetTriggerUnit() local player p = GetTriggerPlayer() local herodata hd call HeroInit(u,p) set hd = GetTableInt(udg_herotables[GetPlayerId(p)], "herodata") endfunction Or am I wrong?? I'm pretty sure that the first one would be more efficient. Please make your question more efficient enough for people such as me to understand. |
| 07-24-2007, 08:59 PM | #3 | |
Quote:
Nope. the code you made is basically exactly like what Ive been doing already... cept slower w/ that extra function call the 'HeroInit' function implied that it was ran when the hero was created/selected. I though the function name would make that clear, guess not The whole point is so that I dont have to make a string point to the table of the players hero EVERY time I use its attached struct in a function. If I do it once with the udg (theoretically) I'll never have to do it again as long as the hero is alive. Just need someone to confirm/deny this |
| 07-24-2007, 10:02 PM | #4 |
You should use GetOwningPlayer(u) instead and yes, this might be faster but you're loosing multiinstanceability, if you're going to do it like this you could have just as well made everything with parallel arrays and not used GameCache. |
| 07-25-2007, 03:25 AM | #5 |
Well, each player has one hero there shouldnt be a problem with MUI. and I suppose I could have used arrays for everything with this situation.. |
