Page 21 of 26

Re: Dynamic Script Usage

PostPosted: 03 Apr 2014, 19:50
by Ben
I'm not good with using arrays. Are you saying that I need to specify the range of which the array contains? Something like var PlayerAmount array of [0,1,2,3,4,5]; or something...not even close to that? XD
Kind of.
Array of known length are declared like so: var ArrayName: array [0..8] of Integer;
Where array is set to have elements from 0 to 8. So you can safely access ArrayName[0], ArrayName[1] .. ArrayName[8].
In your case, of course, you set your maps player count minus one instead of 8.
So that 1st player uses element 0, second player uses element 1, etc.
So it would be written as var ArrayName: array [0,1,2,3,4,5,6,7] of Integer; ? (I separate the numbers with commas?)

Re: Dynamic Script Usage

PostPosted: 03 Apr 2014, 20:07
by Nissarin
I'm not good with using arrays. Are you saying that I need to specify the range of which the array contains? Something like var PlayerAmount array of [0,1,2,3,4,5]; or something...not even close to that? XD
Kind of.
Array of known length are declared like so: var ArrayName: array [0..8] of Integer;
Where array is set to have elements from 0 to 8. So you can safely access ArrayName[0], ArrayName[1] .. ArrayName[8].
In your case, of course, you set your maps player count minus one instead of 8.
So that 1st player uses element 0, second player uses element 1, etc.
So it would be written as var ArrayName: array [0,1,2,3,4,5,6,7] of Integer; ? (I separate the numbers with commas?)
No, it's exactly like he wrote above, in the square brackets you can specify the valid range of indexes ([0..8] = 0, 1, 2... 8, [5..7] = 5, 6, 7).

Re: Dynamic Script Usage

PostPosted: 04 Apr 2014, 03:05
by Ben
Thanks, I'll give this a try :)

Re: Dynamic Script Usage

PostPosted: 04 May 2014, 21:40
by RandomLyrics
Hi, is there any other way to get group id of died unit?
  Code:
procedure OnUnitDied(aUnit: Integer; aKillerIndex: Integer); var g: integer; begin g:= States.UnitsGroup(aUnit); end;
i want to check if all members are dead then ... when unit dies

Re: Dynamic Script Usage

PostPosted: 04 May 2014, 23:39
by Lewin
Hi, is there any other way to get group id of died unit?
  Code:
procedure OnUnitDied(aUnit: Integer; aKillerIndex: Integer); var g: integer; begin g:= States.UnitsGroup(aUnit); end;
i want to check if all members are dead then ... when unit dies
Good point, the warrior was removed from the group before calling the event OnUnitDied, so that's why States.UnitsGroup didn't work. I've changed it so OnUnitDied occurs while the warrior is still in the group :)

It will be in the next release.

Re: Dynamic Script Usage

PostPosted: 11 May 2014, 09:13
by Skypper
Is it possible to give units a smaller view range?

Re: Dynamic Script Usage

PostPosted: 11 May 2014, 10:57
by Lewin
Is it possible to give units a smaller view range?
No, that falls under changing unit statistics (attack, hitpoints, etc.) which we have avoided so far so we don't end up with each map being its own "balance mod" and the game has no consistency.

Although changing unit statistics could be awesome for a Dota/LoL kind of script :P

Re: Dynamic Script Usage

PostPosted: 11 May 2014, 11:24
by Skypper
Oke, thx.
I will look for a other solution

Re: Dynamic Script Usage

PostPosted: 01 Jul 2014, 16:38
by Michalpl
Posible to make something if player is defeated then destroy all of his buildings?

Re: Dynamic Script Usage

PostPosted: 01 Jul 2014, 17:45
by RandomLyrics
u can try to check every 1 sec if States.PlayerDefeated then do something

Re: Dynamic Script Usage

PostPosted: 02 Jul 2014, 06:41
by Lewin
u can try to check every 1 sec if States.PlayerDefeated then do something
Using the event OnPlayerDefeated would be neater :)

Re: Dynamic Script Usage

PostPosted: 02 Jul 2014, 06:55
by RandomLyrics
u can try to check every 1 sec if States.PlayerDefeated then do something
Using the event OnPlayerDefeated would be neater :)
Oh right :D forgot about it :P hehe

Re: Dynamic Script Usage

PostPosted: 14 Jul 2014, 18:40
by RandomLyrics
Hmm i have problem with that:
http://pastebin.com/SfqYhr4p
SetTimer doesn't work ;/ it doesn't write values to TIMER. test(TIMER.mins) shows 0 . dunno why

Re: Dynamic Script Usage

PostPosted: 15 Jul 2014, 01:28
by Lewin
Hmm i have problem with that:
http://pastebin.com/SfqYhr4p
SetTimer doesn't work ;/ it doesn't write values to TIMER. test(TIMER.mins) shows 0 . dunno why
That's because records are passed by value, not by reference. So the procedure SetTimer effectively has its own copy of TIMER that is separate from the original one. Ask Google if you're interested in a more detailed explanation.

To make it pass by reference, put "var" in front of the parameter:
procedure SetTimer(var Timer: aTIMER; aMin, aSec: integer);

Re: Dynamic Script Usage

PostPosted: 15 Jul 2014, 14:18
by RandomLyrics
Thanks Lewin now i understand that :)