Forum
CS2D General Prevent turrets from damaging each otherPrevent turrets from damaging each other
4 replies 1
there is not simple setting for that.
I was thinking about checking the weapon which did the damage, because turrets have the internal weapon id 253 but objectdamage does not have a weapon parameter...
I can only think of another, pretty complicated and dirty solution: check if it is possible that it was the player who did the damage on the turret by checking the rotation and position of the player. it probably was one of the turrets if the player is far away/not looking at the turret which has been hit.
or: check if the turret which has been hit is created by the same player and return 1 in this case (side effect: players can't damage their own turrets at all). you could extend that so only Ts can damage CT turrets and vice versa...
Here's the code that works for it, but a lot of problems such as, grenades (if you don't look at the building your destroying with them) don't damage them(I don't know how to fix it) and if your looking at the object when the turret is shooting then it damages the the object.
1
2
3
4
5
6
7
8
9
10
11
12
13
2
3
4
5
6
7
8
9
10
11
12
13
addhook("objectdamage", "blockdamage") function blockdamage(type2, damage, id) 	if (tonumber(player(object(type2,"player"),"team")) ~= 0) then 		if (player(id,"exists")) then 			x = player(id,"x") 			y = player(id,"y") 			if not (math.abs(math.rad(player(id,"rot")) - math.atan2(y-object(type2,'y'),x-object(type2,'x') - (math.pi/2)%(math.pi*2))) <= 1.6) then 				return 1 			end 		end 	end 	return 0 end
edited 1×, last 26.12.10 04:12:32 am
1