LukeWolf's Recent Forum Activity

  • dop2000 This is now working very well. I just want to make sure that I have done what you have suggested correctly, in terms of performance. There is just one thing I had to change, though, and you will see it just after the timer is triggered for the building, because "For Each" was working but the person was not constructing buildings in the order they were placed (something I forgot to tell you earlier, but don't worry I worked it out!) What was happening was; because each building had an individual timer that was running at independent times to each other (caused by the player not being able to place all blueprints down at once), a building with a higher Build_ID would get attention first if it's timer triggered first, and the person would just get assigned to the later blueprint instead, so pick all blueprints placed seems to fix that.

    Anyway, please have a look now, I hope I have done this adequately:

  • Hey! I just want to thank you guys for responding despite the forum's current condition, which is very frustrating at the moment.

    Even though I have posted something here, I have been hard at work trying to get this right. This is now working but with terrible side-effects. Event 76 is this currently:

    dop2000 I much appreciate your detailed response and suggestions. I wasn't able to simplify things due to the mess I got myself into. I actually like your idea, however, there is one thing I am not sure about; In my game, my player will be able to place multiple blueprints regardless of people availability/resources. What if all my people are building and there is no one free? How is it possible to have a trigger event in those circumstances if I'm not constantly checking conditions every tick?

  • Extremely slow. It's lagging that much for some people that they have ended up multiple posting. It's also impossible to see anyone's forum profile at the moment; I just get a time out error page with a whole stack of error coding:

    Server Error in '/' Application.

    Source Code:

    "An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below..."

  • Hey guys,

    I'm in a bit of a mess with my project.

    In my game, people can construct buildings. However, I can get one person to construct a building, that's fine. But if I have more than one person that can build something, everyone rushes to build it which is not suppose to happen. I simply cannot get it to happen properly. I basically want the closest available person to be picked for the job.

    What happens:

    Buildings:

    For every building placed by the player, the game assigns that building with a unique Build_ID value from the Build_ID global variable which incrementally increased when a building blueprint is placed but before it gets assigned to the building. In this state, the building initially has Builder_On_The_Way set to false and Construction_Progress set to 0. Then the building waits for a person to come and construct it.

    Person:

    People (Person) sprites by default have their status set to 0 so they will just "wander around". The game currently sets the position of the Pathfinding_Destination_Helper sprite to a random co-ordinate on the layout (I use the helper sprite so I can get a visual of where they are going). Their status is set to 0, and by default when set to 0, their BuilderAvailable boolean is also set to false. Under these conditions, a person is available to be assigned a building to construct if they are the closest person to it.

    I believe the problem lies here somewhere, but I can't make sense of it.

    So you understand the statuses:

    Assigning builders:

    Please help, I'm going mad!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Hey dop2000

    Thanks again for your feedback and suggestions. Sorry I took so long getting back to you, here. To my dread, I had a number of boring real life things to deal with, as you do.

    I took up your recommendation about the progress variable which will change for each building depending on the stage it is up to. I think based on this, it should become very easy to create more buildings simply by checking the "Currently_Building" variable on the construction site:

    I hope this is good now.

  • Hey dop2000

    This seems to work all right, but I just wanted to share my C2 code to see if I've done it properly:

  • Oh wow, it was that simple. It just goes to show how much I'm over complicating things with my project. I definitely need to work on that!

    Thanks for your help again, Dop. You're amazing!

  • Thanks again

    I'll definitely look into the Timer and how I can use it to make my game better.

    Just one thing though. Since I implemented the formula you suggested, the growing rate is working perfectly with the construction_Timer now, but I'm struggling setting the position of the building so it only looks like it's growing from the ground not growing out from the middle if that makes sense.

  • Thank you for your response dop2000

    Yes my Construction_Timer variable is an instance variable for the Construction_Site object which is only going to be used during a construction and is set to instances of that object.

    Basically when a building is being constructed, I flatten the height of the building to 0 and then every 0.1 seconds, I want the building to increase in size by 1% of the total height of the building until it reaches its total max height (so it looks like it's growing from the ground). But this needs to happen over a specified construction time, so if I make the construction timer 10 seconds, then it will be 1% of the buildings total height every 0.1 seconds but if the building's total construction timer is 30 seconds, then obviously the 1% will change over that period of time, because some buildings are expected to take longer than others to build depending on the type of building I have for my game, then I need the right formula to get this right.

    Let me provide a more specific example of what I'm experiencing:

    Let's put the construction timer at a total of 10 seconds, so it will take 10 seconds for my building to complete. The total height of the building is 128 pixels. The construction_timer variable reduces every 0.1 seconds, so we have to consider changing the height of the building every 0.1 seconds.

    My old code was this.

    The building grows and finishes exactly as the construction_timer finishes.

    However, if I do this (where I want to reduce hard-coding and magic numbers):

    The building finishes growing at the construction_timer value of 3.7, so the building finishes growing 3.7 seconds earlier than it should.

    I will try your suggestion of using the timer behaviour but please tell me what's wrong with my formula in those event blocks, because I will be using the same sort of idea with the timer behaviour.

    Edit: I tried using the timer but it does not allow me to perform actions every 0.1 seconds. I do not believe I can achieve what I want to achieve with this behaviour, so I will need to do it the way I have been, but I need to work out what I am doing wrong here.

  • Hey guys,

    In my game, my people will be constructing buildings using a 'growing' method where the width stays at the maximum possible value but the height will start at 0 but will gradually increase in height every 0.1 seconds. For this example, the total height of the building is 128 and the construction timer is currently set to 30 seconds.

    What I'm trying to achieve is no hard code, basically; If I adjust the height or the construction_timer values simply for different kinds of buildings, then I want construct 2 to adjust to the new values automatically. Unfortunately my attempt here demonstrates that the building gets completed 9 seconds early (or if the construction time is 10 seconds, its out by 3.7 seconds early) (you will need to copy the image address to get the full image because this post is cutting important information out):

    Please tell me what I'm doing wrong.

    Thanks in advance for your wonderful help!

  • Thanks again, Plinkie! Sorry about the confusion between my edits!

    Yes, I do. It's just not explained in these screenshots very well. You will notice that on the first block of the Construction Complete group that I set Person's Status value to 0. This checks:

    Conditions:

    Person Status = 0 (defined as wander status)

    Person Wander_Path_Cooldown = 0 (another cooldown system where a person will pause for up to couple of seconds when they reach their destination before moving to the next random coordinate),

    Person Not Pathfinding calculating path

    Person Not Pathfinding moving along path

    Actions:

    Person find path to (random(LayoutWidth), random(LayoutHeight)).

    Simple action for this status for the current stage of development.

  • I got it!

    I couldn't just check to see if anyone was overlapping the building or not straight away, I had to create some more variables:

    1) I created a boolean called "Built" - When the person finishes constructing the building, this boolean will be set to true.

    2) I created a variable called Cooldown_Construction_Brand_New with the initial value set to 3 - every second if the value of this is higher than 0, and the boolean "Built" is true, then subtract 1 from this variable.

    Once the Cooldown_Construction_Brand_New variable is 0, Person is not overlapping building and building is not a solid, set solid behaviour to Enabled and then regenerate pathfinding obstacle map.

    As for the person: I don't need the 8direction behaviour (since setting 8direction down would be bad if the building was against some sort of obstacle in that direction and they would not be able to leave it properly). The person will just walk out of the building in whatever direction they deem possible to get out of with their pathfinding behaviour and 'wander' status that I have set and because the building has not become a solid yet due to the cooldown delay, there are no issues with pathfinding, so after they are no longer overlapping buildings, I can set their collision and solid behaviour back to true (that's what the Still_On_Construction_Site boolean is doing when it goes to false).

    Here's a screenshot of my events. Please tell me if you agree with my solution or if there's something better:

    Edit: I made some adjustments because I realised that the last event is not going to work at all, haha:

LukeWolf's avatar

LukeWolf

Member since 14 Jul, 2015

None one is following LukeWolf yet!

Trophy Case

  • 9-Year Club
  • Jupiter Mission Supports Gordon's mission to Jupiter
  • Forum Contributor Made 100 posts in the forums
  • Regular Visitor Visited Construct.net 7 days in a row
  • RTFM Read the fabulous manual
  • Great Comment One of your comments gets 3 upvotes
  • Email Verified

Progress

15/44
How to earn trophies