Jump to content

Quest Evento PVM


kaiquegames069
 Share

Recommended Posts

Boas pessoal,

tenho aqui essa quest de evento pvm que finaliza com um timer, porém pode ser que o timer é finalizado e ainda pode haver mobs a matar no mapa.

Seria possível invés de finalizar com timer, não seria possível finalizar ao verificar se ainda existe algum monstro no mapa?

Caso não exista o evento finalize?

Fica aqui a quest!

https://pastebin.com/6aXFxKaN

Link to comment
Share on other sites

Criei esta função a ver se resolve o teu problema.

Ela conta todos os monstros que existem no mapa através do índex.

 

questlua_pc.cpp:

	int pc_count_monster(lua_State * L)
	{
		CQuestManager& q = CQuestManager::instance();
		LPCHARACTER MapIndex = q.GetCurrentCharacterPtr()->GetMapIndex();

		if (MapIndex)
			lua_pushnumber(L, MapIndex->CountMonster());
		else
		{
			sys_err("something is wrong.");
			lua_pushnumber(L, LONG_MAX);
		}

		return 1;
	}


{ "count_monster",		pc_count_monster		},


 

Exemplo de quest:

quest contagem
	state start begin
		when login with pc.get_map_index() == 1 begin -- Se fizerem o login no mapa cujo o index é 1:		
			if pc.counter_monster() <= 0 then -- Se a contagem dos monstros for inferior ou igual a 0:
  				notice("Todos os monstros foram mortos.")
  			end
		end
	end
end
  				

 

 

OBS: Nada testado.

Link to comment
Share on other sites

  • 1 month later...

 Tá ai a nova função counter_monster_in_map(mapindex) ......

Vá em questlua_global.cpp e adicione isso acima da função:  int _regen_in_map( lua_State * L )

int _counter_monster_in_map(lua_State * L)
    {
        DWORD iMapIndex = (DWORD)lua_tonumber(L, 1);
        LPSECTREE_MAP pMap = SECTREE_MANAGER::instance().GetMap(iMapIndex);
	        if (pMap != NULL)
        {
            lua_pushnumber(L, SECTREE_MANAGER::instance().GetMonsterCountInMap(iMapIndex));
            return 1;
        }
	        return 0;
    }

Depois vá em void RegisterGlobalFunctionTable(lua_State* L) e adicione abaixo da definição :  "get_special_item_group",  _get_special_item_group },

{    "counter_monster_in_map",        _counter_monster_in_map            },

 

Mini quest com a nova função counter_monster_in_map(mapindex):

quest counter_monster begin
    state start begin
    
    when 20095.chat."Verificar o counter_monster" with pc.is_gm() begin
        say("Verificar se existem monstros?")
        say("")
        local s = select("Sim","Não")
        if s == 2 then
            return
        end
        notice(string.format("Total de Mobs: %d.", counter_monster_in_map(200)))
    end
    
    when 20095.chat."Evento counter_monster" with pc.is_gm() begin
        say("Iniciar Evento PVM?")
        say("Status: "..game.get_event_flag("event_pvm"))
        say("")
        local s = select("Iniciar","Finalizar", "Cancelar")
        
        if s == 2 then
            game.set_event_flag("event_pvm", 0)
            clear_server_timer("check_monster")
            notice_all("O Evento PVM foi finalizado!")
            return
        end
        
        if s == 3 then
            return
        end
	        game.set_event_flag("event_pvm", 1)
        notice_all("O Evento PVM foi iniciado!")
        mob.spawn_group(104, pc.get_local_x(), pc.get_local_y(), 1, 1, 1)
        mob.spawn(1093, pc.get_local_x(), pc.get_local_y(), 1)
        server_loop_timer("check_monster", 10)
    end
    
    when kill with not npc.is_pc() begin
        notice(string.format("O jogador %s matou: %s.", pc.get_name(), mob_name(npc.get_race())))    
    end
    
    when check_monster.server_timer begin
        if game.get_event_flag("event_pvm") == 1 then
            if counter_monster_in_map(200) == 0 then
                game.set_event_flag("event_pvm", 0)
                clear_server_timer("check_monster")
                notice_all("O Evento PVM foi finalizado!")
            end
        end
    end
    
    end
end

Isso é tudo boa sorte, qualquer dúvida é só comentar  .....

Edited by juniorsilva
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...