Map Database  •  FAQ  •  RSS  •  Login

Ask for scripts

<<

Brolian

User avatar

Recruit

Posts: 36

Joined: 16 Sep 2014, 19:45

KaM Skill Level: Skilled

Location: Poland

Post 17 Sep 2014, 14:44

Ask for scripts

Hello,
I created map with scripts like 12 pages A4 :-)
And i need some help i must ask here.

I learned many things from https://code.google.com/p/castlesand/wi ... ptsDynamic .
I read in some post like some codes do not work on avaible KaM: Remake which we can download.
Some codes work on some Beta version. If its true then many scripts i can add to mine missions when new
version of Kam:remake will be added.

1. OnPlanRoadPlaced or OnPlanWinefieldPlaced
I tryed to write code, but it didn't work, instead that i used IsRoadAt then begin something end.
i used it in mine first mission for choose game hard level. When we build Winefield in some X: Y: then
we get Easy mode, or hard mode game during play mission.

2. OnPlanRoadRemoved and OnPlanWinefieldRemoved
Same as above, player decline own decision and remove Plan road, then i need code to stop action/states.

3. UnitKill is work fine for me, but GroupKillAll do not work .

4. Actions.HouseAddWaresTo(States.HouseAt(31, 69), 0, 4);
I can with code add some wares to indicate house, but its is possible when we got on Storehouse 50 stone
and but code we -20 stone so after action we got 30 stone. I wish use it for some events which i can add to mine missions
WHen i tip -30 with HouseAddWaresTo then stone chnged from 50 to 650000.

5. I very glad to know how to code which aGroup Knights can atack another aGroup for example Milita.
i used GroupOrderAttackHouse and GroupOrderAttackUnit and that 2 codes work fine but i do not know how
GroupOrderAttackGroup :-) if that code exist.

More like 70% codes from Mission scripts i already tested and used.
<<

Esthlos

User avatar

Knight

Posts: 676

Joined: 23 Jun 2013, 16:02

KaM Skill Level: Beginner

Post 17 Sep 2014, 17:08

Re: Ask for scripts

I read in some post like some codes do not work on avaible KaM: Remake which we can download.
Some codes work on some Beta version. If its true then many scripts i can add to mine missions when new
version of Kam:remake will be added.
As far as I know, this is correct.
In the page you linked, on the left of each function there is a number: if it is higher than 5503, then that function should not be available in the downloadable version.
4. Actions.HouseAddWaresTo(States.HouseAt(31, 69), 0, 4);
I can with code add some wares to indicate house, but its is possible when we got on Storehouse 50 stone
and but code we -20 stone so after action we got 30 stone. I wish use it for some events which i can add to mine missions
WHen i tip -30 with HouseAddWaresTo then stone chnged from 50 to 650000.
Actions.HouseTakeWaresFrom should do what you are trying to, but as far as I know it isn't in 5503...
Just when you think you know something, you have to look at it in another way, even though it may seem silly or wrong. You must try! - John Keating, "Dead Poets Society"
<<

Brolian

User avatar

Recruit

Posts: 36

Joined: 16 Sep 2014, 19:45

KaM Skill Level: Skilled

Location: Poland

Post 17 Sep 2014, 17:23

Re: Ask for scripts

Thanks for informations Esthlos. Then its true codes what i need are in next version :-)
HouseTakeWaresFrom i checked and its not for 5503 version kam remake

Scripts from 1, 2, 3, are not able to version 5503 too so i got answer for that.

So i need to know "only" answer to mine point 5, how to attack aGroup by another aGroup.
<<

Brolian

User avatar

Recruit

Posts: 36

Joined: 16 Sep 2014, 19:45

KaM Skill Level: Skilled

Location: Poland

Post 19 Sep 2014, 08:15

Re: Ask for scripts

Hello, i finded asnwer for me :-)
https://code.google.com/p/castlesand/so ... ipting.txt
Actions.GroupOrderAttackGroup(AttackersGroupID, GroupToAttackID: Integer)

Where we can use that command after new version Kam:remate will appear :-)
Last edited by Brolian on 19 Sep 2014, 11:59, edited 1 time in total.
<<

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 19 Sep 2014, 11:50

Re: Ask for scripts

Hello, i finded asnwer for me :-)
https://code.google.com/p/castlesand/so ... ipting.txt
Actions.GroupOrderAttackGroup(AttackersGroupID, GroupToAttackID: Integer)

Where we can use that command after new version Kam:remate will appear :-)
That command is in the "proposed" section and might not be implemented for the next release. It's not a useful command anyway, since you can use:
Actions.GroupOrderAttackUnit(AttackerGroup, States.GroupMember(GroupToAttack, 0));
That will order them to attack the flag holder of the GroupToAttack. The attacker group must be ordered to attack a single unit, they can't walk to the position of every unit in the group at once. So if we did implement GroupOrderAttackGroup, it would just be a shortcut for what I wrote above...
TOPIC PLS DELETE, now its trash
The point of a forum is that other users can read these threads if they have the same question. Deleting every topic once it is answered defeats that purpose ;)
<<

Brolian

User avatar

Recruit

Posts: 36

Joined: 16 Sep 2014, 19:45

KaM Skill Level: Skilled

Location: Poland

Post 19 Sep 2014, 15:11

Re: Ask for scripts

Thanks for answer Lewin :-) i needed that command.
Yes here is some answer for another players then i wanna help so i give full answer and some usefull Scripts :-)

Its full code, at time 0:00:10 Knights will atttack poor bowmans :-) :
  Code:
var Knights, BowMans: Integer; procedure OnMissionStart; begin Knights := Actions.GiveGroup(0, 22, 10, 10, 2, 9, 3); //group as attackers BowMans := Actions.GiveGroup(1, 17, 10, 18, 2, 9, 3); // group which be attack. // Knights := States.GroupAt(10, 10); //SAME code as above, but usefull when we by editor make own groups on map // BowMans := States.GroupAt(10, 18); // then we must give then own GroupID end; procedure OnTick; begin if States.GameTime = 100 then //from start game, after 10 second // or if States.GameTime > 100 begin Actions.GroupOrderAttackUnit(Knights, States.GroupMember(BowMans, 0)); // knights go attack bowmans end; end;
With that code we can use when Bowmans walk and stand at X:5, Y:5 then knights go there, like Bowmans get in a trap.
But if bowmans keep walking, and move away from X:5, Y:5, Knights just walk there, and Bownmas will stay a life :-) :
  Code:
procedure OnTick; begin if BowMans = States.GroupAt(5, 5) then Actions.GroupOrderWalk(Knights, 20, 20, 2); end;
That come make when just some troop stand on X:5, Y:5 walk to X:15, Y:15, we do not need some States to work, and do not required name aGroupID:
  Code:
Actions.GroupOrderWalk(States.GroupAt(5, 5), 15, 15, 2);

Better ways:
I change a little code from Lewin, now when some troop stand at X:20, Y:20, our Knights attack then even troop walk far away. Knights Race and then no mercy for that troop ;-) :
  Code:
Actions.GroupOrderAttackUnit(Knights, States.GroupMember(States.GroupAt(20, 20), 0));
Same as above, but if some troop stand at 5,5. Will attack some troop on 20,20. But must be troops on that 5,5, as attacker and at 20,20 troop who be attack:
  Code:
Actions.GroupOrderAttackUnit(States.GroupAt(5, 5), States.GroupMember(States.GroupAt(20, 20), 0));

I wrote many ways how to movie our troops in diffrent situation :-)

ADDED:
On Next version Kam:Remake going to be command GroupKillAll. But now we can kill One member in Group.
Just ask what for that command? I already added in mine map which i publicate when it be done, (before make look like map).
FOr example i added it for "Robbers will escape", Bombs kill some member in group etc.
  Code:
var Knights: Integer; procedure OnMissionStart; begin Knights := Actions.GiveGroup(0, 22, 10, 10, 2, 10, 3); end; procedure OnUnitTrained(aUnitID: Integer); begin //1 if States.UnitOwner(aUnitID) = 0 // 0 as Player, AI is from 1 then begin //2 Actions.UnitKill(States.GroupMember(Knights, 0),false); //When Player train in school Unit, Knights will loose one member. end; //2 end; //1


At the moment i know many scripts, maybe in that topic some can make question then i try to answer :-)
<<

Brolian

User avatar

Recruit

Posts: 36

Joined: 16 Sep 2014, 19:45

KaM Skill Level: Skilled

Location: Poland

Post 28 Sep 2014, 18:31

Re: Ask for scripts

I send pack of scripts. I created it when i learning make scripts. Maybe it can be usefull for someone.
Many information is in Polish language, but it can be easier to find and learn how scrips work :-)
You do not have the required permissions to view the files attached to this post.
<<

Esthlos

User avatar

Knight

Posts: 676

Joined: 23 Jun 2013, 16:02

KaM Skill Level: Beginner

Post 04 Oct 2014, 15:46

Re: Ask for scripts

This looks like a good place to ask... :P

How do I remove fields or Winefields through scripting?
Just when you think you know something, you have to look at it in another way, even though it may seem silly or wrong. You must try! - John Keating, "Dead Poets Society"
<<

Brolian

User avatar

Recruit

Posts: 36

Joined: 16 Sep 2014, 19:45

KaM Skill Level: Skilled

Location: Poland

Post 05 Oct 2014, 18:56

Re: Ask for scripts

I tried in RC 6619.
I tested and if we have field or winefield, i just added to that tile roadplan. When road is builded on field/winefield, use script remove road.
Then we have got just clear tile :-)
<<

Esthlos

User avatar

Knight

Posts: 676

Joined: 23 Jun 2013, 16:02

KaM Skill Level: Beginner

Post 05 Oct 2014, 20:08

Re: Ask for scripts

Thank you.

Is there no way to do it through scripting only, then? I mean without Laborers, Serfs or stone?
Just when you think you know something, you have to look at it in another way, even though it may seem silly or wrong. You must try! - John Keating, "Dead Poets Society"
<<

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 06 Oct 2014, 03:11

Re: Ask for scripts

There isn't a command for removing fields since that isn't actually possible the way the game works now. When a field is built the game replaces the terrain tile with the tile of the field, so the game doesn't know what terrain was under the field previously. Therefore you can't actually remove a field.
<<

Esthlos

User avatar

Knight

Posts: 676

Joined: 23 Jun 2013, 16:02

KaM Skill Level: Beginner

Post 06 Oct 2014, 06:58

Re: Ask for scripts

Ah, ok.
Just when you think you know something, you have to look at it in another way, even though it may seem silly or wrong. You must try! - John Keating, "Dead Poets Society"

Return to “Dynamic Scripting”

Who is online

Users browsing this forum: No registered users and 9 guests