Skip to content
This repository has been archived by the owner on May 20, 2023. It is now read-only.

Some fixes events, configkey, optional stages, xp gain rate #2692

Closed
wants to merge 10 commits into from
Closed

Some fixes events, configkey, optional stages, xp gain rate #2692

wants to merge 10 commits into from

Conversation

APenDel
Copy link
Contributor

@APenDel APenDel commented Aug 1, 2021

Behaviour

Actual

Issues opentibiabr/otservbr-global#2464

On login you have one "XP Gain Rate", when you get experience this value changed.
Event schedule only display info, but doesn't work.

Expected

Formulae Tibia Wiki

  • Display correctely "XP Gain Rate".
  • Event Schedule server-side.
  • Exercise Training get bonus of events.

Fixes

global.lua & statup.lua

  • moved form global.lua -> globalevents\others\startup.lua all events rates variables.
    getEventSSkill, getEventSExp and getEventSLoot now load after events module.
  • set GlobalStorage.XpDisplayMode -> 1

player.lua

  • Fixed onGainExperience; Added preyBonus & staminaBoost variable.
    now use simple rule of 3...
    Rat: if 5 exp --- 100% | ? exp --- 150% so... 5 / 100 * 150 = 7(BaseXpGain + etc) see Rat

lib\core\functions.lua

  • getLootRandom approximate to real tibia.
  • getRateFromTable when doesn't have stages, return default.

exercise_training.lua

  • deleted unnecessary variables; if not reused.
  • added SCHEDULE_SKILL_RATE to calculate exp.

configmanager.cpp & configmanager.h

  • added RATE_USE_STAGES boolean config rateUseStages = true.
  • fixed RATE_EXPERIENCE.
  • set base rates to 1.

creaturescript\others\login.lua

  • fixed setBaseXpGain, now work with events too.

spawn.cpp & spawn.h

  • fixed interval spawn time.
  • when the spawn time is less than MINSPAWN_INTERVAL, addMonster with min value.
  • now interval to 30000, less check time.

game.cpp, scripts\luascript.cpp & protocolstatus.cpp

  • some fixes

src\otserv.cpp & config.lua.dist

  • On/Off stagesExp(def: true).
  • set rates to 1

events.xml

  • changed date for test.
  • can use exprate="0", with any argument (this reduce the rate to 0, but not the exp).
    NOTE: exprate, lootrate, spawnrate or skillrate in 100, it's default value.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

How Has This Been Tested

  • Rat Test 1: without event, rateExp x1 + stamina : 150% = 7.5
  • Rat Test 2: with event +100%, rateExp 100% + prey 40% + store 50% + stamina x1.5 : 435% = 21,75

Test Configuration:

  • Server Version: 8e85d5d
  • Client: Client 12.64
  • Operating System: Windows x64

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I checked the PR checks reports
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings (i don't see)
  • I have added tests that prove my fix is effective or that my feature works

Resolves opentibiabr/otservbr-global#2464

## global.lua & statup.lua
- moved form `global.lua -> globalevents\others\startup.lua` all events rates variables.
`getEventSSkill, getEventSExp and getEventSLoot` now load after events module.
- set `GlobalStorage.XpDisplayMode -> 1`

## player.lua
- Fixed `onGainExperience`; Added `preyBonus & staminaBoost` variable.
now use simple rule of 3...
Rat: if 5 exp --- 100% | ? exp --- 150% so... 5 / 100 * 150 = 7(BaseXpGain + etc) see https://www.tibiawiki.com.br/wiki/Rat

## lib\core\functions.lua
- `getLootRandom` approximate to real tibia.
- `getRateFromTable` when doesn't have stages, return default.

## exercise_training.lua
- deleted unnecessary variables; if not reused.
- added `SCHEDULE_SKILL_RATE` to calculate exp.

## configmanager.cpp & configmanager.h
- added `RATE_USE_STAGES` boolean config `rateUseStages = true`.
- fixed `RATE_EXPERIENCE`.
- set base rates to 1.

## creaturescript\others\login.lua
- fixed `setBaseXpGain`, now work with events too.

## spawn.cpp & spawn.h
- fixed interval spawn time.
- when the spawn time is less than `MINSPAWN_INTERVAL`, addMonster with min value.
- now `interval` to `30000`, less check time.

## game.cpp, scripts\luascript.cpp & protocolstatus.cpp
- some fixes

## src\otserv.cpp & config.lua.dist
- On/Off stagesExp(def: true).
- set rates to 1

## events.xml
- changed date for test.
- can use exprate="0", with any argument (this reduce the rate to 0, but not the exp).
NOTE: exprate, lootrate, spawnrate or skillrate in 100, it's default value.
@APenDel APenDel marked this pull request as draft August 1, 2021 20:54
@APenDel APenDel marked this pull request as ready for review August 1, 2021 20:55
@APenDel APenDel marked this pull request as draft August 1, 2021 21:59
APenDel and others added 4 commits August 1, 2021 19:10
## spawn.cpp
- use std: max instead.
(Test done: event active, spawnrate="0" and force 1)
## Some fixes
- the code is reduced to improve readability.
- `setBaseXpGain` now in `advance_save.lua` file for reduce calls.
- `advance_save.lua` unused code removed.
APenDel and others added 2 commits August 8, 2021 10:52
## solved issue opentibiabr/otservbr-global#2522
## events can set rate to 0? true.

## player.lua
- exp and skill rates not less than 0.

## global.lua
- added `SCHEDULE_SPAWN_RATE`.

## exercise_training.lua
- `SCHEDULE_SKILL_RATE` removed.. this one uses `onGainSkillTries`.

## advance_save.lua
- exp rate not less than 0.

## login.lua
- exp rate not less than 0.
- added msg for rapid respawn.

## startup.lua
- get event schedule, spawn rate.

## luascript.cpp
- added `getEventSSpawnRate & luaGamegetEventSSpawnRate`

## luascript.h
- added `luaGamegetEventSSpawnRate`.
@APenDel APenDel marked this pull request as ready for review August 8, 2021 17:23
@mattyx14
Copy link
Contributor

i check it work only have problems on stages on magic level rates

@APenDel
Copy link
Contributor Author

APenDel commented Aug 10, 2021

i check it work only have problems on stages on magic level rates

what kind of problem?...

@mattyx14
Copy link
Contributor

mattyx14 commented Aug 10, 2021

no work

-- Minlevel and multiplier are MANDATORY
-- Maxlevel is OPTIONAL, but is considered infinite by default
-- Create a stage with minlevel 1 and no maxlevel to disable stages
experienceStages = {
	{
		minlevel = 1,
		maxlevel = 50,
		multiplier = 15
	},
	{
		minlevel = 51,
		maxlevel = 100,
		multiplier = 13
	},
	{
		minlevel = 101,
		maxlevel = 200,
		multiplier = 10
	},
	{
		minlevel = 201,
		maxlevel = 400,
		multiplier = 8
	},
	{
		minlevel = 401,
		maxlevel = 600,
		multiplier = 6
	},
	{
		minlevel = 601,
		multiplier = 4
	}
}

skillsStages = {
	{
		minlevel = 1,
		multiplier = 50
	}
}

magicLevelStages = {
	{
		minlevel = 1,
		multiplier = 25
	}
}

Level and Skills work perfecly only magic only read from config.lua

@APenDel
Copy link
Contributor Author

APenDel commented Aug 10, 2021

no work
Level and Skills work perfecly only magic only read from config.lua

It works perfectly for me...
Remember that the objects that give ML influence the stages..(use rateUseStages = true in config.lua).

Edit: tested in ML 123 to 124.

skillsStages = {
  {
    minlevel = 0,
    maxlevel = 1,
    multiplier = 700
  }, {
    minlevel = 2,
    multiplier = 1
  }
}

magicLevelStages = {
  {
    minlevel = 0,
    maxlevel = 123,
    multiplier = 700
  }, {
    minlevel = 124,
    multiplier = 1
  }
}

@mattyx14
Copy link
Contributor

mattyx14 commented Aug 10, 2021

i test with 2 values and work ...

image

@mattyx14
Copy link
Contributor

i test and all ok only require remarge changes

APenDel and others added 3 commits August 11, 2021 13:41
## configmanager.cpp, exercise_training.lua & player.lua
- restore changes.

# config.lua.dist & configmanager.cpp
- `rateUseStages` false by default.
@majestyotbr
Copy link
Contributor

Tested and working.

@XmasGame
Copy link

XmasGame commented Aug 14, 2021

always it appears at half_
https://ibb.co/nkQ8D1y

@APenDel
Copy link
Contributor Author

APenDel commented Aug 14, 2021

always it appears at half_
https://ibb.co/nkQ8D1y

SEE THE EVENTS

%50.... exp.

@majestyotbr
Copy link
Contributor

The repository that submitted this pull request has been deleted. This changes need to be submitted again in a new pull request.

@dudantas
Copy link
Member

The repository that submitted this pull request has been deleted. This changes need to be submitted again in a new pull request.

Ok I'll do it!

@beats-dh
Copy link
Contributor

The repository that submitted this pull request has been deleted. This changes need to be submitted again in a new pull request.

Ok I'll do it!

Can I do it or leave it to you?

@dudantas
Copy link
Member

The repository that submitted this pull request has been deleted. This changes need to be submitted again in a new pull request.

Ok I'll do it!

Can I do it or leave it to you?

Yes you can. It makes it easier for me, as there are other things I need to do in the repository.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants