Issue with inventory system/couple other things

This forum is currently in read-only mode.
From the Asset Store
A collection of various characters spritesheets for creating a 2D top down, RPG, tower defense, or other similar game.
  • Alright. I'm working on doing a large-scale re-make of Rogue Survival (it's a zombie survival roguelike). I've currently implemented grid-based movement (I've got a few questions with that), randomized clothing, a semi-working inventory system, locational-based damage (head/torso/arms/legs). Things I will need to implement include procedurally generated cities (I was thinking doing five to ten building templates, as well as a couple road templates and have a random() function place them along the grid, and as long as the buildings were next to a road it would place it, but I definitely need help there. It's a major part of the gameplay), a proper firearm system (which will work like this: You press F. The game draws a line from your player to the enemy, and this determines the chance of hitting and whether or not there is obstacles in the way. If there's no obstacles in the way, then if you press F again it fires your weapon. If it hits, it displays the amount of damage applied to the target. If it misses, it displays a small MISS icon in the upper-right hand corner of the target. Pressing T while in fire-mode will switch targets. I know how to do most of this, I will list below what I need help with), a field of vision system exactly like this (http://2.bp.blogspot.com/_yvDooAP63r8/T ... banner.jpg), an AI for civilians, a trading system (already know how I'm gonna do this), and a few other things.

    My main problems I'm having at the moment:

    For some reason, with the Inventory system, I've implemented a system that will automatically place objects in the proper inventory slots based on whether or not there is an object in the first/2nd/etc slots. It works perfectly with the actual player inventory, but with the ground inventory (this shows what objects are on the ground), for some reason it will place the object in the first box for a millisecond, then it gets moved to the second box and stays there. I cannot for the life of me figure out why this is being caused; Both scripts are nearly exactly the same, save for some X-position changes due to one inventory-bar being over the other. It's quite puzzling; I'll upload the .cap at the end of this post.

    I need someone to explain to me the best way to do a field of vision system like the one in the screenshot. At the moment I have a simple circular area being lit up, and everything else is black; I need a system that will light up the tiles around me, and in the field of view (which is 360degrees). See the screenshot I posted above for reference. After the tiles have been 'seen', instead of going 100% black after moving, they will have a 50% opacity. This is what I need most help on, and it's also probably THE most if not 2nd most important thing I need to get done.

    I also need some help with the firearms system. I can do the whole thing, but I can't figure out how to have the change-target function work correctly. I can't find a function to find the closest object to the player (in a family), does anyone know of one?

    My number-one important problem right now is the procedurally generated city. I need to find out a way to place buildings (made up of multiple types of tiles), roads, and objects in the already-placed buildings. This is THE most important thing I need to get done; After this, I will be much closer to completion.

    Here is the .cap; look at the events layout, and the GroundInventorySlotNumber variables. If you can figure out why the ground inventory is being such a 'tard, it would be greatly appreciated, as I will be able to move on to other things. Thanks.

    http://filesmelt.com/dl/roguescirrasurvival.cap

  • Here's a quick cap for rogue-like movement

    http://dl.dropbox.com/u/1646976/rogue-movement.cap

    Made with 0.99.82

  • Quick field of vision example.

    http://dl.dropbox.com/u/1646976/rogue-fieldofvision.cap

    Uses a Canvas so depending on the size of your Layout it might not be very efficient. But for a small layout it works very well.

  • Here's a quick cap for rogue-like movement

    http://dl.dropbox.com/u/1646976/rogue-movement.cap

    Made with 0.99.82

    Awesome, thanks a lot bud!

    Edit:

    That field of vision is nearly perfect. There's only one thing.. It's not blocked by objects. I'm not sure if that screenshot showed exactly what I'm trying to get, look at this one:

    <img src="http://filesmelt.com/dl/example12345678.png">

  • Hi. I don't know if you know of RogueBasin, but there is a link to some articles on line of sight and field of vision. There are tons of other articles, links, and other great content there, too. You can find good info on procedural generation of content there as well.

    I think the problem that you had with the inventory may have been due to Else statements. They work a bit better with the newer versions of Construct, but it's best to keep them as simple as possible if you use them. I've not been able to get them to work reliably in nested code.

    For picking closest enemies, there is a condition for that. Look for the Pick group under conditions. There are a few picking options there. You can do something like:

    + Enemies: Pick closest to: Player.X, Player.Y -> (do action to enemy here)

    A couple of other tips:

    I also noticed that you have a lot of unnecessary Always (every tick) conditions in there. Those are useful if that's the only thing there for a condition. If you already have another condition there, you don't need to add the Always, as it will always check the condition anyway, unless it's in a sub-event of another condition...

    With your clothing system, if you plan to add to it, you may want to look into making one sprite for each type of item, and put the variations of it into different animation frames of the sprite. Then you can just set the one sprite for each type of item to the proper frame. You could also possibly use the Container functionality to keep them on the sprite, or only update them when the character moves.

  • I have made (well, not made, the current sprites are just placeholders in a way, it's complicated lol) the articles of clothing into seperate sprites (if that's what you mean). I have a seperate sprite for hair, eyes, torso, legs and feet. The current way I've implemented the randomization is working quite well. I plan on having a LOOOOT of different articles of clothing, and after implementing the rogue-like movement that Minor made, the clothes lag behind the character for a tick or two after moving. Is there any way to remedy this without having to put actions on each clothing event? That would take ages and probably be very inefficient.

    Edit:

    I just got an idea on how to do proper Field of Vision. What if I split that Eraser into 13 separate 32x32 blocks, then run a check every time the player moves to see if the blocks are overlapping an object in the terrain family. If they are, destroy the FOV-block that is overlapping, and I'll have an else function that will create an object at the same offset coordinates (if it is not overlapping any solids). I will do this event for every block (13 isn't TOO bad). The outside blocks will be very simple (pseudocode):

    If FOVBlock1 is overlapping ObjectFamily.Terrain, then

    Destroy FOVBlock1

    Else

    If FOVBlock1 is not overlapping ObjectFamily.Terrain, then

    Create FOVBlock at offset position Player.X+146, Player.Y

    ^Do this for all outside blocks^

    Then for the inner eight blocks:

    If FOVBlock5 is overlapping ObjectFamily.Terrain, then

    Destroy FOVBlock5, FOVBlock1

    Do this for all the inner blocks, but change FOVBlock1 to the corresponding outer FOVBlock# (say FOVBlock1 is the top block, FOVBlock5 is the block right under that)

    I will try this and see how it works, as well as the performance hit (if any). Hopefully this will work as I think it will

    Also, forgot to mention. The blocks will follow the player via a position offset, like so. The top block is 32x32, and the size of the whole thing is 160x160; therefore, the position of the top block will be Player.X+146, Player.Y. I will test this and tweak it until it forms the correct shape, I'm really hoping this will work well as it will have everything I want from the Field of Vision Then I'll move on to making an actual HUD, then probably firearm handling.

    Do you guys see any problems with this (issues you think might happen)? I realized it will take a good amount of time to implement and want to see if the more experienced people with this program think it will or won't. Thanks

  • Here's an example FOV engine with walls that bock vision. Also it uses the imagemanipulator object so less resources are used than using the canvas object.

    http://www.scirra.com/forum/viewtopic.php?f=16&t=6679&start=0

  • Here's an example FOV engine with walls that bock vision. Also it uses the imagemanipulator object so less resources are used than using the canvas object.

    http://www.scirra.com/forum/viewtopic.php?f=16&t=6679&start=0

    I attempted to apply that engine into my game, but I think some of the variables you used in the event layout in yours are dependant on certain things specific to your game. If you could make some sort of explanation to show what is what so that others (including myself I tried putting it into mine, but I got this:

    <img src="http://filesmelt.com/dl/loserror.png">

    Right click the image and click 'view' to view full size (though not entirely necessary, lol)

    (Ignore the horrible guy at the upper right hand corner, re-doing that. :p)

    I created a collision map in the same fashion that you did in your example, and did basically the same exact events that you did in your example. It just doesn't seem to want to work with my game, but the reason I think is because of differences between my game's world size and yours. I'll upload the .cap and see if you can figure it out.

    LINK: Saved with .84

  • Here's a fixed cap:

    http://dl.dropbox.com/u/5426011/fixed/fovfixed.cap

    Only one block was showing because the player had the solid attribute so any other block could not be seen through the player. The block was off center because the mask size was incorrect.

    The mask size should be this:

    Width: 1024/32 = 32

    Height: 768/32 = 24

    With the different size i also adjusted the numbers in the events.

    I removed the colmap sprite as it was not needed the existing TiledBackground2 object did fine.

    -cheers

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Here's a fixed cap:

    http://dl.dropbox.com/u/5426011/fixed/fovfixed.cap

    Only one block was showing because the player had the solid attribute so any other block could not be seen through the player. The block was off center because the mask size was incorrect.

    The mask size should be this:

    Width: 1024/32 = 32

    Height: 768/32 = 24

    With the different size i also adjusted the numbers in the events.

    I removed the colmap sprite as it was not needed the existing TiledBackground2 object did fine.

    -cheers

    Thanks a bunch!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)