• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Catapult

VirrageS

←•†ĿuĀ && ©¤¤•→
Joined
May 30, 2010
Messages
984
Reaction score
63
Location
Poland
Hello :thumbup:

I have two problems with script:

LUA:
function onThink(interval, lastExecution)
	local catapultSpec = getSpectators({x = 84, y = 123, z = 7}, 5, 5, false)
	local damage = math.random(100, 300)
	local shooted = false

	if catapultSpec ~= nil then
		for i = 1, #catapultSpec do
			local target = catapultSpec[i]
			if isNpc(target) == false and shooted == false then
				doSendDistanceShoot({x = 84, y = 123, z = 7}, getCreaturePosition(target), CONST_ANI_LARGEROCK)
				doSendMagicEffect(getCreaturePosition(target), CONST_ME_BLOCKHIT)
				doCreatureAddHealth(target, - damage)
				doSendAnimatedText(getCreaturePosition(target), damage, TEXTCOLOR_RED)
				shooted = true
				return true
			end
		end
	end
	return true
end

1. Is way to set 2 or more catapults with different positions?? (I have tried but not work :()

2. If player is behind wall (it can be wall house or rock wall etc.) then player can't be shot.


Thanks and rep++ for help. :w00t:
 
You can set positions like this:

LUA:
local positions =
	{                        
                        [0] = {x = 1000, y= 1000, z = 7},
                        [1] = {x = 1001, y= 1001, z = 7},
                        [2] = {x = 1002, y= 1002, z = 7},
                        [3] = {x = 1003, y= 1003, z = 7},
                        [4] = {x = 1004, y= 1004, z = 7},
                        [5] = {x = 1005, y= 1005, z = 7},
	}
 
LUA:
local t = {
	{x = 84, y = 123, z = 7},
}

function onThink(interval, lastExecution)
	for _, v in ipairs(t) do
		local catapultSpec = getSpectators(v, 5, 5, false)
		if catapultSpec then
			for i = 1, #catapultSpec do
				local target = catapultSpec[i]
				local pos = getThingPos(target)
				if not isNpc(target) and isSightClear(v, pos, false) then
					doSendDistanceShoot(v, pos, CONST_ANI_LARGEROCK)
					doSendMagicEffect(pos, CONST_ME_BLOCKHIT)
					local damage = math.random(100, 300)
					doTargetCombatHealth(0, target, COMBAT_PHYSICALDAMAGE, -damage, -damage, CONST_ME_NONE)
					break
				end
			end
		end
	end
	return true
end
 
Thanks Cyko :p

Code:
You must spread some Reputation around before giving it to Cykotitan again.
:(
 
Last edited:
Back
Top