Hi all,
i'm trying to make an FPS with DBC, in many parts of the game i closely followed the tutorial "monster hunts", but i have a problem.
My enemy, is always rotated like of 180° in front of me, but it moves, and it shoots in the right way. I saw the piece of code from the turorial, and it's the same, but i can't understand why it's rotated.
I tried in many ways to turn it in the right direction, but i always falied

.
Would you please help me?
The interested piece of code should be in the MonsterAI subroutine, i think it's a "point object" or "set object to object orientation" that is wrong.
here is the full code:
rem ---/// AREA di PROGETTO \\\---
rem ---/// Boglione Luca, Cerati Alberto, Pasero Pier Franco, Testa Stefano 5D INF \\\---
Sync on
Sync rate 60
hide mouse
Backdrop on
Set camera range 1,5000
Autocam off
randomize rnd(20)
fog on
fog color RGB(210,0,0)
fog distance 1500
Set ambient light 80
backdrop on
load image "C:\User\warea\marte.bmp",3
texture backdrop 3
rem Caricamento Matrice con applicazione di texture
make matrix 1,50000,50000,70,70
Load image "C:\user\warea\rock116.bmp",1
load image "C:\user\warea\fire.bmp",4
load image "C:\user\warea\metal008.bmp",2
prepare matrix texture 1,1,1,1
load image "C:\user\warea\SnowBricks.bmp",3
load image "C:\user\warea\mirino.bmp",1337
rem Posizionamento dei muri alla fine della matrice
make object plain 6,55000,500
make object plain 7,55000,500
make object plain 8,55000,500
make object plain 9,55000,500
texture object 6,3
scale object texture 6,0.5,0.5
texture object 7,3
scale object texture 7,0.5,0.5
texture object 8,3
scale object texture 8,0.5,0.5
texture object 9,3
scale object texture 9,0.5,0.5
position object 6,25000,Get Ground Height(1,5000,5500)-1,0
position object 7,25000,Get Ground Height(1,5000,5500)-1,50000
position object 8,50000,Get Ground Height(1,5000,5500)-1,25000
position object 9,0,Get Ground Height(1,5000,5500)-1,25000
yrotate object 8,90
yrotate object 9,90
scale object texture 6,500,5
scale object texture 7,500,5
scale object texture 8,500,5
scale object texture 9,500,5
REM CARICO SHOTGUN .X
load object "C:\user\warea\shotgun_s.x",10
Fix object pivot 10
position object 10,1.5,-7.9,20
Lock object on 10
Rem Creo il proiettile, e lo nascondo
Make Object cylinder 2,3
xRotate Object 2,90
Fix object pivot 2
Hide Object 2
color object 2,rgb(00,00,00)
rem Carico suoni
Load sound "C:\user\warea\Sounds\pl_grass1.wav",5
Load 3dsound "C:\user\warea\Sounds\fireball2.wav",2
load 3dsound "C:\user\warea\Sounds\die.wav",6
rem Randomizzo la matrice
Fill matrix 1,0,1
randomize matrix 1,125
X#=5000
Z#=5000
REM caricamento medikits
load object "C:\user\warea\medikit.x",666
rem Carico un mostro
Load object "C:\user\warea\idle.x",4
append Object "Walk.x",4,21
rem Creo proiettile del mostro
Make Object Sphere 102,2
texture object 102,2
Hide Object 102
rem Creo esplosione mostro (sfera)
Make Object Sphere 130,20
texture object 130,4
ghost object on 130
Hide Object 130
Make Object Sphere 131,20
texture object 131,4
ghost object on 131
Hide Object 131
rem carico le particelle del mostro
For x =100 to 110
Make object plain x+10,5,5
Texture object x+10,2
Set object x+10,1,0,0
Ghost object on x+10
Hide object x+10
Next x
rem inizializzo contatore particelle
Pn=10
MPn=110
Load 3Dsound "C:\user\warea\sounds\fireball2.wav",102
Load 3Dsound "C:\user\warea\sounds\Explode.wav",103
gosub PlacePlayer
gosub PlaceMonster
rem creo l'HUD
Make object Plain 200,1,1
position object 200,-2.7,1.9,4
Lock object on 200
ghost object on 200
Make object Plain 201,1.4,0.5
position object 201,2.5,2.1,4
Lock object on 201
ghost object on 201
load image "C:\User\warea\sky01.bmp",5
texture object 201,5
rem carico la bitmap
Load Bitmap "C:\User\warea\Radar.bmp",2
Create Bitmap 1,50,50
rem mirino
Make object Plain 991,0.3,0.3
position object 991,0,-0.1,4
Lock object on 991
ghost object on 991
texture object 991,1337
REM --------> INIZIO CICLO <--------
med=0
hp$="100"
tuc=1
medikotto=0
medX#=0
medY#=0
medZ#=0
sblocca=0
faso=3
lollo#=20
do
rem movimento medikit
med=med+10
if med>360
med=0
endif
zrotate object 666,med
rem HUD
ink rgb(0,255,0),1
set cursor 520,20
print "Monster Kills: ",PlayerScore
rem Creazione di medikit
while (medikotto>=2)
medikotto=medikotto-2
tuc=1
endwhile
if (medikotto=1 and tuc=1)
tuc=0
medX#=X#+rnd(300)
medZ#=Z#+rnd(300)
medY#= get ground height(1,medX#,medZ#)
xrotate object 666,90
scale object 666,500,600,500
Position object 666,medX#,medY#+30,medZ#
show object 666
endif
rem Controllo distanza tra giocatore e medikit
if Sqrt((medX# - X#)^2 + (medY#+25 - Y#)^2 + (medZ# - Z#)^2) <29
tuc=0
hide object 666
hp=val(hp$)
hp=hp+rnd(15)
if hp>=100 then hp=100
hp$=str$(hp)
endif
set text size 44
set text to bold
text 25,415,"HP:"
text 95,415,hp$
rem Controlli per chiamate alle procedure di esplosione colpi
If MonsterBulletLife > 0 then Gosub MonsterShootBullet
If MonsterExplode > 0
Gosub MonsterExplodeRocket
else
Gosub MonsterAI
endif
rem Controllo per far durare il suono la durata di un passo, almeno
If DurPassi > 0
Dec DurPassi
if DurPassi = 0
stop sound 5
endif
Endif
Rem Movimento con il mouse
oldcAY# = cAY#
oldcAX# = cAX#
cAY# = WrapValue(cAY#+MousemoveX()*0.2)
if cAX#>=290 or cAX#<=90
cAX# = WrapValue(cAX#+MousemoveY()*0.2)
else
cAX#=cAX#+1
endif
caZ# = Camera angle Z()
Rem Controllo input della camera
If Upkey()=1
XTest# = Newxvalue(X#,cAY#,20)
ZTest# = Newzvalue(Z#,cAY#,20)
loop sound 5
DurPassi=7
If XTest#>0 and XTest#<50000 and ZTest#>0 and ZTest#<50000
X#=XTest#
Z#=ZTest#
Endif
Endif
If Downkey()=1
XTest# = Newxvalue(X#,Wrapvalue(cAY#-180),20)
ZTest# = Newzvalue(Z#,Wrapvalue(cAY#-180),20)
loop sound 5
DurPassi=7
If XTest#>0 and XTest#<50000 and ZTest#>0 and ZTest#<50000
X#=XTest#
Z#=ZTest#
Endif
Endif
If Leftkey()=1
XTest# = Newxvalue(X#,Wrapvalue(cAY#-90),20)
ZTest# = Newzvalue(Z#,Wrapvalue(cAY#-90),20)
loop sound 5
DurPassi=7
If XTest#>0 and XTest#<50000 and ZTest#>0 and ZTest#<50000
X#=XTest#
Z#=ZTest#
Endif
Endif
If Rightkey()=1
XTest# = Newxvalue(X#,Wrapvalue(cAY#+90),20)
ZTest# = Newzvalue(Z#,Wrapvalue(cAY#+90),20)
loop sound 5
DurPassi=7
If XTest#>0 and XTest#<50000 and ZTest#>0 and ZTest#<50000
X#=XTest#
Z#=ZTest#
Endif
Endif
Rem Rotate camera
if cAX#>270
if cAX#-270 > 90 then cAX#=270
else
if cAX# > 90 and cAX#-270<270 then cAX#=90
endif
YRotate camera CurveAngle(cAY#,oldcAY#,24)
XRotate camera CurveAngle(cAX#,oldcAX#,24)
Rem Position Camera
Y# = Get ground height(1,X#,Z#)
Position Camera X#,Y#+45,Z#
Rem Position Ascoltatore
Position Listener X#,Y#+35,Z#
Rotate Listener 0,cAY#,0
rem Controllo se clicca il primo tasto del mouse, ovvero se spara
if Mouseclick()=1 and BulletLife=0
Position object 2,X#,Y#+28,Z#
Set object to camera orientation 2
BulletLife =25
show object 2
Loop sound 2
faso=1
lollo#=20
Endif
rem Movimento fucile quando spara
if faso=1 and lollo#>14
lollo#=lollo#-1.7
position object 10,1.5,-7.9,lollo#
else
faso=2
endif
if faso=2 and lollo#<20
lollo#=lollo#+0.5
position object 10,1.5,-7.9,lollo#
endif
rem Salto del player con il tasto destro
if sblocca=0
if Mouseclick()=2
k#=Get Ground Height(1,X#,Z#)+35
j#=k#
ciccio#=Get Ground Height(1,X#,Z#)+130
boglio=1
endif
sblocca=1
endif
if boglio=1 and k#<ciccio#
k#=k#+7
position camera X#,k#,Z#
endif
if k#>ciccio# then boglio=0
if boglio=0 and k#>j#
k#=k#-7
j#=Get Ground Height(1,X#,Z#)+35
position camera X#,k#,Z#
if k#<j# then k#=j#
endif
if k#=j# then sblocca=0
rem Il proiettile dopo un po' cade, dura per un tot di secondi
rem Il contatore si decrementa finchè non arriva a 0
If BulletLife > 0
Dec BulletLife
Move object 2,45
bX#=Object position X(2)
bY#=Object position Y(2)
bZ#=Object position Z(2)
Position sound 2,bX#,bY#,bZ#
if Sqrt((mX# - bX#)^2 + (mY#+25 - bY#)^2 + (mZ# - bZ#)^2) <20
Gosub PlaceMonster
inc PlayerScore
medikotto=PlayerScore
MonsterBulletLife = 1
BulletLife=0
position sound 6,X#,Y#,Z#
play sound 6
endif
if BulletLife = 0
Hide object 2
stop sound 2
endif
Endif
Rem Creazione del radar
Copy Bitmap 2,1
set current bitmap 1
ink rgb(0,0,255),rgb(0,0,0)
PRX#=X#/1000
PRZ#=50-(Z#/1000)
Circle PRX#,PRZ#,1
ink rgb(255,0,0),rgb(0,0,0)
MRX#=mX#/1000
MRZ#=50-(mZ#/1000)
Circle MRX#,MRZ#,1
rem medikit
ink rgb(0,255,0),rgb(0,0,0)
RRX#=medX#/1000
RRZ#=50-(medZ#/1000)
Circle RRX#,RRZ#,1
Get image 200,0,0,50,50
set current bitmap 0
texture object 200,200
ink rgb(255,128,128),rgb(0,0,0)
if val(hp$)<=0
hp$="0"
set text size 100
k=0
repeat
text 120,200,"GAME OVER"
k=k+1
until k>8000
end
endif
Sync
loop
Rem Esplosione colpo del mostro
MonsterExplodeRocket:
Position object 130,MbX#,MbY#,MbZ#
Show object 130
Position object 131,MbX#,MbY#,MbZ#
Show object 131
EScale=20*(30-MonsterExplode)
Scale object 130,EScale,EScale,EScale
Yrotate object 130,WrapValue(MonsterExplode*37)
Scale object 131,EScale/1.5,EScale/1.5,EScale/1.5
Yrotate object 131,WrapValue(359-MonsterExplode*37)
Dec MonsterExplode
If MonsterExplode = 0 then hide object 130: Hide object 131
If MonsterExplode=18
position sound 103,X#,Y#,Z#
play sound 103
endif
If MonsterExplode < 15 then position sound 103,X#,Y#,Z#
Return
Rem Semplice IA per guidare il colpo del mostro
MonsterAI:
Point object 4,X#,Y#,Z#
position object 4,mX#,mY#,mZ#
PDist=Sqrt((mX# - X#)^2 + (mY#+25 - Y#)^2 + (mZ# - Z#)^2)
if PDist<1500
if MonsterBulletLife=0 or MonsterBulletLife < 500-Pdist/10
Point object 4,X#,Y#-15,Z#
Position object 102,mX#,mY#+32,mZ#
Set object to object orientation 102,4
MonsterBulletLife = 500
show object 102
Loop sound 102
Endif
endif
if PDist>1000
rem Salvo vecchi valori
OldmX# = mX#
OldmZ# = mZ#
OldmY# = mY#
Rem Fa partire l'animazione del movimento
Loop Object 4,21,46
Rem Muove il mostro
Move Object 4,15
Rem Get new position
mX# = Object Position X(4)
mZ# = Object Position Z(4)
mY# = Get Ground Height(1,mX#,mZ#)
Endif
Return
Rem Spara colpo del mostro
MonsterShootBullet:
Dec MonsterBulletLife
Move object 102,20
MbX#=Object position X(102)
MbY#=Object position Y(102)
MbZ#=Object position Z(102)
inc MPn
if MPn=121 then MPn=110
Scale object MPn,100,100,100
Position object MPn,MbX#,MbY#,MbZ#
Position sound 102,MbX#,MbY#,MbZ#
point object MPn,X#,Y#,Z#
Zrotate object MPn,rnd(180)
Show object MPn
for x = 1 to 10
scale object int((Wrapvalue((MPn-9+x)*36))/36)+110,100+x*25,100+x*25,100+x*25
next x
if MbY# < Get Ground height(1,MbX#,MbZ#) then MonsterBulletLife=0
Pdist=Sqrt((X# - MbX#)^2 + (Y#+25 - MbY#)^2 + (Z# - MbZ#)^2)
if Pdist<50
MonsterBulletLife = 0
hp=val(hp$)
hp=hp-rnd(30)
hp$=str$(hp)
endif
if MonsterBulletLife = 0
Hide object 102
stop sound 102
for x=110 to 120
hide object x
next x
MonsterExplode = 20
endif
Return
rem Procedura che randomizza la posizione del mostro
PlaceMonster:
mX#=X#+rnd(3000)
mZ#=Z#+rnd(3000)
mY#= get ground height(1,mX#,mZ#)
Position object 4,mX#,mY#,mZ#
loop object 4
Return
rem Procedura che randomizza la nostra posizione
PlacePlayer:
X#=rnd(10000)+500
Z#=rnd(10000)+500
Y#= get ground height(1,X#,Z#)
Position camera X#,Y#+35,Z#
Return
or just the piece of code that i think is wrong:
MonsterAI:
Point object 4,X#,Y#,Z#
position object 4,mX#,mY#,mZ#
PDist=Sqrt((mX# - X#)^2 + (mY#+25 - Y#)^2 + (mZ# - Z#)^2)
if PDist<1500
if MonsterBulletLife=0 or MonsterBulletLife < 500-Pdist/10
Point object 4,X#,Y#-15,Z#
Position object 102,mX#,mY#+32,mZ#
Set object to object orientation 102,4
MonsterBulletLife = 500
show object 102
Loop sound 102
Endif
endif
if PDist>1000
rem Salvo vecchi valori
OldmX# = mX#
OldmZ# = mZ#
OldmY# = mY#
Rem Fa partire l'animazione del movimento
Loop Object 4,21,46
Rem Muove il mostro
Move Object 4,15
Rem Get new position
mX# = Object Position X(4)
mZ# = Object Position Z(4)
mY# = Get Ground Height(1,mX#,mZ#)
Endif
Return
thank you!