Gamestudio Links
Zorro Links
Newest Posts
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 972 guests, and 3 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 2 1 2
more skills #386773
11/09/11 02:47
11/09/11 02:47
Joined: Nov 2011
Posts: 21
MO:US and sometimes Ambato Ecu...
L
LewyT Offline OP
Newbie
LewyT  Offline OP
Newbie
L

Joined: Nov 2011
Posts: 21
MO:US and sometimes Ambato Ecu...
Hello and greetings from a new forum member.
I am new to gamestudio and lite-c.
I have read and played with the tutorial workshops and modified one to start building my own game
It appears I will need more "skills" for my player entities than what is available.
After searching the help file I found "atypes.h" and modified the line that reads "skill[100];" to "skill[200];"
That didn't cause any errors so I wrote a few defines in my game file:
Code:
//  STATS
#define LIFE skill[101]
#define STRENGTH skill[102]
#define AGILITY skill[103]
#define MIND skill[104]
#define SPIRIT skill[105]

// VITALS
#define HEALTH skill[106]
#define MAXHEALTH skill[107]
#define HEALING skill[108]
#define WOUNDS skill[109]

#define STAMINA skill[110]
#define MAXSTAMINA skill[111]
#define STAMREGEN skill[112]

#define MANA skill[113]
#define MAXMANA skill[114]
#define MANAREGEN skill[115]



That didn't cause any errors so I used one in my entity action :
Code:
var ph;
action updatecharacter() // this is called when the entity is created
{ 
	// initialize stuff
	my.HEALTH = 100;

	while (1) // action loop
	{
		ph = my.HEALTH
		// all the character movement and action handling in here
		wait(1);
	}
}



that didn't cause any errors either but when I display the info in a panel it shows the value is zero (0) when it should be 100
Code:
PANEL* panDisplay =
{
	digits(5, 20, "health = %0.f", *, 1, ph);
	flags = SHOW;
}



What am I missing here?
Can I simply not use skills over 100?
please note these code snippets are not my exact code but abbreviated form

Re: more skills [Re: LewyT] #386916
11/11/11 00:19
11/11/11 00:19
Joined: Nov 2011
Posts: 21
MO:US and sometimes Ambato Ecu...
L
LewyT Offline OP
Newbie
LewyT  Offline OP
Newbie
L

Joined: Nov 2011
Posts: 21
MO:US and sometimes Ambato Ecu...
Well, I haven't found an answer to my question yet.
But I did just notice line 4 of atypes.h:
// DO NOT move or edit this file!
woops, ok so I guess I can't do that
for some reason I thought I read somewhere I could edit it as long as I copied it to my work folder...
it must a different include file

so anyway I'm back to square 1
I need a way to store more data for my character entities
I've tried adding a new member to the ENTITY struct but that sometimes crashes the game and sometimes the data is corrupted.
I'm guessing the engine has some hard coded references to the structs that makes editing that file hazardous.

any suggestions?

Re: more skills [Re: LewyT] #386917
11/11/11 00:49
11/11/11 00:49
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
The engine with all its structs is already compiled (so changes won't have any effect), I think atypes.h and similar header files are just information for the compiler.

The best way to store more data is probably creating structs (see manual) and saving struct pointers in entity skills.


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: more skills [Re: LewyT] #386923
11/11/11 07:40
11/11/11 07:40
Joined: Jan 2011
Posts: 122
GUILIN , CHINA
tzw Offline
Member
tzw  Offline
Member

Joined: Jan 2011
Posts: 122
GUILIN , CHINA
it's a offset problem


Full of my eyes are class struggles.....
Re: more skills [Re: tzw] #386939
11/11/11 12:27
11/11/11 12:27
Joined: Nov 2011
Posts: 21
MO:US and sometimes Ambato Ecu...
L
LewyT Offline OP
Newbie
LewyT  Offline OP
Newbie
L

Joined: Nov 2011
Posts: 21
MO:US and sometimes Ambato Ecu...
ok, Thanks guys
I'm going to try the struct and let you know if I have any problems.
I'm not very familiar with C style syntax but I understand I will need to malloc() the pointer
my main concern is how I will reference the data
can I do something like this?
theEntity.theSkill.PlayerStat = 100;

Re: more skills [Re: LewyT] #387071
11/13/11 22:58
11/13/11 22:58
Joined: Nov 2011
Posts: 21
MO:US and sometimes Ambato Ecu...
L
LewyT Offline OP
Newbie
LewyT  Offline OP
Newbie
L

Joined: Nov 2011
Posts: 21
MO:US and sometimes Ambato Ecu...
Ok, I guess I don't know how to implement this.
I'm trying to learn from another thread but I can't seem to get it right.

so I defined my struct (I think this part is right)
Code:
typedef struct INFO {
	var HEALTH;
	var MAXHEALTH;
	var HEALING;
	var WOUNDS;
} INFO;


also defined the skill:
Code:
#define info 		skill37


I assume the next step is in my entity action to set my.info to a pointer to an instance of INFO
I also want to set and retrieve the values of HEALTH, MAXHEALTH, etc
I've tried a few things but I always get errors trying to set those members.

I should probably point out that this is my first time using pointers.
My previous programming experience is with simpler languages and scripting languages.
I'm trying to learn Lite-C because those other languages don't seem to have the power I need.

Re: more skills [Re: LewyT] #387079
11/14/11 02:37
11/14/11 02:37
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
I cant see any reason why its would be a difficult conversion,
entity to struct that is. But then again, Ive had a lot of practice...

Basically, do the same as the other thread says, just replace ent_create with sys_malloc.
Code:
player.skill37 = sys_malloc(sizeof(INFO));
or
player.info = sys_malloc(sizeof(INFO));
//remember sys_malloc does NOT fill the values with zero's)



Then when you want to access the info-data, use the following.
Code:
INFO* temp_info = (INFO*)player->info;
var temp_health = temp_info.HEALTH;



Or, if you want to get really tricky...
Code:
var temp_health = ((INFO*)player->info).HEALTH;




Best of luck...


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: more skills [Re: EvilSOB] #387082
11/14/11 03:16
11/14/11 03:16
Joined: Nov 2011
Posts: 21
MO:US and sometimes Ambato Ecu...
L
LewyT Offline OP
Newbie
LewyT  Offline OP
Newbie
L

Joined: Nov 2011
Posts: 21
MO:US and sometimes Ambato Ecu...
Thanks! that worked great.

Re: more skills [Re: LewyT] #387083
11/14/11 03:40
11/14/11 03:40
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
S'cool dude.


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: more skills [Re: EvilSOB] #387166
11/15/11 10:15
11/15/11 10:15
Joined: Dec 2003
Posts: 1,225
germany
gri Offline
Serious User
gri  Offline
Serious User

Joined: Dec 2003
Posts: 1,225
germany

does we have to care about freeing the memory before closing the engine with this solution ?


"Make a great game or kill it early" (Bruce Shelley, Ensemble Studios)
Page 1 of 2 1 2

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