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

Solved How to create item on dead Body?

whitevo

Feeling good, thats what I do.
Joined
Jan 2, 2015
Messages
3,452
Solutions
1
Reaction score
625
Location
Estonia
Still working on my Cyclops.
I want to make it so that if Cyclops dies while he has stone picked up, the Stone will be created on his dead corpse.

Right now with this script item goes under the dead body...
StoneLob.lua (spell)
Code:
if stonePickedUp == false then
....
Creature(cid):registerEvent("CycStone")
                        return true
end
else
Creature(cid):unregisterEvent("CycStone")
....
end
Creaturescripts.XML
Code:
<event type="death"             name="CycStone"         script="Monsters/CyclopsStone.lua"/>
CyclopsStone.lua
Code:
function onDeath(cid, target)
    local pos = Creature(cid):getPosition()
    addEvent(function() return doCreateItem(3666, 0, pos) end, 1000)
    return true
end
(addEvent is not needed, but just showing that even with this, it makes item under corpse)

How to my make item to go on top of dead body?
Can i register Global Scripts? xD (that would also fix it prolly)

Tried with onKill creaturescript too..
But no hope. Only thing what makes sense is somehow be able to add new globalEvent...
Or Maybe somehow force The stone to be on top of everything, even when something else comes on top of it..
Currently seems hopeless cause
 
Last edited by a moderator:
well just take a look at zbizu ultimate stat system, this part I mean:

Code:
function stat_onDeath(creature, corpse, lasthitkiller, mostdamagekiller, lasthitunjustified, mostdamageunjustified)
--[[ -- generateStats example of looting specific item
        if creature:isMonster() then
                local c = Item(corpse)
                local item = c:addItem("sword")
                item:generateStats(item:getUpgradeType(), math.random(0, STATS_SYSTEM_CONFIG.maxSlotCount), math.random(0, 4), 1, STATS_SYSTEM_CONFIG.maxLevel)
                local item2 = c:addItem("plate shield")
                item2:generateStats({
                        {'lifedrain', 10, 15},
                        {'manadrain', 10, 15},
                        {'ice', 10, 15},
                        {'holy', 10, 15},
                        {'death', 10, 15},
                }, 3, 6, 24)
        end
        ]]
return true
end
 
this has nothing to do with my problem, sorry.
It adds items to corpse. I know how to do that too. But OUT of the Corpse and TOP of the Corpse.
That is a pickle.
 
lemme check tfs functions gonna compile last tfs
test:
Code:
function onKill(creature, target)
    local targetMonster = target:getMonster()
    if not targetMonster then
        return true
    end

    if targetMonster:getName():lower() == 'cyclop' then
        Game.createItem("item", 1, targetMonster:getPosition())
    end
    return true
end
 
Last edited:
i said above i tried with onKill function too and it didnät work.

But thanks to @Evan i found out that unmoveable objects are ALWAYS created at the bottom of the stack. :O!!!

So i tested can make moveable items on corpse. I can.
I will now make that stone moveable and add ActionID what makes it unmoveable.

Thank you for help :D
 
you can also post the solution ya?

Use Player: onMoveItem() and check for the item's actionId, if it's a match, return false (this will prevent the item from moving).
Code:
function Player:onMoveItem(item, count, fromPosition, toPosition)
    if item.actionid == something then
        return false
    end
    return true
end
 
Use Player: onMoveItem() and check for the item's actionId, if it's a match, return false (this will prevent the item from moving).
Code:
function Player:onMoveItem(item, count, fromPosition, toPosition)
    if item.actionid == something then
        return false
    end
    return true
end
This isn't working btw.
I will maybe complete this script today
 
function Player:eek:nMoveItem(item, count, fromPosition, toPosition)
print("woot")
print(item)
print(Item(item.itemid).uid)
if item.itemid == 1293 and item.actionid == 1000 then
print("woot2")
return false
end
return true
end

I tried several ways, but gave up now. No idea how to get that action id and itemid out of that item.
item.itemid = nil
item.actionid = nil
item.uid = error, expect number value

Also tried to make same thing on the function onRemoveItem , but there the problem is i cant get the item position, because inside the function there is 2 of them and there is NO WAY to seperate them...
and return false doesnt change anything...
and if i teleport thing back to the position it came from, i get stackoverflow and server crashes.
 
function Player:eek:nMoveItem(item, count, fromPosition, toPosition)
print("woot")
print(item)
print(Item(item.itemid).uid)
if item.itemid == 1293 and item.actionid == 1000 then
print("woot2")
return false
end
return true
end

I tried several ways, but gave up now. No idea how to get that action id and itemid out of that item.
item.itemid = nil
item.actionid = nil
item.uid = error, expect number value

Also tried to make same thing on the function onRemoveItem , but there the problem is i cant get the item position, because inside the function there is 2 of them and there is NO WAY to seperate them...
and return false doesnt change anything...
and if i teleport thing back to the position it came from, i get stackoverflow and server crashes.

Depends on which revision of 1.1 you have; the actionid, itemid, uid fields weren't added to Item userdatas until midway 1.1.
So you'll have to use item:getActionId() (others can be found here)
 
yeap, working now.
When i create items or move items, so far i have used "item.itemid" and similar words, didn't know that in some places you have to use function to get the values.


OffTopic:
Im using TFS 1.0 because 1.1 has bad experience System and i don't know how to control it, because it seems it has been moved to source code.
 
Back
Top