• 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!

[Lua] Some Lua Scripts Requests

Hrsha

Member
Joined
May 30, 2010
Messages
450
Reaction score
21
Location
Egypt
Hello Otlanders

i have some questions

1- distance weapon attackspeed .

how to set its attackspeed ? i could not do it by /attr spell
or set Attributes on items.xml

2- enchanting spell which make any weapon ( wands - bows - sword)
get stronger hit more dmage


i wish if u could understand me

thanks for reading .... rep ++
 
Last edited:
1. Prolly only possible with source edit and adding new ammo type which accepts both bolt and arrow.

2. XML entry of exori con/hur
LUA:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat, COMBAT_PARAM_BLOCKARMOR, true)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ETHEREALSPEAR)

function onGetFormulaValues(cid, level, skill)
	return -(((skill + 30) / 3) + (level / 4)), -((skill + 30) + (level / 4)), 0
end

setCombatCallback(combat, CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")

local function isWalkable(pos, creature, proj, pz)-- by Nord
	if getTileThingByPos({x = pos.x, y = pos.y, z = pos.z, stackpos = 0}).itemid == 0 then return false end
	if getTopCreature(pos).uid > 0 and creature then return false end
	if getTileInfo(pos).protection and pz then return false, true end
	local n = not proj and 3 or 2
	for i = 0, 255 do
		pos.stackpos = i
		local tile = getTileThingByPos(pos)
		if tile.itemid ~= 0 and not isCreature(tile.uid) then
			if hasProperty(tile.uid, n) or hasProperty(tile.uid, 7) then
				return false
			end
		end
	end
	return true
end


local function push(id, dir, t)
	if t < 0 or not(isCreature(id)) then return true end
	local pos = getPositionByDirection(getThingPos(id), dir)
	if not(isWalkable(pos, true, false, true)) then
		return true
	end
	doTeleportThing(id, pos, false)
	doSendMagicEffect(pos, CONST_ME_STONES)
	doSendMagicEffect(pos, CONST_ME_POFF)
	addEvent(push, 200, id, dir, t-1)
end

local config = {
	ammu = {2543, 2544},
	pushBack = 2	
}
function onCastSpell(cid, var)
	local removed = false
	for _, itemid in pairs(config.ammu) do
		if getPlayerItemCount(cid, itemid) >= 1 then
			doPlayerRemoveItem(cid, itemid, 1)
			removed = true
			break
		end
	end
	if not(removed) then return doPlayerSendCancel(cid, "You need ammunation for this spell.") and false end	
	local ret = doCombat(cid, combat, var)
	if ret then
		local dirTo = getDirectionTo(getThingPos(cid), getThingPos(variantToNumber(var)))
		push(variantToNumber(var), dirTo, config.pushBack)
	end
	return ret
end

3. Think its released.

4. a) If any item is on the slot : if getPlayerSlotItem(cid, CONST_SLOT_HEAD).itemid > 0 then
b) If a certain item is on the slot: if getPlayerSlotItem(cid, CONST_SLOT_HEAD).itemid == ITEM_ID then
 
1. Prolly only possible with source edit and adding new ammo type which accepts both bolt and arrow.

2. XML entry of exori con/hur
LUA:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat, COMBAT_PARAM_BLOCKARMOR, true)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ETHEREALSPEAR)

function onGetFormulaValues(cid, level, skill)
	return -(((skill + 30) / 3) + (level / 4)), -((skill + 30) + (level / 4)), 0
end

setCombatCallback(combat, CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")

local function isWalkable(pos, creature, proj, pz)-- by Nord
	if getTileThingByPos({x = pos.x, y = pos.y, z = pos.z, stackpos = 0}).itemid == 0 then return false end
	if getTopCreature(pos).uid > 0 and creature then return false end
	if getTileInfo(pos).protection and pz then return false, true end
	local n = not proj and 3 or 2
	for i = 0, 255 do
		pos.stackpos = i
		local tile = getTileThingByPos(pos)
		if tile.itemid ~= 0 and not isCreature(tile.uid) then
			if hasProperty(tile.uid, n) or hasProperty(tile.uid, 7) then
				return false
			end
		end
	end
	return true
end


local function push(id, dir, t)
	if t < 0 or not(isCreature(id)) then return true end
	local pos = getPositionByDirection(getThingPos(id), dir)
	if not(isWalkable(pos, true, false, true)) then
		return true
	end
	doTeleportThing(id, pos, false)
	doSendMagicEffect(pos, CONST_ME_STONES)
	doSendMagicEffect(pos, CONST_ME_POFF)
	addEvent(push, 200, id, dir, t-1)
end

local config = {
	ammu = {2543, 2544},
	pushBack = 2	
}
function onCastSpell(cid, var)
	local removed = false
	for _, itemid in pairs(config.ammu) do
		if getPlayerItemCount(cid, itemid) >= 1 then
			doPlayerRemoveItem(cid, itemid, 1)
			removed = true
			break
		end
	end
	if not(removed) then return doPlayerSendCancel(cid, "You need ammunation for this spell.") and false end	
	local ret = doCombat(cid, combat, var)
	if ret then
		local dirTo = getDirectionTo(getThingPos(cid), getThingPos(variantToNumber(var)))
		push(variantToNumber(var), dirTo, config.pushBack)
	end
	return ret
end

3. Think its released.

4. a) If any item is on the slot : if getPlayerSlotItem(cid, CONST_SLOT_HEAD).itemid > 0 then
b) If a certain item is on the slot: if getPlayerSlotItem(cid, CONST_SLOT_HEAD).itemid == ITEM_ID then

Thx for help

1- how to edit source code to do it ?

2- i got this error

Code:
[20:15:40.468] [Error - Spell Interface]
[20:15:40.468] data/spells/scripts/attack/test.lua:onCastSpell
[20:15:40.468] Description:
[20:15:40.468] (luaGetThingPosition) Thing not found

[20:15:40.468] [Error - Spell Interface]
[20:15:40.468] data/spells/scripts/attack/test.lua:onCastSpell
[20:15:40.468] Description:
[20:15:40.468] data/lib/032-position.lua:18: attempt to index local 'pos2' (a bo
olean value)
[20:15:40.468] stack traceback:
[20:15:40.468]  data/lib/032-position.lua:18: in function 'getDirectionTo'
[20:15:40.468]  data/spells/scripts/attack/test.lua:58: in function <data/spells
/scripts/attack/test.lua:46>
 
You have needtarget="1" in spells.xml?

THanks Help Master ;) and Rep ++

i still did not solve problem 1 and 4

problem 4 is that i want a line allow these function if i wear armors on body only and block its work
if i wear them on hands

Code:
doAddCondition(cid,conditionHP[tonumber(n)])
            doCreatureAddHealth(cid,HP-getCreatureHealth(cid))
 
Last edited by a moderator:
Added New problem :S

5- distance weapon attackspeed .

how to set its attackspeed ? i could not do it by /attr spell
or set Attributes on items.xml
 
if it's stackable, it's not going to work
otherwise it'll work with doItemSetAttribute(uid, 'attackspeed', 1000) for 1 second
 
new problem added .....

6- how do i cread item

for example : i find on some servers 1 item have 3 different ids
so i wana do something like that i got i item and its have 1 id only
i wana from it 3 item id's but with the same look (picture)
 
6- how do i cread item

for example : i find on some servers 1 item have 3 different ids
so i wana do something like that i got i item and its have 1 id only
i wana from it 3 item id's but with the same look (picture)
you need your custom client and edit the sprites, however 1 item with diffent id maybe you've seen ummm music sheet or idk
 
new problem added

7- how to limit
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
meaning how to limit item like if xitem has description " ....... " false script or dont use item on it
is that possible ?

i already has one but it does not work here is it

Code:
  if getSlotCount(nam) < conf.maxSlotCount then

Code:
function getSlotCount(nam)
		local c = 0
		for _ in nam:gmatch('%[(.-)%]') do
			c = c+1
		end
		return c
	end
 
emm attack speed try with this:

PHP:
function onUse(cid, item, fromPosition, itemEx, toPosition)
		if isInArray({2447, 7959, 7735, 7405, 8927, 7453, 7958, 8929, 8925}, itemEx.itemid) then
			doItemSetAttribute(itemEx.uid, "description", " x2.5 Attack Speed It belongs to ".. getCreatureName(cid) .. ".")
			doItemSetAttribute(itemEx.uid, "attackspeed", 200)
	    		doPlayerSendTextMessage(cid, 19, "You changed the attack speed of your weapon. Good luck then.")
			doRemoveItem(item.uid)
		else
			doPlayerSendCancel(cid, "Sorry, not possible.")
	end
	
	return true
end
abdo?
 
emm attack speed try with this:

PHP:
function onUse(cid, item, fromPosition, itemEx, toPosition)
		if isInArray({2447, 7959, 7735, 7405, 8927, 7453, 7958, 8929, 8925}, itemEx.itemid) then
			doItemSetAttribute(itemEx.uid, "description", " x2.5 Attack Speed It belongs to ".. getCreatureName(cid) .. ".")
			doItemSetAttribute(itemEx.uid, "attackspeed", 200)
	    		doPlayerSendTextMessage(cid, 19, "You changed the attack speed of your weapon. Good luck then.")
			doRemoveItem(item.uid)
		else
			doPlayerSendCancel(cid, "Sorry, not possible.")
	end
	
	return true
end
abdo?

yes abdo :P

it does not work on bow - xbow
 
Back
Top