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.

DarkBASIC Discussion / Player controlling empty A.I vehicles

Author
Message
vampyre
22
Years of Service
User Offline
Joined: 14th Nov 2002
Location:
Posted: 15th Aug 2004 07:28 Edited at: 15th Aug 2004 21:05
I think I can suss out how to make NPC A.I and player pilots/drivers get into and out of vehicles

But how would I allow a player to control an empty A.I vehicle, and how can I allow the revers to be true as well to let an A.I pilot controll an empty player vehicle plus how can I allow an A.I player to control a vehicle with the player as a passenger, for example say the player is a captain of a Starship and he orders his helm to turn left or right how can I do this and still allow the player to be able to take control the ship if he has too?
Ilya
21
Years of Service
User Offline
Joined: 10th Aug 2003
Location:
Posted: 15th Aug 2004 12:37 Edited at: 15th Aug 2004 13:05
Arrays.
Custom Types(If that's in DBC).

If the AI isn't hostile, it will let the player in and maybe let him drive.

-Ilya
vampyre
22
Years of Service
User Offline
Joined: 14th Nov 2002
Location:
Posted: 15th Aug 2004 21:06 Edited at: 19th Aug 2004 08:13
Cutom types isn't that more Blitz Basic? Arrays? how do you do it with arrays then?
Ilya
21
Years of Service
User Offline
Joined: 10th Aug 2003
Location:
Posted: 16th Aug 2004 03:45 Edited at: 16th Aug 2004 04:03
Custom Types are in DBP.

Arrays:

Sample program:

This example creates a 2-dimension array.
It then fills random areas of the array with random numbers.
Then it displays the value of random locations of the array.

`Make resaults diffrent every run
randomize timer()
`Make a 2d array
DIM arrayname(10,10)
`For loop
for i=1 to 50 step 1
`A random position in the array = a random number
arrayname(rnd(9)+1,rnd(9)+1) = rnd(1000)
`End of for loop
next
`Do loop
do
`i1 = random number from 1-10
i1=rnd(9)+1
`same with i2
i2=rnd(9)+1
`print the number in a random location in the array
print str$(i1)+" - "+str$(i2)+" = "+str$(arrayname(i1,i2))
`wait a little
wait 500
`end of do loop
loop

Code to store bot names and types:

Type 1 is hostile1
Type 2 is nutrul1
Type 3 is friendlyL1
Type 4 is friendlyM1
Type 5 is friendlyH1
Type 6 is hostile2
Type 7 is nutrul2
Type 8 is friendlyL2
Type 9 is friendlyM2
Type 10 is friendlyH2
Use space to modify a bot and control to lookup a bot.

The code:
dim bottypes(10)
bottypes(1)=1
bottypes(2)=1
bottypes(3)=1
bottypes(4)=1
bottypes(5)=1
bottypes(6)=1
bottypes(7)=1
bottypes(8)=1
bottypes(9)=1
bottypes(10)=1
do
if spacekey()=1
input "Which bot(1-10)? ",botnum
if botnum<1 or botnum>10 then goto addfail
input "Change to what type(1-10)? ",bottype
if bottype<1 or botntype>10 then print "Invalid" : goto addfail
bottypes(botnum)=bottype
if bottype=1 then print "botnum "+str$(botnum)+" is now hostile1"
if bottype=2 then print "botnum "+str$(botnum)+" is now nutrul1"
if bottype=3 then print "botnum "+str$(botnum)+" is now friendlyL1"
if bottype=4 then print "botnum "+str$(botnum)+" is now friendlyM1"
if bottype=5 then print "botnum "+str$(botnum)+" is now friendlyH1"
if bottype=6 then print "botnum "+str$(botnum)+" is now hostile2"
if bottype=7 then print "botnum "+str$(botnum)+" is now nutrul2"
if bottype=8 then print "botnum "+str$(botnum)+" is now friendlyL2"
if bottype=9 then print "botnum "+str$(botnum)+" is now friendlyM2"
if bottype=10 then print "botnum "+str$(botnum)+" is now friendlyH2"
addfail:
endif
if controlkey()=1
input "Which bot(1-10)? ",botnum
if botnum<1 or botnum>10 then print "Invalid" : goto viewfail
bottype=bottypes(botnum)
print bottype
if bottype=1 then print "botnum "+str$(botnum)+" is hostile1"
if bottype=2 then print "botnum "+str$(botnum)+" is nutrul1"
if bottype=3 then print "botnum "+str$(botnum)+" is friendlyL1"
if bottype=4 then print "botnum "+str$(botnum)+" is friendlyM1"
if bottype=5 then print "botnum "+str$(botnum)+" is friendlyH1"
if bottype=6 then print "botnum "+str$(botnum)+" is hostile2"
if bottype=7 then print "botnum "+str$(botnum)+" is nutrul2"
if bottype=8 then print "botnum "+str$(botnum)+" is friendlyL2"
if bottype=9 then print "botnum "+str$(botnum)+" is friendlyM2"
if bottype=10 then print "botnum "+str$(botnum)+" is friendlyH2"
viewfail:
endif
loop

EDIT Fixed Code Above
EDIT Fixed Code Above Again
EDIT Fixed Code Above Again And Now Works!

-Ilya
vampyre
22
Years of Service
User Offline
Joined: 14th Nov 2002
Location:
Posted: 16th Aug 2004 04:18
Thanks !!!!!!! although I will have to figure it out but thanks Ilya
Ilya
21
Years of Service
User Offline
Joined: 10th Aug 2003
Location:
Posted: 16th Aug 2004 14:06
I segest thinking of arrays as varibles with paramiters.

-Ilya
vampyre
22
Years of Service
User Offline
Joined: 14th Nov 2002
Location:
Posted: 19th Aug 2004 08:12
OK Ilya but how would this be done using DBC? I see that the code you put up was for DBP I know that I really got to learn to understand the variables in Dark Basic as I need to get the in and out of vehicles thing learnt

Login to post a reply

Server time is: 2025-05-25 10:09:37
Your offset time is: 2025-05-25 10:09:37