Page 12 of 26
Re: Dynamic Script Usage
PostPosted: 12 Jun 2013, 17:58
by Islar
if i want the allie AI not to share his covered fog than i must use this right?
- Code:
procedure OnMissionStart;
begin
Actions.PlayerShareFog (0, 2, false);
Actions.PlayerShareFog (0, 3, false);
Actions.PlayerShareFog (0, 4, false);
Actions.PlayerShareFog (0, 5, false);
Actions.PlayerShareFog (0, 6, false);
end;
Everyone, except player 8, is allied. what i want is to not see the AI's buildings and units when the game starts (thats what i want to plan later (i know how))
is it because player 2 and everone can see the allie and give that ''information'' to my so i can see it? Or do i use it wrong?
Edit:
If i want to change the AI aliance to enemy when 2 towers are destroyed at a certain place (for example 12:12 and 20:20) how can i make this. I also want when i destroy the towers the AI aliance changes to allie again.
Re: Dynamic Script Usage
PostPosted: 12 Jun 2013, 20:08
by Siegfried
- Code:
procedure OnMissionStart;
PlacedWoodcutter := False;
begin
The 'begin' marks the start of that procedure. So you have to put it after that:
- Code:
procedure OnMissionStart;
begin
PlacedWoodcutter := False;
end;
Re: Dynamic Script Usage
PostPosted: 13 Jun 2013, 09:26
by Islar
i have this script. The houses that planned are build so as i want to. But when i want them to build the goldmine they only build the road and not the goldmine. How can that be? the goldmine is the last one.
- Code:
procedure OnHouseBuilt(aHouseID: Integer);
begin
if States.HouseOwner(aHouseID) <> 3 then
Exit;
if (States.HouseType(aHouseID) = 13) then
begin
//dorp noordwest
Actions.PlanAddHouse (3, 14, 39, 94);
Actions.PlanAddRoad (3, 39, 95);
Actions.PlanAddRoad (3, 38, 95);
Actions.PlanAddRoad (3, 37, 95);
Actions.PlanAddHouse (3, 14, 43, 95);
Actions.PlanAddRoad (3, 43, 96);
Actions.PlanAddRoad (3, 42, 96);
Actions.PlanAddRoad (3, 42, 97);
Actions.PlanAddRoad (3, 42, 98);
Actions.PlanAddRoad (3, 41, 96);
Actions.PlanAddRoad (3, 41, 95);
Actions.PlanAddRoad (3, 40, 95);
end;
if States.HouseOwner(aHouseID) <> 3 then
Exit;
if (States.HouseType(aHouseID) = 14) then
begin
Actions.PlanAddHouse (3, 9, 30, 87);
Actions.PlanAddHouse (3, 9, 31, 84);
Actions.PlanAddRoad (3, 31, 85);
Actions.PlanAddRoad (3, 31, 86);
Actions.PlanAddRoad (3, 31, 87);
Actions.PlanAddRoad (3, 31, 88);
Actions.PlanAddRoad (3, 31, 89);
Actions.PlanAddRoad (3, 31, 90);
Actions.PlanAddRoad (3, 31, 91);
Actions.PlanAddRoad (3, 31, 92);
Actions.PlanAddRoad (3, 31, 93);
Actions.PlanAddRoad (3, 30, 88);
end;
if States.HouseOwner(aHouseID) <> 3 then
Exit;
if (States.HouseType(aHouseID) = 9) and not PlacedSawmill then
begin
PlacedSawmill := True;
Actions.PlanAddHouse (3, 0, 33, 89);
Actions.PlanAddRoad (3, 33, 90);
Actions.PlanAddRoad (3, 32, 90);
end;
if States.HouseOwner(aHouseID) <> 3 then
Exit;
if (States.HouseType(aHouseID) = 0) then
begin
Actions.PlanAddHouse (3, 5, 49, 81);
Actions.PlanAddHouse (3, 5, 53, 82);
Actions.PlanAddRoad (3, 49, 82);
Actions.PlanAddRoad (3, 49, 83);
Actions.PlanAddRoad (3, 50, 83);
Actions.PlanAddRoad (3, 51, 83);
Actions.PlanAddRoad (3, 52, 83);
Actions.PlanAddRoad (3, 51, 84);
Actions.PlanAddRoad (3, 51, 85);
Actions.PlanAddRoad (3, 51, 86);
Actions.PlanAddRoad (3, 51, 87);
Actions.PlanAddRoad (3, 51, 88);
Actions.PlanAddRoad (3, 51, 89);
Actions.PlanAddRoad (3, 51, 90);
Actions.PlanAddRoad (3, 51, 91);
Actions.PlanAddRoad (3, 51, 92);
Actions.PlanAddRoad (3, 51, 93);
Actions.PlanAddRoad (3, 51, 94);
Actions.PlanAddRoad (3, 51, 95);
Actions.PlanAddRoad (3, 51, 96);
Actions.PlanAddRoad (3, 51, 97);
Actions.PlanAddRoad (3, 51, 98);
Actions.PlanAddRoad (3, 51, 99);
Actions.PlanAddRoad (3, 51, 100);
Actions.PlanAddRoad (3, 51, 101);
Actions.PlanAddRoad (3, 51, 102);
Actions.PlanAddRoad (3, 50, 102);
end;
end;
Re: Dynamic Script Usage
PostPosted: 13 Jun 2013, 10:09
by Lewin
Check that you can place a gold mine at the coordinates you entered (select gold mine in the map editor and make sure it lets you place it there). You need to use the coordinates of the door.
Re: Dynamic Script Usage
PostPosted: 13 Jun 2013, 10:18
by Islar
Check that you can place a gold mine at the coordinates you entered (select gold mine in the map editor and make sure it lets you place it there). You need to use the coordinates of the door.
I checked it again, but it is possible to build the gold mine there and the coordinates are correct. Could it be something else?
Re: Dynamic Script Usage
PostPosted: 13 Jun 2013, 10:27
by Lewin
Check that you can place a gold mine at the coordinates you entered (select gold mine in the map editor and make sure it lets you place it there). You need to use the coordinates of the door.
I checked it again, but it is possible to build the gold mine there and the coordinates are correct. Could it be something else?
Maybe, send me a test map where it happens and I'll see what's going on.
Re: Dynamic Script Usage
PostPosted: 13 Jun 2013, 11:31
by Lewin
The problem is the place where you put the goldmines is unexplored for the AI, and PlanAddHouse currently only works if the location is explored. That's not how it should work (AIs should be allowed to plan houses in unexplored areas) and we'll fix this, but for now you can just reveal that hill for the AI.
Re: Dynamic Script Usage
PostPosted: 13 Jun 2013, 13:18
by Islar
Could someone help my?
I my map a tower is destroyed by the enemy, i want to cover that part of the map when the tower is destroyed. How do i use it?
- Code:
Procedure OnHouseDestroyed (aHouseID: Integer; aDestroyerIndex: Integer);
begin
//Toren1
if States.HouseOwner(aHouseID) <> 2 then
Exit;
if(aHouseID = States.HouseAt(81, 153)) then
begin
Actions.FogCoverCircle (0, 83, 137, 20);
Actions.FogCoverCircle (1, 83, 137, 20);
Actions.FogCoverCircle (0, 111, 147, 20);
Actions.FogCoverCircle (1, 111, 147, 20);
end;
end;
I tried this but i did not work
Re: Dynamic Script Usage
PostPosted: 13 Jun 2013, 13:41
by Lewin
Try testing which part is not working. Put this line somewhere and you will get a message when the game reaches that code:
Actions.ShowMsg(-1, 'Test');
So for example, put it inside the if-statement with your CoverCircle commands and then you'll get a message when that code is run. You can also test values of things. For example try this line before your if-statement:
Actions.ShowMsg(-1, 'ID: '+IntToStr(aHouseID)+' tower ID: '+IntToStr(States.HouseAt(81, 153)));
Then you can see the IDs of the two houses it's trying to compare. Tell me what the IDs are when the tower is destroyed and maybe I can help you further.
By the way, your code will only work if the tower is owned by player 2, since you Exit if it's not 2.
Re: Dynamic Script Usage
PostPosted: 13 Jun 2013, 14:05
by Islar
i get an error thats says ''Warnings in script [Error] ONHOUSEDESTROYED(409:1); Type mismatch''
Re: Dynamic Script Usage
PostPosted: 13 Jun 2013, 14:51
by Lewin
i get an error thats says ''Warnings in script [Error] ONHOUSEDESTROYED(409:1); Type mismatch''
Well, show me the code around line 409 and I might be able to help you

(lines numbers shown on the left side of Notepad++, and the current line is shown in the status bar at the bottom)
Re: Dynamic Script Usage
PostPosted: 13 Jun 2013, 15:27
by Islar
i get an error thats says ''Warnings in script [Error] ONHOUSEDESTROYED(409:1); Type mismatch''
Well, show me the code around line 409 and I might be able to help you

(lines numbers shown on the left side of Notepad++, and the current line is shown in the status bar at the bottom)
that's is just the strange think, i don't have anything on line 409
- Code:
Procedure OnHouseDestroyed (aHouseID: Integer; aDestroyerIndex: Integer);
begin
Actions.ShowMsg(-1, 'ID: '+IntToStr(aHouseID)+' tower ID: '+IntToStr(States.HouseAt(81, 153)));
end;
end; is on line 408.
i tried the same with this but i get the same error but then on line 419
- Code:
Procedure OnHouseDestroyed (aHouseID: Integer; aDestroyerIndex: Integer);
begin
//Toren1
if States.HouseOwner(aHouseID) <> 2 then
Exit;
if(aHouseID = States.HouseAt(81, 153)) then
begin
Actions.FogCoverCircle (0, 83, 137, 20);
Actions.FogCoverCircle (1, 83, 137, 20);
Actions.FogCoverCircle (0, 111, 147, 20);
Actions.FogCoverCircle (1, 111, 147, 20);
end;
end;
the last end; is on line 418
Re: Dynamic Script Usage
PostPosted: 13 Jun 2013, 15:42
by Siegfried
This error means, that you have assigned a wrong type.
It happens for example when you try to assign a text to a number like this:
- Code:
var
number: integer;
procedure DoSomething;
begin
number := "lalala";
end;
This problem can be less apparent, for example when you try something like
- Code:
var
number: integer;
text: string;
procedure DoSomething;
begin
number := text;
end;
In your case, you did assign a wrong type to your global variable 'ONHOUSEDESTROYED' somewhere. Just cycle through every ONHOUSEDESTROYED in your code and check if something wrong is happening.
The validator does not show the line numbers in this case. So as sad as this is, we can't help you finding the particular error without having access to the whole script. You'll have to find it by your own. Sorry.
Re: Dynamic Script Usage
PostPosted: 14 Jun 2013, 09:00
by Tef
Please use a record instead of that two dimensional array, it's much neater
Oh...oh...wow...'records' finally make any sense to me now!
*seriously starts rewriting a whole lot of dynamic scripts*
Re: Dynamic Script Usage
PostPosted: 14 Jun 2013, 09:39
by Lewin
Please use a record instead of that two dimensional array, it's much neater
Oh...oh...wow...'records' finally make any sense to me now!
*seriously starts rewriting a whole lot of dynamic scripts*
Glad to hear it!

That's the great thing about helping people publicly on the forum, everyone can benefit from it.