Map Database  •  FAQ  •  RSS  •  Login

Dynamic Script Usage Questions

<<

Ben

User avatar

Former Site Admin

Posts: 3814

Joined: 08 Jan 2009, 23:00

Location: California - Pacific Time (UTC -8/-7 Summer Time)

Post 03 Apr 2014, 19:50

Re: Dynamic Script Usage

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?)
I used to spam this forum so much...
<<

Nissarin

User avatar

Pikeman

Posts: 185

Joined: 26 Sep 2012, 18:11

KaM Skill Level: Average

Location: Poland

Post 03 Apr 2014, 20:07

Re: Dynamic Script Usage

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).
<<

Ben

User avatar

Former Site Admin

Posts: 3814

Joined: 08 Jan 2009, 23:00

Location: California - Pacific Time (UTC -8/-7 Summer Time)

Post 04 Apr 2014, 03:05

Re: Dynamic Script Usage

Thanks, I'll give this a try :)
I used to spam this forum so much...
<<

RandomLyrics

User avatar

Sword Fighter

Posts: 298

Joined: 21 Jul 2013, 02:15

KaM Skill Level: Fair

Post 04 May 2014, 21:40

Re: Dynamic Script Usage

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
<<

Lewin

User avatar

KaM Remake Developer

Posts: 3822

Joined: 16 Sep 2007, 22:00

KaM Skill Level: Skilled

ICQ: 269127056

Website: http://lewin.hodgman.id.au

Yahoo Messenger: lewinlewinhodgman

Location: Australia

Post 04 May 2014, 23:39

Re: Dynamic Script Usage

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.
<<

Skypper

Knight

Posts: 436

Joined: 28 Jun 2013, 09:37

KaM Skill Level: Fair

Location: Dutch :D

Post 11 May 2014, 09:13

Re: Dynamic Script Usage

Is it possible to give units a smaller view range?
Greets Skypper (Totally Insane)

- Beginning map maker -
<<

Lewin

User avatar

KaM Remake Developer

Posts: 3822

Joined: 16 Sep 2007, 22:00

KaM Skill Level: Skilled

ICQ: 269127056

Website: http://lewin.hodgman.id.au

Yahoo Messenger: lewinlewinhodgman

Location: Australia

Post 11 May 2014, 10:57

Re: Dynamic Script Usage

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
<<

Skypper

Knight

Posts: 436

Joined: 28 Jun 2013, 09:37

KaM Skill Level: Fair

Location: Dutch :D

Post 11 May 2014, 11:24

Re: Dynamic Script Usage

Oke, thx.
I will look for a other solution
Greets Skypper (Totally Insane)

- Beginning map maker -
<<

Michalpl

Sword Fighter

Posts: 318

Joined: 10 May 2014, 21:46

KaM Skill Level: Fair

Post 01 Jul 2014, 16:38

Re: Dynamic Script Usage

Posible to make something if player is defeated then destroy all of his buildings?
<<

RandomLyrics

User avatar

Sword Fighter

Posts: 298

Joined: 21 Jul 2013, 02:15

KaM Skill Level: Fair

Post 01 Jul 2014, 17:45

Re: Dynamic Script Usage

u can try to check every 1 sec if States.PlayerDefeated then do something
<<

Lewin

User avatar

KaM Remake Developer

Posts: 3822

Joined: 16 Sep 2007, 22:00

KaM Skill Level: Skilled

ICQ: 269127056

Website: http://lewin.hodgman.id.au

Yahoo Messenger: lewinlewinhodgman

Location: Australia

Post 02 Jul 2014, 06:41

Re: Dynamic Script Usage

u can try to check every 1 sec if States.PlayerDefeated then do something
Using the event OnPlayerDefeated would be neater :)
<<

RandomLyrics

User avatar

Sword Fighter

Posts: 298

Joined: 21 Jul 2013, 02:15

KaM Skill Level: Fair

Post 02 Jul 2014, 06:55

Re: Dynamic Script Usage

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
<<

RandomLyrics

User avatar

Sword Fighter

Posts: 298

Joined: 21 Jul 2013, 02:15

KaM Skill Level: Fair

Post 14 Jul 2014, 18:40

Re: Dynamic Script Usage

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
<<

Lewin

User avatar

KaM Remake Developer

Posts: 3822

Joined: 16 Sep 2007, 22:00

KaM Skill Level: Skilled

ICQ: 269127056

Website: http://lewin.hodgman.id.au

Yahoo Messenger: lewinlewinhodgman

Location: Australia

Post 15 Jul 2014, 01:28

Re: Dynamic Script Usage

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);
<<

RandomLyrics

User avatar

Sword Fighter

Posts: 298

Joined: 21 Jul 2013, 02:15

KaM Skill Level: Fair

Post 15 Jul 2014, 14:18

Re: Dynamic Script Usage

Thanks Lewin now i understand that :)

Return to “Dynamic Scripting”

Who is online

Users browsing this forum: No registered users and 4 guests