I'm making a game where a player has to survive multiple levels (or waves) of enemies.
I have it working for ONE enemy, but I don't know WHERE to beggin for multiple enemies. Basically I want at each new level, the health the be multiplied by 1.5 and damage multiplied but 1.25 and the number of enemies to grow ect... so they get stronger and more in number each round.
I've tried "for i" and "freeobject" but I cannot seem to be able to control ALL the AI at once... Any help!? Here is my code!
Rem Game Variables
`Map
Level# = 1
`Player
player = 2
cam = 1
cam_limb = 3
Hero = 4
`Physics
Grav# = -10
Momentum# = 0.0
forwback# = 0
sideside# = 0
`Controls
Max_Speed# = 4
RMax_Speed# = -4
Max_Inc# = .125
Max_Dec# = .125
`Camera
Cam_distance# = -200
`Enemy
Enemy = 5
alive = 1
Health# = 100
Damage# = 10
Rem Load media
Load object "media\map\map.dbo", 1 `Load the map
Load object "media\obj\enemy.3ds",enemy
Rem Setup player
Make object box player, 50,100,50 : Position object player, 0,100,0 : Color object player, rgb(255,0,0)
`Limbs
Make object box cam_limb, 20,20,20 : Make Mesh from object 1,cam_limb : Add limb player, 1,1 : offset limb player, 1,0,0,Cam_distance#
Hide object cam_limb : hide limb player, 1
Rem Setup camera
Make camera cam
Set camera range Cam,10,5000
Set camera FOV Cam, 75
Rem Main loop
Do
Gosub Controls
Gosub Camera
Gosub GUI
Gosub EnemyAI
Gosub Shoot
Gosub BulletLife
Loop
Controls:
`Old player pos
ox# = object position x(player)
oy# = object position Y(player)
oz# = object position Z(player)
Rem Acually move player
`Forwards or backwards
If forwback# > 0 then move object player, forwback#
if forwback# < 0 then Move object player, forwback#
`Side to side (left or right)
If sideside# > 0 then move object left player, sideside#
if sideside# < 0 then Move object left player, sideside#
Rem Controls
`Increasing/decreasing forward or backward momentum.
If keystate(17) and forwback# < Max_Speed# then Inc forwback#, Max_Inc# `Forward
If keystate(17)=false and forwback# > 0 then dec forwback#, Max_Dec#
If keystate(31) and forwback# > RMax_Speed# then Dec forwback#, Max_Inc# `Back
If keystate(31)=false and forwback# < 0 then inc forwback#, Max_Dec#
`Increasing/decreasing side to side momentum.
If keystate(30) and sideside# < Max_Speed# then Inc sideside#, Max_Inc# `Right
If keystate(30)=false and sideside# > 0 then dec sideside#, Max_Dec#
If keystate(32) and sideside# > RMax_Speed# then Dec sideside#, Max_Inc# `Left
If keystate(32)=false and sideside# < 0 then inc sideside#, Max_Dec#
`Mouse controls
Yrotate object player, object angle Y(player) + mousemovex()*.25
Return
Camera:
lOx# = Limb position x (player,1) : lOy# = Limb position y (player,1) : lOz# = Limb position z (player,1)
Position camera cam,lOx#,lOy#+900,lOz#
Rotate camera cam,60,object angle y(player),0
Return
GUI:
ReturnX# = EoX# - ox#
ReturnY# = EoZ# - oz#
Set cursor 10,10 : Print Screen FPS()
Set cursor 10,25 : Print forwback#
Set cursor 10,40 : Print sideside#
Set cursor 10,55 : Print "EoX#: ", EoX#
Set cursor 10,70 : Print "EoZ#: ", EoZ#
Set cursor 10,85 : Print "oX#: ", oX#
Set cursor 10,100 : Print "oZ#: ", oZ#
Set cursor 10,115 : Print "Return X#: ", ReturnX#
Set cursor 10,130 : Print "Return Z#: ", ReturnY#
Set cursor 10,145 : Print "Alive: ", Alive
Set cursor 10,160 : Print "EC: ", Enemies_Created
Set cursor 10,175 : Print "DeathPlay: ", DeathPlay
Set cursor 10,190 : Print "Yrotate: ", rotateY
Set cursor 10,205 : Print "Collision: ", collision
Set cursor 10,205 : Print "Shot: ", Shot
Return
EnemyAI:
if object exist(enemy)
`Old Enemy pos
Eox# = object position x(enemy)
Eoy# = object position Y(enemy)
Eoz# = object position Z(enemy)
collision = Object collision(enemy,player)
Set object speed Enemy, 10 `Sets the object animation speed
If Alive = 1 then Point object Enemy, ox#,0,oz# `If enemy alive, aim at player
`Moves enemy
ReturnX# = EoX# - ox#
ReturnZ# = EoZ# - oz#
`Moves enemy towards player
If ReturnX# > 45 and alive = 1 then move object Enemy, 1.5
If ReturnX# < -45 and alive = 1 then move object Enemy, 1.5
If ReturnY# > 45 and alive = 1 then move object Enemy, 1.5
If ReturnY# < -45 and alive = 1 then move object Enemy, 1.5
Rem attack/not attack - animations
If collision=0 and alive=1 then loop object enemy, 40,79 `If enemy is out of range do not attack
If collision=1 and alive=1 then loop object enemy, 0,15 `If enemy is in range attack
Rem Handles enemies death
If Alive = 0 and DeathPlay=0
play object enemy, 85, 100 `If enemy dead, play death animation
DeathPlay=1 `Animation has been played
`Handles the enemy fading away.
For i = -100 to 0
Set alpha mapping on Enemy,abs(i)
sync
next i
endif
endif
Return
Shoot:
If mouseclick() and shoot_timer <= timer()
Gosub Bullet
endif
Return
Bullet:
Aim# = Camera angle y (Cam)
Bullet = FreeObject()
shoot_timer = timer() + 500
Make object cube Bullet,10 : Color object Bullet, rgb(255,255,255)
Position object Bullet, ox#,oy#,oz#
Yrotate object Bullet,Aim#
`Sets bullet alive
BulletMove=1
Return
BulletLife:
If BulletMove=1
Move object Bullet,15
shot = Object Collision(bullet,enemy)
If shot=1 then alive=0
endif
Return
Function FreeObject()
Repeat
inc i
if object exist(i)=0 then found#=1
until found#
EndFunction i
I don't expect anyone to code an AI system for me, but I would greatly appreciate any help that can be given!!
ßõw§€r¥¤