Forum

> > CS2D > Scripts > bot isnt working
Forums overviewCS2D overview Scripts overviewLog in to reply

English bot isnt working

No replies
To the start Previous 1 Next To the start

old bot isnt working

EnderCrypt
User Off Offline

Quote
well, again a bot error that i really cant solve
i tryed for like, well 3 hours

error:
1
2
3
4
LUA ERROR (ai_update_living): bots/HTM bot.lua:52: attempt to perform arithmetic on a
boolean value

Freezing bots to stop Lua error msg flood! Use 'bot_freeze 0' to unfreeze bots!

i assume errors cause the target doesent exist, the error often apper when many bots die or leave

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
function round(num)
	return math.floor(num+0.5)
end

bot = {}
bot.dir = {}
bot.aim = {}
bot.target = {}
i = 0
while (i < 32) do
i = i + 1
bot.target[i] = 0
end

function ai_update_dead(id)
	ai_respawn(id)
end

function ai_onspawn (id)
	bot.dir[id] = math.random(0,360)
	bot.aim[id] = math.random(0,360)
	ai_selectweapon(id,50)
	change_wand_image (id,1)
end

addhook("hit","bot_hit")
function bot_hit(id,source,weapon,hpdmg,apdmg)
	if player(id,"bot") then
		bot.target[id] = source
	end
end

function ai_update_living(id)
	if bot.target[id] == 0 then
		ai_move(id,bot.dir[id])
		bot.dir[id] = bot.dir[id] + math.random(-5,5)

		ai_rotate(id,bot.aim[id])
		bot.aim[id] = bot.aim[id] + math.random(-25,25)
	else
		ai_aim(id,player(bot.target[id],"x"),player(bot.target[id],"y"))
		bot.dir[id] = player(id,"rot")
		bot.aim[id] = player(id,"rot")
		if ai_freeline(id,player(bot.target[id],"x"),player(bot.target[id],"y")) then
			if player(bot.target[id],"health") > 0 then
				if bot.target[id] == id then
					bot.target[id] = 0
				else
					ai_attack(id)
					ai_move(id,player(id,"rot"))
					ai_aim(id,player(bot.target[id],"x"),player(bot.target[id],"y")+1)
				end
			else
				bot.target[id] = 0
			end
		else
			ai_move(id,player(id,"rot"))
		end
	end
end

addhook ("die","bot_magic_die")
function bot_magic_die(victim,killer,weapon,x,y)
	if player(killer,"bot") then
		if bot.target[killer] == victim then
			bot.target[killer] = 0
		end
	end
end

addhook ("attack","bot_magic_attack",1)
function bot_magic_attack(id)
	if player(id,"bot") then
		ai_selectweapon(id,50)
		over_ride_fireball(id)
		return 0
	end
end

function ai_hear_radio (id)

end

function ai_hear_chat (id)

end

function over_ride_fireball(id)
	fireball_x[#fireball_x+1] = player(id,"x")
	fireball_y[#fireball_y+1] = player(id,"y")
	fireball_id[#fireball_id+1] = id
	fireball_dir[#fireball_dir+1] = player(id,"rot")
	fireball_image[#fireball_image+1] = image(fireball_directory,fireball_x[#fireball_x],fireball_y[#fireball_y],1)
end

the
function over_ride_fireball(id)
is the attack command
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview