• 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!
  • If you're using Gesior 2012 or MyAAC, please review this thread for information about a serious security vulnerability and a fix.

TFS 0.X Please I need help in movements

Leo Nard

New Member
Joined
Feb 13, 2022
Messages
8
Reaction score
0
local grenadeConfig = {
exhaustionType = 0, -- Type of exhaustion: 1 (same that for spells), 0 - exhaustion only for grenades
exhaustionTime = 1, -- Time in seconds
exhaustionSV = 1237, -- Storage value for exhaustion (if exhaustionType = 0 choosen)
grenade = { -- Grenade basic spell options
combatArea = {{1}},
attackType = COMBAT_PHYSICALDAMAGE,
attackEffect = 6,
charges = 20, -- how many times one granade can be used
},
disabledPositions = { -- List of disabled positions
{x = 100, y = 100, z = 7},
{x = 2064, y = 835, z = 7},
{x = 2065, y = 835, z = 7},
{x = 2066, y = 835, z = 7},
{x = 2067, y = 835, z = 7},
{x = 2068, y = 835, z = 7},
{x = 2069, y = 835, z = 7},
{x = 2070, y = 835, z = 7}
},
}


local exhaustion = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaustion, CONDITION_PARAM_SUBID, EXHAUST_COMBAT)
setConditionParam(exhaustion, CONDITION_PARAM_TICKS, grenadeConfig.exhaustionTime * 1000)
setCombatCondition(combat, exhaustion)

local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_RED)
local condition = createConditionObject(CONDITION_PARALYZE)
setConditionParam(condition, CONDITION_PARAM_TICKS, 1000)
setConditionFormula(condition, -1, 40, -1, 40)
setCombatCondition(combat, condition)
local combat2 = createCombatObject()
setCombatParam(combat2, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_RED)
local exhaustion = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaustion, CONDITION_PARAM_SUBID, 1)
setConditionParam(exhaustion, CONDITION_PARAM_TICKS, 1000)
setCombatCondition(combat2, exhaustion)
local exhaustion = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaustion, CONDITION_PARAM_SUBID, 2)
setConditionParam(exhaustion, CONDITION_PARAM_TICKS, 1000)
setCombatCondition(combat2, exhaustion)

function returnPlayerItem(cid, item)
local useCount = getItemAttribute(item.uid, "grenade")
doRemoveItem(item.uid)
local newItem = doPlayerAddItem(cid, item.itemid)
doItemSetAttribute(newItem, "grenade", useCount)
doItemSetAttribute(newItem, "description", "You have " .. (grenadeConfig.grenade.charges - useCount) .. " charges left.")
end

local function sendEffect(cid)
if not isPlayer(cid) then return end
doSendMagicEffect(getThingPos(cid), 34)
doSendAnimatedText(getThingPos(cid), 'Protected', COLOR_GREY)
end

local function unregister(cid)
if not isPlayer(cid) then return end
unregisterCreatureEvent(cid, 'ImmunitySpell')
end

function onAddItem(moveItem, tileItem, position, cid)

local voc = getPlayerVocation(cid)
if voc == 3 or voc == 7 then
returnPlayerItem(cid, moveItem)
return false
end

if getTilePzInfo(position) == true or getTilePzInfo(getThingPosition(cid)) then
returnPlayerItem(cid, moveItem)
return false
end

local useCount = getItemAttribute(moveItem.uid, "grenade")
if useCount == nil or useCount < 0 then
useCount = 0
end

if grenadeConfig.exhaustionType == 0 then
local exhaust = getPlayerStorageValue(cid, grenadeConfig.exhaustionSV)
if exhaust >= os.time() then
returnPlayerItem(cid, moveItem)
return false
end
elseif grenadeConfig.exhaustionType == 1 then
if getCreatureCondition(cid, CONDITION_EXHAUST, EXHAUST_COMBAT) == true then
returnPlayerItem(cid, moveItem)
return false
end
else
returnPlayerItem(cid, moveItem)
return false
end

if #grenadeConfig.disabledPositions > 0 then
for _, disabled in pairs(grenadeConfig.disabledPositions) do
if disabled.x == position.x and disabled.y == position.y and disabled.z == position.z then
returnPlayerItem(cid, moveItem)
return false
end
end
end

local var = {pos = position, type = 2}
local pos = variantToPosition(var)
local pid = getTopCreature(pos).uid
local speed = getCreatureSpeed(pid)
if isPlayer(pid) then
if not isPaladin(pid) then
doCombat(cid, combat2, pos)
end
doSendAnimatedText(pos, "PARALYZED", TEXTCOLOR_PURPLE)
doChangeSpeed(pid, -speed + 150)
doSendMagicEffect(pos, CONST_ME_MAGIC_RED)
addEvent(function()
if isPlayer(pid) then
doChangeSpeed(pid, speed)
end
end, 1000)
end


if (useCount + 1) >= grenadeConfig.grenade.charges then
doRemoveItem(moveItem.uid)
else
doItemSetAttribute(moveItem.uid, "grenade", (useCount + 1))
doItemSetAttribute(moveItem.uid, "description", "You have " .. (grenadeConfig.grenade.charges - useCount - 1) .. " charges left.")
returnPlayerItem(cid, moveItem)
end

if grenadeConfig.exhaustionType == 0 then
setPlayerStorageValue(cid, grenadeConfig.exhaustionSV, (os.time() + grenadeConfig.exhaustionTime))
else
doAddCondition(cid, exhaustion)
end

return true
end

[13/2/2022 22:32:50] [Error - MoveEvents Interface]
[13/2/2022 22:32:50] data/movements/scripts/grenade7.lua:eek:nAddItem
[13/2/2022 22:32:50] Description:
[13/2/2022 22:32:50] (luaGetCreatureSpeed) Creature not found
 

Datero

New Member
Joined
Apr 16, 2013
Messages
6
Reaction score
1
Like it say, " creature not found "
You need add main creature who use this script, like player = Player(cid), at the top of the script.
 
Top