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

CreatureEvent Boss Reward

tetra20

DD
Joined
Jan 17, 2009
Messages
1,315
Solutions
4
Reaction score
323
Location
Egypt
What does this script do?
-
When you kill a monster(boss) with a group, the loot is automatically configured that everyone in the group gets item randomly, instead of loot in corpse

Does it depend on Damage?
-No,it Doesn't, it would need source edit , to get Damage Map

Can it add special attributes?
-
Yes it can add special attributes

Who does it give Loot to?
-Anyone who did damage to the boss,or in the Damage Map(did not get protection zone or die)

Screenshots
4108f690678950e6b31aaa4496657bf0.png

620acda1208ba20ee48a3aa69bd20868.png

eb85a5697e816534039ce20ae8631821.png


Script

Code:
local config = {
  ["Poseidon"] = {
  loot = {{2663,4,1},{2656,4,1},{7730,4,1},{2202,4,1},{2640,4,1},{8849,4,1},{8926,4,1},{7407,4,1},{7450,4,1},{8911,4,1},{2534,4,1},{2157,50,50},{2157,25,100}},
  message = "Congratulation For Defeating Poseidon,Your Reward is now in bag",
  effect = CONST_ME_SOUND_PURPLE,
    use_stats = false,
  chance_attr = {{'lifesteal',5,{3,7},{"melee","wand","dist"}},{'dodge',5,{1,5},{"armor"}}},
  animatedText = {COLOR_BLUE,"YA!"},
  SendToDepot = false,
  BagId = 9775
  },
  ["Hypnos"] = {
  loot = {{2493,4,1},{2494,4,1},{2495,4,1},{2214,4,1},{5462,4,1},{8850,4,1},{8925,4,1},{7382,4,1},{2436,4,1},{8921,4,1},{6391,4,1},{2157,50,75},{2157,50,50},{2157,25,100}},
  message = "Congratulation For Defeating Hypnos,Your Reward is now in bag",
  effect = CONST_ME_SOUND_YELLOW,
    use_stats = false,
  chance_attr = {{'lifesteal',4,{3,7},{"melee","wand","dist"}},{'dodge',4,{1,5},{"armor"}}},
  animatedText = {COLOR_MAYABLUE,"YA!"},
  SendToDepot = false,
  BagId = 2000
  },
  ["Hades"] = {
  loot = {{2533,4,1},{7899,4,1},{7894,4,1},{2209,4,1},{7891,4,1},{8851,4,1},{8924,4,1},{7385,4,1},{2421,4,1},{8922,4,1},{2496,4,1},{2157,50,100},{2157,50,100},{2157,25,100}},
  message = "Congratulation For Defeating Hades,Your Reward is now in depot",
  effect = CONST_ME_FIREWORK_RED,
    use_stats = false,
  chance_attr = {{'lifesteal',3,{3,7},{"melee","wand","dist"}},{'dodge',3,{1,5},{"all"}}},
  animatedText = {COLOR_RED,"YA!"},
  SendToDepot = true,
  BagId = 9775
  },
  ["Devil"] = {
  loot = {{2542,4,1},{7902,4,1},{7897,4,1},{7896,4,1},{2124,4,1},{7892,4,1},{8852,4,1},{7455,4,1},{7420,4,1},{2445,4,1},{7424,4,1},{2157,50,100},{2157,50,100},{2157,50,100},{2157,25,100}},
  message = "Congratulation For Defeating Devil,Your Reward is now in depot",
  effect = CONST_ME_HEARTS,
    use_stats = false,
  chance_attr = {{'lifesteal',1,{3,7},{"melee","wand","dist"}},{'dodge',1,{1,5},{"armor"}}},
  animatedText = {COLOR_PINK,"YA!"},
  SendToDepot = true,
  BagId = 9775
  }
  --[[
  ["NameOfMonster"] = {
  loot = {{itemid,chance,count},{itemid,chance,count}},
  message = "Message produced when you kill the boss",
  effect = "Effect when you kill boss",
  use_stats = false -- if it is true then special attribute will be added
  chance_attr = {{'attribute name',chance,{min,max},{applied weapons}},{'attribute name',chance,{min,max},{applied weapons}}},
  animatedText = {Color of text,"Text produced"},
  SendToDepot = true will send item to the depot, false will send item to player bag auto,
  BagId = dont need explanation
  }
   
  ]]
}
--forgive this part V couldn't think of any better solution
function ItemInfo(array,item)
  for i = 1,#array do
  if(array[i] == "melee")then
  if getItemInfo(item).weaponType == WEAPON_SWORD or getItemInfo(item).weaponType == WEAPON_CLUB or getItemInfo(item).weaponType == WEAPON_AXE then
  return true
  end
  elseif(array[i] == "armor")then
  if getItemInfo(item).armor ~= 0 and getItemInfo(item).wieldPosition ~= CONST_SLOT_NECKLACE then
  return true
  end
  elseif(array[i] == "wand")then
  if getItemInfo(item).weaponType == WEAPON_WAND then
  return true
  end
  elseif(array[i] == "dist")then
  if getItemInfo(item).weaponType == WEAPON_DIST and getItemInfo(item).ammoType ~= 0 then
  return true
  end
  elseif(array[i] == "shield")then
  if getItemInfo(item).weaponType == WEAPON_SHIELD and getItemInfo(item).defense ~= 0 then
  return true
  end   
  elseif(array[i] == "all")then
  return true
  end
  end
  return false
end
--- info scanner End

function onKill(cid, target, damage, flags,war)
  if isPlayer(cid) and isMonster(target) then
  local monster = config[getCreatureName(target)]
  if monster then
  local bag = doCreateItemEx(monster.BagId, 1)
  for i = 1,#monster.loot do
  if monster.loot[i][2] >= math.random(1,100) then -- random chance to get the item
  local item = doAddContainerItem(bag, monster.loot[i][1],monster.loot[i][3])
      if (monster.use_stats) then
         for z = 1,#monster.chance_attr do
           if(monster.chance_attr[z][2] >= math.random(1,100) and ItemInfo(monster.chance_attr[z][4], monster.loot[i][1]))then
             doItemSetAttribute(item, monster.chance_attr[z][1], math.random(monster.chance_attr[z][3][1],monster.chance_attr[z][3][2])) -- add attribute
           end
         end
       end
  end
  end
  if(getContainerItem(bag, 0).uid > 0)then -- check if the container has items or not
  doSendMagicEffect(getThingPos(cid), monster.effect)
  doSendAnimatedText(getThingPos(cid), monster.animatedText[2],monster.animatedText[1])
  if monster.SendToDepot then
  doPlayerSendMailByName(getCreatureName(cid), bag, getPlayerTown(cid), "Admin") -- send to depot
  else
  doPlayerAddItemEx(cid, bag,true) -- send to bag
  end
  doPlayerSendTextMessage(cid, 25, monster.message)
  else
  doPlayerSendTextMessage(cid, 25, "Better Luck Next Time,You Got No Reward.")
  end
  end
  end
  return true
end

It could be better than that, but well xD ..

Everything is Fully explained in the script

Info
-Any item sent to depot will be "Parcel" it can be changed by source edits only..

Thanks xD

Update
-Added use_stats,incase someone dont want to use attributes
 
Last edited:
Awesome. What version of tfs use this script?
 
Cool will test this :) thank you my dear friend
 
Is it possible to do reward only for 3 highest damaged on the boss?
Because it is like now everyone who attack the boss will get same reward it may do a mess with the server, (alot of chars attack same boss get same reward 100X instead of 1x only corpse)
Thanks.
 
Is it possible to do reward only for 3 highest damaged on the boss?
Because it is like now everyone who attack the boss will get same reward it may do a mess with the server, (alot of chars attack same boss get same reward 100X instead of 1x only corpse)
Thanks.
if you want source edits then sure, it is possible, only with source edit
 
Typically, Damage in onKill() just return a player damage, so you cant compare it with other players

so you will get damageMap

Which will return

[PlayerId] = {Damage = x, ticks = time of damage}

Then sorting this table to greatest.. and just giving reward to t[1] , t[2], t[3]

The problem is:

damageMap is protected inside creature.h, so you would need a function to return DamageMap in Public.and lua function.. this explains mostly everything
 
Typically, Damage in onKill() just return a player damage, so you cant compare it with other players

so you will get damageMap

Which will return

[PlayerId] = {Damage = x, ticks = time of damage}

Then sorting this table to greatest.. and just giving reward to t[1] , t[2], t[3]

The problem is:

damageMap is protected inside creature.h, so you would need a function to return DamageMap in Public.and lua function.. this explains mostly everything
Ah okey thanks :D.
 
nice work, here's the script with indentation.

Code:
local config = {
    ["Poseidon"] = {
        loot = {{2663,4,1},{2656,4,1},{7730,4,1},{2202,4,1},{2640,4,1},{8849,4,1},{8926,4,1},{7407,4,1},{7450,4,1},{8911,4,1},{2534,4,1},{2157,50,50},{2157,25,100}},
        message = "Congratulation For Defeating Poseidon,Your Reward is now in bag",
        effect = CONST_ME_SOUND_PURPLE,
        use_stats = false,
        chance_attr = {{'lifesteal',5,{3,7},{"melee","wand","dist"}},{'dodge',5,{1,5},{"armor"}}},
        animatedText = {COLOR_BLUE,"YA!"},
        SendToDepot = false,
        BagId = 9775
    },
    ["Hypnos"] = {
        loot = {{2493,4,1},{2494,4,1},{2495,4,1},{2214,4,1},{5462,4,1},{8850,4,1},{8925,4,1},{7382,4,1},{2436,4,1},{8921,4,1},{6391,4,1},{2157,50,75},{2157,50,50},{2157,25,100}},
        message = "Congratulation For Defeating Hypnos,Your Reward is now in bag",
        effect = CONST_ME_SOUND_YELLOW,
        use_stats = false,
        chance_attr = {{'lifesteal',4,{3,7},{"melee","wand","dist"}},{'dodge',4,{1,5},{"armor"}}},
        animatedText = {COLOR_MAYABLUE,"YA!"},
        SendToDepot = false,
        BagId = 2000
    },
    ["Hades"] = {
        loot = {{2533,4,1},{7899,4,1},{7894,4,1},{2209,4,1},{7891,4,1},{8851,4,1},{8924,4,1},{7385,4,1},{2421,4,1},{8922,4,1},{2496,4,1},{2157,50,100},{2157,50,100},{2157,25,100}},
        message = "Congratulation For Defeating Hades,Your Reward is now in depot",
        effect = CONST_ME_FIREWORK_RED,
        use_stats = false,
        chance_attr = {{'lifesteal',3,{3,7},{"melee","wand","dist"}},{'dodge',3,{1,5},{"all"}}},
        animatedText = {COLOR_RED,"YA!"},
        SendToDepot = true,
        BagId = 9775
    },
    ["Devil"] = {
        loot = {{2542,4,1},{7902,4,1},{7897,4,1},{7896,4,1},{2124,4,1},{7892,4,1},{8852,4,1},{7455,4,1},{7420,4,1},{2445,4,1},{7424,4,1},{2157,50,100},{2157,50,100},{2157,50,100},{2157,25,100}},
        message = "Congratulation For Defeating Devil,Your Reward is now in depot",
        effect = CONST_ME_HEARTS,
        use_stats = false,
        chance_attr = {{'lifesteal',1,{3,7},{"melee","wand","dist"}},{'dodge',1,{1,5},{"armor"}}},
        animatedText = {COLOR_PINK,"YA!"},
        SendToDepot = true,
        BagId = 9775
}
  --[[
  ["NameOfMonster"] = {
  loot = {{itemid,chance,count},{itemid,chance,count}},
  message = "Message produced when you kill the boss",
  effect = "Effect when you kill boss",
  use_stats = false -- if it is true then special attribute will be added
  chance_attr = {{'attribute name',chance,{min,max},{applied weapons}},{'attribute name',chance,{min,max},{applied weapons}}},
  animatedText = {Color of text,"Text produced"},
  SendToDepot = true will send item to the depot, false will send item to player bag auto,
  BagId = dont need explanation
  }
   
  ]]
}
--forgive this part V couldn't think of any better solution
function ItemInfo(array,item)
    for i = 1,#array do
        if(array[i] == "melee")then
            if getItemInfo(item).weaponType == WEAPON_SWORD or getItemInfo(item).weaponType == WEAPON_CLUB or getItemInfo(item).weaponType == WEAPON_AXE then
                return true
            end
        elseif(array[i] == "armor")then
            if getItemInfo(item).armor ~= 0 and getItemInfo(item).wieldPosition ~= CONST_SLOT_NECKLACE then
                return true
            end
        elseif(array[i] == "wand")then
            if getItemInfo(item).weaponType == WEAPON_WAND then
                return true
            end
        elseif(array[i] == "dist")then
            if getItemInfo(item).weaponType == WEAPON_DIST and getItemInfo(item).ammoType ~= 0 then
                return true
            end
        elseif(array[i] == "shield")then
            if getItemInfo(item).weaponType == WEAPON_SHIELD and getItemInfo(item).defense ~= 0 then
                return true
            end  
        elseif(array[i] == "all")then
            return true
        end
    end
    return false
end
--- info scanner End

function onKill(cid, target, damage, flags,war)
    if isPlayer(cid) and isMonster(target) then
        local monster = config[getCreatureName(target)]
        if monster then
            local bag = doCreateItemEx(monster.BagId, 1)
            for i = 1,#monster.loot do
                if monster.loot[i][2] >= math.random(1,100) then -- random chance to get the item
                    local item = doAddContainerItem(bag, monster.loot[i][1],monster.loot[i][3])
                    if (monster.use_stats) then
                        for z = 1,#monster.chance_attr do
                            if(monster.chance_attr[z][2] >= math.random(1,100) and ItemInfo(monster.chance_attr[z][4], monster.loot[i][1]))then
                                doItemSetAttribute(item, monster.chance_attr[z][1], math.random(monster.chance_attr[z][3][1],monster.chance_attr[z][3][2])) -- add attribute
                            end
                        end
                    end
                end
            end
           
            if(getContainerItem(bag, 0).uid > 0)then -- check if the container has items or not
                doSendMagicEffect(getThingPos(cid), monster.effect)
                doSendAnimatedText(getThingPos(cid), monster.animatedText[2],monster.animatedText[1])
                if monster.SendToDepot then
                    doPlayerSendMailByName(getCreatureName(cid), bag, getPlayerTown(cid), "Admin") -- send to depot
                else
                    doPlayerAddItemEx(cid, bag,true) -- send to bag
                end
                doPlayerSendTextMessage(cid, 25, monster.message)
            else
                doPlayerSendTextMessage(cid, 25, "Better Luck Next Time,You Got No Reward.")
            end
        end
    end
    return true
end
 
Guys, is it possible to make it like that all the players will get a reward who fight (hit) the monster? But NOT in party?
 
Back
Top