Angband.oook.cz
Angband.oook.cz
AboutVariantsLadderForumCompetitionComicScreenshotsFunniesLinks

Go Back   Angband Forums > Angband > Vanilla

Reply
 
Thread Tools Display Modes
Old May 23, 2013, 11:09   #1
PowerWyrm
Prophet
 
PowerWyrm's Avatar
 
Join Date: Apr 2008
Posts: 2,672
PowerWyrm is on a distinguished road
[3.5-dev] Monster opening/bashing refactoring

Monster opening:

Code:
if (cave_iscloseddoor(cave, ny, nx) || cave_issecretdoor(cave, ny, nx))
{
    cave_open_door(c, ny, nx);
}
else if (cave_islockeddoor(cave, ny, nx))
{
    ...

    /* Handle viewable doors */
    if (player_has_los_bold(ny, nx))
         do_view = TRUE;
}
First problem: cave_iscloseddoor() defined in cave.c includes locked doors, so the "else" part is dead code; I think cave_iscloseddoor() should only define "closed non locked" doors so monsters don't open locked doors without a lock power check (I think there are similar problems elsewhere in the code where the wrong check is made).

Second problem: refreshing display (do_view) should be called when the door is opened, not when a monster only "fiddles" with a lock; so the corresponding code should be put in the "if" part, not the "else" part.


Monster bashing:

Code:
else if (rf_has(m_ptr->race->flags, RF_BASH_DOOR))
{
    bash door...
}
This means that monsters having both OPEN_DOOR and BASH_DOOR will always try to open a door instead of bashing it, making BASH_DOOR obsolete. Before the refactoring, monsters failing to unlock a door would try to bash it.
__________________
PWMAngband variant maintainer - check http://powerwyrm.monsite-orange.fr (or http://www.mangband.org/forum/viewforum.php?f=9) to learn more about this new variant!
PowerWyrm is offline   Reply With Quote
Old May 24, 2013, 17:35   #2
AnonymousHero
Veteran
 
AnonymousHero's Avatar
 
Join Date: Jun 2007
Posts: 1,367
AnonymousHero is on a distinguished road
Why is it that you don't have commit/push rights to the repo?
AnonymousHero is offline   Reply With Quote
Old May 25, 2013, 03:27   #3
takkaria
Veteran
 
takkaria's Avatar
 
Join Date: Apr 2007
Posts: 1,936
Donated: $40
takkaria is on a distinguished road
Quote:
Originally Posted by AnonymousHero View Post
Why is it that you don't have commit/push rights to the repo?
I have to admit, PowerWyrm, I'm consistently impressed with a) your tenacity and b) your eye for detail when it comes to bughunting. Thanks a lot for all the time you've spent reporting issues you've found - you catch so many of them that we miss!
__________________
takkaria whispers something about options. -more-
takkaria is offline   Reply With Quote
Old June 27, 2013, 13:19   #4
PowerWyrm
Prophet
 
PowerWyrm's Avatar
 
Join Date: Apr 2008
Posts: 2,672
PowerWyrm is on a distinguished road
Something is slamming against my head!!!!!!

Code:
/* Stuck doors -- attempt to bash them down if allowed */
else if (rf_has(m_ptr->race->flags, RF_BASH_DOOR)) {
	int k = cave_door_power(cave, ny, nx);

	/* Print a message */
	if (m_ptr->ml)
		msg("%s slams against the door.", m_name);
	else
		msg("Something slams against a door.");

	/* Attempt to bash */
	if (randint0(m_ptr->hp / 10) > k && one_in_(2)) {
		cave_smash_door(c, ny, nx);
		msg("You hear a door burst open!");

		...
	}
}
This message that repeats indefinitely every time something tries to bash a door on a level is extremely annoying...

Also for anything that has less than 20 hps (ants and such), bashing is not possible, so the poor thing will bump forever the door.

To fix this, and to simplify the code a lot (not mentioning the bugs from the previous post), it would be nice to process opening and bashing the same way:
- process closed and secret doors: choose between bashing and opening depending on the OPEN_DOOR and BASH_DOOR flags (50/50 chance if both are present)
- process locked doors: compute door power, try to unlock it, print a message if success and reduce the door power by one

Code should look like this:

Code:
/* Handle doors and secret doors */
else if (cave_iscloseddoor(cave, ny, nx) || cave_issecretdoor(cave, ny, nx))
{
	/* Take a turn */
	do_turn = TRUE;

	/* Learn about door abilities */
	if (m_ptr->ml) {
		rf_on(l_ptr->flags, RF_OPEN_DOOR);
		rf_on(l_ptr->flags, RF_BASH_DOOR);
	}

	/* Creature can open or bash doors */
	if (rf_has(m_ptr->race->flags, RF_OPEN_DOOR) || rf_has(m_ptr->race->flags, RF_BASH_DOOR))
	{
		bool may_bash = ((rf_has(m_ptr->race->flags, RF_BASH_DOOR) && one_in_(2))? TRUE: FALSE);

		/* Stuck door -- try to unlock it */
		if (cave_islockeddoor(cave, ny, nx))
		{
			int k = cave_door_power(cave, ny, nx);

			if (randint0(m_ptr->hp / 10) > k)
			{
				/* Print a message */
				if (m_ptr->ml)
				{
					if (may_bash)
						msg("%s slams against the door.", m_name);
					else
						msg("%s fiddles with the lock.", m_name);
				}
				else
				{
					if (may_bash)
						msg("Something slams against a door.");
					else
						msg("Something fiddles with a lock.");
				}

				/* Reduce the power of the door by one */
				cave_set_feat(c, ny, nx, cave->feat[ny][nx] - 1);
			}
		}

		/* Closed or secret door -- open or bash if allowed */
		else
		{
			if (may_bash)
			{
				cave_smash_door(c, ny, nx);
				msg("You hear a door burst open!");

				disturb(p_ptr, 0, 0);

				/* Fall into doorway */
				do_move = TRUE;
			}
			else
				cave_open_door(c, ny, nx);

			/* Handle viewable doors */
			if (player_has_los_bold(ny, nx))
				do_view = TRUE;
		}
	}
}
__________________
PWMAngband variant maintainer - check http://powerwyrm.monsite-orange.fr (or http://www.mangband.org/forum/viewforum.php?f=9) to learn more about this new variant!
PowerWyrm is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Angband 3.5-dev Magnate Vanilla 70 July 2, 2012 17:47
V 3.4 dev new version takkaria Vanilla 1 March 23, 2012 13:19
Compling with Dev-C++ PaulBlay Development 6 December 15, 2009 23:32
Merge in 3.0.9e changes with dev. Irashtar Vanilla 22 September 18, 2008 20:01
Opening a savefile in Windows Zero Vanilla 13 June 28, 2008 06:55


All times are GMT +1. The time now is 23:43.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.