Page 1 of 1

Semi-procedual problem solved

PostPosted: Mon May 20, 2019 12:00 am
by DazaKiwi
Inspired by Theo's recent post about procedural terrains, I made something similar although not as elaborate with generating several names for a location and it works for the most part except for when any 4 Village locations get a rename, after 3 have been renamed the next village entered i get errors but not a crash.

Over all I think for the other terrain renaming aspect this system is basic enough and should be able to handle adding lots of new location types without a lot of work. With just Creating 1 new location group and one new task and adding the new possible names to the main array.
The village part was an attempt to see if i could have finite names as repeating a name of a village wouldn't make sense.
The villages has a limited number of names to pick just 4 just for demo purposes.

So the idea in simple terms was to track which index Numbers are picked for villages and when all 4 of them picked it should switch to a task that now adds the next new village location to a group that changes the name to Abandoned Village. Thats the idea anyway.

This whole renaming process is done using a single array to store all the types of terrain names and villages and I am moving a dummy character ahead of the Player to match the location (is dummy within group x etc) group and trigger the correct task that selects a name via index of the main array using a rand within a min and max index range for that single array (LocationType_18) The num 18 is the array limit. So that it picks a name befitting the location the dummy character moves to before the player.

Getting back to the Villages problem:
So to track which index numbers have been chosen for the villages i created another clone array called (ArrayIndexChecker) and set all its data to 0 and uses the same index variable as the main array. So when a new index number is picked for a village the index position in the clone array becomes a 1. One of the tasks run checks all 4 indexes are equal to 1 which if true another variable AllVillagesDone is set to 1 and is part of the restrictions for the other 2 tasks that now becomes redundant because all 4 villages player entered now has used a preset name. So at this point any new villages entered into should now move dummy/players location into a group that will change the short desc name to 'Abandoned Village'. But this is where the break down is at the moment.

So the 3 Villages you enter gets a random name given and the 4th one the error kicks in - "Attempting to read index 0 outside of variable LocationType_18(18)" it shows this message 4 times. The debug shows the tasks that should fail do so and the index itself is not 0 at all. So i am a bit mystified as to what is going on and was wondering if someone could have a look, there are only four tasks that handles the villages. All the other parts of the demo works fine.

I hope this write up is clear to understand and when looking at the demo in the dev.

Re: Semi-procedual problem

PostPosted: Mon May 20, 2019 11:48 pm
by DazaKiwi
I have managed to find a solution to this problem and now is working as intended. The error was the fact the villages group property indexes were set to 0 which triggered the error when the player entered the location.

What i did to get it working, I added a 19th array entry called 'Abandoned Villages" and in the group properties of Abandoned Villages set the Index property to 19. All the villages were added to that group, so by default they will be an abandoned village. When the player enters one of these village locations the usual tasks run as described in OP happens and changes it to a new name until all entries from the main array have been used.

I have also a system to have hidden locations that has a chance of being revealed on the map, there are five of these and there can be a chance none of these show. This can work in with the rename system or just be a location on its own with a unique name.

Feel free to use this system and there is a read me with steps.