Hi, How would I make an entity do a melee attack. When I try to set the ai set antity attack distance to, lets say, 5, the monster attack at a more greater distance. here's my code:
REM Project: AI
REM Created: 2007-02-28 18:01:06
REM
REM ***** Main Source File *****
REM
sync on
sync rate 60
hide mouse
autocam off
ai start
make object box 1, 5, 2.5, 5
load object "monster-animated-character-X.x", 2
scale object 2, 15, 15, 15
position object 2, 50, 0, 50
make object box 3, 15, 2.5, 5
position object 3, 25, 0, 25
ai add static obstacle 3
ai add enemy 2
ai set entity aggressive 2
ai set entity view arc 2, 90, 180
ai set entity view range 2, 100
ai set entity avoid distance 2, 10
ai set entity attack distance 2, 5
ai set entity speed 2, 25.0
ai debug show paths 0
ai debug show waypoint edges 0, 0
ai debug show waypoints 0, 0
set object speed 2, 50
ai add player 1, 1
do
Move()
Camera()
Stats()
if ai get entity is moving(2)=1 then loop object 2, 150, 210
attack = ai get entity can fire(2)
if DistTarget(2) <= 1
if ai get entity can see(2, ai get entity destination x(2), ai get entity destination z(2), object position y(1)) = 1
attack = 1
endif
endif
if attack = 1
ai entity look at position 2, ai get entity destination x(2), ai get entity destination z(2)
ai entity stop 2
loop object 2, 250, 330
endif
ai update
sync
loop
function DistTarget(object)
Dist# = sqrt((ai get player x() - ai get entity x(object)) + (object position y(1) - object position y(object)) + (ai get player z() - ai get entity z(object)))
endfunction Dist#
function Stats()
text 0, 0, "FPS: "+str$(screen fps())
text 0, 10, "Ai: "+ ai get entity action$(2)
text 0, 20, "X: "+str$(object position x(2) - object position x(1))
text 0, 30, "Z: "+str$(object position z(2) - object position z(1))
endfunction
function Move()
if keystate(17)=1
XAngle# = object angle x(1)
xrotate object 1, 0
move object 1, .5
xrotate object 1, XAngle#
endif
if keystate(31)=1
XAngle# = object angle x(1)
xrotate object 1, 0
move object 1, -.5
xrotate object 1, XAngle#
endif
if keystate(30)=1 then move object left 1, .5
if keystate(32)=1 then move object right 1, .5
endfunction
function Camera()
position camera object position x(1), object position y(1)+5, object position z(1)
rotate camera camera angle x(0)+(mousemovey()/4.0),camera angle y(0)+(mousemovex()/4.0), 0
rotate object 1, camera angle x(0)+(mousemovey()/4.0), camera angle y(0)+(mousemovex()/4.0), 0
endfunction
Windows XP,pentium IV, 3.0 MGZ, 1024 mb memory, 256 mb ATI Radeon PCIE X700 Pro 'sett squadron back on the assault'