• 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 [TFS 1.1] Random Item Stats

Soul Jocker

Premium User
Premium User
Joined
Sep 26, 2011
Messages
21
Best answers
0
Reaction score
0
Hey guys, I have a few questions about the system.

1) Can it works with Slot System (Skills%)?

2) Bosses with Reward System can't drop items with stats. How I can fix it?? Is it possible?


It's a great system!!
Thanks!!
 

Soul Jocker

Premium User
Premium User
Joined
Sep 26, 2011
Messages
21
Best answers
0
Reaction score
0
Sorry about douple post but I don't know how to edit my last post.

I was testing the compatibility with this system with slot system and I found a incompatibility when you use a "slot remover" on a legendary item for example.

The slot remover will clean this item stats >> [attr:x%] ([atk:16%] for example).
But the item dont change and dont goes back to normal. It still legendary with more stats.

And when you use slot remover you can use slot jewels to imbue skills% in the same item, making a OP legendary item with many skills%

I need help to fix this compatibility and to fix the reward system too.

Thanks very much!
 

demon088

#088 in the Horde
Joined
Jun 17, 2009
Messages
179
Best answers
3
Reaction score
17
Location
Hell
Is there a way to add this system to quests? I mean when you use a chest or an item that adds equipments to the player, you get the quest equips but boosted with this system, It would be beauty to add this system to my quests. I loved this system! Thank you so much!
 

Allesn

Member
Joined
May 4, 2011
Messages
208
Best answers
1
Reaction score
23
If I wanted to add an item that would increase the skill (distance, example), how would I do that?
 

Allesn

Member
Joined
May 4, 2011
Messages
208
Best answers
1
Reaction score
23
Sorry for double post, but I can't edit.

How to add WEAPON_AMMO on list?
I put:
Lua:
if wp == WEAPON_AMMO then -- type ammo
                            table.insert(available_stats, stats[1])
But it does not work
 

Homeslice

-anoyn/Rage the Mage
Joined
May 9, 2010
Messages
114
Best answers
2
Reaction score
54
Location
Canada

whisperftw

New Member
Joined
Jul 20, 2010
Messages
6
Best answers
0
Reaction score
0
Is it possible to make a command out of this? So I could add stats to armours/weapons manually?
 

lazarus321

Member
Joined
May 8, 2017
Messages
209
Best answers
0
Reaction score
18
for show the name "prefix = 'rare', prefix = 'epic', prefix = 'legendary'," when kill the mob what i need do?
Im kill the mob and same name "rare" show even if i drop an epic item.
 

_M4G0_

Well-Known Member
Joined
Feb 6, 2016
Messages
433
Best answers
13
Reaction score
70
Please be aware I'm no C++ or LUA god.
Most of this is splicing existing code.

It could very much be broken down into separate and more modulated lua files.

DATA EDITS

lib/core.lua

add:
Code:
dofile('data/lib/core/lualoot.lua')
lib/core/lualoot.lua
lualoot.lua - Pastebin.com (http://pastebin.com/WEjezpxC)

creaturescripts.xml
add:
Code:
<!-- RPG Items  -->
   <event type="death" name="DropMonsterLoot" script="drop_monster_loot.lua"/>
drop_monster_loot.lua
Code:
function onDeath(monster, corpse, killer, mostdamagekiller, lasthitunjustified, mostdamageunjustified)
   if not monster:isMonster() or monster:getMaster() then
     return true
   end

   if not corpse:isContainer() then
     return true
   end

   local owner = mostdamagekiller
   if killer and killer:isPlayer() then
     owner = killer
   end

   local modifier = 1
   if owner and owner:isPlayer() then
     corpse:setAttribute(ITEM_ATTRIBUTE_CORPSEOWNER, owner:getId())
   end

   monster:getType():createLoot(corpse, 1)

   return true
end
events.xml
add:
Code:
    <!-- Monster method -->
   <event class="Monster" method="onSpawn" enabled="1" />
events/scripts/monster.lua
Code:
function Monster:onSpawn(pos, forced)
   self:registerEvent("DropMonsterLoot")

   return true
end


SOURCE EDITS:

events.cpp

after:
Code:
  playerOnTradeRequest = -1;
   playerOnTradeAccept = -1;
   playerOnGainExperience = -1;
   playerOnLoseExperience = -1;
   playerOnGainSkillTries = -1;
add:
Code:
   // Monster
   monsterOnSpawn = -1;
after:
Code:
      } else if (methodName == "onGainSkillTries") {
         playerOnGainSkillTries = event;
       } else {
         std::cout << "[Warning - Events::load] Unknown player method: " << methodName << std::endl;
       }
add:
Code:
    } else if (className == "Monster") {
       if (methodName == "onSpawn") {
         monsterOnSpawn = event;
       } else {
         std::cout << "[Warning - Events::load] Unknown monster method: " << methodName << std::endl;
       }
after:
Code:
  if (scriptInterface.protectedCall(L, 3, 1) != 0) {
     LuaScriptInterface::reportError(nullptr, LuaScriptInterface::popString(L));
   } else {
     tries = LuaScriptInterface::getNumber<uint64_t>(L, -1);
     lua_pop(L, 1);
   }

   scriptInterface.resetScriptEnv();
}
add:
Code:
// Monster
bool Events::eventMonsterOnSpawn(Monster* monster, const Position& position, bool forced) {
   // Monster:onSpawn(pos, forced)
   if (monsterOnSpawn == -1) {
     return true;
   }

   if (!scriptInterface.reserveScriptEnv()) {
     std::cout << "[Error - Events::eventMonsterOnSpawn] Call stack overflow" << std::endl;
     return false;
   }

   ScriptEnvironment* env = scriptInterface.getScriptEnv();
   env->setScriptId(monsterOnSpawn, &scriptInterface);

   lua_State* L = scriptInterface.getLuaState();
   scriptInterface.pushFunction(monsterOnSpawn);

   LuaScriptInterface::pushUserdata<Monster>(L, monster);
   LuaScriptInterface::setMetatable(L, -1, "Monster");

   LuaScriptInterface::pushPosition(L, position);

   LuaScriptInterface::pushBoolean(L, forced);

   return scriptInterface.callFunction(3);
}
events.h

after:
Code:
    void eventPlayerOnGainExperience(Player* player, Creature* source, uint64_t& exp, uint64_t rawExp);
     void eventPlayerOnLoseExperience(Player* player, uint64_t& exp);
     void eventPlayerOnGainSkillTries(Player* player, skills_t skill, uint64_t& tries);
add:
Code:
    // Monster
     bool eventMonsterOnSpawn(Monster* monster, const Position& pos, bool forced);
after:
Code:
    int32_t playerOnTradeAccept;
     int32_t playerOnGainExperience;
     int32_t playerOnLoseExperience;
     int32_t playerOnGainSkillTries;
add:
Code:
    // Monster
     int32_t monsterOnSpawn;
luascript.cpp

after:
Code:
  registerMethod("Container", "hasItem", LuaScriptInterface::luaContainerHasItem);
   registerMethod("Container", "addItem", LuaScriptInterface::luaContainerAddItem);
   registerMethod("Container", "addItemEx", LuaScriptInterface::luaContainerAddItemEx);
add:
Code:
registerMethod("Container", "getContentDescription", LuaScriptInterface::luaContainerGetContentDescription);
after:
Code:
registerMethod("Party", "isSharedExperienceEnabled", LuaScriptInterface::luaPartyIsSharedExperienceEnabled);
   registerMethod("Party", "shareExperience", LuaScriptInterface::luaPartyShareExperience);
   registerMethod("Party", "setSharedExperience", LuaScriptInterface::luaPartySetSharedExperience);
add:
Code:
registerMethod("Party", "broadcastLoot", LuaScriptInterface::luaPartyBroadcastLoot);
after:
Code:
  int32_t index = getNumber<int32_t>(L, 3, INDEX_WHEREEVER);
   uint32_t flags = getNumber<uint32_t>(L, 4, 0);
   ReturnValue ret = g_game.internalAddItem(container, item, index, flags);
   if (ret == RETURNVALUE_NOERROR) {
     ScriptEnvironment::removeTempItem(item);
   }
   lua_pushnumber(L, ret);
   return 1;
}
add:
Code:
int LuaScriptInterface::luaContainerGetContentDescription(lua_State* L)
{
   // container:getContentDescription()
   Container* container = getUserdata<Container>(L, 1);
   if (container) {
     pushString(L, container->getContentDescription());
   } else {
     lua_pushnil(L);
   }
   return 1;
}
after:
Code:
int LuaScriptInterface::luaPartySetSharedExperience(lua_State* L)
{
   // party:setSharedExperience(active)
   bool active = getBoolean(L, 2);
   Party* party = getUserdata<Party>(L, 1);
   if (party) {
     pushBoolean(L, party->setSharedExperience(party->getLeader(), active));
   } else {
     lua_pushnil(L);
   }
   return 1;
}
add:
Code:
int LuaScriptInterface::luaPartyBroadcastLoot(lua_State* L)
{
   // party:broadcastLoot(lootMessage)
   const std::string& lootMessage = getString(L, 2);
   Party* party = getUserdata<Party>(L, 1);
   if (party) {
     party->broadcastPartyLoot(lootMessage);
     pushBoolean(L, true);
   } else {
     lua_pushnil(L);
   }
   return 1;
}
luascript.h

after:
Code:
    static int luaContainerGetItem(lua_State* L);
     static int luaContainerHasItem(lua_State* L);
     static int luaContainerAddItem(lua_State* L);
     static int luaContainerAddItemEx(lua_State* L);
add:
Code:
static int luaContainerGetContentDescription(lua_State* L);
after:
Code:
    static int luaPartyIsSharedExperienceActive(lua_State* L);
     static int luaPartyIsSharedExperienceEnabled(lua_State* L);
     static int luaPartyShareExperience(lua_State* L);
     static int luaPartySetSharedExperience(lua_State* L);
add:
Code:
static int luaPartyBroadcastLoot(lua_State* L);
This is tested and worked in my little sandbox.
However this hasn't been tested on a live server.
how i can remove double loot ?

00:55 Loot of a hydra: 29 gold coins, a knight armor, ham, a rare knight armor
 

Leo32

Getting back into it...
Joined
Sep 21, 2007
Messages
958
Best answers
14
Reaction score
411
how i can remove double loot ?

00:55 Loot of a hydra: 29 gold coins, a knight armor, ham, a rare knight armor
code is old af dude, dont use it.

Use this instead:
 

oen432

Excellent OT User
Joined
Oct 3, 2014
Messages
806
Best answers
29
Reaction score
741
Location
Poland
how i can remove double loot ?

00:55 Loot of a hydra: 29 gold coins, a knight armor, ham, a rare knight armor
Or if you want something more advanced and customizable
 
Top