• 0
Cripplez

solved [Source] how to do "Can't use mount/horse in dungeon"

Question

Hi, I'd like to add in source that you can't use the mount and horse while you are in a dungeon

				if pc.in_dungeon() then
					syschat("You can't use this mount while you are in a Dungeon.")
					return
				end

I used this in my quest of ride.lua, but i would prefer add this in the server source and add that you can't summon/ride the horse in dungeon and if you are riding a mount/horse you unmount it.

Anyone can help me to do this? Thank you again!

Share this post


Link to post
Share on other sites

14 answers to this question

  • 1

Like this you won't ride in any map with index >=10000 it's not safe.

Do the check with the dungeon index.

Share this post


Link to post
Share on other sites
  • 0
On 10/5/2019 at 4:22 PM, WeedHex said:

Like this you won't ride in any map with index >=10000 it's not safe.

Do the check with the dungeon index.

Only the dungeon should have >= 10000, so I don't think this could be a problem for me, it is fine if every dungeon has mount blocked.

I'm trying to make that when you enter a dungeon you unmount the horse or mount, but i can't make it work :(

This is working only for horse, if you are riding a mount it doesn't work

 

		when login with dungeon_test.beran_test_index(pc.get_map_index()) begin
			pc.set_warp_location (99, 1234, 5678)
			
			if pc.get_level() < 90 then
				warp_to_village()
			end
			
			timer ( "time_test_dungeon", 20 * 60 )
			pc.unmount()
			horse.unsummon()
			d.setf("mobs_left", d.count_monster())
		end

 

EDIT:
I resolved the mount problem adding

timer ( "time_unmount", 6 ) above the other timer

        when time_unmount.timer with dungeon_test.beran_test_index(pc.get_map_index()) begin
                    pc.unmount()
        end

But i don't really like this solution..., i was wondering if there is something better

Share this post


Link to post
Share on other sites
  • 0

Not tested, but you can try to do something like:

  • Srcs/Server/game/src/questlua_horse.cpp
Spoiler

// Search in horse_summon function:
		bool bFromFar = lua_isboolean(L, 1) ? lua_toboolean(L, 1) : false;
// Add before:
#ifdef ENABLE_BLOCK_RIDING_IN_DUNGEON
		if (ch && ch->GetDungeon())
			return 0;
#endif
  • Srcs/Server/game/src/questlua_pc.cpp
Spoiler

// Search in pc_mount_bonus and pc_mount function:
		LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
// Add after:
#ifdef ENABLE_BLOCK_RIDING_IN_DUNGEON
		if (ch && ch->GetDungeon())
			return 0;
#endif
  • Srcs/Server/game/src/input_login.cpp
Spoiler

// Search in CInputLogin::Entergame(LPDESC d, const char * data) for:
	if (ch->GetHorseLevel() > 0)
	{
		DWORD pid = ch->GetPlayerID();

		if (pid != 0 && CHorseNameManager::instance().GetHorseName(pid) == NULL)
			db_clientdesc->DBPacket(HEADER_GD_REQ_HORSE_NAME, 0, &pid, sizeof(DWORD));
	}
// Add after:
#ifdef ENABLE_BLOCK_RIDING_IN_DUNGEON
		if (ch && ch->GetDungeon())
		{
			if (ch->IsHorseRiding())
			{
				ch->StopRiding();
				ch->HorseSummon(false);
			}

			if (ch->FindAffect(AFFECT_MOUNT))
			{
				ch->RemoveAffect(AFFECT_MOUNT);
				ch->RemoveAffect(AFFECT_MOUNT_BONUS);
			}
		}
#endif
  • Srcs/Server/game/service.h
Spoiler

#define ENABLE_BLOCK_RIDING_IN_DUNGEON

Share this post


Link to post
Share on other sites
  • 0
11 hours ago, VegaS™ said:

Not tested, but you can try to do something like:

  • Srcs/Server/game/src/questlua_horse.cpp
  Hide contents


// Search in horse_summon function:
		bool bFromFar = lua_isboolean(L, 1) ? lua_toboolean(L, 1) : false;
// Add before:
#ifdef ENABLE_BLOCK_RIDING_IN_DUNGEON
		if (ch && ch->GetDungeon() && ch->IsHorseRiding())
		{
			ch->StopRiding();
			ch->HorseSummon(false);
			return 0;
		}
#endif
  • Srcs/Server/game/src/questlua_pc.cpp
  Hide contents


// Search in pc_mount_bonus function:
		LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
// Add after:
#ifdef ENABLE_BLOCK_RIDING_IN_DUNGEON
		if (ch && ch->GetDungeon() && ch->FindAffect(AFFECT_MOUNT))
		{
			ch->RemoveAffect(AFFECT_MOUNT);
			ch->RemoveAffect(AFFECT_MOUNT_BONUS);
			return 0;
		}
#endif
  • Srcs/Server/game/src/input_login.cpp
  Hide contents


// Search in CInputLogin::Entergame(LPDESC d, const char * data) for:
	if (ch->GetHorseLevel() > 0)
	{
		DWORD pid = ch->GetPlayerID();

		if (pid != 0 && CHorseNameManager::instance().GetHorseName(pid) == NULL)
			db_clientdesc->DBPacket(HEADER_GD_REQ_HORSE_NAME, 0, &pid, sizeof(DWORD));
	}
// Add after:
#ifdef ENABLE_BLOCK_RIDING_IN_DUNGEON
		if (ch && ch->GetDungeon())
		{
			if (ch->IsHorseRiding())
			{
				ch->StopRiding();
				ch->HorseSummon(false);
			}

			if (ch->FindAffect(AFFECT_MOUNT))
			{
				ch->RemoveAffect(AFFECT_MOUNT);
				ch->RemoveAffect(AFFECT_MOUNT_BONUS);
			}
		}
#endif
  • Srcs/Server/game/service.h
  Hide contents


#define ENABLE_BLOCK_RIDING_IN_DUNGEON

Thank you, it is working for horse, but not for the mount :(

Maybe is because first the game read if i'm riding and make me StopRiding, but if I login in a map while i was riding a mount, the game doesn't immediatly know I'm riding and update my character riding 1 second later? Sometimes when i login with a mount i see my character standing and 1 second later i am riding again my mount

I'm not sure if i did this part as you write in your message, maybe the problem is here?

Spoiler

	if (ch->GetHorseLevel() > 0)
	{
		DWORD pid = ch->GetPlayerID();

		if (pid != 0 && CHorseNameManager::instance().GetHorseName(pid) == NULL)
			db_clientdesc->DBPacket(HEADER_GD_REQ_HORSE_NAME, 0, &pid, sizeof(DWORD));
		//@fix horse_level update at login
		ch->SetHorseLevel(ch->GetHorseLevel());
		ch->SkillLevelPacket();
#ifdef ENABLE_BLOCK_RIDING_IN_DUNGEON
		if (ch && ch->GetDungeon())
		{
			if (ch->IsHorseRiding())
			{
				ch->StopRiding();
				ch->HorseSummon(false);
			}

			if (ch->FindAffect(AFFECT_MOUNT))
			{
				ch->RemoveAffect(AFFECT_MOUNT);
				ch->RemoveAffect(AFFECT_MOUNT_BONUS);
			}
		}
#endif
	}

 

 

Share this post


Link to post
Share on other sites
  • 0
2 hours ago, Cripplez said:

I'm not sure if i did this part as you write in your message, maybe the problem is here?

  Hide contents


	if (ch->GetHorseLevel() > 0)
	{
		DWORD pid = ch->GetPlayerID();

		if (pid != 0 && CHorseNameManager::instance().GetHorseName(pid) == NULL)
			db_clientdesc->DBPacket(HEADER_GD_REQ_HORSE_NAME, 0, &pid, sizeof(DWORD));
		//@fix horse_level update at login
		ch->SetHorseLevel(ch->GetHorseLevel());
		ch->SkillLevelPacket();
#ifdef ENABLE_BLOCK_RIDING_IN_DUNGEON
		if (ch && ch->GetDungeon())
		{
			if (ch->IsHorseRiding())
			{
				ch->StopRiding();
				ch->HorseSummon(false);
			}

			if (ch->FindAffect(AFFECT_MOUNT))
			{
				ch->RemoveAffect(AFFECT_MOUNT);
				ch->RemoveAffect(AFFECT_MOUNT_BONUS);
			}
		}
#endif
	}

 

You added it wrong, not inside of GetHorseLevel > 0, outside of condition. 

Spoiler

	if (ch->GetHorseLevel() > 0)
	{
		DWORD pid = ch->GetPlayerID();

		if (pid != 0 && CHorseNameManager::instance().GetHorseName(pid) == NULL)
			db_clientdesc->DBPacket(HEADER_GD_REQ_HORSE_NAME, 0, &pid, sizeof(DWORD));
		//@fix horse_level update at login
		ch->SetHorseLevel(ch->GetHorseLevel());
		ch->SkillLevelPacket();
	}
#ifdef ENABLE_BLOCK_RIDING_IN_DUNGEON
	if (ch && ch->GetDungeon())
	{
		if (ch->IsHorseRiding())
		{
			ch->StopRiding();
			ch->HorseSummon(false);
		}

		if (ch->FindAffect(AFFECT_MOUNT))
		{
			ch->RemoveAffect(AFFECT_MOUNT);
			ch->RemoveAffect(AFFECT_MOUNT_BONUS);
		}
	}
#endif

 

 

Share this post


Link to post
Share on other sites
  • 0
5 hours ago, VegaS™ said:

You added it wrong, not inside of GetHorseLevel > 0, outside of condition. 

  Reveal hidden contents


	if (ch->GetHorseLevel() > 0)
	{
		DWORD pid = ch->GetPlayerID();

		if (pid != 0 && CHorseNameManager::instance().GetHorseName(pid) == NULL)
			db_clientdesc->DBPacket(HEADER_GD_REQ_HORSE_NAME, 0, &pid, sizeof(DWORD));
		//@fix horse_level update at login
		ch->SetHorseLevel(ch->GetHorseLevel());
		ch->SkillLevelPacket();
	}
#ifdef ENABLE_BLOCK_RIDING_IN_DUNGEON
	if (ch && ch->GetDungeon())
	{
		if (ch->IsHorseRiding())
		{
			ch->StopRiding();
			ch->HorseSummon(false);
		}

		if (ch->FindAffect(AFFECT_MOUNT))
		{
			ch->RemoveAffect(AFFECT_MOUNT);
			ch->RemoveAffect(AFFECT_MOUNT_BONUS);
		}
	}
#endif

 

 

Okay

I tried like this but when i'm riding a mount it still doesn't make me unmount it :( with the horse it is perfect

Share this post


Link to post
Share on other sites
  • 0
1 hour ago, Cripplez said:

I tried like this but when i'm riding a mount it still doesn't make me unmount it :( with the horse it is perfect

Then your problem is that you've costume mount slot, not the default mount, replace the code what i gave you with:

#ifdef ENABLE_BLOCK_RIDING_IN_DUNGEON
	if (ch && ch->GetDungeon())
	{
		const LPITEM pMount = ch->GetWear(WEAR_COSTUME_MOUNT);
		if (pMount && pMount->IsEquipped())
			ch->UnequipItem(pMount);
	
		if (ch->IsHorseRiding())
		{
			ch->StopRiding();
			ch->HorseSummon(false);
		}
	}
#endif

Be careful to have on all of your vnums type: ITEM_COSTUME < 28, sub type: COSTUME_MOUNT < 2

Share this post


Link to post
Share on other sites
  • 0

Was better with timer solution, mount begin load after other things so checking the login is useless cuz there isn't still the mount :)

  • Sad 1

Share this post


Link to post
Share on other sites
  • 0
2 hours ago, WeedHex said:

Was better with timer solution, mount begin load after other things so checking the login is useless cuz there isn't still mount at login :)

No, we don't need a timer for this, you're right that you can't do this inside of login because the POINT_MOUNT is seted after, so, this method is for all types of mounts/horses: 

  • Srcs/Server/game/src/input_login.cpp
Spoiler

// Search in CInputLogin::Entergame(LPDESC d, const char * data) for:
	if (ch->GetHorseLevel() > 0)
	{
		[...]
	}
// Add after:
#ifdef ENABLE_BLOCK_RIDING_IN_DUNGEON
	if (ch->IsHorseRiding())
	{
		ch->StopRiding();
		ch->HorseSummon(false, true);
	}
#endif
  • Srcs/Server/game/src/char.cpp
Spoiler

// Search for:
void CHARACTER::MountVnum(DWORD vnum)
{
// Add after:
	#ifdef ENABLE_BLOCK_RIDING_IN_DUNGEON
	if (GetDungeon())
	{
		if (FindAffect(AFFECT_MOUNT, POINT_MOUNT))
		{
			RemoveAffect(AFFECT_MOUNT);
			RemoveAffect(AFFECT_MOUNT_BONUS);

			m_dwMountVnum = 0;
			m_dwMountTime = 0;
			return;
		}
	}
	#endif

Not tested.

  • Like 1

Share this post


Link to post
Share on other sites
  • 0

VegaS helped me on AnyDesk and he resolved the problem! Now everything works perfect, he even added a list of the mount that can be used in dungeon if i want.

Thank you again! :D

Share this post


Link to post
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

  • Recently Browsing   0 members

    No registered users viewing this page.