Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, Nymphodora), 1,592 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 3 1 2 3
Name of the assigned function and model #462308
09/20/16 12:36
09/20/16 12:36
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline OP
Senior Expert
3run  Offline OP
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
Hi there!

Is there anyway to get what function and model names specific model has? F.e. I have an entity that uses 'guard.mdl' and has function 'hero' assigned to it. And inside of that function I want to get the name of the model (guard.mdl) and the name of the function (hero). I checked 'atypes.h' and in entities structure I found this:
Quote:
EVENT local; // client side function
void* model; // mesh/skin info pointer
But 'my.local' is NULL when I try to access it from the hero function. And yet I can't understand how to use 'void* model', I need to save name of the model into the string.

Edit: plus, now I started thinking about how could I save functions name properly, so I could recreate the object and assign that function to it? You may already understand, I'm trying to create some kind of a load/save system, which will save the whole level into the file, and then read it back when needed (could be used for loading levels as well, like in good old resident evil type of games, where each level is a separate room). Any ideas are welcome! Thank you in advance.

Best regards!


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: Name of the assigned function and model [Re: 3run] #462314
09/20/16 16:53
09/20/16 16:53
Joined: Dec 2011
Posts: 1,823
Netherlands
Reconnoiter Offline
Serious User
Reconnoiter  Offline
Serious User

Joined: Dec 2011
Posts: 1,823
Netherlands
Hi,

str_for_entfile returns the model name. As for the function, not sure but I think you can save it in entity.string1/.string2.
Perhaps engine_getscript (char* name ) is also usefull here.

Are you making a level editor or such? If yes I think you can use entity.string1/2 to save the action in a .wmb. Personally for my level editor I just use a skill to save the action as an ID/number (+DEFINE to make the script readable tongue ).

Last edited by Reconnoiter; 09/20/16 16:54.
Re: Name of the assigned function and model [Re: Reconnoiter] #462316
09/20/16 17:53
09/20/16 17:53
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline OP
Senior Expert
3run  Offline OP
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
No, I'm trying to create save/load system between levels (like in old Resident Evil type of games). So I could separate the game into small rooms and when I'll go from one room into the other one, I'll save progress into the file (so picked up items won't appear again, or already killed enemies won't try to kick my ass over and over again).

Thank you for a tip with 'str_for_entfile', it worked flawlessly. Now I can save NPCs with their unique bounding boxes, plus positions/orientations, but no functions yet. I don't really know, how it would be better to save the function name, maybe saving it into the string before writing it into the file, but then, how I'll be able to restore it to be used with ent_create as an EVENT action? Saving the function name automatically would be better than saving it by hand, but we'll see. Any ideas are welcome!

Best regards!


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: Name of the assigned function and model [Re: 3run] #462319
09/20/16 18:21
09/20/16 18:21
Joined: Dec 2011
Posts: 1,823
Netherlands
Reconnoiter Offline
Serious User
Reconnoiter  Offline
Serious User

Joined: Dec 2011
Posts: 1,823
Netherlands
In that case I think I would save the action as a string in your save/txt file and when creating the entity on save load / map load use engine_getscript (char* name ) + the saved string in your ent_create function.

OR use game_save/game_load and only to save the functions/level/ents. Could be buggy though.

Re: Name of the assigned function and model [Re: Reconnoiter] #462320
09/20/16 21:20
09/20/16 21:20
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline OP
Senior Expert
3run  Offline OP
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
I got it working so far, but there is still a lot to do.

F.e. I would like to write all levels into one .txt file (or maybe separate all entities by types in the file), organize it like .ini file:
Quote:
[level1] list of entities
[level2] list of entities
If you guys would give me any advices about this, I would really appreciate it.

Best regards!


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: Name of the assigned function and model [Re: 3run] #462323
09/21/16 09:32
09/21/16 09:32
Joined: Dec 2011
Posts: 1,823
Netherlands
Reconnoiter Offline
Serious User
Reconnoiter  Offline
Serious User

Joined: Dec 2011
Posts: 1,823
Netherlands
Originally Posted By: 3run
F.e. I would like to write all levels into one .txt file (or maybe separate all entities by types in the file), organize it like .ini file:
Quote:
[level1] list of entities
[level2] list of entities
If you guys would give me any advices about this, I would really appreciate it.
, with writing to txt file (simple example):
Code:
function file_skip1line(var handle_file)
{	
	file_asc_write(handle_file, 13); //new line
	file_asc_write(handle_file, 10);
}

...
function write_to_txtblabla() {
  var handle_file = file_open_write (filepath_str);
  file_str_write(handle_file, "Enemy 1");
  file_skip1line(handle_file);
  file_str_write(handle_file, "Enemy 2");
  file_close(handle_file);
}



For loading than use file_str_readto and str_parse is usefull too. Now for skipping to a certain string/point maybe try file_find , not sure about that one though. For only reading out number you can try file_var_read. Alternatively you can use txt_load if the text is not to big and use lite-c string functions to do your Acknex magic, than you can check with str_cmpni to check delimiters/strings that divide entities or levels or whatever.
For both you want some kind of delimiter/string to divide stuff in your text file, or keywords that help you find specific stuff like 'Damage:'.

This might also be helpfull to find specific stuff when you have it in your string:

Quote:
str_parse_tail(STRING* to,char*from,char* tail)
str_parse_head(STRING* to,char*from,char* head)
Extracts a word out of a string when its last characters (str_parse_tail) or its first characters (str_parse_head) are given.

Last edited by Reconnoiter; 09/21/16 09:42.
Re: Name of the assigned function and model [Re: Reconnoiter] #462325
09/21/16 10:41
09/21/16 10:41
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline OP
Senior Expert
3run  Offline OP
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
Thank you very much! I'll look more into those 'file_' and 'str_' functions! laugh

Edit: maybe I won't save function's name at all, but object's ID instead. So I'll have only one function for NPCs (same for items etc), and inside of that function I'll set specific parameters for each NPC depending on it's ID.

Best regards!


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: Name of the assigned function and model [Re: 3run] #462327
09/21/16 13:16
09/21/16 13:16
Joined: Dec 2011
Posts: 1,823
Netherlands
Reconnoiter Offline
Serious User
Reconnoiter  Offline
Serious User

Joined: Dec 2011
Posts: 1,823
Netherlands
Originally Posted By: 3run
Thank you very much! I'll look more into those 'file_' and 'str_' functions! laugh

Edit: maybe I won't save function's name at all, but object's ID instead. So I'll have only one function for NPCs (same for items etc), and inside of that function I'll set specific parameters for each NPC depending on it's ID.

Best regards!
, your welcome laugh . I would indeed go for 1 shared function. It saves alot of duplicated code and when expanding or changing your game your happy you have only 1 action. To keep it flexible and clear I personally try to throw as much of the code in small functions that I call in the big action if conditions are met (e.g. if (clip <= 0 && ammo > 0) reload(); ).

Also instead of saving the object ID you could also retrieve the object ID from its filename (if each object ID has a different model ofcourse). Say:
Player.mdl = 0 / PLAYER_ID
Rat.mdl = 1 / RAT_ID
Depends ofcourse what you want to achieve, but its more readable in the text file that way and easier to mod/change. Plus if you ever want to add a map editor, this will speed up the process for mappers since its 1 less variable to worry about.

Re: Name of the assigned function and model [Re: Reconnoiter] #462328
09/21/16 13:44
09/21/16 13:44
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline OP
Senior Expert
3run  Offline OP
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
About retrieving the objects ID from it's file name. I save only bounding box models (so each object could have it's own BBOX). Because I split collisions and visual part of entities, and each object will have it's own visual model depending on it's ID anyway (created in it's function as a parent). But it's all only in my head right now, let's see how it turns out on practise.

Best regards!


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: Name of the assigned function and model [Re: 3run] #462340
09/22/16 17:04
09/22/16 17:04
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline OP
Senior Expert
3run  Offline OP
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
After thinking about this save/load system once again, I guess I just overthinked everything and made it way too complicated... (well, as I almost always do). I do not need to recreate any entities, cause they are already created with proper model and action attached to them while level loading. All I need to do, is load their settings (position/orientation and some skills) from file, and thats all grin Hopefully this will go right (anyway, I got recreating from file working, saving the function name into the string, then reading it back and using engine_getscript works flawlessly).

Best regards!


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Page 1 of 3 1 2 3

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1