Map Database  •  FAQ  •  RSS  •  Login

I need help, please

<<

ShabanS

Peasant

Posts: 2

Joined: 25 Dec 2019, 17:06

Post 25 Dec 2019, 17:23

I need help, please

Ok so I like wanted to start my own project of customizing maps and stuff, however I am not even sure if what I am trying to achieve is actually possible.

Let me get this straight, I love the game however I think that some adjustments need to be made in order for it to be made playable.

At least in terms of multiplayer or skrmish, now what I want is the following, I want to make say a map where coal miner gives 3 coal instead of one every time he enters a house.

I also want to know HOW TO SCRIPT properly cuz thats the only things I want to add, I dont need any compaign like experience I just want to modify some things to my extent to make the game more playable.

So let me get this straight, can someone please make a map similar to this and have the description so I can edit and change it.

Either this or the fact that resources magically return and go back each time they are exhausted.

Please my coding skills arent that graet, and I would apreciate anyone offerning me any practical advice on a map that I can actuallY SSEE its effect and how its made.

So, anybody?
<<

Darnavir

Serf

Posts: 9

Joined: 26 Dec 2019, 21:43

Post 26 Dec 2019, 22:08

Re: I need help, please

I made a script replenishing mines long ago for my own use. It's a bit of brute force (restoring mineable tiles to their starting content) because of lack of better options when it was made. It might have a slight performance impact, but it works with any map. I can't upload it there, used pastebin instead.

https://pastebin.com/MqcaSNBm
<<

ShabanS

Peasant

Posts: 2

Joined: 25 Dec 2019, 17:06

Post 27 Dec 2019, 14:15

Re: I need help, please

Intersting

After some issues with lunch, apperantly i got some mesasge that "script could not start" I deleted some of the files mostly commentary and now it WOKRS!

Althoughi twasnt exactly what i Planned for, but thanks anyway.

However, if somebody ever finds a way to say, have more breadf from flour or something and to know how to edit these things, please let me know :D

Thanks!
<<

Darnavir

Serf

Posts: 9

Joined: 26 Dec 2019, 21:43

Post 27 Dec 2019, 16:45

Re: I need help, please

As of version 6720, making houses produce more items at once is complicated because there is no way to directly detect when a house finished production. At least it isn't documented at https://github.com/Kromster80/kam_remak ... amicEvents
The only way of doing it I see would be checking every producing house all the time (like every second) and when there are more products then there were the previous check, add desired amount. Of course, this would also require storing previous resource values and whether it has been changed since last production. Given how often it would have to be done, there might be a significant performance impact too. If in the beta there are DynamicEvents telling when a house produced something or a tile got changed (no idea what is in the beta), these scripts would be far simpler and easy to implement.
<<

grayter

Barbarian

Posts: 107

Joined: 18 Aug 2014, 12:06

KaM Skill Level: Skilled

Location: Poland

Post 27 Dec 2019, 18:42

Re: I need help, please

...there is no way to directly detect when a house finished production.
You are completely wrong. There is new version of remake, there is no point to create maps for older one. You need to use OnWareProduced event and detect house type and produced ware. Use Rey's wiki instead of Krom's. You can find it here: https://github.com/reyandme/kam_remake/ ... amicEvents
<<

Darnavir

Serf

Posts: 9

Joined: 26 Dec 2019, 21:43

Post 27 Dec 2019, 19:57

Re: I need help, please

Are any of these new versions considered official and stable? As far as the website goes, the last official stable version is 6720. Given that OP is a new user, I assumed he doesn't have a newer version than 6720 anyways.
Also, that OnWareProduced event would make what OP wants easy.
<<

grayter

Barbarian

Posts: 107

Joined: 18 Aug 2014, 12:06

KaM Skill Level: Skilled

Location: Poland

Post 27 Dec 2019, 20:44

Re: I need help, please

Are any of these new versions considered official and stable?
Nope, each version after 6720 is considered as beta. But sooner or later it will be official :)
<<

Darnavir

Serf

Posts: 9

Joined: 26 Dec 2019, 21:43

Post 27 Dec 2019, 22:55

Re: I need help, please

I checked it in r10240 and Events.OnWareProduced doesn't help. At all. The problem is that adding wares to a building that produces that type of ware counts as ware production and starts an infinite loop. I wanted to play with that, but, unless this changes (I have no idea how the game internally handles production), it seems too complicated and time consuming.
Also, while "natural" production can exceed 5 items stored (when more than 1 are produced at once), Actions.HouseAddWaresTo doesn't allow to exceed this limit. Apparently, it wasn't meant to tamper with production numbers. :?
<<

Esthlos

User avatar

Knight

Posts: 676

Joined: 23 Jun 2013, 16:02

KaM Skill Level: Beginner

Post 28 Dec 2019, 01:49

Re: I need help, please

I checked it in r10240 and Events.OnWareProduced doesn't help. At all. The problem is that adding wares to a building that produces that type of ware counts as ware production and starts an infinite loop. I wanted to play with that, but, unless this changes (I have no idea how the game internally handles production), it seems too complicated and time consuming.
You could use a global counter: increase it by how many wares you add.
Then, in OnWareProduced, add a check: if the counter is > 0 then reduce it by 1 and exit; else, add the wares (to both the house and the counter).
Also, while "natural" production can exceed 5 items stored (when more than 1 are produced at once), Actions.HouseAddWaresTo doesn't allow to exceed this limit. Apparently, it wasn't meant to tamper with production numbers. :?
Another global counter: keep checking on that house (store its id in a global variable) and, when its wares drop below the max, add what part can be added of the bonus.

Personally, the global counter I'd use would look like
  Code:
gBonusWares: array of Record iSkip, iBonus, iWare, iHouse: Integer; end;
where iHouse is the id of the house to be checked and iWare the id of the ware.

Then, OnWareProduced for me would look like:
  Code:
begin for i := 0 to Length(gBonusWares)-1 do if (aHouse = gBonusWares[i].iHouse) AND (aType = gBonusWares[i].iWare) then begin if (gBonusWares[i].iSkip > 0) then gBonusWares[i].iSkip := gBonusWares[i].iSkip-1 else gBonusWares[i].iBonus := gBonusWares[i].iBonus+[BONUS QUANTITY TO BE ADDED]; Break; end; //If this house is not in the array then either add it from here or from OnHouseBuilt end
Lastly, OnTick (divide the global counter by player id when saving it (e.g. declaring it as array of array of Record) to get a lighter load; "iPlayer := States.GameTime mod States.LocationCount;" can then be used to manage the "turns" for each player's counter):
  Code:
begin for i := 0 to Length(gBonusWares)-1 do begin iQty := Min(5-States.HouseResourceAmount(gBonusWares[i].iHouse, gBonusWares[i].iWare), gBonusWares[i].iBonus); if iQty > 0 then begin gBonusWares[i].iBonus := gBonusWares[i].iBonus-iQty; gBonusWares[i].iSkip := gBonusWares[i].iSkip+1; //Or +iQty? How many times does this proc OnWareProduced? Actions.HouseAddWaresTo(gBonusWares[i].iHouse, gBonusWares[i].iWare, iQty); end; end; end;
(Using "with gBonusWares do" would make it more readable)
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"
<<

Darnavir

Serf

Posts: 9

Joined: 26 Dec 2019, 21:43

Post 28 Dec 2019, 13:30

Re: I need help, please

I thought about it some more and I don't really like any of the options I found. There is no event on wares taken from a house, so the only way to do this would be using OnTick all the time. There are too many possible house IDs, so they have to be stored in an array that would have to be searched all the time (making an array with indexes equivalent to the house IDs is impossible). Each player having a different array seems like a good idea and for all practical purposes, checking the houses something like every 2 seconds is fine. Tying wares and house IDs could be useful for weapon production because of multiple possible products.
Also, I imagined the global counter for addition more like true/false, where if false, OnWareProduced would change it to true, if true, the script would work and change it to false. Adding wares by HouseAddWaresTo would change it to false as well.
My main concern with this approach is searching. OnWareProduced would need counters associated with the house ID and that would mean checking half the existing house IDs on average every time a house produces something or something is added to it. Also, major traffic jams or insufficient serfs could significantly increase the number of OnWareProduced calls when too many houses produce more than 1 item at once, because the houses can be producing when already full and call OnWareProduced with every item taken. I don't know how fast/slow it would be without testing, might try it later.

Edit:
I looked into it and made a script for r10240 (not compatible with r6720 and unknown compatibility with later releases). Unless something major changes with Actions.OnWareProduced procedure, it hopefully won't stop working. There are probably some forgotten no longer used variables etc. but it seems, that it can reliably change the amount of wares houses produce. Performance doesn't seem that bad, 1 player with a smallish town could run on x10 speed without slowdowns. A scenario of several big cities is untested and might not perform very well. If someone wants to look at it, there's a link:
https://pastebin.com/7U75NqG8

Return to “Map Design”

Who is online

Users browsing this forum: No registered users and 16 guests