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

RewardChest delivering items unique="1" to all players

nanduzenho

Member
Joined
Mar 21, 2021
Messages
187
Solutions
1
Reaction score
15
GitHub
nanduzenho
RewardChest delivering items unique="1" to all players, when in fact it was only supposed to be delivered to one player, any solution?

lib/rewardboss.lua

Lua:
function MonsterType.createLootItem(self, lootBlock, chance, lootTable)
    local lootTable, itemCount = lootTable or {}, 0
    local randvalue = math.random(0, 100000) / (getConfigInfo("rateLoot") * chance)
    if randvalue < lootBlock.chance then
        if (ItemType(lootBlock.itemId):isStackable()) then
            itemCount = randvalue % lootBlock.maxCount + 1
        else
            itemCount = 1
        end
    end

    while itemCount > 0 do
        local n = math.min(itemCount, 100)
        itemCount = itemCount - n
        table.insert(lootTable, {lootBlock.itemId, n})
    end

    return lootTable
end

function MonsterType.getBossReward(self, lootFactor, topScore)
    local result = {}
    if getConfigInfo("rateLoot") > 0 then
        local loot = self:getLoot() or {}
        for i = #loot, 0, -1 do
            local lootBlock = loot[i]
            if lootBlock then
                if lootBlock.unique and not topScore then
                    --continue
                else
                    self:createLootItem(lootBlock, lootFactor, result)
                end
            end
        end
    end
    return result
end


XML:
<?xml version="1.0" encoding="UTF-8"?>
<monster name="Ferumbras" nameDescription="Ferumbras" race="venom" experience="12000" speed="320" script="rewardboss.lua">
    <health now="50000" max="50000"/>
    <look type="229" corpse="6078"/>
    <targetchange interval="5000" chance="8"/>
    <flags>
        <flag rewardboss="1" />
        <flag summonable="0"/>
        <flag attackable="1"/>
        <flag hostile="1"/>
        <flag illusionable="0"/>
        <flag convinceable="0"/>
        <flag pushable="0"/>
        <flag canpushitems="1"/>
        <flag canpushcreatures="1"/>
        <flag targetdistance="2"/>
        <flag staticattack="90"/>
        <flag runonhealth="2500"/>
    </flags>
    <attacks>
        <attack name="melee" interval="2000" min="0" max="-350"/>
        <attack name="manadrain" interval="2000" chance="20" range="7" min="-500" max="-700">
            <attribute key="areaEffect" value="redshimmer"/>
        </attack>
        <attack name="lifedrain" interval="2000" chance="25" length="8" spread="0" min="-300" max="-450">
            <attribute key="areaEffect" value="greenspark"/>
        </attack>
        <attack name="lifedrain" interval="2000" chance="21" radius="6" target="0" min="-450" max="-500">
            <attribute key="areaEffect" value="poff"/>
        </attack>
        <attack name="poisoncondition" interval="2000" chance="15" range="7" min="-20" max="-40">
            <attribute key="shooteffect" value="poison"/>
        </attack>
        <attack name="lifedrain" interval="2000" chance="15" target="0" radius="3" range="4" min="-900" max="-1000"/>
        <attack name="energycondition" interval="2000" chance="18" radius="6" target="0" min="-300" max="-400">
            <attribute key="areaEffect" value="energy"/>
        </attack>
        <attack name="firecondition" interval="3000" chance="20" range="7" radius="7" target="1" min="-500" max="-600">
            <attribute key="shootEffect" value="fire"/>
            <attribute key="areaEffect" value="firearea"/>
        </attack>
    </attacks>
    <defenses armor="100" defense="120">
        <defense name="healing" interval="2000" chance="10" min="900" max="1500">
            <attribute key="areaEffect" value="greenshimmer"/>
        </defense>
        <defense name="invisible" interval="4000" chance="20" duration="5000">
            <attribute key="areaEffect" value="blueshimmer"/>
        </defense>
    </defenses>
    <elements>
        <element firePercent="90"/>
        <element holyPercent="20"/>
    </elements>
    <immunities>
        <immunity earth="1"/>
        <immunity energy="1"/>
        <immunity lifedrain="1"/>
        <immunity paralyze="1"/>
        <immunity invisible="1"/>
    </immunities>
    <summons maxSummons="4">
        <summon name="Demon" interval="3000" chance="12"/>
    </summons>
    <voices interval="5000" chance="20">
        <voice sentence="NO ONE WILL STOP ME THIS TIME!" yell="1"/>
        <voice sentence="THE POWER IS MINE!" yell="1"/>
        <voice sentence="I returned from death and you dream about defeating me?"/>
        <voice sentence="Witness the first seconds of my eternal world domination!"/>
        <voice sentence="Even in my weakened state I will crush you all!"/>
    </voices>
    <loot>
        <item id="5903" chance="100000" unique="1"/>                <!-- ferumbras' hat -->
        <item id="2148" countmax="100" chance="98000"/>    <!-- gold coin -->
        <item id="2148" countmax="84" chance="98000"/>    <!-- gold coin -->
        <item id="9971" countmax="2" chance="75000"/>    <!-- gold ingot -->
        <item id="2522" chance="26000" unique="1"/>                <!-- great shield -->
        <item id="8903" chance="26000"/>                <!-- spellbook of lost souls -->
        <item id="2466" chance="24000"/>                <!-- golden armor -->
        <item id="2470" chance="22000"/>                <!-- golden legs -->
        <item id="8902" chance="22000"/>                <!-- spellbook of mind control -->
        <item id="8868" chance="22000"/>                <!-- velvet mantle -->
        <item id="2520" chance="20000"/>                <!-- demon shield -->
        <item id="8885" chance="20000"/>                <!-- divine plate -->
        <item id="7894" chance="20000"/>                <!-- magma legs -->
        <item id="2542" chance="20000"/>                <!-- tempest shield -->
        <item id="2127" chance="18000"/>                <!-- emerald bangle -->
        <item id="7896" chance="18000"/>                <!-- glacier kilt -->
        <item id="7895" chance="18000"/>                <!-- lightning legs -->
        <item id="2539" chance="18000"/>                <!-- phoenix shield -->
        <item id="8918" chance="18000"/>                <!-- spellbook of dark mysteries -->
        <item id="7885" chance="18000"/>                <!-- terra legs -->
        <item id="8930" chance="16000"/>                <!-- emerald sword -->
        <item id="7405" chance="16000"/>                <!-- havoc blade -->
        <item id="7451" chance="16000"/>                <!-- shadow sceptre -->
        <item id="2149" countmax="100" chance="16000"/>    <!-- gold ingot -->
        <item id="7632" countmax="5" chance="14000"/>    <!-- giant shimmering pearl -->
        <item id="7633" countmax="5" chance="14000"/>    <!-- giant shimmering pearl -->
        <item id="2472" chance="14000"/>                <!-- magic plate armor -->
        <item id="2514" chance="14000"/>                <!-- mastermind shield -->
        <item id="7417" chance="14000"/>                <!-- runed sword -->
        <item id="8904" chance="14000"/>                <!-- spellscroll of prophecies -->
        <item id="7427" chance="12000"/>                <!-- chaos mace -->
        <item id="8926" chance="12000"/>                <!-- demonwing axe -->
        <item id="8869" chance="12000"/>                <!-- greenwood coat -->
        <item id="2146" countmax="98" chance="12000"/>    <!-- small sapphire -->
        <item id="2143" countmax="88" chance="12000"/>    <!-- white pearl -->
        <item id="7407" chance="10000"/>                <!-- haunted blade -->
        <item id="8924" chance="10000"/>                <!-- hellforged axe -->
        <item id="7411" chance="10000"/>                <!-- ornamented axe -->
        <item id="2150" countmax="54" chance="10000"/>    <!-- small amethyst -->
        <item id="9970" countmax="87" chance="10000"/>    <!-- small topaz -->
        <item id="7382" chance="8000"/>                    <!-- demonrage sword -->
        <item id="7422" chance="8000"/>                    <!-- jade hammer -->
        <item id="2152" countmax="58" chance="8000"/>    <!-- platinum coin -->
        <item id="7423" chance="8000"/>                    <!-- skullcrusher -->
        <item id="5944" countmax="9" chance="8000"/>    <!-- soul orb -->
        <item id="6527" countmax="100" chance="15950"/><!--token-->
        <item id="6527" countmax="50" chance="15950"/><!--token-->
    </loot>
</monster>
 
seems as though parsing the XML to create the lootBlocks on startup aren't reading the unique attribute.

Try printing lootBlock.unique and seeing if the items that should be unique, actually are....
Lua:
if lootBlock then
    print(lootBlock.unique)
    if lootBlock.unique and not topScore then
 
seems as though parsing the XML to create the lootBlocks on startup aren't reading the unique attribute.

Try printing lootBlock.unique and seeing if the items that should be unique, actually are....
Lua:
if lootBlock then
    print(lootBlock.unique)
    if lootBlock.unique and not topScore then
how do I do that?
 
you should look into your src/monsters.cpp, and search for where it deserialises the "unique" attribute (if it exists....)
 
Solution
Back
Top