Forum

> > CS2D > Scripts > Attacking Images
Forums overviewCS2D overview Scripts overviewLog in to reply

English Attacking Images

1 reply
To the start Previous 1 Next To the start

old Attacking Images

KaBooMa
User Off Offline

Quote
Alright, I know tibia had something along the lines. But basically i want to add a image ( npc ) i can kill. I cant really explain what i want. :S I want to attack images This is going to replace the npcs in my server script. I had everything going nice but then...omg this zombie npc is to slow If i could get some tips on how to create and image and remove it when shot. I would love you. Somehow when i started scripting i avoided images o.o

old Re: Attacking Images

EngiN33R
Moderator Off Offline

Quote
Try to check if there are any enemies with attack hook and sine and cosine of player's angle.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
addhook("attack","checkenemies")
function checkenemies(id)
	local rad=math.rad(player(id,"rot"))
	local sin=math.sin(rad)
	local cos=math.cos(rad)
	local range=128 --range how far to shoot (in px!)
	for x=1,cos*range do
		for y=1,sin*range do
			for enemy=1,256 do
				if (enemyexists(enemy,x,y)) then
					hitenemy(enemy,dmg) --dmg is damage dealt to enemy
				end
			end
		end
	end
end

It may need some fixes, I wrote this 8 AM in the morning, just woke up.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview