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 / them wacky ERRORS.. and my ignorace of course

Author
Message
Uriel The Ignoble
23
Years of Service
User Offline
Joined: 13th Jun 2003
Location: In a tiny box in the attic
Posted: 22nd Jun 2003 18:30
im trying to make some weapons for FPS here.. the program runs fine without them but when i add this code it works until i press the mousebutton 1 and it freezes and crashes and gives me an error
the variables also wont print.. they aren't a necesity i just like to see them in action to make sure they are working.. which they.. arent!.. can anyone tell me what im doing wrong?..
Uriel The Ignoble
23
Years of Service
User Offline
Joined: 13th Jun 2003
Location: In a tiny box in the attic
Posted: 22nd Jun 2003 19:00
oops.. yeah i fixed the problem halfway, i had a bunch of variables screwed up and made an endless loop which crashed the program :-p
i fixed it from crashing to just doing nothing at all, which is slightly better than crashing, ill post the "fixed" code..

thats why i put this post in "newcommers corner"

Scorpyo
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: italy
Posted: 22nd Jun 2003 19:11
You can t call a routine from inside it

>shooting:
If mouseclick() = 1
shooting = 1
gosub shooting:
endif

This is how i see your code should be done..may be wrong tho since i do not know what you want to do exactly..

Rem Make bullet
FOR t = 4 to 20
make object sphere t, 2
position object t, camera position X(),camera position Y(),camera position Z()
NEXT t

REM movement Variables
run# = 0
stamina# = 360 - run#
jmp = 0
time# = 0

REM shooting variables
shooting# = 0
bulletrange# = 50
bulletspread# = 30
bulletrate# = 60
bulletspeed# = 20
waittime# = 0
bulletlife# = 0
ammo# = 40

Do
Gosub Input_movement
If mouseclick() = 1 then shooting = 1
If mouseclick() = 0 then shooting = 0
gosub shooting
sync
loop

REM shooting

shooting:
REM guntypes : 1= bullets 2= missles, 3= thrown, 4= seeking
If guntype# = 1 and shooting = 1 and bullets > 1 and waittime = bulletrate
set object to camera orientation t
bX# = newxvalue(X#,object angle y(t)+rnd(bulletspread),bulletspeed)
bZ# = newyvalue(Z#,object angle y(t)+rnd(bulletspread),bulletspeed)
ammo = ammo - 1
inc bulletlife
waittime = 0
shooting = 0
position object t, bX#,camera position y(),bZ#

REM repeat
REM inc waittime
REM until waittime = bulletrate

endif
set cursor 0,0
print shooting#
print bulletrange#
print bulletspread#
print bulletrate#
print bulletspeed#
print waittime#
print bulletlife#
print ammo#
return
Uriel The Ignoble
23
Years of Service
User Offline
Joined: 13th Jun 2003
Location: In a tiny box in the attic
Posted: 22nd Jun 2003 20:58
i found that gosub problem after i posted.. thats fixed.. anywayz i also have some variable problems, i already had t set to help randomize the textures on the matrix, i changed the code a little bit but it still doesn't work. I thought at 1st maybe its shooting but just not where i can see it, so i set the sphere bullet to where i can see it, and its still not moving.

what im trying to do is make weapons that are more flexable and have differnt stats. like varrying accuracy which is why i put in bulletspread# and this thing:
bX# = newxvalue(camera position x(),object angle y(b)+rnd(bulletspread#),bulletspeed#)

i want the objects initial position to be the camera position, i want it to move at its facing (which is already set to = the camera's facing) and move at that angle, plus innacuracy provided by bulletspread#, and move at bulletspeed# speed.

with newvalue, does the 1st number have to be its actual old position? because when the map loads its sitting in the corner near 0,0,0

Uriel The Ignoble
23
Years of Service
User Offline
Joined: 13th Jun 2003
Location: In a tiny box in the attic
Posted: 22nd Jun 2003 21:15
sorry to post constant replies to my own message.. but im figuring new stuff out as i work on it..
i think i found the source of my problems, but i have no idea how to fix it...
i believe it will work now except that now when i shoot, it crashes and says the object does not exist at line 89, line 89 is "set object to camera orientation b"
does the program not accept b as a variable?.. b is suppose to equal 4-20....

Scorpyo
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: italy
Posted: 22nd Jun 2003 23:00
sure it does accept it..
are you sure that the object has not been deleted or that b carries the right value within 4-20 ?
Uriel The Ignoble
23
Years of Service
User Offline
Joined: 13th Jun 2003
Location: In a tiny box in the attic
Posted: 23rd Jun 2003 01:37
ill post the code i have right now..
when i click, it crashes and says that object does not exist still.. at the line that says "set object to camera orientation b"

maybe i did something wrong with the For&next thingie...

Scorpyo
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: italy
Posted: 24th Jun 2003 00:25
you don 't re-declare b anywhere before calling the routine
at the exit of the "for b=4 to 20 next b" loop, b will hold 21, therefore the error

Login to post a reply

Server time is: 2026-07-05 22:37:08
Your offset time is: 2026-07-05 22:37:08