New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reward Boss implementation faithful to Tibia's one. #1628
Conversation
|
||
<event type="death" name="BossDeath" script="boss.lua" /> | ||
<event type="healthchange" name="BossParticipation" script="boss.lua" /> | ||
<event type="think" name="BossThink" script="boss.lua" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indendation on all the lines
error in compilation, how to fix? /theforgottenserver/src/actions.cpp: In member function 'ReturnValue Actions::internalUseItem(Player_, const Position&, uint8_t, Item_, bool)': |
@socket2810 Just curious if there is any reason for closing this PR... |
I had made it in my master branch. Whenever I make any new changes I'll open another PR and reference this one. |
You could as well rename your branch locally, push it to github, then reset against this master... |
@ranisalt |
Reasoning
After seeing a few reward systems on OTLand try and fail to replicate the original one, I decided to give it a try myself. Some images of the result:
How I did it
Boss Corpses
The difference between a normal monster corpse and a corpse that should yield individual rewards to players that participated in the fight is its attributes. ITEM_ATTRIBUTE_CORPSEOWNER is set to 2^31-1 and ITEM_ATTRIBUTE_DATE stores the time it was killed.
New class: Reward
It's the Reward class responsibility to store the different rewards a player may receive and, just like a depot chest, its contents are stored into the database when the player logs out and again loaded when they log back.
New class: Reward Chest
Analogous to the Depot Locker, the Reward Chest contains the Reward (that inside the game is a reward container. However, it contains all the Rewards. They are inserted into the chest during the player load phase and every time another Reward is created via:
Specifics
Timestamps
Timestamps are set both on the boss corpse and on the in-game reward container / Reward object. They're used to identify the Reward and to limit how long the reward is stored in the database (Tibia chose a maximum of 7 days).
How is each player attributed a different
corpsereward container?The Player class now holds a rewardCorpses map that stores each corpse, which are instantiated the first time that the player opens the body and are collected in the player destructor (together with the player's Rewards).(Not anymore: 7db6344)The boss now drops a proxy reward container, meaning it is not a Reward object, but simply an item with the same id. Whenever a player tries to open this container, he will actually open his own Reward, this way there is no need to store unique corpses objects for each player.
How is the loot handled?
Each player's contribution is measured by an onHealthChange event. The player will be considered active in the fight if he is currently in the boss' targetList - or whenever he heals someone that is currently active. The contribution is kept stored even if the player disconnects during the fight. If during the loot distribution phase the player is offline, he'll still receive his reward (Lua implementation: insertRewardBag(guid, timestamp, itemList)).
How to enable reward distribution to a boss
Set the *rewardboss flag to true on the monster .xml file:
To make a loot unique and awarded to the highest scoring player:
And register the corresponding events by calling Monster.setReward(self, enable) whenever a boss is summoned (e.g place_monster.lua).
Player contribution
Player contribution is currently calculated like this:
Each lootBlock is therefore lootFactor times more probable to be awarded to a specific player. However it is far from being optimal if we want to achieve a result similar to Tibia's and only with the community help we will manage that.