Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / dec health by distance

Author
Message
SAAB Driver
19
Years of Service
User Offline
Joined: 1st Nov 2005
Location:
Posted: 24th Aug 2009 20:51
Hi i have been working with this one for a while.
What i am tryin to write is a code for a bombexplosion.
The players health value will dec if the bomb explode and the player is within a certain distance from the explosion.

I have searh the forum and i have found a lot of distance codes but i dont understand how to use for this code witch would be something like this :


Thanks for taking time guys!

Hello!
Indicium
16
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 24th Aug 2009 23:42
Maybe a bomb range,

say,


something like that?

Omricon W.I.P
chwilly
15
Years of Service
User Offline
Joined: 23rd Feb 2009
Location:
Posted: 25th Aug 2009 04:57
Why not get a vector of the distance between the player and the bomb:

SAAB Driver
19
Years of Service
User Offline
Joined: 1st Nov 2005
Location:
Posted: 25th Aug 2009 22:11
Thank you!

chwilly
Can you please explain that code, what each part means and i would be very greatful. Ive seen it before but i dont understand. how can i for example change the width of the "bomb hurt area" in that code?

I am very greatful for this help

Hello!
Dream And Death
18
Years of Service
User Offline
Joined: 21st Feb 2006
Location: The circus! Juggling job, kids and DBPro
Posted: 26th Aug 2009 00:21
SAAB - all that chwilly's code does is to give you the distance between the player and the bomb.

You need to work out the damage from that.

A reasonable formula for damge by distance might be something like:
Damage = 100/(Dist+1)
This would do 100 damage at Dist = 0, (I use Dist + 1 to get rid of the problem of dividing by zero), then do 50 damage at one unit distance, then 33.3 at 2 units and so on down to ~9 damage at 10.

If you want a wider radius for the explosion, you could do something like:
Damage=100/((Dist/10)+1)
which would reduce much slower.

"You get what everyone gets, you get a lifetime!" - Death, The Sandman Library

First you Dream, then you ... - Neil Gaiman, 2001
chwilly
15
Years of Service
User Offline
Joined: 23rd Feb 2009
Location:
Posted: 26th Aug 2009 09:26
I like SAAD's idea for damage based on distance.

The code is just the Pythagerean theorom:

a^2 + b^2 = c^2 (c = the distance between the player and the bomb)

so c = sqrt(a^2 + b^2)

I don't know if DB has a native command to get that thought.
chwilly
15
Years of Service
User Offline
Joined: 23rd Feb 2009
Location:
Posted: 26th Aug 2009 09:48
Woops, that wasn't SAAD's idea it was Dream And Death's idea, sorry

Login to post a reply

Server time is: 2024-11-25 02:44:19
Your offset time is: 2024-11-25 02:44:19