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

Bug Summon drop loot and xp

rafaaw

New Member
Joined
Feb 24, 2019
Messages
22
Reaction score
1
Can anyone tell me why my "utevo res" is dropping loot and xp?

Lua:
function onCastSpell(creature, variant)
    if creature:getSkull() == SKULL_BLACK then
        creature:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
        return false
    end

    local monsterName = variant:getString()
    local monsterType = MonsterType(monsterName)

    if not monsterType then
        creature:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
        creature:getPosition():sendMagicEffect(CONST_ME_POFF)
        return false
    end

    if not creature:hasFlag(PlayerFlag_CanSummonAll) then
        if not monsterType:isSummonable() then
            creature:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
            creature:getPosition():sendMagicEffect(CONST_ME_POFF)
            return false
        end

        if #creature:getSummons() >= 2 then
            creature:sendCancelMessage("You cannot summon more creatures.")
            creature:getPosition():sendMagicEffect(CONST_ME_POFF)
            return false
        end
    end

    local manaCost = monsterType:getManaCost()
    if creature:getMana() < manaCost and not creature:hasFlag(PlayerFlag_HasInfiniteMana) then
        creature:sendCancelMessage(RETURNVALUE_NOTENOUGHMANA)
        creature:getPosition():sendMagicEffect(CONST_ME_POFF)
        return false
    end

    local position = creature:getPosition()
    local summon = Game.createMonster(monsterName, position, true)
    if not summon then
        creature:sendCancelMessage(RETURNVALUE_NOTENOUGHROOM)
        position:sendMagicEffect(CONST_ME_POFF)
        return false
    end

    creature:addMana(-manaCost)
    creature:addManaSpent(manaCost)
    creature:addSummon(summon)
    position:sendMagicEffect(CONST_ME_MAGIC_BLUE)
    summon:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
    return true
end
 
Solution
Hi man, for fix this bug go to in your source : /src/creature.h

And edit

Code:
        void setDropLoot(bool lootDrop) {
            lootDrop = lootDrop;
        }
        void setSkillLoss(bool skillLoss) {
            skillLoss = skillLoss;
        }

Change to:

Code:
        void setDropLoot(bool lootDrop) {
            this->lootDrop = lootDrop;
        }
        void setSkillLoss(bool skillLoss) {
            this->skillLoss = skillLoss;
        }

Goodbye.
Post your creaturescripts.xml and scripts for onDeath.
You are likely missing the summon check in one of them.
Lua:
function onDeath(monster, corpse, killer, mostdamagekiller, lasthitunjustified, mostdamageunjustified)
    if not monster:isMonster() or monster:getMaster() then
        return true
    end
    ...
end
 
Post your creaturescripts.xml and scripts for onDeath.
You are likely missing the summon check in one of them.
Lua:
function onDeath(monster, corpse, killer, mostdamagekiller, lasthitunjustified, mostdamageunjustified)
    if not monster:isMonster() or monster:getMaster() then
        return true
    end
    ...
end
Code:
<?xml version="1.0" encoding="UTF-8"?>
<creaturescripts>
    <!-- Events -->
    <event type="death" name="Generator_Death" script="events/CastleWar/Generator_Death.lua" />
    <event type="death" name="MainGenerator_Death" script="events/CastleWar/MainGenerator_Death.lua" />
    <event type="healthchange" name="Generator_Health" script="events/CastleWar/Generator_Health.lua" />
    
    <!-- Anti-Entrosa -->
    <event type="login" name="WarPrivateLogin" script="events/War_Anti_Entrosa/warPrivate_creaturescript.lua"/>
    <event type="logout" name="WarPrivateLogout" script="events/War_Anti_Entrosa/warPrivate_creaturescript.lua"/>
    <event type="death" name="WarPrivateDeath" script="events/War_Anti_Entrosa/warPrivate_creaturescript.lua"/>
    
    <!-- BattleField Event -->
    <event type="login" name="battleflogin" script="events/Battle_Field/battlefield.lua"/>
    <event type="preparedeath" name="battledeath" script="events/Battle_Field/battlefield.lua"/>
    
    <!-- WarMaps -->
    <event type="login" name="warmapslogin" script="events/WarMaps/warmaps.lua"/>
    <event type="preparedeath" name="warmapsdeath" script="events/WarMaps/warmaps.lua"/>
    
    <!-- Rush War -->
    <event type="preparedeath" name="RushDeath" script="events/RushWar/RushWar_Death.lua"/>
    
    <!-- Blood Castle -->   
    <event type="death" name="Blooder_Death" script="events/BloodCastle/Blooder_Death.lua" />
    <event type="death" name="MainBlooder_Death" script="events/BloodCastle/MainBlooder_Death.lua" />
    <event type="preparedeath" name="blooddeath" script="events/BloodCastle/bloodcastle.lua"/>   
    
    <!-- Others -->
    <event type="login" name="PlayerLogin" script="others/login.lua" />
    <event type="logout" name="PlayerLogout" script="others/logout.lua" />
    <event type="login" name="FirstItems" script="others/firstitems.lua" />
    <event type="login" name="OfflineTraining" script="others/offlinetraining.lua" />
    <event type="login" name="RegenerateStamina" script="others/regeneratestamina.lua" />
    <event type="death" name="PlayerDeath" script="others/playerdeath.lua" />
    <event type="death" name="DropLoot" script="others/droploot.lua" />
    <event type="death" name="WhiteDeerScoutsDeath" script="others/whitedeer_scouts.lua" />
    <event type="advance" name="AdvanceSave" script="others/advance_save.lua" />
    <event type="login" name="Anti-Multiclient" script="others/antimc.lua"/>
    <event type="extendedopcode" name="ExtendedOpcode" script="others/extendedopcode.lua" />
    <event type="modalwindow" name="ModalWindowHelper" script="others/modalwindowhelper.lua" />
    
    <!-- Elemental Spheres Quest -->
    <event type="kill" name="ElementalSpheresOverlords" script="quests/elemental spheres/OverlordsKill.lua" />

    <!-- The New Frontier Quest -->
    <event type="kill" name="NewFrontierShardOfCorruption" script="quests/the new frontier/ShardOfCorruption.lua" />
    <event type="kill" name="NewFrontierTirecz" script="quests/the new frontier/TireczKill.lua" />

    <!-- In Service Of Yalahar Quest -->
    <event type="kill" name="ServiceOfYalaharAzerus" script="quests/in service of yalahar/AzerusKill.lua" />
    <event type="kill" name="ServiceOfYalaharDiseasedTrio" script="quests/in service of yalahar/DiseasedTrioKill.lua" />
    <event type="kill" name="ServiceOfYalaharQuaraLeaders" script="quests/in service of yalahar/QuaraLeadersKill.lua" />

    <!-- Inquisition Quest -->
    <event type="kill" name="InquisitionBosses" script="quests/inquisition/inquisitionQuestBosses.lua" />
    <event type="kill" name="InquisitionUngreez" script="quests/inquisition/inquisitionQuestUngreez.lua" />

    <!-- Killing In The Name Of Quest -->
    <event type="kill" name="KillingInTheNameOfKills" script="quests/killing in the name of/kills.lua" />
    
    <!-- Thieves Guild Quest -->
    <event type="kill" name="ThievesGuildNomad" script="others/nomad.lua" />
    
    <!-- Secret Service Quest -->
    <event type="kill" name="SecretServiceBlackKnight" script="others/blackKnight.lua" />

    <!-- Wrath of the Emperor Quest -->
    <event type="kill" name="WotELizardMagistratus" script="quests/wrath of the emperor/lizardmagistratus.lua" />
    <event type="kill" name="WotELizardNoble" script="quests/wrath of the emperor/lizardnoble.lua" />
    <event type="kill" name="WotEKeeper" script="quests/wrath of the emperor/keeper.lua" />
    <event type="kill" name="WotEBosses" script="quests/wrath of the emperor/bosses.lua" />
    <event type="kill" name="WotEZalamon" script="quests/wrath of the emperor/zalamon.lua" />
    
    <!-- Pythius The Rotten (Firewalker Boots Quest) -->
    <event type="kill" name="PythiusTheRotten" script="others/PythiusTheRotten.lua" />
    
    <!-- Svargrond Arena: Killing a boss -->
    <event type="kill" name="SvargrondArenaKill" script="quests/svargrond arena/arena_kill.lua" />
</creaturescripts>
Post automatically merged:

TFS version?
1.3
 
My best guess would be here:
XML:
<event type="death" name="DropLoot" script="others/droploot.lua" />

Post this script and we should be able to solve this.
 
My best guess would be here:
XML:
<event type="death" name="DropLoot" script="others/droploot.lua" />

Post this script and we should be able to solve this.
Code:
function onDeath(player, corpse, killer, mostDamage, unjustified, mostDamage_unjustified)
    if player:hasFlag(PlayerFlag_NotGenerateLoot) or player:getVocation():getId() == VOCATION_NONE then
        return true
    end
    
    local amulet = player:getSlotItem(CONST_SLOT_NECKLACE)
    local hasSkull = table.contains({SKULL_RED, SKULL_BLACK}, player:getSkull())
    if amulet and amulet.itemid == ITEM_AMULETOFLOSS and not hasSkull then
        local isPlayer = false
        if killer then
            if killer:isPlayer() then
                isPlayer = true
            else
                local master = killer:getMaster()
                if master and master:isPlayer() then
                    isPlayer = true
                end
            end
        end

        if not isPlayer or not player:hasBlessing(6) then
            player:removeItem(ITEM_AMULETOFLOSS, 1, -1, false)
        end
    else
        local lossPercent = player:getLossPercent()
        for i = CONST_SLOT_HEAD, CONST_SLOT_AMMO do
            local item = player:getSlotItem(i)
            if item then
                if hasSkull or math.random(item:isContainer() and 100 or 1000) <= lossPercent then
                    if not item:moveTo(corpse) then
                        item:remove()
                    end
                end
            end
        end
    end

    if not player:getSlotItem(CONST_SLOT_BACKPACK) then
        player:addItem(ITEM_BAG, 1, false, CONST_SLOT_BACKPACK)
    end

    return true
end
 
No that's not it, that's for when players die.

Something is editing your normal monster drops, if you haven't any loot changes via sources then IT IS one of those scripts.
one of these maybe?
XML:
<event type="death" name="Generator_Death" script="events/CastleWar/Generator_Death.lua" />
<event type="death" name="MainGenerator_Death" script="events/CastleWar/MainGenerator_Death.lua" />
 
MainGenerator_Death
Code:
function onDeath(creature, corpse, killer, mostDamageKiller, unjustified, mostDamageUnjustified)
    if CASTLE then
        CASTLE:onMainGeneratorDeath(creature, killer)
    end
    return true
end

Generator_Death
Code:
function onDeath(creature, corpse, killer, mostDamageKiller, unjustified, mostDamageUnjustified)
    if CASTLE then
        CASTLE:onGeneratorDeath(creature, killer)
    end
    return true
end
Post automatically merged:

Post your creaturescripts.xml and scripts for onDeath.
You are likely missing the summon check in one of them.
Lua:
function onDeath(monster, corpse, killer, mostdamagekiller, lasthitunjustified, mostdamageunjustified)
    if not monster:isMonster() or monster:getMaster() then
        return true
    end
    ...
end
if I create a file like this, can it work?
 
Last edited:
in data\lib\core\creature.lua change
Lua:
summon:setDropLoot(true)
to
Lua:
summon:setDropLoot(false)
 
I forgot to mention there's 2
Lua:
summon:setDropLoot(false)
You'll have to edit this one
Lua:
function Creature:addSummon(monster)
    local summon = Monster(monster)
    if not summon then
        return false
    end

    summon:setTarget(nil)
    summon:setFollowCreature(nil)
    summon:setDropLoot(false)
    summon:setSkillLoss(false)
    summon:setMaster(self)

    return true
end
and keep thee other one as true.
 
Hi man, for fix this bug go to in your source : /src/creature.h

And edit

Code:
        void setDropLoot(bool lootDrop) {
            lootDrop = lootDrop;
        }
        void setSkillLoss(bool skillLoss) {
            skillLoss = skillLoss;
        }

Change to:

Code:
        void setDropLoot(bool lootDrop) {
            this->lootDrop = lootDrop;
        }
        void setSkillLoss(bool skillLoss) {
            this->skillLoss = skillLoss;
        }

Goodbye.
 
Solution
Hi man, for fix this bug go to in your source : /src/creature.h

And edit

Code:
        void setDropLoot(bool lootDrop) {
            lootDrop = lootDrop;
        }
        void setSkillLoss(bool skillLoss) {
            skillLoss = skillLoss;
        }

Change to:

Code:
        void setDropLoot(bool lootDrop) {
            this->lootDrop = lootDrop;
        }
        void setSkillLoss(bool skillLoss) {
            this->skillLoss = skillLoss;
        }

Goodbye.

Thanks!
 
Back
Top