![]() |
#1 |
Prophet
Join Date: Apr 2008
Posts: 2,831
![]() |
[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; } 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... }
__________________
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! |
![]() |
![]() |
![]() |
#2 |
Veteran
Join Date: Jun 2007
Posts: 1,372
![]() |
Why is it that you don't have commit/push rights to the repo?
|
![]() |
![]() |
![]() |
#3 |
Veteran
Join Date: Apr 2007
Posts: 1,947
Donated: $40
![]() |
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- |
![]() |
![]() |
![]() |
#4 |
Prophet
Join Date: Apr 2008
Posts: 2,831
![]() |
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!"); ... } } ![]() 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! |
![]() |
![]() |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Display Modes | |
|
|
![]() |
||||
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 |