|
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
Locoweed
Expert
|
Expert
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: Joey]
#329305
06/19/10 02:09
06/19/10 02:09
|
Joined: Oct 2002
Posts: 2,256 Oz
Locoweed
Expert
|
Expert
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.
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
Locoweed
Expert
|
Expert
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
Locoweed
Expert
|
Expert
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.aviLove ya, Seriously, "Bite me".
Professional A8.30 Spoils of War - East Coast Games
|
|
|
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
Locoweed
Expert
|
Expert
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
Senior Expert
|
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; This should do the job, in case the previous examples didn´t:
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
|
|
|
|