Skip to content

Commit

Permalink
Updates 26/06/2020
Browse files Browse the repository at this point in the history
  • Loading branch information
moviebr committed Jun 26, 2020
1 parent 1999379 commit 6a757e2
Show file tree
Hide file tree
Showing 1,523 changed files with 97,951 additions and 103 deletions.
1 change: 1 addition & 0 deletions data/creaturescripts/creaturescripts.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<event type="kill" name="Exiva" script="custom/exiva.lua" />
<event type="kill" name="Tasks" script="custom/task.lua" />
<event type="login" name="FirstItems" script="custom/firstitems.lua" />
<event type="think" name="SuperUP" script="custom/superup.lua" />

<!-- Reward Chest -->
<event type="login" name="LoginBossPlayer" script="custom/reward/reward.lua" />
Expand Down
26 changes: 26 additions & 0 deletions data/creaturescripts/scripts/custom/superup.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
function onThink(creature, interval)
local player = creature:getPlayer()
if not player then
return false
end

local storIndex = player:getStorageValue(STORAGEVALUE_SUPERUP_INDEX)
local storTime = player:getStorageValue(STORAGEVALUE_SUPERUP_TEMPO)

for a, b in pairs(SUPERUP.areas) do
if storIndex == a and isInArea(player:getPosition(), b.from, b.to) then
if storTime <= os.time() then
player:teleportTo(player:getTown():getTemplePosition())
player:getPosition():sendMagicEffect(CONST_ME_POFF)
end
end
if storIndex == a and storTime <= os.time() then
db.query(string.format("UPDATE exclusive_hunts SET `guid_player` = %d, `time` = %s, `to_time` = %s WHERE `hunt_id` = %d", 0, 0, 0, storIndex))
player:setStorageValue(STORAGEVALUE_SUPERUP_TEMPO, 0)
player:setStorageValue(STORAGEVALUE_SUPERUP_INDEX, 0)
player:sendCancelMessage(SUPERUP.msg.tempoAcabou)
end
end

return true
end
1 change: 1 addition & 0 deletions data/creaturescripts/scripts/others/login.lua
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,6 @@ function onLogin(player)
player:registerEvent("Exiva")
player:registerEvent("Events")
player:registerEvent("Tasks")
player:registerEvent("SuperUP")
return true
end
8 changes: 8 additions & 0 deletions data/events/scripts/monster.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,15 @@ function Monster:onDropLoot(corpse)
local mType = self:getType()
if not player or player:getStamina() > 840 then
local monsterLoot = mType:getLoot()

-- Boost Creature
local percent = 0
if (mType:getName():lower() == boostCreature[1].name) then
percent = (boostCreature[1].loot / 100)
end

for i = 1, #monsterLoot do
monsterLoot[i].chance = monsterLoot[i].chance + (monsterLoot[i].chance * percent)
local item = corpse:createLootItem(monsterLoot[i])
if not item then
print('[Warning] DropLoot:', 'Could not add loot item to corpse.')
Expand Down
16 changes: 9 additions & 7 deletions data/events/scripts/player.lua
Original file line number Diff line number Diff line change
Expand Up @@ -314,17 +314,19 @@ function Player:onGainExperience(source, exp, rawExp)
end

-- Castle 24H
local guild = self:getGuild()
if not guild then
return exp
end

if self:getGuild():getId() == getGuildIdFromCastle() then
if self:getGuild() and self:getGuild():getId() == getGuildIdFromCastle() then
local expCastle = 1.2 -- 20% a mais de exp
exp = exp * expCastle
end

return exp
local extraXp = 0
if (source:getName():lower() == boostCreature[1].name) then
local extraPercent = boostCreature[1].exp
extraXp = exp + (exp * extraPercent / 100)
self:sendTextMessage(MESSAGE_STATUS_DEFAULT, "[Boosted Creature] Você ganhou ".. extraXp .." de experiência.")
end

return exp + extraXp
end

function Player:onLoseExperience(exp)
Expand Down
12 changes: 12 additions & 0 deletions data/global.lua
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ function getFormattedWorldTime()
return hours .. ':' .. minutes
end

function firstToUpper(str)
return (str:gsub("^%l", string.upper))
end

function getLootRandom()
return math.random(0, MAX_LOOTCHANCE) / configManager.getNumber(configKeys.RATE_LOOT)
end
Expand Down Expand Up @@ -208,4 +212,12 @@ string.diff = function (diff, translate)
end

return table.concat(t)
end

function hourToNumber(str)
local hour = (tonumber(str:sub(1,2))*3600) + (tonumber(str:sub(4,5)) * 60)
if #str > 5 then
hour = hour + tonumber(str:sub(7,8))
end
return hour
end
5 changes: 4 additions & 1 deletion data/globalevents/globalevents.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@
<!-- Custom -->
<globalevent name="Bosses" interval="198000000" script="custom/bosses.lua" />
<globalevent name="TextEffect" interval="3000" script="custom/textEffect.lua" />
<!--globalevent name="EventsShow" interval="5000" script="custom/eventsShow.lua" /-->
<globalevent name="EventsShow" interval="5000" script="custom/eventsShow.lua" />
<globalevent name="EffectTemple" interval="1300" script="custom/effectTemple.lua" />
<globalevent name="Shop" interval="30000" script="custom/shop.lua" />
<globalevent name="SuperUP" interval="5000" script="custom/superup.lua" />
<globalevent type="startup" name="BoostCreature" script="custom/boostCreature.lua" />
<globalevent name="BoostCreatureThink" interval="10800000" script="custom/boostCreature.lua" />

<!-- Events -->
<globalevent name="Lottery" time="15:00:00" script="custom/events/lottery.lua" />
Expand Down
12 changes: 12 additions & 0 deletions data/globalevents/scripts/custom/boostCreature.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
function onStartup()
BoostedCreature:start()
if BoostedCreature.db then
db.query(string.format("UPDATE `boost_creature` SET `name` = '%s', `exp` = %d, `loot` = %d", firstToUpper(boostCreature[1].name), boostCreature[1].exp, boostCreature[1].loot))
end
return true
end

function onThink(interval)
Game.broadcastMessage(string.format(BoostedCreature.msg.showBoost, firstToUpper(boostCreature[1].name), boostCreature[1].loot, boostCreature[1].exp))
return true
end
8 changes: 4 additions & 4 deletions data/globalevents/scripts/custom/eventsShow.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ local EventsList = {
{name = "SafeZone", time = "20:00"},
},
["Friday"] = {
{name = "SnowBall", time = "10:00"},
{name = "SnowBall", time = "12:00"},
{name = "Battlefield", time = "15:00"},
{name = "SafeZone", time = "20:00"},
},
Expand All @@ -37,8 +37,8 @@ function onThink(interval, lastExecution)
local spectators = Game.getSpectators(position, false, true, 7, 7, 5, 5)
local event = EventsList[os.date("%A")]
for a, b in pairs(event) do
local eventTime = b.time
local realTime = (os.date("%H:%M:%S"))
local eventTime = hourToNumber(b.time)
local realTime = hourToNumber(os.date("%H:%M:%S"))
if eventTime >= realTime then
if #spectators > 0 then
for i = 1, #spectators do
Expand All @@ -52,12 +52,12 @@ function onThink(interval, lastExecution)
else
spectators[i]:say("Próximo evento:\n"..b.name.." às "..b.time..".", TALKTYPE_MONSTER_SAY, false, spectators[i], position)
position:sendMagicEffect(40)
return true
end
end
end
end
end
break
end
return true
end
12 changes: 12 additions & 0 deletions data/globalevents/scripts/custom/superup.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
function onThink(interval)

local ricardoViado = SUPERUP:freeCave()

for _, b in pairs(ricardoViado) do
if os.time() >= b[2] then
-- db.query(string.format("UPDATE player_storage SET value = 0 WHERE `key` IN(%d,%d) AND `player_id` = %d", STORAGEVALUE_SUPERUP_INDEX, STORAGEVALUE_SUPERUP_TEMPO, b[3]))
db.query(string.format("UPDATE exclusive_hunts SET `guid_player` = %d, `time` = %s, `to_time` = %s WHERE `hunt_id` = %d", 0, 0, 0, b[1]))
end
end
return true
end
9 changes: 7 additions & 2 deletions data/globalevents/scripts/custom/textEffect.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local effects = {
function onThink(interval)
local effects = {
{position = Position(986, 1216, 7), effect = 29},
{position = Position(988, 1216, 7), effect = 29},
{position = Position(987, 1217, 7), text = "[PREMIUM]", effect= 40},
Expand Down Expand Up @@ -31,9 +32,13 @@ local effects = {
{position = Position(477, 1379, 6), text = "Cidades", effect = 49},
{position = Position(478, 1379, 6), text = "Bosses", effect = 49},
{position = Position(984, 1212, 7), text = "Rotworms", effect = 57},
{position = Position(1002, 1204, 7), text = "Reward Chest", effect = 40},
{position = Position(987, 1214, 8), text = "Boosted Creature\n ", effect = 30},
{position = Position(986, 1213, 8), text = "+" .. boostCreature[1].exp .."% de EXP"},
{position = Position(986, 1215, 8), text = "+" .. boostCreature[1].loot .."% de Loot"},

}

function onThink(interval)
for i = 1, #effects do
local settings = effects[i]
local spectators = Game.getSpectators(settings.position, false, true, 7, 7, 5, 5)
Expand Down
2 changes: 1 addition & 1 deletion data/items/items.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4336,7 +4336,7 @@
<attribute key="type" value="mailbox" />
</item>
<item id="2594" article="a" name="depot chest">
<attribute key="containerSize" value="30" />
<attribute key="containerSize" value="2" />
</item>
<item id="2595" article="a" name="parcel">
<attribute key="type" value="container" />
Expand Down
22 changes: 22 additions & 0 deletions data/lib/custom/boostCreature.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
if not boostCreature then boostCreature = {} end

BoostedCreature = {
monsters = {"Rotworm"},
db = true,
exp = {3, 15},
loot = {3, 15},
position = Position(987, 1214, 8),
msg = {
showBoost = "[Boosted Creature] A criatura %s foi a escolhida, adicionado +%d% de loot e +%d% de experiência.",
}
}

function BoostedCreature:start()
local rand = math.random
local monsterRand = BoostedCreature.monsters[rand(#BoostedCreature.monsters)]
local expRand = rand(BoostedCreature.exp[1], BoostedCreature.exp[2])
local lootRand = rand(BoostedCreature.loot[1], BoostedCreature.loot[2])
table.insert(boostCreature, {name = monsterRand:lower(), exp = expRand, loot = lootRand})
local monster = Game.createMonster(boostCreature[1].name, BoostedCreature.position, false, true)
monster:setDirection(WEST)
end
60 changes: 34 additions & 26 deletions data/lib/custom/superup.lua
Original file line number Diff line number Diff line change
@@ -1,47 +1,55 @@
--[[
1. Player tem uma chave, ao tentar passar por
1.1. Caso não tenha uma chave disponível, retornar erro
1.2. Caso já tenha uma cave, retornar erro
1.3. Comprar cave se tudo certo
1. Adicionar uma storage com o value do index da cave
2. Adicionar no banco de dados quem comprou, horário de compra e até quando ele comprou
3. Adicionar uma storage com o tempo que ele tem de cave
1. Fazer um onLogin e onThink para retirar ele da cave caso tenha acabado o tempo
2. Função verificar se tem cave
3. Função verificar de quem é a cave e quanto tempo restante
4. Função retirar player da cave caso tempo tenha acabado
--]]

--[[
CREATE TABLE `exclusive_hunts` (
`hunt_id` int(2) NOT NULL,
`bought_by` VARCHAR(32) NOT NULL,
`hunt_id` int(2) NOT NULL AUTO_INCREMENT,
`guid_player` VARCHAR(32) NOT NULL,
`time` int(11) NOT NULL,
`to_time` int(11) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
]]

SUPERUP = {
msg = {
naoDisponivel = "Essa cave está ocupada pelo jogador %s até %d.",
disponivel = "Parabéns, você comprou uma cave do Super UP!",
naoDisponivel = "Essa cave está ocupada pelo jogador %s até %s.",
disponivel = "Parabéns, você comprou uma cave do Super UP com duração de %d %s!",
naoItem = "Você precisa de uma %s para comprar uma cave.",
tempoAcabou = "O seu tempo de Super UP acabou!",
possuiCave = "Você já possui uma cave do Super UP!",
},
areas = {
[1] = {nome = "Demon", entrada = Position(284, 223, 7), from = Position(284, 223, 7), to = Position(284, 223, 7)},
[1] = {nome = "Demon", entrada = Position(546, 1250, 7), from = Position(1008, 889, 7), to = Position(1030, 903, 7)},
},
setTime = 3, -- Em horas
itemID = 8978,
}

function Player.hasCave(self)
if self:getStorageValue(STORAGEVALUE_SUPERUP) >= 1 or self:getStorageValue(STORAGEVALUE_SUPERUP_TEMPO) > os.time() then
self:sendCancelMessage(SUPERUP.possuiCave)
self:getPosition():sendMagicEffect(CONST_ME_POFF)
function SUPERUP:getCave(id)
local resultCave = db.storeQuery("SELECT guid_player, to_time FROM exclusive_hunts WHERE `hunt_id` = " .. id)
if not resultCave then
return false
end

local caveOwner = result.getDataInt(resultCave, "guid_player")
local caveTime = result.getDataLong(resultCave, "to_time")
result.free(resultCave)

return {dono = caveOwner, tempo = caveTime}
end

function SUPERUP:freeCave()
freeCaves = {}
local db = db.storeQuery("SELECT `hunt_id`, `to_time`, `guid_player` FROM exclusive_hunts")
if not db then
return false
else
return true
end

repeat
local idHunt = result.getDataInt(db, "hunt_id")
local tempoFinal = result.getDataLong(db, "to_time")
local guidPlayer = result.getDataInt(db, "guid_player")
result.free(db)

table.insert(freeCaves, {idHunt, tempoFinal, guidPlayer})

until not result.next(db)
return freeCaves
end
8 changes: 7 additions & 1 deletion data/lib/lib.lua
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,14 @@ dofile('data/lib/events/firestorm.lua')
-- Tasks
dofile('data/lib/custom/task.lua')

-- SuperUP
dofile('data/lib/custom/superup.lua')

-- Reward Boss
dofile('data/lib/custom/rewardBoss.lua')

-- Premium Points
dofile('data/lib/custom/premiumPoints.lua')
dofile('data/lib/custom/premiumPoints.lua')

-- Boost Creature
dofile('data/lib/custom/boostCreature.lua')
6 changes: 4 additions & 2 deletions data/migrations/29.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
function onUpdateDatabase()
return false
end
print("> Updating database to version 30 (AutoLoot)")
db.query("ALTER TABLE `players` ADD `autoloot` BLOB DEFAULT NULL")
return true
end
6 changes: 6 additions & 0 deletions data/migrations/30.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
function onUpdateDatabase()
print("> Updating database to version 31 (Boost Creature)")
db.query("CREATE TABLE `boost_creature` ( `name` VARCHAR(255) NOT NULL , `exp` INT(11) NOT NULL DEFAULT '0' , `loot` INT(11) NOT NULL DEFAULT '0' ) ENGINE = InnoDB;")
db.query("INSERT INTO `boost_creature` (`name`, `exp`, `loot`) VALUES ('', '0', '0');")
return true
end
3 changes: 3 additions & 0 deletions data/migrations/31.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
function onUpdateDatabase()
return false
end
1 change: 1 addition & 0 deletions data/movements/movements.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<movements>

<!-- Custom -->
<movevent event="StepIn" actionid="20001" script="custom/superup.lua" />
<movevent event="StepIn" actionid="4537" script="custom/temple.lua" />
<movevent event="StepIn" actionid="6489" script="custom/events/battlefield.lua" />
<movevent event="StepIn" actionid="6412" script="custom/events/safezone.lua" />
Expand Down
Loading

0 comments on commit 6a757e2

Please sign in to comment.