Code: Select all
SCREEN 1280,1024,0,0
Type NPCs
Field obj
Field health
Field speed
Field intelligence
Field name$
Field gunname$
Field gun
Field damage
Field bullets
Field secondarybullets
Field bulletspeed
Field secondarybulletspeed
Field reload
Field action$
Field specialaction$
Field side$
End Type
kenttä=LoadMap("media\testmap.til","media\tileset.bmp")
trooperobj=LoadObject("media\guy.bmp",72)
ShowObject trooperobj,OFF
smgobj=LoadObject("media\cow.bmp",72)
ShowObject smgobj,OFF
SpawnNPC("actinoid trooper",trooperobj,"smg",smgobj,kenttä,5,8)
SpawnNPC("actinoid trooper",trooperobj,"smg",smgobj,kenttä,3,8)
SpawnNPC("actinoid trooper",trooperobj,"smg",smgobj,kenttä,1,8)
Repeat
If KeyHit(cbkeyf) and showinfo=0 then showinfo=1
If KeyHit(cbkeyf) and showinfo=1 then showinfo=0
UpdateNPCs()
DrawScreen
Forever
Function SpawnNPC(enemy$,img,gun$,gunimg,map,x,y,spesiaali$="")
For vihu.npcs=each npcs
vihu.npcs=New (npcs)
vihu\obj=MakeObject()
PaintObject vihu\obj,img
vihu\gun=MakeObject()
PaintObject vihu\gun,gunimg
SetupCollision vihu\obj,map,2,4,2
Select enemy
Case "trooper"
vihu\health=40
vihu\speed=4
vihu\intelligence=3
vihu\name$="Enemy Trooper"
vihu\action$=""
vihu\specialaction$=spesiaali
vihu\side$="Enemies"
End Select
Select gun
Case "smg"
vihu\damage=4
vihu\secondarybullets=5
vihu\bullets=50
vihu\bulletspeed=8
vihu\secondarybulletspeed=5
vihu\gunname$="SMG"
End Select
PositionObject vihu\obj,x*32,y*32
CloneObjectPosition vihu\gun,vihu\obj
CloneObjectOrientation vihu\gun,vihu\obj
If showdata=1 Then AddText "Spawned NPC "+vihu\name$+" armed with "+vihu\gunname$+" at "+x+","+y+"."
Next vihu
EndFunction
Function UpdateNPCs()
For vihu.npcs=each npcs
CloneObjectPosition vihu\gun,vihu\obj
CloneObjectOrientation vihu\gun,vihu\obj
Select vihu\name$
Case "enemy trooper"
'...tekoäly...
End Select
Select vihu\gunname$
Case "smg"
'...ampuminen...
End Select
Select vihu\action
Case "die"
DeleteObject vihu\obj
Delete vihu
kills+1
end Select
Select vihu\specialaction
Case "take cover"
'suojautuminen
End Select
next vihu
EndFunction
Miksei vihollisten spawnaamiseen tarkoitettu koodi tee mitään?