Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (dr_panther, VoroneTZ, AndrewAMD), 834 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 4 1 2 3 4
Falling Damage #456940
12/16/15 11:27
12/16/15 11:27
Joined: Jun 2010
Posts: 590
California
Ruben Offline OP
User
Ruben  Offline OP
User

Joined: Jun 2010
Posts: 590
California
I am trying to make it so that if the player falls vertically a certain distance, the player will take damage to its health.

So far, this is the code that causes the player to fall with gravity:

Code:
action player_code()
{
   ...

   dtimer();
			
   if(c_trace(my.x, vector(my.x, my.y, my.z - my.FEET_HEIGHT), 
      IGNORE_ME | IGNORE_PASSABLE | IGNORE_PASSENTS | 
      USE_POLYGON))
   {
      time_elapsed = dtimer();
	      	
      my.z = target.z + (my.FEET_HEIGHT);	
	         
      DEBUG_VAR(my.z, 150);
      DEBUG_VAR(time_elapsed, 200);
	         
      gravity_var = 0;
      jumplck = 0;	
	         
      if(time_elapsed >= 20)
      {
         beep();
      }
   }

   ...	
}



I am assuming that I would use the dtimer() function somehow, in that if the player falls within a certain amount of time, the player will take a certain amount of damage?

Right now, I am trying to get the program to beep() while the player is falling in mid-air, and run the dtimer() during that period of falling. No beeping is occurring while the player falls in mid-air, with the above code. Does anyone know how I can measure how long the player falls?

I notice that the time_elapsed and my.z values using the DEBUG_VAR() function above disappear to nothing (no value visible) while the player falls in mid-air. These values only show up when the player is walking on the ground without falling.

Does anyone have an idea on how to make the player take damage while falling? I am trying different methods, but none seem to be working. Any help would be appreciated. Thank you.

Last edited by Ruben; 12/16/15 18:30.
Re: Falling Damage [Re: Ruben] #456951
12/16/15 15:16
12/16/15 15:16
Joined: Feb 2012
Posts: 371
Dico Offline
Senior Member
Dico  Offline
Senior Member

Joined: Feb 2012
Posts: 371
Use c_trace when player in air then when player on the ground calcule the deffrent between the first point in air and the point when player on the ground .
The distance between these two point its the damage health.

Re: Falling Damage [Re: Dico] #456957
12/17/15 04:36
12/17/15 04:36
Joined: Jun 2010
Posts: 590
California
Ruben Offline OP
User
Ruben  Offline OP
User

Joined: Jun 2010
Posts: 590
California
But I wonder how I would take a point before, and another point after falling, and compare the two. In other words, I am trying to figure out where in the code the actual falling takes place.

Even when I put this code in the program:

Code:
action player_code()
{
   ...

   DEBUG_VAR(my.z, 150);

   ...

   if(my.z == NULL)
   {
      beep();
   }

   ...
}



...the game does not beep when the player drops off a cliff in mid-air, even though my.z does not give off any value through the DEBUG_VAR() function while the player is falling. my.z does show a value through DEBUG_VAR() when the player is touching the ground.

Last edited by Ruben; 12/17/15 04:38.
Re: Falling Damage [Re: Ruben] #456958
12/17/15 05:00
12/17/15 05:00
Joined: Jun 2010
Posts: 590
California
Ruben Offline OP
User
Ruben  Offline OP
User

Joined: Jun 2010
Posts: 590
California
Even if I change the code to:

Code:
if(my.z < 0)
{
   beep();
}


or
Code:
if(my.z > 0)
{
   beep();
}


or
Code:
if(my.z == 0)
{
   beep();
}


or
Code:
if(my.z == NULL)
{
   beep();
}



...no beeping is taking place while the player is not touching the ground, while jumping or falling off a ledge.

For the:
Code:
if(my.z > 0)
...


The game beeps when the player is touching the ground, but does not beep when the player jumps, or falls off a ledge. In other words, every time the player is not touching the ground, no beeping takes place.

Last edited by Ruben; 12/17/15 05:01.
Re: Falling Damage [Re: Ruben] #456960
12/17/15 05:44
12/17/15 05:44

M
Malice
Unregistered
Malice
Unregistered
M



^ both post
LMFAO!!!!

the player my.z is it's z location in the world.
Code:
var z_before =0;
var z_after =0;
var fall=0;
while()....

{

if()....
z_before=my.z; 
.... fall
if(my.falling !=true)
z_after=my.z;
fall=vec_dist(vector(0,0,z_before),vector(0,0,z_after));
}



my.z ==0 only when your player is at world (x,x,0)

Who's code did you hijack and hack up? Really man, you don't know where in your code, you wrote the part that does the falling?

Thanks for the laughs
Mal

Last edited by Malice; 12/17/15 05:47.
Re: Falling Damage [Re: ] #456961
12/17/15 06:19
12/17/15 06:19
Joined: Jun 2010
Posts: 590
California
Ruben Offline OP
User
Ruben  Offline OP
User

Joined: Jun 2010
Posts: 590
California
Okay, I see your point about my.z = 0. But what about my.z = NULL?

When the player stands on a ledge, my.z = 2333.827 . When the player walks off the ledge, and the player is falling in mid-air, the value of my.z disappears to nothing, as in no value visible. I would think that the my.z would still remain visible, and show it counting down rapidly, but it does not.

When the player lands on the ground, a value for my.z suddenly appears as 49.267. Yes, I would like to take 2333.827 - 49.267 = 2284.56, and judging by 2284.56, give the player damage to its health, but I am trying to make this work for any two values that my.z ends up equaling, after the player falls.

And yes, to be honest, I believe I got this code from someone else a long time ago. I thought I understood enough of it to be effective for me, but I have unexpectedly run into this issue. When I solve this issue, it will allow me to understand it better.

Re: Falling Damage [Re: Ruben] #456962
12/17/15 07:23
12/17/15 07:23
Joined: Jun 2010
Posts: 590
California
Ruben Offline OP
User
Ruben  Offline OP
User

Joined: Jun 2010
Posts: 590
California
So, I notice that when I place this code in the program:

Code:
action player_code()
{
   ... 

   if(my.z > 49)
   {
      beep();
   }

   ...
}



...the game beeps like crazy while the player is at my.z = 2333.827 . If I jump in the air (not stepping off a ledge), the game stops beeping while I am in the air, and resumes beeping once the player lands back on the ground.

When the player steps off a ledge and falls in mid-air, the game stops beeping while the player falls, and starts beeping again once the player lands on the ground with a my.z of 49.267 .

Re: Falling Damage [Re: Ruben] #456963
12/17/15 07:50
12/17/15 07:50
Joined: Jun 2010
Posts: 590
California
Ruben Offline OP
User
Ruben  Offline OP
User

Joined: Jun 2010
Posts: 590
California
Okay, I see where I am falling (surprised why I did not notice it before):

Code:
action player_code()
{
   ...

   var gravity_force = 2;

   ...

   my.GRAVITY_VAR -= gravity_force * time_step;

   ...

   c_move(me, move_vec, vector(0, 0, my.GRAVITY_VAR), USE_POLYGON | 
      IGNORE_PASSABLE | GLIDE); 

   ...

   DEBUG_VAR(my.z, 300);

   ...
}



It seems to me that my.GRAVITY_VAR should be affecting my.z while player is falling, but it shows nothing while player falls, judging by the DEBUG_VAR(my.z, 300); .

Last edited by Ruben; 12/17/15 07:52.
Re: Falling Damage [Re: Ruben] #456964
12/17/15 10:08
12/17/15 10:08
Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
txesmi Offline
Serious User
txesmi  Offline
Serious User

Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
When player touches the floor if player falling speed is faster than a fixed amount substract to the health.

Salud!

Re: Falling Damage [Re: txesmi] #456965
12/17/15 11:05
12/17/15 11:05
Joined: Mar 2012
Posts: 927
cyberspace
W
Wjbender Offline
User
Wjbender  Offline
User
W

Joined: Mar 2012
Posts: 927
cyberspace
approach your problems with the theory behind the code .

"As an object falls, its speed increases
because it's being pulled on by gravity.
The acceleration of gravity near the earth
is g = -9.81 m/s^2. To find out
something's speed (or velocity ) after a
certain amount of time, you just multiply
the acceleration of gravity by the amount
of time since it was let go of"

this is how the equation for calculating a falling object's velocity is described by a physics site , therefore given the theory and equations , you need simply the correct values to plug in to the equations under the correct conditions .

if you ever face a problem , remember that there are real world answers , to approach it .


Compulsive compiler
Page 1 of 4 1 2 3 4

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1