Map Database  •  FAQ  •  RSS  •  Login

Scripts duplicate wares from code. HELP

<<

Paulpolska

Blacksmith

Posts: 25

Joined: 21 Aug 2012, 07:59

KaM Skill Level: Skilled

Post 04 Jan 2015, 12:46

Scripts duplicate wares from code. HELP

Scripts should give me wares If I have right buildings like this

If I have one Sawmill I have 5 longbows but if I have 2 sawmills script gives me 20 longsbows instead of 10 why ?? Of course with other buildings problem is the same like this.
  Code:
function GiveWaresTo:integer; var A: array of integer; j, k: integer; begin for j:= 0 to 3 do begin if States.PlayerEnabled(j) and ( States.PlayerDefeated(j) = false ) then begin A:= States.PlayerGetAllHouses(j); for k:= 0 to Length(A)-1 do begin //Length(A)-1 if HouseTypeToWare(States.HouseType(A[k])) = 0 then begin Actions.GiveWeapons(j, 24, 5*States.StatHouseTypeCount(j,0)); end; // - It's here. I dont understand this. if HouseTypeToWare(States.HouseType(A[k])) = 2 then begin Actions.GiveWeapons(j, 17, 4*States.StatHouseTypeCount(j,2)); end; if HouseTypeToWare(States.HouseType(A[k])) = 5 then begin Actions.GiveWares(j, 7, 4*States.StatHouseTypeCount(j,5)); end; if HouseTypeToWare(States.HouseType(A[k])) = 7 then begin Actions.GiveWares(j, 10, 10*States.StatHouseTypeCount(j,7)); end; if HouseTypeToWare(States.HouseType(A[k])) = 10 then begin Actions.GiveWeapons(j, 19, 8*States.StatHouseTypeCount(j,10)); end; if HouseTypeToWare(States.HouseType(A[k])) = 12 then begin Actions.GiveWeapons(j, 26, 5*States.StatHouseTypeCount(j,12)); end; if HouseTypeToWare(States.HouseType(A[k])) = 15 then begin Actions.GiveWares(j, 7, 8*States.StatHouseTypeCount(j,15)); end; end;end;end; end;
<<

netbeck

User avatar

Peasant

Posts: 1

Joined: 13 Feb 2014, 16:38

KaM Skill Level: Beginner

ICQ: 462003227

Location: Internet

Post 19 Jan 2015, 18:21

Re: Scripts duplicate wares from code. HELP

Ahoi, Paulpolska! :D

It would be better if you post all relevant functions for this code, so people can try it and have a better chance to find your mistakes.

I don't know what this function does --> HouseTypeToWare... (?)

But I guess the problem in your code is that you run it for every single house, but if you find a Sawmill you will add (5 * count of house types) longbows instead of (just) 5.

Every house will give (5 * count of house types) wares.
So if you have one Sawmill you will add 5x1 longows, if you have 2 Sawmill you will add 5x2 + 5x2 longbows, 3 Sawmill = 5x3 + 5x3 + 5x3 longbows and so on.

:idea:
You should just add 5 longbows for each Sawmill. (Not 5 * count of house types).
Or you only write for each house add number of house types * 5.


If this doesn't help or is not the problem please post more code or PM me.

Return to “Dynamic Scripting”

Who is online

Users browsing this forum: No registered users and 5 guests