project-navigation
Personal tools

Author Topic: Research code  (Read 21191 times)

Hoehrer

  • Guest
Research code
« on: March 23, 2006, 10:05:53 am »
Since i really want to see research implemented in the game as soon as possible i have basically two questions:

* What does work already (and how/where) ?
* What needs to be done code-wise and content/text-wise to get the basics working?

I suspect all the relevant code is in src/client/cl_research.c and src/client/cl_research.h, so I might have a look into this in the next few days. But every hint is welcome, 'cause learning everything from the code is rather slow :-/

Werner

Offline Mattn

  • Administrator
  • PHALANX Commander
  • *****
  • Posts: 4831
  • https://github.com/mgerhardy/vengi
    • View Profile
    • Vengi Voxel Tools
Research code
« Reply #1 on: March 23, 2006, 11:26:13 am »
well,

the weapons and items have a flag "researchNeeded" - if this flag is 1 you are not able to use the item/weapon. These items/weapons should come up in the research menu.
Have a look at game/q_shared.h. you'll a a typedef to objDef_t with all current researchflags included. the weapons.ufo includes the researchneeded flags for all alien weapons.

if any questions left - feel free to ask

Hoehrer

  • Guest
Research code
« Reply #2 on: March 23, 2006, 01:29:44 pm »
Ah, thanks.

Quote from: "Mattn"
if any questions left - feel free to ask

Yeah, one question. Do we already have a list or number of hired scientists?

If not i wuold just add a simple int to client.h. But if there is a better place please tell me.
Code: [Select]
typedef struct base_s
{
//the internal base-id
int id;
char    title[MAX_VAR];
int map[BASE_SIZE][BASE_SIZE][MAX_BASE_LEVELS];

qboolean founded;
vec2_t pos;

// to decide which actions are available in the basemenu
byte hasHangar;
byte hasLab;

int NumScientists; <-- add this one??
...


Werner

Offline Mattn

  • Administrator
  • PHALANX Commander
  • *****
  • Posts: 4831
  • https://github.com/mgerhardy/vengi
    • View Profile
    • Vengi Voxel Tools
Research code
« Reply #3 on: March 23, 2006, 01:42:09 pm »
Code: [Select]

typedef struct building_s
{
// FIXME: This can be a char* name and char* base.... don't it? See bmData in basemanagement.c
char    name[MAX_VAR];
char    base[MAX_VAR];
char title[MAX_VAR];
char    *text, *image, *needs, *depends, *mapPart, *produceType, *pedia;
float   energy, workerCosts, produceTime, fixCosts, varCosts;
int     production, level, id, timeStart, buildTime, techLevel,
       notUpOn, maxWorkers, minWorkers, assignedWorkers;

//if we can build more than one building of the same type:
buildingStatus_t buildingStatus[BASE_SIZE*BASE_SIZE];
int condition[BASE_SIZE*BASE_SIZE];

vec2_t  size;
byte visible;
int used;

// event handler functions
char onConstruct[MAX_VAR];
char onAttack[MAX_VAR];
char onDestroy[MAX_VAR];
char onUpgrade[MAX_VAR];
char onRepair[MAX_VAR];
char onClick[MAX_VAR];

//more than one building of the same type allowed?
int moreThanOne;

//how many buildings are there of the same type?
//depends on the value of moreThanOne ^^
int howManyOfThisType;

//position of autobuild
vec2_t pos;

//autobuild when base is set up
byte autobuild;

//autobuild when base is set up
byte firstbase;

//this way we can rename the buildings without loosing the control
byte isLab;
byte isHangar;

struct  building_s *dependsBuilding;
struct  building_s *prev;
struct  building_s *next;
} building_t;


if the isLab flag is set we can use the assignedWorkers (which are scientists in a lab) to get the amount.

Hoehrer

  • Guest
Research code
« Reply #4 on: March 23, 2006, 01:52:08 pm »
Ok, so i need to check how many labs there are and sum up the number of "assigned workers" of each to get the total numbers of scientists, am i right?

Werner

Offline Mattn

  • Administrator
  • PHALANX Commander
  • *****
  • Posts: 4831
  • https://github.com/mgerhardy/vengi
    • View Profile
    • Vengi Voxel Tools
Research code
« Reply #5 on: March 23, 2006, 01:53:38 pm »
yes you are right - and fast with your replies ,too :-D

Hoehrer

  • Guest
Research code
« Reply #6 on: March 23, 2006, 02:11:31 pm »
Ok, i found the "B_HowManyPeopleInBase" function cl_basemanagement.c

SHould i modify this to accept a second parameter (type of people .. e.g. 0=all, 1=scientists, 2=workers, 3=soldiers) or create a second (mostly redundant) function e.g. B_HowManyScientistsInBase instead?

Werner

Offline Mattn

  • Administrator
  • PHALANX Commander
  • *****
  • Posts: 4831
  • https://github.com/mgerhardy/vengi
    • View Profile
    • Vengi Voxel Tools
Research code
« Reply #7 on: March 23, 2006, 02:15:09 pm »
right now there is no difference between workers, soldiers and so on - the type of people in a base resp. building depends on the building-type. maybe you can add a second parameter - would be best to ask whether a building is a lab, or something other...

Hoehrer

  • Guest
Research code
« Reply #8 on: March 23, 2006, 05:57:33 pm »
Ok, i'll make it so it returns the people in the different rooms and all people depending on the second parameter ... it's not on high priority though ;)

Another (more important) thing i'm thinking about is a structure for the techtree/researchtree in ufo format that provides the relationships between the researched items. I'll post a mockup as soon as i get my troubles with the x-server under control (posting under knoppix right now).

What i need to know with the ufo-techtree is how i get this into C-variables. Is there a 'common' parser or do i need something special in C?
Not that i'm lazy, but you might have more experience with this ... If i post the mockup, could you provide me with this pasing things in C?

EDIT the first draft .... comments/critics are welcome. This is meant to be a new ufo-file that links together all the technology that it listed in the other ufo files and some new "pseudo' technology/research items that are only there to provide additional infos and some basic starting points.
Code: [Select]
//--------------
// research tree
//--------------

// This is just an example of how we _could_ implement a simple researh tree.

//item
//  The _unique_ name of the research item in the tree.

//type
//  Just says where to look for more information.
//  "research" items have all the information in here, everything else in the correct ufo file.

//name
//  self-explaining i hope :) Only needed when type=research

//requires
//  if you get an alien-item everything that it requires is made available for research (tree top/down)
//  e.g. collect a plasrifle -> get the plasma technology but not the plasmpistol.
//       The plasrifle itself will not be researchable until the plasmpistol has been researched.
//  "initial" - You can research this tech from the beginning.
//  "nothing" - You need to collect at least one item (that requires it directly or indirectly) to be able to research this.
//  everything else - a research "item"

//provides
//  The item name in the correct ufo file. This can be produced once the research item has been finished.

//time
//  Time the research needs.
//  If time is 0 the item can be produced at the same time the "required" item can be.
//  TODO: good values that are in sync with the game-time.
//  TODO: A good algorithm for splitting up this time over several scientists.


//-----------------------------------------------------
item tachyon
{
type research
name "Tachyon control"
requires initial
description "tachyon_txt"
time 100
}

item tachyonrifle
{
type weapon
requires tachyon
provides tachyonrifle
time 200
}

item tachyonrifle_ammo
{
type weapon
requires tachyonrifle
provides tachyonrifle_ammo
time 0
}

item tachyonsniper
{
type weapon
requires tachyonrifle
provides tachyonsniper
time 300
}

item tachyonsniper_ammo
{
type weapon
requires tachyonsniper
provides tachyonsniper_ammo
time 0
}

//-----------------------------------------------------
item plasma
{
type research
name "Advanced plasma technology"
requires initial
description "plasma_txt"
time 100
}

item plaspistol
{
type weapon
requires plasma
provides plaspistol
time 300
}

item plaspistol_ammo
{
type weapon
requires plaspistol
provides plaspistol_ammo
time 100
}

item plasrifle
{
type weapon
requires plaspistol
provides plasrifle
time 500
}

item plasrifle_ammo
{
type weapon
requires plasrifle
provides plasrifle_ammo
time 0
}

//-----------------------------------------------------
item irgoggles
{
type weapon
requires initial
provides irgoggles
time 200
}

item nano
{
type research
name "Nano technology"
requires initial
description "nano_txt"
time 200
}

item nano_armor
{
type armor
requires nano
provides medium
time 400
}

item nano_hull //this is just an example of multiple "requirements"
{
type craft
requires nano_armor plasma
provides craft_hull_medium
time 1000
}


Werner

Offline Mattn

  • Administrator
  • PHALANX Commander
  • *****
  • Posts: 4831
  • https://github.com/mgerhardy/vengi
    • View Profile
    • Vengi Voxel Tools
Research code
« Reply #9 on: March 23, 2006, 07:39:01 pm »
have a look at the parser in cl_basemanagement.c
maybe i can help you with that if i find the time - no big deal.

the structure looks reasonable

Offline Mattn

  • Administrator
  • PHALANX Commander
  • *****
  • Posts: 4831
  • https://github.com/mgerhardy/vengi
    • View Profile
    • Vengi Voxel Tools
Research code
« Reply #10 on: March 24, 2006, 11:22:45 am »
maybe you have to rename item to research or something like that - item is already a known parserentity.
have a look at client/cl_main.c function CL_ParseScriptSecond. here you can add your parser.

Offline Mattn

  • Administrator
  • PHALANX Commander
  • *****
  • Posts: 4831
  • https://github.com/mgerhardy/vengi
    • View Profile
    • Vengi Voxel Tools
Research code
« Reply #11 on: March 24, 2006, 03:51:26 pm »
great job so far - researching works - but i think that showing the finished items in list is not a good idea - we need to keep the list small - othervise there may be more than 28 items. maybe we have to put this into the statistics view.

Hoehrer

  • Guest
Research code
« Reply #12 on: March 24, 2006, 04:44:00 pm »
Quote from: "Mattn"
great job so far - researching works - but i think that showing the finished items in list is not a good idea - we need to keep the list small - othervise there may be more than 28 items. maybe we have to put this into the statistics view.


I see your point and this is just a test-implemention after all, but your logic fails anyway, because it is possible that more than 28 items are available for research at one time ... in theory that is ;)
In this case i'm all for a scrollable list .... but that has a low priority right now though.

I'm currently writing on the parser for the ufo files and alot of functions to access the resulting data. Most of it works (at least in theory .. since i haven't tested it yet) but alot of minor things need to be fixed/finished before we can start linking the research to the rest.

Will commit some of the changes soon.

Werner

Offline Mattn

  • Administrator
  • PHALANX Commander
  • *****
  • Posts: 4831
  • https://github.com/mgerhardy/vengi
    • View Profile
    • Vengi Voxel Tools
Research code
« Reply #13 on: March 24, 2006, 04:46:32 pm »
i've implemented the parser for the technologies - use the command "technologylist" to list them in console. anything else i can do?

Hoehrer

  • Guest
Research code
« Reply #14 on: March 24, 2006, 05:46:04 pm »
Quote from: "Mattn"
i've implemented the parser for the technologies - use the command "technologylist" to list them in console. anything else i can do?


Whoo, a working skeleton for the techtree, something i can work with .. sweet, thanks a lot :D

That is enough for me to continue my work ... just need to adapt some of my pre-written functions/code.

Werner