Gamestudio Links
Zorro Links
Newest Posts
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Trading Journey
by 7th_zorro. 04/27/24 04:42
Help with plotting multiple ZigZag
by M_D. 04/26/24 20:03
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
M1 Oversampling
by jcl. 04/26/24 11:12
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
Eigenwerbung
by jcl. 04/26/24 11:08
MT5 bridge not working on MT5 v. 5 build 4160
by EternallyCurious. 04/25/24 20:49
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (Akow, AndrewAMD, Quad), 733 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 3 1 2 3
Re: array in skill, is it possible? [Re: pararealist] #328813
06/15/10 14:24
06/15/10 14:24
Joined: May 2005
Posts: 2,713
Lübeck
Slin Offline
Expert
Slin  Offline
Expert

Joined: May 2005
Posts: 2,713
Lübeck
This should do the job, in case the previous examples didn´t:
Code:
my.skill2 = (var)sys_malloc(100*sizeof(var)); // Create array
((var*)my.skill2)[5] = 6;
printf("((var*)my.skill2)[5] = %f", (double)((var*)my.skill2)[5]); // Test



Re: array in skill, is it possible? [Re: Slin] #329152
06/18/10 04:36
06/18/10 04:36
Joined: Oct 2002
Posts: 2,256
Oz
L
Locoweed Offline
Expert
Locoweed  Offline
Expert
L

Joined: Oct 2002
Posts: 2,256
Oz
I always use like skill1 for EntityNum, a specific unique ID when that entity is created, after that, you can use that EntityNum to do what ever you want.

I create a structure, I usually call it like Skills and just make it array size of Max entities I will ever have in game, and can free up EntityNum's when units are killed, etc. But using a unique EntityNum you can basically created as many skills and types as you like in a structure format. I realize its not pretty, but very effective.

Example:

#define MAX_ENTITIES 50000

typedef struct _SKILLS
{
ENTITY* pEnemy[100];

// just some examples stuff of variable types you can add to Skills structure
ENTITY* pWeapon; // pointer to unit's weapon
var FlyByHeight;
var CruiseHeight;
var LastWingAngTiltAdj;
var bCanStrafe;
var aircraftStallRoll;
var HoverAngle;
ANGLE vHoverAngle; // hovering anjust angle to make sway while hovering
var bTakingOff; // aircraft taking off?
var bLanding; // aircraft landing?
var DistanceToGround; // current distance to ground
var bTracedTerrain; // was terrain traced when checking distance to ground?
VECTOR vTerrainNormal; // what was the normal of the terrain on the trace to ground


} SKILLS;

static SKILLS Skills[MAX_ENTITIES]; // Skills structure


So after this you can basically have infinite skills of any variable type you like (including arrays).

Now to set pointer to first enemy in list you just:

Skills[my.EntityNum].pEnemy[0] = you;

To retrieve a entitiy # x from enemy list you:

ENTITY* pEnt;
x = 50; // let's get my enemy # 50
pEnt = Skills[my.EntityNum].pEnemy[x];

Simple and effective way to basically create more skills of whatever variable type you want (and can make arrays inside the structure), as long as you give each Entity it's own unique EntityNum.

In a games like the one I am working on where we exhausted the 100 skills long ago per entity, creating a unique ID for each entity and then using a structure, especailly with arrays is a godsend. With our multiplayer game we general save the actual 3DGS Skills for variables being sent over multiplayer, and put local skills into the structure skills.

Later,
Loco


Professional A8.30
Spoils of War - East Coast Games
Re: array in skill, is it possible? [Re: Locoweed] #329185
06/18/10 11:32
06/18/10 11:32
Joined: Jan 2003
Posts: 4,615
Cambridge
Joey Offline
Expert
Joey  Offline
Expert

Joined: Jan 2003
Posts: 4,615
Cambridge
yeah, it's people like you who write browsers that take up half a gig of ram wink. no, honestly, that's a waste of memory, isn't it?

Re: array in skill, is it possible? [Re: Joey] #329305
06/19/10 02:09
06/19/10 02:09
Joined: Oct 2002
Posts: 2,256
Oz
L
Locoweed Offline
Expert
Locoweed  Offline
Expert
L

Joined: Oct 2002
Posts: 2,256
Oz
It's not the 1980's like when your 64k of memory had to be used to the extreme. Yes, it waste some memory, but with today's machines, its not as big as deal as you are making it out to be.

But, if you are very anal about memory useage, by all means, don't use that method.

It's just a possible method, and of course, most games will never have like 50000 entities either. Probably more like 500 entities in game at once at most. If you want to worry about memory more than functionality, be my guest.

I can also go back and write games in machine langauge again also like the old days, but I prefer to use higher languages now, even though machine language is much more efficient.

I know, post is worthless without pics. wink


Professional A8.30
Spoils of War - East Coast Games
Re: array in skill, is it possible? [Re: Joey] #329337
06/19/10 05:34
06/19/10 05:34
Joined: Oct 2002
Posts: 2,256
Oz
L
Locoweed Offline
Expert
Locoweed  Offline
Expert
L

Joined: Oct 2002
Posts: 2,256
Oz
You have really rubbed me the wrong way Joey. Forum entique would say you don't get attitude with people that have been on forum longer than you. All you had to say was, doesn't that waste memory? But you had to say before that, "it's people like you who write browsers that take up half gig of ram".

So, bite me.

I was going to write "Bite me" in chat of game, but to condense time, I ran game in single player with enemies at close range.


Professional A8.30
Spoils of War - East Coast Games
Re: array in skill, is it possible? [Re: Locoweed] #329338
06/19/10 05:55
06/19/10 05:55
Joined: Oct 2002
Posts: 2,256
Oz
L
Locoweed Offline
Expert
Locoweed  Offline
Expert
L

Joined: Oct 2002
Posts: 2,256
Oz
So whenever you are involved with a game like I am, you can clown me, until then, shut the frack up and don't disrepect me.

Just say, "Doesn't that waste memory," not "it's people like you who write browsers that take up half a gig of ram."

Don't be expecting our company to be calling you for cover art, lol.

I put video up in single player mode, with enemies at front door, to keep video size down. Also reduced video size to make video smaller.

And yeah, we have SpeedTree and SpeedGrass in game also, just not in this example.

Until the time you are working on a project like where this one is at, please, don't disrepect me again dude. I really don't appreciate that.

Although you did manage to get a video up with 1/20th of game play. And no one will ever see it.

http://www.darkdawnstudios.com/3DGS/GameWastingMemory.avi


Love ya, Seriously, "Bite me".


Professional A8.30
Spoils of War - East Coast Games
Re: array in skill, is it possible? [Re: Locoweed] #329342
06/19/10 08:46
06/19/10 08:46
Joined: Jan 2003
Posts: 4,615
Cambridge
Joey Offline
Expert
Joey  Offline
Expert

Joined: Jan 2003
Posts: 4,615
Cambridge
is it possible that you may have overseen the ;)-smiley? and the "no, honestly" part? that means that the first part was a joke, okay?

Re: array in skill, is it possible? [Re: Joey] #329353
06/19/10 10:58
06/19/10 10:58
Joined: Oct 2002
Posts: 2,256
Oz
L
Locoweed Offline
Expert
Locoweed  Offline
Expert
L

Joined: Oct 2002
Posts: 2,256
Oz
It's my bad Joey, I get irritated easily anymore, maybe take things to seriously, thus why I never post anymore. Sorry that I went off. Just been one of those days and the first sentence set me off for some reason.


Professional A8.30
Spoils of War - East Coast Games
Re: array in skill, is it possible? [Re: Slin] #338789
08/21/10 17:14
08/21/10 17:14
Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Pappenheimer Offline
Senior Expert
Pappenheimer  Offline
Senior Expert

Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Sorry for digging up an old thread.
Is it possible to make a define of those array 'positions'?
For instance:
#define ((var*)my.skill2)[0] speed_rel
#define ((var*)my.skill2)[1] speed_abs
#define ((var*)my.skill2)[2] fall_speed
...
and write instead
((var*)my.skill2)[2] = 6;
this
fall_speed = 6;

Originally Posted By: Slin
This should do the job, in case the previous examples didn´t:
Code:
my.skill2 = (var)sys_malloc(100*sizeof(var)); // Create array
((var*)my.skill2)[5] = 6;
printf("((var*)my.skill2)[5] = %f", (double)((var*)my.skill2)[5]); // Test



Re: array in skill, is it possible? [Re: Pappenheimer] #338819
08/21/10 20:01
08/21/10 20:01
Joined: Dec 2008
Posts: 271
Saturnus Offline
Member
Saturnus  Offline
Member

Joined: Dec 2008
Posts: 271
Sure, you can do this.

However, it should read
#define fall_speed ((var*)my.skill2)[2]
instead of
#define ((var*)my.skill2)[2] fall_speed
(etc).

It's not very flexible that way, though, as it requires the my pointer.

This is probably somewhat more convenient:
#define fall_speed(ent) ((var*)(ent)->skill2)[2]
...
fall_speed(my) = 56;


Page 2 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