home *** CD-ROM | disk | FTP | other *** search
- --------------------------------------------------------------------------------
- -- Carnage Contest AI (Artificial Intelligence) Script
- -- Script by DC, February 2010, www.UnrealSoftware.de
- --------------------------------------------------------------------------------
-
- ai={}
-
- -- Initialization Function (called once at each start of AI turn)
- function ai_init()
- math.randomseed(os.time())
- ai.movetimer=math.random(50,300)
- ai.dir=math.random(0,1)
- ai.aim=math.random(-100,100)
- ai.power=math.random(50,200)
- end
-
- -- Movement Function (called each frame, pre attack)
- function ai_move()
- if ai.movetimer>0 then
- if ai.dir==0 then
- ai_left()
- else
- ai_right()
- end
- ai.movetimer=ai.movetimer-1
- elseif ai.aim~=0 then
- if ai.aim>0 then
- ai_down()
- ai.aim=ai.aim-1
- else
- ai_up()
- ai.aim=ai.aim+1
- end
- elseif ai.power>0 then
- ai_attack()
- ai.power=ai.power-1
- end
- end
-
- -- Backing Function (called each frame, post attack)
- function ai_back()
- if ai.dir==0 then
- ai_right()
- else
- ai_left()
- end
- end
-
-
- --------------------------------------------------------------------------------
- -- AI Helper Functions
- -- Attention: These functions are also used by orig. AI weapon Lua scripts
- -- !!! CHECK ALL DEPENDENCIES WHEN CHANGING !!!
- --------------------------------------------------------------------------------