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 / Function Problem!!!

Author
Message
demons breath
20
Years of Service
User Offline
Joined: 4th Oct 2003
Location: Surrey, UK
Posted: 2nd Jan 2005 21:34 Edited at: 2nd Jan 2005 21:39
I am making a First Person Shooter and I wrote a basic code for the thugs using Pythagoras' theorem to detect if you are within a certain distance from them:


When I try and create a function for this, however, it doesn't do anything. This is my function:


I am calling this function using:




<!--EDIT-->
object no's are all between 36-45
thugno = 3
Thugpos#(t,1),Thugpos#(t,2) and Thugpos#(t,3) store the x, y and z positions of the object (t*5)+26 respectively
guardlimit(t) is the natural alertness of thug t
susp#(t) is the suspicion of thug t (If he notices you this will go up, but then it will decrease again gradually as he doesnt see you

The models are being rotated by 180 degrees because I need to do that for all the guard models I'm using (DM1 - thug)

Am I the only one here who's really confused?
http://db1games.topcities.com
(used to be demonsbreath)
wmf
19
Years of Service
User Offline
Joined: 6th Nov 2004
Location:
Posted: 3rd Jan 2005 00:34

this might be an easier way
demons breath
20
Years of Service
User Offline
Joined: 4th Oct 2003
Location: Surrey, UK
Posted: 3rd Jan 2005 01:14
Thanks wmf - my function is now
, and I'm calling it with
but it still doesn't work [img] [/img]

Am I the only one here who's really confused?
http://db1games.topcities.com
(used to be demonsbreath)
wmf
19
Years of Service
User Offline
Joined: 6th Nov 2004
Location:
Posted: 3rd Jan 2005 02:46
is x#,y#,z$ and any other variables in the function declared global.
I can't run the code so I can't help very much.
wmf
19
Years of Service
User Offline
Joined: 6th Nov 2004
Location:
Posted: 3rd Jan 2005 02:49
oops, correction z#
blanky
20
Years of Service
User Offline
Joined: 3rd Aug 2004
Location: ./
Posted: 3rd Jan 2005 19:01
Yeah - for example, the following code WOULD NOT WORK:

(DBC & DBPro-compatible)

z#=3.1
DoStuff()
wait key
end
function DoStuff()
print z#
endfunction

You'd get a big '0' on your screen.

This is because variables that are inside a function, and variables that are outside a function are kept seperate, and as soon as a function finishes all that function's variables disappear.

Therefore, I think it'd be better to actually do the moving and animating code of the thugs inside the ThugAI() function.

2005. 2005. 2005. No way. 2005. 2005. You've got to be kidding me. 2005 already!?
demons breath
20
Years of Service
User Offline
Joined: 4th Oct 2003
Location: Surrey, UK
Posted: 3rd Jan 2005 19:02 Edited at: 3rd Jan 2005 19:10
oops...

I'll jus change those to camera position z() etc...

[edit]
:-( DBC doesn't support global variables... guess I'll have to do everything the hard way - how do you return values from a function? because I'll need to do that for all of the Susp# values etc...
[/edit]

Am I the only one here who's really confused?
http://db1games.topcities.com
(used to be demonsbreath)
demons breath
20
Years of Service
User Offline
Joined: 4th Oct 2003
Location: Surrey, UK
Posted: 4th Jan 2005 02:26
Thanks a lot for all the help - I decided just to use a gosub instead of a function in the end.

Am I the only one here who's really confused?
http://db1games.topcities.com
(used to be demonsbreath)

Login to post a reply

Server time is: 2024-09-23 08:23:57
Your offset time is: 2024-09-23 08:23:57