Issue with inventory system/couple other things

For questions about using Classic.

Post » Mon Jun 28, 2010 6:40 pm

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
B
1
G
2
Posts: 6
Reputation: 637

Post » Mon Jun 28, 2010 8:36 pm

Here's a quick cap for rogue-like movement

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

Made with 0.99.82
B
46
S
23
G
7
Posts: 459
Reputation: 6,763

Post » Mon Jun 28, 2010 9:23 pm

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.
B
46
S
23
G
7
Posts: 459
Reputation: 6,763

Post » Mon Jun 28, 2010 9:36 pm

[quote="Minor":1ku05opn]Here's a quick cap for rogue-like movement

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

Made with 0.99.82[/quote:1ku05opn]

Awesome, thanks a lot bud! :D That works perfectly, just like I need it. And, for some reason, downloading 0.9984 fixed the inventory issue. Now, I mainly need some help with the field of vision effect. If anyone can help me out with that, it'll help me IMMENSELY. That's the main thing I can't figure out how to do for the life of me :|

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:

B
1
G
2
Posts: 6
Reputation: 637

Post » Mon Jun 28, 2010 10:29 pm

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.
B
3
S
2
G
2
Posts: 187
Reputation: 1,449

Post » Mon Jun 28, 2010 10:54 pm

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 :D

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 :D 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 :)
B
1
G
2
Posts: 6
Reputation: 637

Post » Tue Jun 29, 2010 10:12 pm

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.
[url:w1rqnblk]http://www.scirra.com/forum/viewtopic.php?f=16&t=6679&start=0[/url:w1rqnblk]
B
79
S
24
G
54
Posts: 4,746
Reputation: 40,755

Post » Wed Jun 30, 2010 2:48 am

[quote="R0J0hound":2979uv52]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.
[url:2979uv52]http://www.scirra.com/forum/viewtopic.php?f=16&t=6679&start=0[/url:2979uv52][/quote:2979uv52]

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 :D ) can implement that engine into their games, it would be very nice :) I tried putting it into mine, but I got this:


[i]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
B
1
G
2
Posts: 6
Reputation: 637

Post » Wed Jun 30, 2010 9:53 pm

Here's a fixed cap:
[url:3sg8v278]http://dl.dropbox.com/u/5426011/fixed/fovfixed.cap[/url:3sg8v278]
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
B
79
S
24
G
54
Posts: 4,746
Reputation: 40,755

Post » Thu Jul 01, 2010 5:01 am

[quote="R0J0hound":o76gh2eh]Here's a fixed cap:
[url:o76gh2eh]http://dl.dropbox.com/u/5426011/fixed/fovfixed.cap[/url:o76gh2eh]
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[/quote:o76gh2eh]

Thanks a bunch! :D
B
1
G
2
Posts: 6
Reputation: 637

Next

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 0 guests