TresCom Forums

TresCom : The Trespasser Fan Gateway...
It is currently Fri Mar 22, 2019 1:05 am

All times are UTC




Post new topic Reply to topic  [ 14 posts ] 
Author Message
 Post subject: Source-code discussion
PostPosted: Tue Jul 06, 2010 3:08 am 
Offline
Albertosaurus
Albertosaurus
User avatar

Joined: Mon Apr 24, 2006 12:12 pm
Posts: 2197
Location: Australia
I'm okay with posting source-code in here for the new engine (it doesn't bother me) so people can criticize it constructively or add to it or do as they please ;)

All source-code must and will be in C++ or C, and must be either commented or simple enough to understand it's purpose or happenings.

Definitions:
Code:
//AI Constants, used in AIType property of Instances
#define AI_NONE 0
#define AI_PLAYER 1
#define AI_MEAT 2
#define AI_FOLIAGE 3
#define AI_WATER 4
#define AI_ANIMAL 5
#define AI_HUMAN 6

//ArchType Constants, used in ArchType property of CAnimal
#define ARCH_CARNIVORE 0
#define ARCH_HERBIVORE 1
#define ARCH_OMNIVORE 2
#define ARCH_CARN_DOCILE 3
#define ARCH_HERB_MEAN 4

//ActionType Constants, used in the ActionType property of CTrigger and it's siblings
/* Space is reserved... */


Cinstance Class:
Code:
class CInstance
{
public:
   float x,y,z;   //3D Space co-ordinates
   float xr,yr,zr;   //Rotation angles in radians
   float scale;   //Scale of mesh

   //Properties of the instance
   BOOL   Tangible;
   BOOL   Moveable;
   BOOL   Visible;
   BOOL   AI;
   BOOL   Planted;
   BOOL   AlwaysFace;
   BOOL   Bumpmaps;
   BOOL   Curved;
   BOOL   MipMap;
   BOOL   Reflect;
   BOOL   Refract;
   BOOL   Shadow;
   BOOL   Unlit;
   BOOL   Floats;
   BOOL   Frozen;
   long   AIType;
   long   AlphaChannel;
   long   Normals;
   float   AIMass;
   float   Damage;
   float   Height;
   float   Armour;
   float   Bumpiness;
   float   Diffuse;
   float   Emissive;
   float   RefractIndex;
   float   Specular;
   float   SpecularAngle;
   float   Density;
   float   Elasticity;
   float   Friction;
   float   Mass;
   string  Mesh;
   string  Physics;
   string   SoundMaterial;
   string   Type;
   string   Model00,
         Model01,
         Model02,
         Model03,
         Model04,
         Model05,
         Model06,
         Model07,
         Model08,
         Model09;
};

_________________
~ They told me humans weren't real... I proved them wrong.
ImageAnthropology ~ A beautiful tale.
EpicZen
Carnivores Hub ~ Need the full games without all the hassle of torrents or viruses? Run on over to EpicZen's Carnivores Hub!


Top
 Profile  
 
PostPosted: Tue Jul 06, 2010 3:23 am 
Offline
Gallimimus
Gallimimus
User avatar

Joined: Sun May 13, 2007 7:22 pm
Posts: 635
Location: Ohio, United States
Nice! simple defining variables! Stuff I can almost understand. yay!

_________________
ImageImage
Blog
Reviews
tumblr


Top
 Profile  
 
PostPosted: Tue Jul 06, 2010 3:27 am 
Offline
T-Rex Killer
T-Rex Killer
User avatar

Joined: Mon Dec 06, 2004 5:21 pm
Posts: 11506
Location: Portland, OR
Looking good at a quick glance...


(Mickey, quick reply? pretty please? :yum:)

_________________
Image
Image Image T-Script Reference / Trespasser Millennium / JP Dark Secrets / Tres File Box


Top
 Profile  
 
PostPosted: Tue Jul 06, 2010 8:27 am 
Offline
Albertosaurus
Albertosaurus
User avatar

Joined: Mon Apr 24, 2006 12:12 pm
Posts: 2197
Location: Australia
What can you guys spot? Heheheheh...

Code:
class CAnimal
{
public:
   string   Name;
   float   x,y,z;
   float   xr,yr,zr;
   float   scale;

   CMesh   Mesh;
   CMesh   Collision;
   
   long   ArcheType;
   long   Team;
   //1.0 = 1 metre;
   float   Width,
         Length,
         Height;
   float   ClawReach,
         TailReach,
         HeadReach,
         FeintReach;
   float   MaxHitPoints;
   float   HitPoints;
   float   Mass;
   float   Danger;
   float   Anger,
         Fear,
         Hunger,
         Thirst,
         Curiosity,
         Love,
         Fatigue;
   
   
   //========ACTIONS=========
   //Movement
   BOOL   ActWander,
         ActFlee,
         ActDash,
         ActPursue,
         ActRearBack,
         ActCircle,
         ActFeint,
         ActJump,
         ActCrawl,
         ;
   //Senses
   BOOL   ActLookAround,
         ActStare,
         ActSniff,
         ActSniffTarget,
         ActTaste;
   //Other
   BOOL   ActEat,
         ActDrink,
         ActSleep,
         ActWake,
         ActHerd;
   //Attacks
   BOOL   ActBite,
         ActStomp,
         ActRam,
         ActTailSwipe,
         ActSlash;
   //Vocals
   BOOL   ActSnarl,   //Make intimidating sounds
         ActWhimper,   //Make crying sounds
         ActStalk,   //Make stalking sounds (soft purring or breathing)
         ActDying,   //Make dying cries, is also animated
         ActHowl,   //Make chilling cries
         ActBark,   //Make curt, sharp barking sounds
         ActRoar,   //Make a scary bellow, may also perform animation
         ActHelp;   //Make a threatened call for help (alerts pack/herd/family)
};


The units of measurement are metric (metric scale is easier to program with, it's mathematically simple) so ClawReach = 1.0 means that this creature's claws can reach 1 metre away, and Mass = 1.0 means that this object/creature weighs 1 kilogram. I think that it would be possible to make the measurement system an option in the editors if necessary (as I know some people are more fond of Imperial system (I admit I gauge distance in feet and inches ;))

_________________
~ They told me humans weren't real... I proved them wrong.
ImageAnthropology ~ A beautiful tale.
EpicZen
Carnivores Hub ~ Need the full games without all the hassle of torrents or viruses? Run on over to EpicZen's Carnivores Hub!


Top
 Profile  
 
PostPosted: Tue Jul 06, 2010 3:00 pm 
Offline
Dilophosaurus
Dilophosaurus
User avatar

Joined: Sun Nov 10, 2002 9:58 pm
Posts: 2529
Location: England/Portugal
Draconisaurus wrote:
(Mickey, quick reply? pretty please? :yum:)

Done :)

_________________
Image


Top
 Profile  
 
PostPosted: Tue Jul 06, 2010 8:26 pm 
Offline
-=TresCom Developer=-
-=TresCom Developer=-
User avatar

Joined: Sat Jun 12, 2004 6:52 pm
Posts: 4712
Location: Atlanta
Code:
//ArchType Constants, used in ArchType property of CAnimal
#define ARCH_CARNIVORE 0
#define ARCH_HERBIVORE 1
#define ARCH_OMNIVORE 2
#define ARCH_CARN_DOCILE 3
#define ARCH_HERB_MEAN 4


Specifically numbers 3 & 4 -- why are you defining them thus instead of allowing TScripts to govern personality?

_________________
0066521C: 'Cannot create local swap file - Is Trespasser installed??',0Ah,0
"Cold lino was the driving force behind world power!"


Top
 Profile  
 
PostPosted: Tue Jul 06, 2010 8:38 pm 
Offline
T-Rex Killer
T-Rex Killer
User avatar

Joined: Thu Apr 24, 2003 11:20 pm
Posts: 11313
Location: Lima, Peru
He isn't, he's just defining the equivalence between the labels and the numerical values...

_________________
Visit The Carnivores Saga - a forum devoted to modding Action Forms' Carnivores, Carnivores 2 and Carnivores: Ice Age games
Tres WIP: updated T-Script Reference and File Formats documents
Sound name listings for the Demo (build 117), Retail (build 116), Beta 103, Beta 99, Beta 97, Beta 96, Build 55, PC Gamer Alpha (build 32) and E3 1998 Alpha (build 22) TPA files


Top
 Profile  
 
PostPosted: Tue Jul 06, 2010 9:37 pm 
Offline
Albertosaurus
Albertosaurus
User avatar

Joined: Mon Apr 24, 2006 12:12 pm
Posts: 2197
Location: Australia
Slugger wrote:
Code:
//ArchType Constants, used in ArchType property of CAnimal
#define ARCH_CARNIVORE 0
#define ARCH_HERBIVORE 1
#define ARCH_OMNIVORE 2
#define ARCH_CARN_DOCILE 3
#define ARCH_HERB_MEAN 4


Specifically numbers 3 & 4 -- why are you defining them thus instead of allowing TScripts to govern personality?

We have 0,1 and -1 in current Tres, 0 being Carnivore, 1 being Herbivore and -1 being a Carnivore who ignores Anne unless she annoys it, so why not expand upon it a little? Herbivores are generally docile and Carnivores are generally mean, so I added extra stuff in there to add greater weight to the Animal's actions.

_________________
~ They told me humans weren't real... I proved them wrong.
ImageAnthropology ~ A beautiful tale.
EpicZen
Carnivores Hub ~ Need the full games without all the hassle of torrents or viruses? Run on over to EpicZen's Carnivores Hub!


Top
 Profile  
 
PostPosted: Tue Jul 06, 2010 9:57 pm 
Offline
Albertosaurus
Albertosaurus
User avatar

Joined: Mon Apr 24, 2006 12:12 pm
Posts: 2197
Location: Australia
string class type definition:
Code:

#include "string.h"


class string
{
public:
   char *s;

   string()
   {
      s = NULL;
   }
   ~string()
   {
      if (s != NULL)
      delete [] s;
   }

   inline operator char*(void)
   {
      return s;
   }
   inline void operator = (const char *str)
   {
      if (s != NULL)
         delete [] s;
      s = new char[strlen(str)];
      strcpy(this->s,str);
      return;
   }
   inline string& operator = (string &str)
   {
      return str;
   }
   inline string& operator + (string &str)
   {
      if (s != NULL)
      {
         char *s2;
         s2 = new char[strlen(s)];
         strcpy(s2,s);

         delete [] s;
         this->s = new char[strlen(s2)+strlen(str.s)];
         
         strcpy(this->s,s2);
         strcat(this->s,str.s);

         delete [] s2;
      }
      return *this;
   }

   inline string& operator + (const char *str)
   {
      if (s != NULL)
      {
         char *s2;
         s2 = new char[strlen(this->s)];
         strcpy(s2,this->s);

         

         delete [] this->s;
         this->s = new char[strlen(s2)+strlen(str)];
         
         strcpy(this->s,s2);
         strcat(this->s,str);
         
         MessageBox(0,s,"+",MB_OK);

         delete [] s2;
      }
      return *this;
   }

   inline void operator += (const char *str)
   {
      if (s != NULL)
      {
         char *s2;
         s2 = new char[strlen(this->s)];
         strcpy(s2,s);
      
         delete [] s;
         s = new char[strlen(str)+strlen(s2)];

         strcpy(this->s,s2);
         strcat(this->s,str);
         delete [] s2;
      }
      return;
   }
   inline void operator += (string &str)
   {
      if (s != NULL)
      {
         char *s2;
         s2 = new char[strlen(s)];
         strcpy(s2,s);
         MessageBox(0,s2,"s",MB_OK);
      
         delete [] s;
         s = new char[strlen(str.s)+strlen(s2)];

         strcpy(s,s2);
         strcat(s,str.s);
         delete [] s2;
      }
      return;
   }
   //--OPERATORS -- EVALUATIONS
   inline BOOL operator == (const char *str)
   {
      if (strcmp(this->s,str)==0)
         return TRUE;
      else
         return FALSE;
   }
   inline BOOL operator == (string &str)
   {
      if (strcmp(this->s,str.s)==0)
         return TRUE;
      else
         return FALSE;
   }
   inline BOOL operator != (const char *str)
   {
      if (strcmp(this->s,str)==0)
         return FALSE;
      else
         return TRUE;
   }
   inline BOOL operator != (string &str)
   {
      if (strcmp(this->s,str.s)==0)
         return FALSE;
      else
         return TRUE;
   }
};


I had to create this for the TScript engine, but gee it makes strings a helluva lot easier to use in C++...

_________________
~ They told me humans weren't real... I proved them wrong.
ImageAnthropology ~ A beautiful tale.
EpicZen
Carnivores Hub ~ Need the full games without all the hassle of torrents or viruses? Run on over to EpicZen's Carnivores Hub!


Top
 Profile  
 
PostPosted: Wed Jul 07, 2010 8:11 pm 
Offline
Compsognathus
Compsognathus
User avatar

Joined: Fri Jan 04, 2008 12:14 am
Posts: 1066
Location: Switzerland
What exactly are you trying to do here?

_________________
Image
Leader, Head Programmer: Epsylon | Drag[en]gine ( Wiki )


Top
 Profile  
 
PostPosted: Thu Jul 08, 2010 1:23 am 
Offline
Albertosaurus
Albertosaurus
User avatar

Joined: Mon Apr 24, 2006 12:12 pm
Posts: 2197
Location: Australia
Dragonlord wrote:
What exactly are you trying to do here?

Recreate Trespasser from the ground up, using Trespasser's features as a base and expanding upon them (or in some cases removing them or simplifying them) I was actually going to ask you if you would mind venturing with me in this endeavour as your work is pretty damn cool on your own game engine.

As for this thread... I'm posting parts of the source code (actual processes are still coming so it's just classes and whatnot for now... but as you can see, I make heavy use of the inline keyword in my classes ;) there's a lot of functions written in headers.)

_________________
~ They told me humans weren't real... I proved them wrong.
ImageAnthropology ~ A beautiful tale.
EpicZen
Carnivores Hub ~ Need the full games without all the hassle of torrents or viruses? Run on over to EpicZen's Carnivores Hub!


Top
 Profile  
 
PostPosted: Thu Jul 08, 2010 6:33 pm 
Offline
Compsognathus
Compsognathus
User avatar

Joined: Fri Jan 04, 2008 12:14 am
Posts: 1066
Location: Switzerland
Why not using an existing engine? Or is it for education purpose?

Concerning inlines... beware! Compilers are rather sophisticated and what's marked inline is not required to be inline. Furthermore smacking too much code into headers blows up binaries causing other kinds of problems if you are unlucky. Inlines should be only used on specific places, in general one-liners (getters). Function call overhead is in general very low. Add inlines to more complex functions only if profiling shows a real bottle neck and after you optimized the code logic first. I've seen even people forcing inlining complex functions. We call this "premature optimizations" and they are as bad as not optimizing at all :P

_________________
Image
Leader, Head Programmer: Epsylon | Drag[en]gine ( Wiki )


Top
 Profile  
 
PostPosted: Thu Jul 08, 2010 10:25 pm 
Offline
Albertosaurus
Albertosaurus
User avatar

Joined: Mon Apr 24, 2006 12:12 pm
Posts: 2197
Location: Australia
Dragonlord wrote:
Why not using an existing engine? Or is it for education purpose?

Concerning inlines... beware! Compilers are rather sophisticated and what's marked inline is not required to be inline. Furthermore smacking too much code into headers blows up binaries causing other kinds of problems if you are unlucky. Inlines should be only used on specific places, in general one-liners (getters). Function call overhead is in general very low. Add inlines to more complex functions only if profiling shows a real bottle neck and after you optimized the code logic first. I've seen even people forcing inlining complex functions. We call this "premature optimizations" and they are as bad as not optimizing at all :P

Other people's engines always tend to never be low-level enough for me, they lack the customization many of my ideas require.

_________________
~ They told me humans weren't real... I proved them wrong.
ImageAnthropology ~ A beautiful tale.
EpicZen
Carnivores Hub ~ Need the full games without all the hassle of torrents or viruses? Run on over to EpicZen's Carnivores Hub!


Top
 Profile  
 
PostPosted: Fri Jul 09, 2010 12:30 am 
Offline
Compsognathus
Compsognathus
User avatar

Joined: Fri Jan 04, 2008 12:14 am
Posts: 1066
Location: Switzerland
RexHunter99 wrote:
Dragonlord wrote:
Why not using an existing engine? Or is it for education purpose?

Concerning inlines... beware! Compilers are rather sophisticated and what's marked inline is not required to be inline. Furthermore smacking too much code into headers blows up binaries causing other kinds of problems if you are unlucky. Inlines should be only used on specific places, in general one-liners (getters). Function call overhead is in general very low. Add inlines to more complex functions only if profiling shows a real bottle neck and after you optimized the code logic first. I've seen even people forcing inlining complex functions. We call this "premature optimizations" and they are as bad as not optimizing at all :P

Other people's engines always tend to never be low-level enough for me, they lack the customization many of my ideas require.

Good... then my engine goes the right way :P

_________________
Image
Leader, Head Programmer: Epsylon | Drag[en]gine ( Wiki )


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 14 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  

Powered by phpBB® Forum Software © phpBB Group