Jump to content

Pet system with experience and level effect


Denis

Recommended Posts

M2 Download Center

This is the hidden content, please
( Internal )

Hello,

Like the title says it's a pet system with level effect and experience.

 

Spoiler

quest pet_system begin
    state start begin
        function give_pet_exp(ammount)
            local pet_item = pc.getqf("pet_item")
            local pet_level = pc.getqf("pet_"..pet_item.."_level")
            local pet_exp = pc.getqf("pet_"..pet_item.."_exp")
            local exp_table = {100,200,300,400,500,600,700,800,900,1000,1100,1200,1300,1400,1500,1600,1700,1800,1900,20000}
            local mobVnum = pet_system.get_pet_info(pet_item)[1]
            
            local MAX_LEVEL = 20
            
            if pet_level <= MAX_LEVEL then
                if pet_exp > exp_table[pet_level] then
                    pet.spawn_effect(mobVnum, "d:ymir workeffectetclevelup_1level_up.mse")
                    pc.setqf("pet_"..pet_item.."_level",pet_level+1)
                    pc.setqf("pet_"..pet_item.."_exp",1)
                    syschat("Your pet has reached Level "..pet_level)
                else
                    pc.setqf("pet_"..pet_item.."_exp",pet_exp+ammount)
                end
            end
            
        end
        function get_pet_info(itemVnum)
            pet_info_map = {
                [53001]     = { 34001, gameforge.pet_system._010_say ,0},
                [53002]     = { 34002, gameforge.pet_system._020_say ,0},
                [53003]     = { 34003, gameforge.pet_system._040_say ,0},
                [53005]     = { 34004, gameforge.pet_system._050_say, 1},
                [53006]     = { 34009, gameforge.pet_system._050_say, 1},
                [53010]     = { 34008, gameforge.pet_system._060_say, 0},
                [53011]     = { 34007, gameforge.pet_system._070_say, 0},
                [53012]     = { 34005, gameforge.pet_system._080_say, 0},
                [53013]     = { 34006, gameforge.pet_system._090_say, 0},
                [53007]     = { 34010, gameforge.pet_system._100_say, 0},
                [53008]     = { 34011, gameforge.pet_system._110_say, 0},
                [53009]     = { 34012, gameforge.pet_system._120_say, 0},
                [38200]     = { 34006, gameforge.pet_system._090_say, 0},
                [38201]     = { 34006, gameforge.pet_system._090_say, 0},
                [53014]     = { 34013, gameforge.pet_system._130_say, 0},
                [53015]     = { 34014, gameforge.pet_system._140_say, 0},
                [53016]     = { 34015, gameforge.pet_system._150_say, 0},
                [53017]     = { 34016, gameforge.pet_system._160_say, 0},
            }

            itemVnum = tonumber(itemVnum)

            return pet_info_map[itemVnum]
        end
        function get_spawn_effect_file(idx)
            effect_table = {
                [0] = nil,
                [1] = "d:ymir workeffectetcappear_dienpc2_appear.mse",
            }
            return effect_table [idx]
        end
        when 38200.use or 38201.use or 53007.use or 53013.use or 53012.use or 53011.use or 53010.use or 53006.use  or 53005.use or 53002.use or 53001.use or 53003.use or 53008.use or 53009.use or 53014.use or 53015.use  or 53016.use or 53017.use begin
            local pet_info = pet_system.get_pet_info(item.vnum)
            if pc.getqf("pet_"..item.vnum.."_exp") == 0 then
                pc.setqf("pet_"..item.vnum.."_exp",1)
                pc.setqf("pet_"..item.vnum.."_level",1)
            end
            pc.setqf("pet_item",item.vnum)
            if null != pet_info then

                local mobVnum = pet_info[1]
                local petName = pet_info[2]
                local spawn_effect_file_name = pet_system.get_spawn_effect_file(pet_info[3])

                if true == pet.is_summon(mobVnum) then
                    if spawn_effect_file_name != nil then
                        pet.spawn_effect (mobVnum, spawn_effect_file_name)
                    end
                    pet.unsummon(mobVnum)
                else
                    if pet.count_summoned() < 1 then
                        pet.summon(mobVnum, petName, false)
                    else
                        syschat(gameforge.pet_system._030_chat)
                    end
                    if spawn_effect_file_name != nil then
                        pet.spawn_effect (mobVnum, spawn_effect_file_name)
                    end
                end
            end
        end
        when kill with pet.count_summoned() == 1 and not npc.is_pc() begin
            local exp_give = number(1,40)
            local finnaly_exp = (pc.get_level() * exp_give / 10) * 2
            pet_system.give_pet_exp(finnaly_exp)
        end
    end
end

 

If you want to change the max level just change this variable:

local MAX_LEVEL = 20

But if you change the max level you have to edit the exp table too.For example I set

local MAX_LEVEL = 25

so the exp table should looks like this:

local exp_table = {100,200,300,400,500,600,700,800,900,1000,1100,1200,1300,1400,1500,1600,1700,1800,1900,2000,2100,2200,2300,2400,2500}

for any bugs/problems feel free to ask...

  • Metin2 Dev 31
  • Smile Tear 1
  • Scream 1
  • Lmao 1
  • Good 14
  • muscle 1
  • Love 2
  • Love 36
Link to comment
Share on other sites

The affect.add_collect / affect.remove_collect are only the functions..Here is an example:

local bonuses = {
	[1] = {apply.MAX_HP,5000,60*60*24},
	[2] = {apply.MAX_HP,5500,60*60*24},
	[3] = {apply.MAX_HP,6000,60*60*24},
	[4] = {apply.MAX_HP,6500,60*60*24},
	[5] = {apply.MAX_HP,7000,60*60*24},
}
affect.add_collect(bonuses[pet_level][1],bonuses[pet_level][2],bonuses[pet_level][3])

When i'll have time i'll update the post to update the pet system with bonuses / level etc..

  • Love 1
Link to comment
Share on other sites

  • 2 weeks later...
  • 3 weeks later...
  • 4 weeks later...
  • 3 weeks later...

Hello @Denis! Your quest gives me no errors although it's not working (pets arent summoning). Any thoughts?

Btw, really good job. I would like to use it, if you know what can be wrong please message me.

 

Regards.

Everything's ok now. Once again thank you for the amazing work, it's really easy to edit which is why I find it very usefull.

Link to comment
Share on other sites

  • 4 months later...

Announcements



  • Similar Content

  • Activity

    1. 5

      Effect weapons

    2. 3

      Crystal Metinstone

    3. 3

      Feeding game source to LLM

    4. 113

      Ulthar SF V2 (TMP4 Base)

    5. 3

      Feeding game source to LLM

    6. 0

      Target Information System

    7. 3

      Feeding game source to LLM

    8. 2

      anti exp explanation pls

  • Recently Browsing

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.