Custom Menu System

Topics regarding Scripting with Reality Factory
Post Reply
Juryiel
Posts: 103
Joined: Fri Jan 04, 2008 1:18 pm

Custom Menu System

Post by Juryiel »

So now I'm working on a custom menu system and I've got a bunch of questions.

First, can I pause the 'action' of the entire world for an indefinite amount of time somehow, except for the menu? And I mean everything, model and texture animations, enemy movement and AI, everything, so that way when the menu is brought up nothing happens in the world, since the player won't be able to see. I was thinking of a while loop as a low level function, and while that does it, it won't let any frames go by so the menu won't be able to draw what it needs to.

Also, it says that the ShowHudPicture command is supposed to draw ABOVE the the HUD but this doesn't seem to be true, as the health bar and compas (the only hud pieces showing) are on top of my ShowHudPicture image. What gives? :)

Finally, I would like to make an item system that my menu system can read. Is it possible to write item info in a database of some kind with my own custum-defined fields? I was thinking either SQL or even just a straight text file, but with fields that I define myself that are not predefined by the engine. Basically, what I need is a command that will read and parse data files, and once I have that, I can code the rest. I tried to look in the docs but nothing caught my eye right away.

Any help always appreciated :)
Jay
RF Dev Team
Posts: 1232
Joined: Fri Jul 08, 2005 1:56 pm
Location: Germany

Post by Jay »

I was working on a feature like this called TimeScale which lets you set a TimeScale which multiplies the time for everything! You could set it to 0 and then the time would be stopped, but LowLevel functions would still be executed. (Setting it to negative numbers is possible but NOT recommended, i don't know but i suppose this would mess up the engine) I could send you my modified version of RealityFactory which lets you do some pretty interesting thinghs with scripting... (But problem is i haven't needed this feature before, so it could be buggy or even not working, also this version could be obsolete when the next official RF comes out )

I was going to use this feature for my game in the sequences where you controlled Tim (the wind-mage) and used Windwalker to make him appear to be faster than everyone else (by making him faster and slowing down the others at the same time, so he remained the same speed)

For the HUD, i would rather use DrawFlipBookImage(...) as it always draws over other thinghs.

For the items, well i am doing this in my game, and currently i am writing RPG Tutorial 2: Items and Inventory (But i have slowed down because it is so much work writing tutorials). I'll look if i can speed up this a bit.
You have good understanding of the scripting language and put a lot of effort behind the thinghs you do from what i've seen so far.
Everyone can see the difficult, but only the wise can see the simple.
-----
Juryiel
Posts: 103
Joined: Fri Jan 04, 2008 1:18 pm

Post by Juryiel »

Hey Jay, your help is always invaluable as you seem very knowledgable about RF. Do you mean the SetTimeScale function that's in the docs, or another custom made one? Because that one seems to have the same description. I'll try giving that one a try and see how it goes. I'll also try the flip book, and see how that goes.

The tutorial sounds great :) I was also looking for ways to modify the current inventory system to a custom one, but I haven't figured anything out yet. I wanted to have things like Item stats and descriptions like RPGs do etc, so I couldn't figure out hwere to store that information, and more importantly, how to read it into the game. I suppose it is possible to store all that in the scripted player script in some gigantic array but I can only imagine that this will somehow make things incredibly inefficient to have all of it loaded in memory at once!

I'm glad you like the things I try to make :) I think that polish is more important than anything, including high poly graphics and nifty shader effects, so I try to put as much of it in as I can. I think that's what tends to make or break how immersive a game is, and I'm sure you know that this is paramount in an adventure/rpg type setting :)
Jay
RF Dev Team
Posts: 1232
Joined: Fri Jul 08, 2005 1:56 pm
Location: Germany

Post by Jay »

Actually i DO use a gigantic array (I use one for the abilities too, it has 200+ entries!) And from my experience it does not make thinghs ineffecient. I actually use many arrays for the items. For the different attributes they can have. Also the items can be equipped (if they have this state set) and have different types like 'potion' or 'weapon' that do different thinghs when used (And i have 'relics' that need your mana when you activate them and they give you powerfull boosts like 20 light resistance). But i will explain this all in the tutorial. The tutorial is for an inventory with like 16 slots and every item needs a slot. And the items are numbers that are stored in player attributes.

I used to think that it would slow down the game too, but it does not affect the game that much that you should think about it. Also i have not found a limit in filesize yet. My main player script which does almost everything in the game (The pawns use its functions too to get item stats, do damage, read inventory, check abilities...) has gotten pretty huge, it's 80kb!

SetTimeScale():
Oh no, the SetTimeScale(...) you mean is for SkyDome scripts, and will only affect the SkyDome.

Oh and thanks, yes i know much about RF, but since i have benn using it for so long, that's no wonder (Don't even know exactly when i did start was long ago)
Everyone can see the difficult, but only the wise can see the simple.
-----
Juryiel
Posts: 103
Joined: Fri Jan 04, 2008 1:18 pm

Post by Juryiel »

Ahh, that's good to know! Time to read up on SimKin arrays then! I have horrible memories of last summer trying to read gigantic files into a perl script array all at once and having the computer lock up. Of course, those text files were over 400mb in size, and I guess an item array, even with a ton of items, won't be more than a few KB!

Well if you can post that RF version that has your new function to stop time please go for it :) I would really appreciate it. A brief list of any new things that I can do with it would also be helpful, but not necessary at teh moment, since for now I'll just be using it for the TimeScale command.

EDIT: Hmm, I can't seem to find any array documentation for simkin, as far as commands for getting array size, attaching stuff to either the end or start, and all the other types of useful array functions that you can find in most other scripts. Do those exist? If not it's cool, I can plan around them.

Also, can you do matrices/MultiDimensional Arrays and such so I can have an array of items, and then each member is an array itself with all the item properties? I guess I could set up an array with arrays in it if that's allowed by the language, but then I'm not sure how I would go about referencing individual entries.

EDIT2: After much, much looking on how to do arrays (these docs are either incomplete or I'm too stupid to use them :P) I found that I can do soemthing like:

Code: Select all

ITEM0_ARRAY
{
     ITEM0_ARRAY1 [value]
     ITEM0_ARRAY2 [value]
}
ITEM1_ARRAY
{
     ITEM1_ARRAY1 [value]
     ITEM1_ARRAY2 [value]
}
And then just reference an entry i, j as ITEM # i # _ARRAY # [j], which is in essence a multidimensional array. If there's a more direct way of doing it I'd appreciate it if someone would let me know :) I haven't tried the above yet so I'm going to give it a try, I think it should work though!

I also read about flipbook but it seems you have to add that entity to each level if I understand it correctly. I'll probably forget to do that, so instead I opted for the SetHudDraw(false) command, which I just found, and works nicely :)

And one more question. I'm trying to use the following image as a menu cursor, but when I save it as a PNG the colors are all broken when I load it as a HudPicture and the transparency isn't working right. I'm not sure what the deal is, but using gif lowers the quality to unacceptable levels. I'm currently using jpg + alpha map but it's tough to get the alpha map to be precise when the transparancy transition is gradual. I got it pretty good, but it's not 100% perfect, so if there's something I can do with the .png file please let me know
Attachments
cursor.png
cursor.png (16.26 KiB) Viewed 1789 times
Jay
RF Dev Team
Posts: 1232
Joined: Fri Jul 08, 2005 1:56 pm
Location: Germany

Post by Jay »

The only other thing about hte arrays is that it does not matter hwo the elements are named, so this

ARRAY
{
ARRAY1[0]
ARRAY2[0]
}

is the same as this:

ARRAY
{
0
1
}

and you can call all arrays with

ARRAY[j]

if you want

The indices always start at 0 i believe. I normally use the second way of describing arrays because then the 'name' of the item is also the same as the index of this item.

Here is the modified RealityFactory.exe and the modified GameEntityDataTypes.h (in the source directory)
http://www.mediafire.com/?cl9dzdzk3js
http://www.mediafire.com/?bmtelcmsy9k

This is the same as the CommunityRelease but also has some extra script commands. These are the ones you will be using

SetTimeScale(float scale);
This sets a time scale that can make EVERYTHING slowe or faster. You could do SlowMo or FastMo with that. The self.time value will also increase slower.
It may not be too save to set it to very low numbers (lower number->slower) like <0.1... however setting it to high numbers is save (higher numbers ->faster). The default TimeScale is 1.0.

GetTimeScale();
gets the current time scale

You can also look here:
http://www.realityfactory.info/forum/vi ... &start=105
and here
http://www.realityfactory.info/forum/vi ... php?t=2138
for further infos.
But don't expect all the features in the first topic to be implemented, the pathfinding and the QuadMesh were kinda buggy so i had to leave them out. (There were others that had bugs, but i don't remember which. The features in there are bugless from what i know)

EDIT: Oh and if it does not work, first install the CommunityRelease and then install it over the CR.
Everyone can see the difficult, but only the wise can see the simple.
-----
Juryiel
Posts: 103
Joined: Fri Jan 04, 2008 1:18 pm

Post by Juryiel »

Hmm, both the CR version and the normal version crash and I get the message:
*WARNING* OpenRFFile: file open attempt failed on type '10', file '.\scripts\JuryPawn'

*WARNING* File .\CPawn.cpp - Line 1390: Failed to open file: 'scripts\JuryPawn'
in my log.

If I copy my script file and rename it to JuryPawn (without an extension) it still crashes but with no error message in the log, right after the line "Initializing Pawn Manager Subsystem"

I wonder what could be wrong.
Jay
RF Dev Team
Posts: 1232
Joined: Fri Jul 08, 2005 1:56 pm
Location: Germany

Post by Jay »

I have no idea. It works great on my comp.

Did you install the CR before you installed the version here? Because there is a modified Genesis.dll in the CR...

Also, in EnvironmentSetup, you must change the Gravity field to a vector (or it could crash). Just double-click and it should become one.
Everyone can see the difficult, but only the wise can see the simple.
-----
Juryiel
Posts: 103
Joined: Fri Jan 04, 2008 1:18 pm

Post by Juryiel »

Yeah I copied all the files all over the place :)

Gravity you say? Would the commands Gravity(true) and Gravity(false) cause such a problem ?

I'll check the environment stuff.
Juryiel
Posts: 103
Joined: Fri Jan 04, 2008 1:18 pm

Post by Juryiel »

Hmm, that damned RFEdit tool is giving me a ton of problems at the moment. I didn't realize if I copy over the RF directories and tools that RFEdit starts choking, probably due to some sort of directory path problem. It seems to not want to make the gravity of my existing map into a 3d vector, but it makes gravity of new maps into one so I'll just make a new level and test it out.


EDIT: Ok I got it to load now, it was indeed the 3d vector for gravity :) Yay!

EDIT2: Well the SetTimeScale command doesn't do exactly what I want since it doesn't seem to stop gravity at least, I was looking for something ore along the lines of what happens when you open the default inventory, minus the "accumulating acceleration when in mid air and inventory is open" effect. However, I can do some really nifty things, so I think I'll keep it.
Juryiel
Posts: 103
Joined: Fri Jan 04, 2008 1:18 pm

Post by Juryiel »

Well I got the first two levels of my menu working nicely, but now the third and final level is giving me problems. I can't figure out how to do 2D arrays or any similar types of structures and I basically need to. The reason is that each item is an array with each field as a different value like item name, item power, item description etc. But I also need to have a general way to reference the item selves, for example for when I list them in my menu, I want to search through the entire list of items (which is thereby a second array). Is there some good way to do this?

Here's my current workaround:

Code: Select all

Test_Array
{
	item0[name0]
	item0[descript0]
	item0[power0]
	item0[quant0]
	
	item1[name1]
	item1[descript1]
	item1[power1]
	item1[quant1]
	
	item2[name2]
	item2[descript2]
	item2[power2]
	item2[quant2]
}

RunPlayer[()
{              
 	numEntriesPerItem=4;  
	if(IsKeyDown(K_TEST))
	{
		for i = 0 to (Test_Array.numChildren+1)-numEntriesPerItem step numEntriesPerItem
		{
			//debug(Test_Array[i]); //Give names
			//debug(Test_Array[i+1]); //Give descript
			//debug(Test_Array[i+2]); //Give power
			debug(Test_Array[i+3]); //Give quant
		}
	}
}
But a more natural way would be GREATLY appreciated!
Juryiel
Posts: 103
Joined: Fri Jan 04, 2008 1:18 pm

Post by Juryiel »

Also, yet another question. How can I go about saving the values of an array and then loading them when the game starts? I would like to be able to change the quantities of items in my custom menu system, and that value is stored in an array. So what clever tricks have you all come up with to write this type of stuff to a file and then load it? :)
Post Reply