3D Game Programming -> Concept Help 16 replies

  • 1
  • 2

Please wait...

adelphospro

I'm accepted, He was condemned

50 XP

26th February 2007

0 Uploads

1,458 Posts

0 Threads

#1 10 years ago

Hey guys, I'm working on improving an old game engine and would like some input on a concept.

Concept: The hunter (its a hunting game) should be affected by the surrounding temperature (of the air, water, animals, fire, etc).

What I need help on: What is the most realistic way this happens?

For example, you don't need to give me pseudo code, but a solid concept would be greatly appreciated, like when to update the hunters temperature, how it should be updated compared to surrounding temperature, etc.

Right now this is how I'm doing it:

Every 1 minute the engine calls UpdateTemperature() The engine checks the players temperature against the temperature he "feels" and lowers or highers his temperature a little bit (based on temperature change resistance, like clothes) towards the temperature he feels. After about 10 minutes or so of hunting if they player has not found a heat source (or cooled down) he may die depending on how cold/hot his surroundings are.

Code: void UpdateTemperature() { if (!MyHealth) return; //Players[0].temperature.degrees; Players[0].temperature.ftime += TimeDt; int timwait = (1000*60); if (Players[0].temperature.ftime >= timwait) { //Every minute your temperature drops/rises Players[0].temperature.ftime = 0; int feel,watertemp; feel = 80; //Temp of outside + windchill watertemp = 25; if (ONWATER) feel = min(feel,watertemp) + (max(feel,watertemp)/2); if (UNDERWATER) feel = watertemp; //Apply new temperature. Players[0].temperature.degrees = max(Players[0].temperature.degrees,feel) - (min(Players[0].temperature.degrees,feel)*0.01); char tmpCh[120]; sprintf(tmpCh,"Degrees: %dF",int(Players[0].temperature.degrees)); AddTextMessage(tmpCh); if (Players[0].temperature.degrees < Players[0].temperature.min) { PlaceKilledHunter(NULL,HUNT_FALL); } } }

Thanks!




Aeroflot

I would die without GF

169,400 XP

2nd May 2003

0 Uploads

15,205 Posts

0 Threads

#2 10 years ago

Well, first of all, why do you want temperature to affect the hunter?




jjz-

Software Engineer

50 XP

16th October 2008

0 Uploads

511 Posts

0 Threads

#3 10 years ago

Hi, That code looks like old C code. To start building a bigger and more stable game, you might want to look into converting the old code into C++ first and setting up a very logical hierarchy.

That will all take some time; however, believe me when I say that it makes everything MUCH easier to deal with when you are handling huge applications. Also make sure to come up with a nomenclature for your members and classes, and stick to it. This way you never have to go searching for your variable / function names and never forget what your class names are. Namespaces are also essential when you are dealing with a project that might have more than one module you are working on (thus more than one project solution file).

Now, to answer your question about UpdateTemperature.

Make it an event that is fired by some thread in the game's environment engine. The thread should be a low priority one that only runs code for the environment that needs to be updated every 30 seconds or 1 minute. When the event is fired, the character should catch this event and then perform, basically, what is listed in that function.

If you want to add functionality, you can add speed and reaction members and whatnot to your Character class. YOu can then have the temperature automatically affect the base values (always negatively, you are never going to have a temperature that makes you go faster lol). Also, if the player is going to be able to die from temperatures being so cold, just look up how long it takes for hypothermia to keep in, and generally at what temperature. Follow that, and don't forget to warn the player that he is becoming extremely cold :P.




Mr. Pedantic

I would die without GF

234,620 XP

8th October 2006

0 Uploads

23,127 Posts

0 Threads

#4 10 years ago

It depends on how realistic you want this temperature effect to be. If it is very simplistic, then the heat effect could be modeled by a tan function: int_0^t x^3 dx. The closer t is to 0 (whatever your optimal temperature wants to be) the less the hunter is affected by the temperature, and the greater efficiency he can operate at. However, the further the temperature difference from the optimum, the greater the effect. You'll need to convert the final value into an absolute value at the end, or else negative temperatures will give your character a boost.

However, if you really want to make it complicated, then you need to include the hunter's power output as well. Say the hunter has a maximum power output of 1700W. The hunter occupies a certain amount of this with every action (walking, running, jumping, standing still, etc.) On top of this, you should have the function mentioned above, the cubic function, dictating how much power he needs to contribute to keeping his body at 37 degrees. If the centered moving mean of the heat regulation power requirement plus the actions power requirement for any 15-second time period is greater than 1700W, the hunter will start to take damage exponentially proportional to the surplus power required. In addition you will need to factor in the negative effect on performance of the temperature on the hunter at all times, regardless of whether he takes damage or not.




adelphospro

I'm accepted, He was condemned

50 XP

26th February 2007

0 Uploads

1,458 Posts

0 Threads

#5 10 years ago
That code looks like old C code. To start building a bigger and more stable game, you might want to look into converting the old code into C++ first and setting up a very logical hierarchy.

Yeah, it was designed in 1998 by Action Forms :/ (Its the source to the old game: Carnivores 2. We got it under a non-dis closer agreement. We can release small snippets, and we can release compiled patches.)

Now, to answer your question about UpdateTemperature. Make it an event that is fired by some thread in the game's environment engine. The thread should be a low priority one that only runs code for the environment that needs to be updated every 30 seconds or 1 minute. When the event is fired, the character should catch this event and then perform, basically, what is listed in that function. If you want to add functionality, you can add speed and reaction members and whatnot to your Character class. YOu can then have the temperature automatically affect the base values (always negatively, you are never going to have a temperature that makes you go faster lol). Also, if the player is going to be able to die from temperatures being so cold, just look up how long it takes for hypothermia to keep in,

I'll look into it!

It depends on how realistic you want this temperature effect to be. If it is very simplistic, then the heat effect could be modeled by a tan function: int_0^t x^3 dx. The closer t is to 0 (whatever your optimal temperature wants to be) the less the hunter is affected by the temperature, and the greater efficiency he can operate at. However, the further the temperature difference from the optimum, the greater the effect. You'll need to convert the final value into an absolute value at the end, or else negative temperatures will give your character a boost. However, if you really want to make it complicated, then you need to include the hunter's power output as well. Say the hunter has a maximum power output of 1700W. The hunter occupies a certain amount of this with every action (walking, running, jumping, standing still, etc.) On top of this, you should have the function mentioned above, the cubic function, dictating how much power he needs to contribute to keeping his body at 37 degrees. If the centered moving mean of the heat regulation power requirement plus the actions power requirement for any 15-second time period is greater than 1700W, the hunter will start to take damage exponentially proportional to the surplus power required. In addition you will need to factor in the negative effect on performance of the temperature on the hunter at all times, regardless of whether he takes damage or not.

I will certainly do this. Thanks! I had no clue how to work with temperatures.

Well, first of all, why do you want temperature to affect the hunter?

To spice up the game. Actually, I'm copying the concept from (Cryostasis). Basically, this will keep the player from wondering off into jungles or staying in the water the whole time for easy kills. Also, the hunter will need to kill something to stay warm (at least, until I can program a particle system :/)

I'm also trying to program support for popular model formats (it only supports its own ".car" format) OR make a tool to convert to it.




jjz-

Software Engineer

50 XP

16th October 2008

0 Uploads

511 Posts

0 Threads

#6 10 years ago

You are going to have a long year ahead of you. Have fun.




adelphospro

I'm accepted, He was condemned

50 XP

26th February 2007

0 Uploads

1,458 Posts

0 Threads

#7 10 years ago

Well we've (The Carnivores Saga) gone a long way already (See Carnivores Community Edition). The biggest challenge will be converting all the code to classes and such.... I have a few ideas as to how to do it though.

It's a good engine though (Atmosfear 1), and uses maps that are 1024x1024 tiles (I did some tests on maps 2048x2048. It worked but was crazy big to walk around!)




jjz-

Software Engineer

50 XP

16th October 2008

0 Uploads

511 Posts

0 Threads

#8 10 years ago
The biggest challenge will be converting all the code to classes and such....

If you are planning to do a full overhaul of the engine into a modern engine, converting the current engine to c++ is not going to be the biggest challenge :P.

How much are you planning to change in the engine?




Junk angel

Huh, sound?

166,880 XP

29th January 2007

0 Uploads

15,678 Posts

0 Threads

#9 10 years ago

I'd seequite a simple concept of getting the update and temprature to be honest. Albeit very rough.

You can have a 3d area in which you will have simple mesh boxes which will be invisible. Each of these carries a temperature value. The temperature value would get updated the moment the hunter collides with a new box.




adelphospro

I'm accepted, He was condemned

50 XP

26th February 2007

0 Uploads

1,458 Posts

0 Threads

#10 10 years ago
If you are planning to do a full overhaul of the engine into a modern engine, converting the current engine to c++ is not going to be the biggest challenge :P. How much are you planning to change in the engine?

Well, here's what it looks like:

I've got a few CPP files: game.cpp (Contains things like loading the resources, etc) hunt.cpp (Contains the actual hunt functions, like trapping character input, tracking the player, and processing kills, the main game loop etc characters.cpp (mostly contains the different dinosaur AI and such) renderd3d.cpp (The core of the 3d engine; this simply uses raw DX6 I believe commands to draw objects and stuff) mathmatics.cpp (Guess :P)

hunt.h (The main header. Contains alot of global variables and structs. NO classes, but I added one for dinosaur hunting packs)

Sound is now controlled using irrklang (used to be old external dlls and directsound which had loads of problems).

What I originally wanted to do was move the game to irrict, since the majority of the game is renderd3d.cpp and the dinosaur AI.

I also thought about compacting everything into different classes, like: graphics->drawscene(); sound->play2D(etc); etc.

I don't know. There's alot to do and too little time lol

Whatever I do I should not have alot to program except the ai, which is pretty simple actually (Dinos wander around until they get "spooked", then they'll attack or run depending on their type) Each AI had their own function, which I think kind of sucks (I hate functions. Classes are my favs)

Anyway, I'm sort of alone on the project (The other C++ programers are buisy with other projects. I'm kind of the only one doing the game code).

I'd seequite a simple concept of getting the update and temprature to be honest. Albeit very rough. You can have a 3d area in which you will have simple mesh boxes which will be invisible. Each of these carries a temperature value. The temperature value would get updated the moment the hunter collides with a new box.

No kidding.

That would be the ideal method, but the problem is I haven't seen any mesh boxes used in the engine. It seems all collision checking is done using pure mathematics (Those russians are too darn smart).




  • 1
  • 2