Map Database  •  FAQ  •  RSS  •  Login

Gnarf

<<

MaxDeus

User avatar

Warrior

Posts: 116

Joined: 08 Jan 2014, 09:05

KaM Skill Level: Fair

Location: Germany

Post 20 Jan 2014, 11:02

Re: Gnarf

And how can i use it?
There it says he wants to have anboolean, so i made

var a: boolean;
a := 2, 34, 72;

if HouseCanReachResources(a) false
------(rest)

it must look like this:
"Returns true if the specified house can reach the resources that it mines (coal, stone, fish, etc.) 1 - House ID Boolean"
what does house ID mean, and why does he ask me for duplicate?
GR
MaxDeus
It is not to be against something, it is to be for something!!!
<<

MaxDeus

User avatar

Warrior

Posts: 116

Joined: 08 Jan 2014, 09:05

KaM Skill Level: Fair

Location: Germany

Post 20 Jan 2014, 21:00

Re: Gnarf

So. Now he only does not know the command HouseCanReachResources anymore.
What can i do to change that? Do i need to use a shortcut?
GR
MaxDeus
It is not to be against something, it is to be for 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 21 Jan 2014, 00:12

Re: Gnarf

States.HouseCanReachResources was added after r5503 so you should use the nightly.

A "House ID" is a pointer to a house. You get it from a function like States.HouseAt(X, Y). For example you could write code like this:
  Code:
procedure OnTick; begin if not States.HouseCanReachResources(States.HouseAt(57, 86)) then Actions.ShowMsg(-1, 'House at 57 87 can't reach resources'); end;
You could also write it like this:
  Code:
procedure OnTick; var House: Integer; begin House := States.HouseAt(57, 86); if not States.HouseCanReachResources(House) then Actions.ShowMsg(-1, 'House at 57 87 can't reach resources'); end;
But you can also get a House ID from Actions.GiveHouse or States.PlayerGetAllHouses (gives you an array of house IDs for all houses the player has), and also certain events like OnHouseBuilt.
<<

MaxDeus

User avatar

Warrior

Posts: 116

Joined: 08 Jan 2014, 09:05

KaM Skill Level: Fair

Location: Germany

Post 21 Jan 2014, 08:38

Re: Gnarf

Yeah. Theanks You made it again. my mistake was to forget the "states" in front of the command.
Now i know that i need it nearly everywhere, exept of the times when i need "action" :)
(Next time i will have a look at the help first, there it sais the same, under the commands...)
GR
MaxDeus
It is not to be against something, it is to be for something!!!
<<

MaxDeus

User avatar

Warrior

Posts: 116

Joined: 08 Jan 2014, 09:05

KaM Skill Level: Fair

Location: Germany

Post 21 Jan 2014, 10:15

Re: Gnarf

next problem:
I want him (player 2) to build a house. No problem, i implemeted the command, but: in the game he cannot build. So he only makes the plan to build something, but does not start to work.
when i give him the command:
  Code:
if not States.HouseCanReachResources(States.HouseAt(24,65)) then begin Actions.AIAutoBuild(2, a); Actions.HouseUnlock(2,3); Actions.PlanAddHouse(2,3,34,71); Actions.PlanAddRoad(2,34,72); ...
he says everything is okay, but in fact, he does not work on it. a: boolean (set as true before).
(maybe the mistake is the boolean-key, but how do i get a boolean-key?)

GR
MaxDeus
It is not to be against something, it is to be for 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 21 Jan 2014, 11:24

Re: Gnarf

You don't need to use a boolean variable. A boolean just means true or false. So you can just put: Actions.AIAutoBuild(2, true);

Also, there's no need to unlock the house or set AIAutoBuild. PlanAddHouse will work regardless of whether the house is unlocked. AutoBuild means the AI will plan his village automatically (like in some campaign missions where the AI just starts with a storehouse and builds a village).

So in your script all you need to do is use PlanAddHouse and PlanAddRoad. Make sure the AI has some labourers and stone/wood otherwise it won't work obviously.
<<

MaxDeus

User avatar

Warrior

Posts: 116

Joined: 08 Jan 2014, 09:05

KaM Skill Level: Fair

Location: Germany

Post 21 Jan 2014, 11:50

Re: Gnarf

But i tries it, and when i only made the house-plan( also the roads), he only made them in the replay. But infact he does not build them, only stand there, don´t do nothing. He has 5 builder, 12 serfs and enough resources. Now it looks like this. (strange fact: the storehouse of the player does not allow to store stones inside, but i don´t say that before...)
  Code:
if not States.HouseCanReachResources(States.HouseAt(24,65)) then begin Actions.PlanAddHouse(2,3,34,71); Actions.PlanAddRoad(2,34,72); Actions.PlanAddRoad(2,33,72); Actions.PlanAddRoad(2,32,72); Actions.PlanAddRoad(2,31,72); Actions.PlanAddRoad(2,30,72); Actions.PlanAddRoad(2,29,72); end;
Maybe i made some mistake at the coordinates of the house? it´s a coalmine, the frontdoor is at 24,65...
But when there is no caol anymore he destroyes the house now.

GR
MaxDeus
It is not to be against something, it is to be for 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 21 Jan 2014, 12:20

Re: Gnarf

If the AI is on auto build they will destroy unusable coal mines and block stone delivery when they have enough in their storehouse. If auto build is off the AI will not manage their own economy at all.

You won't see plans belonging to enemies except in the replay. Are you sure you are using the right player numbers? Remember the script uses player indexes from 0 (so the first player is 0, second is 1, etc.). The labourers should not ignore plans like that if they are for the right player.
<<

MaxDeus

User avatar

Warrior

Posts: 116

Joined: 08 Jan 2014, 09:05

KaM Skill Level: Fair

Location: Germany

Post 21 Jan 2014, 12:29

Re: Gnarf

-.- playernumber -.-
I made 2, instead of 1 :/
Now he destroyes and build a new. Thanks.
GR
MaxDeus
It is not to be against something, it is to be for something!!!
<<

MaxDeus

User avatar

Warrior

Posts: 116

Joined: 08 Jan 2014, 09:05

KaM Skill Level: Fair

Location: Germany

Post 21 Jan 2014, 17:14

Re: Gnarf

And one more:
Is there a command/ can we add one, to place new "tiles" in the game, while playing? I mean: I play for about 1 hour and then there should be a new bridge be builded, for a little amount of res?
GR
MaxDeus
It is not to be against something, it is to be for something!!!
<<

Ben

User avatar

Former Site Admin

Posts: 3814

Joined: 08 Jan 2009, 23:00

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

Post 22 Jan 2014, 00:19

Re: Gnarf

It has been suggested but I believe turned down since it would take a monumental amount of code and work to change a small area of the map.
I used to spam this forum so much...
<<

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 22 Jan 2014, 02:01

Re: Gnarf

It has been suggested but I believe turned down since it would take a monumental amount of code and work to change a small area of the map.
I don't think we've ruled out ever implementing it, but there are quite a few technical issues to sort out first. The game just isn't designed to handle any tile on the map being changed, for example what if you turn a stone tile into grass while a stonemason is mining it? That would cause an error when he tries to remove the hill. There are probably hundreds of cases like this. We either need to overcome these issues so it can cope with changes or somehow prevent the script command from changing tiles that could cause problems.

I agree that it would be cool to dynamically change the map so hopefully we can get around to this in the future :)
<<

MaxDeus

User avatar

Warrior

Posts: 116

Joined: 08 Jan 2014, 09:05

KaM Skill Level: Fair

Location: Germany

Post 22 Jan 2014, 07:32

Re: Gnarf

The game just isn't designed to handle any tile on the map being changed, for example what if you turn a stone tile into grass while a stonemason is mining it?
I did not know that it´s so hard. Than you really have to change many parts of the game. :|
I agree that it would be cool to dynamically change the map so hopefully we can get around to this in the future :)
I will hope for it too, and if you need any help which i can handle, than i´ll be there.
It is not to be against something, it is to be for something!!!

Return to “Dynamic Scripting”

Who is online

Users browsing this forum: No registered users and 13 guests