home home

downloads files

forum forum

docs docs

wiki wiki

faq faq

Cube & Cube 2 FORUM


adding drowning

by phoenixsux on 11/22/2007 22:58, 10 messages, last message: 11/29/2007 22:27, 1571 views, last view: 04/27/2024 11:20

dificulty - not quite for C++ noobies

*NOTE: MY MODIFYVELOCITY AND OTHER SUBS ARE FURTHER MODIFIED FOR OTHER MATTS, YOUR PASS VARABLES WILL NOT MATCH IN THIS AND SOME OF THE OTHER SUBS POSTED.
THE COMPLETE MOD SOURCE MAY NOT BE LISTED HERE DUE TO ME NOT HAVING DOCUMENTED MY CHANGES AND I APPOLOGIZE FOR ANY INCOMPLETE INFORMATION.


In some games, such as some quake games, when you are under water for too long you start to drown.
these are the instructions for how to add this into your game mod and apparently holds up true with network play (not tested on laggy connections)

in struct physent of ents.h
at the top where you're defining your varables add in:

int wair; //represents air in lungs or water air
bool water; //will become true when in water, false when out.


in
void reset() of struct physent add in:
wair = 5000;

in fps.cpp
void update world (vec &pos, int curtime, int lm)
after
maptime += curtime;
add this line:
doMATTS(curtime);

before
void update world(ved &pos, int curtime, int lm)
add in this void function:

void doMATTS (int curtime)
{
//matts modifiers will be placed here.
if (player1->water)
{
int mytime;
mytime = curtime / 5;
if (mytime < 1) mytime = 1;
player->wair = player1->wair - (mytime);
}
if (!player1->water)
{
player1->wair = player1->wair + (curtime/2);
}
if (player1->wair > 5000) player1->wair = 5000;
if (player1->wair <0)
{
worldhurts(player1,curtime);
player1->wair = 500;
}
}

in fps.cpp
void gameplayhud (int w, int h)
after
draw_textf("%d",90,822,player1->state==CS_DEAD > 0 : player1->health);
add this line:
draw_textf("%d",450,822,(player1->wair/50));

*in physics.cpp
void modify velocity(physent *pl, bool local, bool water, bool floating, int curtime, bool ladder)

pl->water = water;

*in physics.cpp
bool moveplayer(physent *pl, int movers, bool local, int curtime)

( is this line in the default source code? i don't recall. make sure this line is in there:
bool water = c.ext && c.ext->material == MAT_WATER;

)

after

float secs = curtime / 1000.f;

*add this line:
modifyvelocity(pl,local,water,floating,curtime,ladder);



IF this works for you then you will see a new air indicator on your screen.
it will go down when you're in the water and up when you're out of the water.
when you're in the water and it hits zero then you get roughly 10 points of damage per second until you get to the surface.
on the surface it will take a small amount of time to refill your lungs for your next dive.

   Board Index   

#1: ..

by yvfc_cebtenzzre on 11/22/2007 23:43

have you heard of unified diff?

reply to this message

#2: ..

by Julius on 11/23/2007 00:44

na, this is more of a tutorial on how to do certain things, thus it is nice the way it is.

All these tutorials really need to be added to the wiki though.

reply to this message

#3: Re: ..

by tentus_ on 11/23/2007 02:19, refers to #2

Still, it's a good idea to put them up here so people can give input and discuss them- moreover, any redundancy between the forum and the wiki just make it easier for people to find what they want. Text is cheap.

reply to this message

#4: subs/functions

by demosthenes on 11/28/2007 03:56

While the two terms are functionally identical, the correct term in C++ is "function" rather than "sub", which is a shortened form of "subroutine" from BASIC.

reply to this message

#5: Lava damage

by SheeEttin on 11/28/2007 04:15

Hmm, this reminds me...
I've done some thinking about lava. Does anyone else think that lava should do some damage as it's being stood in (i.e. lava and player bounding box colliding = damage)? Full submersion would still kill, of course...

reply to this message

#6: Re: Lava damage

by shadow,516 on 11/28/2007 04:20, refers to #5

I suggested this to eihrul, and he said it was too complicated

reply to this message

#7: Re: Lava damage

by w 400% on 11/28/2007 04:22, refers to #5

i was thinking another material like acid would be good t0o. Same as lava except that its slowly deals damage.

reply to this message

#8: Re: Lava damage

by SheeEttin on 11/28/2007 05:29, refers to #6

Doesn't seem complicated... But then, I'm not the one who'd be doing the coding. :P

reply to this message

#9: Re: Lava damage

by Hirato Kirata on 11/29/2007 10:50, refers to #7

You can make lava look like acid using /materialreset

and following that up with

/texture lava "path to acid-tex"
/texture 1 "path to acid-tex"

you can see an example of such commands no <a href="http://www.quadropolis.us/node/967">quadropolis</a>

reply to this message

#10: Re: Lava damage

by SheeEttin on 11/29/2007 22:27, refers to #9

Yeah, you could use that bright green texture... Maybe make it partially transparent, like the water.
(You'd also need to set lavacolour to match the texture color. Maybe lavafog as well.)

reply to this message

   Board Index   


Unvalidated accounts can only reply to the 'Permanent Threads' section!


content by Aardappel & eihrul © 2001-2024
website by SleepwalkR © 2001-2024
53871315 visitors requested 71646517 pages
page created in 0.017 seconds using 10 queries
hosted by Boost Digital