Map Database  •  FAQ  •  RSS  •  Login

New scripts since r5503

<<

Krom

User avatar

Knights Province Developer

Posts: 3280

Joined: 09 May 2006, 22:00

KaM Skill Level: Fair

Location: Russia

Post 02 Oct 2013, 04:54

New scripts since r5503

Here's a list of scripts that got implemented since the last Scripting Demo (r5503). Until the next Demo is released these are subject to change. If you have any ideas or suggestions about THESE scripts (functioning, parametres, etc.) please write them here :)
If you want to suggest new script ideas - discussion is here: viewtopic.php?f=24&t=1495
Full list of script commands can be found at KaM Remake project wiki: https://code.google.com/p/castlesand/wi ... ptsDynamic

Events:
|| Version || Event || Description || Parameters and types ||
|| 5882
|| `OnHouseDamaged`
|| Occurs when a house is damaged by the enemy soldier. If AttackerIndex is -1 the house was damaged some other way, such as from Actions.HouseDamage.
|| aHouseID: Integer; //House that is damaged <br> aAttackerIndex: Integer; //UnitID of attacker
||
|| 5871
|| `OnHousePlanPlaced`
|| Occurs when player has placed a house plan
|| aPlayerIndex: Integer; //Player who placed it <br> X: Integer; //X coordinate of the plan <br> Y: Integer; //Y coordinate of the plan <br> aHouseType: Integer; //Type of house of the plan
||
|| 5884
|| `OnUnitWounded`
|| Happens when unit is wounded. Attacker can be a warrior, recruit in tower or unknown (-1)
|| aUnitID: Integer; //UnitID who was wounded <br> AttackerID who attacked the unit
||

Actions:
|| Version || Action || Description || Parameters (Integer) || Return value ()
||
|| 5778
|| `AIEquipRate`
|| Sets the warriors equipment rate for AI. (type: 0 - leather, 1 - iron)
|| 1 - player index <br> 2 - type <br> 2 - rate
||
|| 5777
|| `FogCoverRect`
|| Covers a rectangular area in fog of war for player
|| 1 - player index <br> 2 - from X <br> 3 - from Y <br> 4 - to X <br> 5 - to Y
||
|| 5777
|| `FogRevealRect`
|| Reveals a rectangular area in fog of war for player
|| 1 - player index <br> 2 - from X <br> 3 - from Y <br> 4 - to X <br> 5 - to Y
||

P.S. Sorry about formatting, this is almost straight c/p from the wiki code.
Knights Province at: http://www.knightsprovince.com
KaM Remake at: http://www.kamremake.com
Original MBWR/WR2/AFC/FVR tools at: http://krom.reveur.de
<<

sado1

User avatar

Council Member

Posts: 1430

Joined: 21 May 2012, 19:13

KaM Skill Level: Skilled

Post 02 Oct 2013, 09:04

Re: New scripts since r5503

|| 5871
|| `OnHousePlanPlaced`
|| Occurs when player has placed a house plan
|| aPlayerIndex: Integer; //Player who placed it <br> X: Integer; //X coordinate of the plan <br> Y: Integer; //Y coordinate of the plan <br> aHouseType: Integer; //Type of house of the plan
How about a version for at least the road plans? (and maybe fields/wineyards as well?) Pleeeeeeaaase :)
<<

Krom

User avatar

Knights Province Developer

Posts: 3280

Joined: 09 May 2006, 22:00

KaM Skill Level: Fair

Location: Russia

Post 02 Oct 2013, 10:29

Re: New scripts since r5503

@sado1: I think this will be the next script event I'm going to implement :)
Knights Province at: http://www.knightsprovince.com
KaM Remake at: http://www.kamremake.com
Original MBWR/WR2/AFC/FVR tools at: http://krom.reveur.de
<<

Ben

User avatar

Former Site Admin

Posts: 3814

Joined: 08 Jan 2009, 23:00

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

Post 02 Oct 2013, 15:46

Re: New scripts since r5503

Yes! OnHousePlanPlaced is implemented :D Time for limiting the number of towers people can build;)
I used to spam this forum so much...
<<

sado1

User avatar

Council Member

Posts: 1430

Joined: 21 May 2012, 19:13

KaM Skill Level: Skilled

Post 02 Oct 2013, 16:16

Re: New scripts since r5503

To is probably the happiest man on Earth right now
<<

Ben

User avatar

Former Site Admin

Posts: 3814

Joined: 08 Jan 2009, 23:00

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

Post 02 Oct 2013, 16:46

Re: New scripts since r5503

And Borris is the saddest :D
I used to spam this forum so much...
<<

andreus

User avatar

Sword Fighter

Posts: 343

Joined: 18 Dec 2011, 12:05

KaM Skill Level: Beginner

Website: https://github.com/andreus791/maps_feedback

Location: Russia

Post 20 Nov 2013, 19:07

Re: New scripts since r5503

I just inform that more scripts are implemented:

5924 Actions.AIAutoBuild(aPlayer: Byte, aAuto: Boolean)
5924 Actions.AIAutoDefence(aPlayer: Byte; aAuto: Boolean)
5924 Actions.AIRecruitsDelay(aPlayer: Byte, aDelay: Integer)
5924 Actions.AISerfsFactor(aPlayer, aLimit: Byte)
5924 Actions.AIWorkersLimit(aPlayer, aLimit: Byte)
5927 States.PlayerIsAI(aPlayer: Byte): Boolean - returns true if certain player is AI
5927 Actions.RemoveField(X, Y: Word) - works only for winefields now.
5927 Actions.RemoveRoad(X, Y: Word)
5932 Actions.AIAutoRepair(aPlayer: Byte; aAuto: Boolean)
5932 Actions.AISoldiersLimit(aPlayer: Byte; aLimit: Integer)
5932 Actions.AIDefensePositionAdd(aPlayer: Byte; X: Integer; Y: Integer; aDir: Byte; aGroupType: Byte; aRadius: Word; aDefType: Byte) - adds new AI defence position
5932 States.GroupType(aGroupID: Integer) - returns type of certain group (melee, ranged...)
5934 States.HouseCanReachResources(aHouseID: Integer): Boolean
5934 Actions.AIGroupsFormationSet(aPlayer, aType: Byte; aCount, aColumns: Word)
5934 Actions.GroupHungerSet(aGroupID, aHungerLevel: Integer) - someone was dreaming of it? :P
5934 Actions.GroupKillAll(aGroupID: Integer; aSilent: Boolean) - someone was dreaming of it? :P
5934 Actions.PlayerCenterScreenSet(aPlayer: Byte; X, Y: Integer) - hmmm... it's only beginning I think :P

59** States.ClosestHouse(aPlayer, X, Y: Integer): Integer
59** States.ClosestGroup(aPlayer, X, Y: Integer): Integer
59** States.ClosestUnit(aPlayer, X, Y: Integer): Integer
59** Actions.GroupOrderAttackGroup(aID1, aID2: Integer)
59** States.HouseOccupant(aHouseID: Integer): Integer - returns unit type which works in cretain house. Imagine script like this:
  Code:
H := States.PlayerGetAllHouses(0); for I := 0 to length(H) - 1 do Actions.GiveUnit(0, States.HouseOccupant(H[I]), States.HousepositionX(H[I]), 1 + States.HousepositionY(H[I]), 5); end;
Much easier than placing every unit...

Any comments? :)
<<

RandomLyrics

User avatar

Sword Fighter

Posts: 298

Joined: 21 Jul 2013, 02:15

KaM Skill Level: Fair

Post 20 Nov 2013, 22:32

Re: New scripts since r5503

OnHouseDamaged - can you add - aDamageTaken: integer ?
andreus - great scripts - it will reduce the length of our codes :)
States.ClosestEnemyHouse , States.ClosestEnemyGroup , States.ClosestEnemyUnit - will be awesome :)
<<

andreus

User avatar

Sword Fighter

Posts: 343

Joined: 18 Dec 2011, 12:05

KaM Skill Level: Beginner

Website: https://github.com/andreus791/maps_feedback

Location: Russia

Post 27 Nov 2013, 08:52

Re: New scripts since r5503

States.ClosestEnemyHouse , States.ClosestEnemyGroup , States.ClosestEnemyUnit - will be awesome :)
Implemented in new nightly build ;)
<<

RandomLyrics

User avatar

Sword Fighter

Posts: 298

Joined: 21 Jul 2013, 02:15

KaM Skill Level: Fair

Post 27 Nov 2013, 14:28

Re: New scripts since r5503

Thanks!! :D its very usefull for AI scripting ;) its already implemted in r5961 ? i dont see it anywhere ;p
<<

andreus

User avatar

Sword Fighter

Posts: 343

Joined: 18 Dec 2011, 12:05

KaM Skill Level: Beginner

Website: https://github.com/andreus791/maps_feedback

Location: Russia

Post 27 Nov 2013, 17:15

Re: New scripts since r5503

Yes, it's implemented in r5961.

5938 Actions.CinematicStart(aPlayer: Byte);
5938 Actions.CinematicEnd(aPlayer: Byte);
5938 Actions.CinematicPanTo(aPlayer: Byte; X, Y, Duration: Word);
5943 States.ClosestGroup(aPlayer, X, Y: Integer): Integer
5943 States.ClosestHouse(aPlayer, X, Y: Integer): Integer
5943 States.ClosestUnit(aPlayer, X, Y: Integer): Integer
5943 States.HouseOccupant(aHouseID: Integer): Integer
<<

RandomLyrics

User avatar

Sword Fighter

Posts: 298

Joined: 21 Jul 2013, 02:15

KaM Skill Level: Fair

Post 27 Nov 2013, 17:23

Re: New scripts since r5503

I need the oposite(not player unit but enemy of player) of ClosestGroup for AI , it gives you closest enemy group it looks kinda like this:
  Code:
//CLOSEST ENEMY GROUP TO ATTACK function ClosestEnemyGroup(aPlayer, X, Y, radius:Integer): Integer; var Groups: array of Integer; i, j, BestDistanceSqr, ThisDistanceSqr, DX, DY, fUnit: Integer; begin Result := -1; for j := 0 to MAX_PLAYERS-1 do begin if (States.PlayerEnabled(j) = true) and (States.PlayerDefeated(j) = false) and (j <> aPlayer) then begin if( States.PlayerAllianceCheck(aPlayer, j) <> true ) then begin Groups := States.PlayerGetAllGroups(j); for i := 0 to Length(Groups) -1 do begin fUnit:=States.GroupMember(Groups[i], 0); DX := X - States.UnitPositionX(fUnit); DY := Y - States.UnitPositionY(fUnit); ThisDistanceSqr := (DX*DX) + (DY*DY); if ((Abs(DX)<radius) and (Abs(DY)<radius)) and ((Result = -1) or (ThisDistanceSqr < BestDistanceSqr)) then begin BestDistanceSqr := ThisDistanceSqr; Result := Groups[i]; end; //end; end; end; end; end; end;
<<

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 28 Nov 2013, 02:42

Re: New scripts since r5503

I need the oposite(not player unit but enemy of player) of ClosestGroup for AI , it gives you closest enemy group it looks kinda like this:
I don't think we should add script commands to cover every possible case of getting the closest thing. It was already possible to write your own GetClosestUnit (like you did in your previous post for groups), however that can have performance issues since there can be a lot of units to check and dynamic scripts are slower than native executable code. So it makes sense for us to write GetClosestUnit/House/Group because the code will run much faster when implemented as a command rather than your own function in a dynamic script (and it's a fairly common thing to want to query).

However, I don't think we need to implement GetClosest[Enemy/Ally][Group/Unit/House] because it can be implemented like you did in your "ClosestEnemyGroup" function, but using States.GetClosestGroup instead of States.PlayerGetAllGroups. That way you only need to loop and check at most 7 different groups (if you have 7 enemies) so it won't be slow to run.
<<

RandomLyrics

User avatar

Sword Fighter

Posts: 298

Joined: 21 Jul 2013, 02:15

KaM Skill Level: Fair

Post 28 Nov 2013, 03:06

Re: New scripts since r5503

I need the oposite(not player unit but enemy of player) of ClosestGroup for AI , it gives you closest enemy group it looks kinda like this:
I don't think we should add script commands to cover every possible case of getting the closest thing. It was already possible to write your own GetClosestUnit (like you did in your previous post for groups), however that can have performance issues since there can be a lot of units to check and dynamic scripts are slower than native executable code. So it makes sense for us to write GetClosestUnit/House/Group because the code will run much faster when implemented as a command rather than your own function in a dynamic script (and it's a fairly common thing to want to query)
yea, i was thinking about that, for 500 groups for exmaple, you have to do a looooot of this things - and for now its realy freeze the game for about 1 sec - and im forced to do my script running every 25 sec or 40 sec than 5 or evan 1 for better precizion. I will check it with the newest CloestUnit function. :)
<<

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 28 Nov 2013, 03:58

Re: New scripts since r5503

yea, i was thinking about that, for 500 groups for exmaple, you have to do a looooot of this things - and for now its realy freeze the game for about 1 sec - and im forced to do my script running every 25 sec or 40 sec than 5 or evan 1 for better precizion. I will check it with the newest CloestUnit function. :)
If your script freezes the game for one second then it doesn't matter if you run it every 5 seconds or every 50 seconds, it will still cause the game to freeze for 1 second which is very annoying for the player, even if it is less frequent. You'd want to spread the processing out over multiple ticks (storing partial results in global variables), but that's kind of complicated to implement. That's why these Closest* functions were really needed :)

Return to “Ideas / Suggestions”

Who is online

Users browsing this forum: No registered users and 9 guests