Ir para conteúdo

Featured Replies

Postado
  • Administrador

Olá pessoal! Estou trabalhando em um sistema para criaturas e chefes boostados no meu servidor TFS 1x. Não estou interessado em integrar este sistema ao código-fonte por razões óbvias, já que isso facilitaria a edição para outros servidores. Estou postando isso para colaborar na melhoria do sistema atual implementando novos conceitos e refinando os existentes.

 

Sobre o código: GlobalEvents: Estou usando Eventos Globais para atualizar a criatura e o chefe boostado na inicialização do servidor. Para evitar a necessidade de reinicializar o servidor ao alterar o chefe, estou considerando mudar de onStartup para onThink e especificar um horário preciso para o evento ocorrer. Simultaneamente, armazeno o índice da criatura em um armazenamento global para evitar consultas ao banco de dados ao procurar o monstro boostado do dia.

 

CreatureScript: Com o monstro atualizado no banco de dados e o armazenamento global configurado com o índice do monstro atual, verifico em um CreatureScript qual monstro o jogador está derrotando. Usando dmgMap, posso identificar um ou mais jogadores contribuindo para a morte do monstro boostado diário. Certifico-me de registrar o evento quando um jogador faz login para evitar problemas potenciais.

Sobre as melhorias: Em vez de criar uma função responsável por passar boostedCreature(tipo, nomeDoMonstro), o que seria ideal, criei duas funções - uma para chefes e outra para criaturas. Esta é uma melhoria significativa que pode simplificar consideravelmente o código adicionando esta função de utilidade.

 

Melhorias importantes: A função onKill do sistema de criatura boostada está funcional e sem problemas. No entanto, alguns conceitos estão faltando. Atualmente, todos os jogadores que contribuem para a morte da criatura recebem o XP total. Há uma parte comentada no código onde o compartilhamento de XP da criatura é aplicado, mas não está funcional. Isso precisa ser ajustado - sinta-se à vontade para compartilhar quaisquer insights aqui!

 

O que está faltando: Além do XP, o monstro também deve fornecer saques extras (A fazer). Também estou trabalhando em adicionar o evento para a morte do chefe (Em andamento).

Outras melhorias: Sinta-se à vontade para sugerir melhorias adicionais para o sistema!

 

Alterações aqui
Boosted system creaturescript globalevents lib by Underewarrr · Pull Request #1 · thetibiaking/forgottenserver (github.com)

  • 1 year later...
  • Respostas 5
  • Visualizações 941
  • Created
  • Última resposta

Top Posters In This Topic

Most Popular Posts

  • use onstatschange and lua table = {} to store the damage then count total damage divide it by the expereince and give correct experience to players aditionally to loot just use events monster ond

  • Mateus Robeerto
    Mateus Robeerto

    Using onStatsChange in TFS 1.x? That's completely incorrect — the proper way is to use onHealthChange and onManaChange. However, there is an alternative that doesn't require using two separate fu

Postado

use onstatschange and lua table = {} to store the damage then count total damage divide it by the expereince and give correct experience to players

aditionally to loot just use events monster ondroploot and add validity check there if its boosted creature to give double loot

function Monster:onDropLoot(corpse)
    if configManager.getNumber(configKeys.RATE_LOOT) == 0 then
        return
    end

    local player = Player(corpse:getCorpseOwner())
    local mType = self:getType()
    
    if not player or player:getStamina() > 840 then
        local monsterLoot = mType:getLoot()

        -- Generate primary loot
        for i = 1, #monsterLoot do
            local item = corpse:createLootItem(monsterLoot[i])
            if not item then
                print('[Warning] DropLoot:', 'Could not add loot item to corpse.')
            end
        end

        -- Check for extra loot with 2% chance if player has specific storage value
        if player and player:getStorageValue(656002) > 0 and math.random(1, 100) <= 2 then
            --print("Extra loot generated due to 2% chance!")
            local secondaryLoot = mType:getLoot()  -- Assume you have a method to get secondary loot
            for i = 1, #secondaryLoot do
                local item = corpse:createLootItem(secondaryLoot[i])
                if not item then
                    print('[Warning] DropLoot:', 'Could not add secondary loot item to corpse.')
                end
            end
        end

        -- Send loot message to player or party
        if player then
            local text = ("Loot of %s: %s"):format(mType:getNameDescription(), corpse:getContentDescription())
            local party = player:getParty()
            if party then
				-- Broadcast to the party
				party:broadcastPartyLoot(text)
			else
                --player:sendTextMessage(MESSAGE_INFO_DESCR, text)
				
                --sendChannelMessage(9, TALKTYPE_CHANNEL_O, text)
				
				player:sendChannelMessage("", text, TALKTYPE_CHANNEL_O, 9) --9 is the channel ID, yours might be different
				
				if player:getStorageValue(48484848) > 0 then
				player:sendTextMessage(MESSAGE_INFO_DESCR, text)
				end
				
            end
        end
    else
        -- Send message about no loot due to low stamina
        if player then
            local text = ("Loot of %s: nothing (due to low stamina)"):format(mType:getNameDescription())
            local party = player:getParty()
            if party then
                party:broadcastPartyLoot(text)
            else
            --sendChannelMessage(9, TALKTYPE_CHANNEL_O, text)
			
			player:sendChannelMessage("", text, TALKTYPE_CHANNEL_O, 9) --9 is the channel ID, yours might be different
            --player:sendTextMessage(MESSAGE_INFO_DESCR, text)
				if player:getStorageValue(48484848) > 0 then
					player:sendTextMessage(MESSAGE_INFO_DESCR, text)
				end
			end
        end
    end
end

 

Postado
  • Autor
  • Administrador
Em 20/04/2025 em 17:13, idlerpl disse:

use onstatschange and lua table = {} to store the damage then count total damage divide it by the expereince and give correct experience to players

aditionally to loot just use events monster ondroploot and add validity check there if its boosted creature to give double loot


function Monster:onDropLoot(corpse)
    if configManager.getNumber(configKeys.RATE_LOOT) == 0 then
        return
    end

    local player = Player(corpse:getCorpseOwner())
    local mType = self:getType()
    
    if not player or player:getStamina() > 840 then
        local monsterLoot = mType:getLoot()

        -- Generate primary loot
        for i = 1, #monsterLoot do
            local item = corpse:createLootItem(monsterLoot[i])
            if not item then
                print('[Warning] DropLoot:', 'Could not add loot item to corpse.')
            end
        end

        -- Check for extra loot with 2% chance if player has specific storage value
        if player and player:getStorageValue(656002) > 0 and math.random(1, 100) <= 2 then
            --print("Extra loot generated due to 2% chance!")
            local secondaryLoot = mType:getLoot()  -- Assume you have a method to get secondary loot
            for i = 1, #secondaryLoot do
                local item = corpse:createLootItem(secondaryLoot[i])
                if not item then
                    print('[Warning] DropLoot:', 'Could not add secondary loot item to corpse.')
                end
            end
        end

        -- Send loot message to player or party
        if player then
            local text = ("Loot of %s: %s"):format(mType:getNameDescription(), corpse:getContentDescription())
            local party = player:getParty()
            if party then
				-- Broadcast to the party
				party:broadcastPartyLoot(text)
			else
                --player:sendTextMessage(MESSAGE_INFO_DESCR, text)
				
                --sendChannelMessage(9, TALKTYPE_CHANNEL_O, text)
				
				player:sendChannelMessage("", text, TALKTYPE_CHANNEL_O, 9) --9 is the channel ID, yours might be different
				
				if player:getStorageValue(48484848) > 0 then
				player:sendTextMessage(MESSAGE_INFO_DESCR, text)
				end
				
            end
        end
    else
        -- Send message about no loot due to low stamina
        if player then
            local text = ("Loot of %s: nothing (due to low stamina)"):format(mType:getNameDescription())
            local party = player:getParty()
            if party then
                party:broadcastPartyLoot(text)
            else
            --sendChannelMessage(9, TALKTYPE_CHANNEL_O, text)
			
			player:sendChannelMessage("", text, TALKTYPE_CHANNEL_O, 9) --9 is the channel ID, yours might be different
            --player:sendTextMessage(MESSAGE_INFO_DESCR, text)
				if player:getStorageValue(48484848) > 0 then
					player:sendTextMessage(MESSAGE_INFO_DESCR, text)
				end
			end
        end
    end
end

 

I love it! i will add soon on code base, we are changing the current github so in the mommet not possible!
 

Postado
Em 20/04/2025 em 17:13, idlerpl disse:

onstatschange

Using onStatsChange in TFS 1.x? That's completely incorrect — the proper way is to use onHealthChange and onManaChange.

However, there is an alternative that doesn't require using two separate functions. It's working — I did it for OTG Global. Take a look at this:

https://github.com/otg-br/global-11x/blob/main/data/scripts/custom_system_event/boosted_creature_system_full.lua#L192

 

 

@Under, dá uma olhada nesse sistema. O que eu fiz é bem diferente do seu, mas está funcionando 100%.

Ele exibe monstros como estátuas, mostra informações de boost, porcentagem de XP e loot. Também envia mensagens com essas informações ao logar.

Além disso, dá pra colocar em um piso com actionID, e quando o jogador pisa, aparece a mensagem ou executa um comando. Tudo está funcionando perfeitamente, inclusive o loot e a experiência.

Se quiser, fique à vontade para dar uma olhada, adaptar para o seu GitHub ou até tornar público.

Postado
  • Autor
  • Administrador
15 horas atrás, Mateus Robeerto disse:

Using onStatsChange in TFS 1.x? That's completely incorrect — the proper way is to use onHealthChange and onManaChange.

However, there is an alternative that doesn't require using two separate functions. It's working — I did it for OTG Global. Take a look at this:

https://github.com/otg-br/global-11x/blob/main/data/scripts/custom_system_event/boosted_creature_system_full.lua#L192

 

 

@Under, dá uma olhada nesse sistema. O que eu fiz é bem diferente do seu, mas está funcionando 100%.

Ele exibe monstros como estátuas, mostra informações de boost, porcentagem de XP e loot. Também envia mensagens com essas informações ao logar.

Além disso, dá pra colocar em um piso com actionID, e quando o jogador pisa, aparece a mensagem ou executa um comando. Tudo está funcionando perfeitamente, inclusive o loot e a experiência.

Se quiser, fique à vontade para dar uma olhada, adaptar para o seu GitHub ou até tornar público.

Vou olhar com certeza!

Participe da conversa

Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.

Visitante
Responder

Quem Está Navegando 0

  • Nenhum usuário registrado visualizando esta página.

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.7k

Informação Importante

Confirmação de Termo