Commit c108115 breaks teleport other

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • PowerWyrm
    Prophet
    • Apr 2008
    • 2986

    Commit c108115 breaks teleport other

    Before this commit, the new location of the monster was put in project_m_x and project_m_y, but since these have been removed, the code now uses the old location.
    PWMAngband variant maintainer - check https://github.com/draconisPW/PWMAngband (or http://www.mangband.org/forum/viewforum.php?f=9) to learn more about this new variant!
  • Nick
    Vanilla maintainer
    • Apr 2007
    • 9637

    #2
    Really? I can't see that this is the case from the code, and teleport other till seems to be working for me.
    One for the Dark Lord on his dark throne
    In the Land of Mordor where the Shadows lie.

    Comment

    • PowerWyrm
      Prophet
      • Apr 2008
      • 2986

      #3
      Old code:

      Code:
      	/* Check for NULL, since polymorph can occasionally return NULL. */
      	if (mon != NULL) {
      		/* Update the monster */
      		if (!mon_died) update_mon(mon, cave, FALSE);
      
      		[B]/* Hack -- get new location in case of teleport */ <-- changes x and y
      		y = mon->fy;
      		x = mon->fx;[/B]
      
      		/* Redraw the monster grid */
      		square_light_spot(cave, y, x);
      
      		/* Update monster recall window */
      		if (player->upkeep->monster_race == mon->race) {
      			/* Window stuff */
      			player->upkeep->redraw |= (PR_MONSTER);
      		}
      	}
      
      	/* Track it */
      	project_m_n++;
      	project_m_x = x;
      	project_m_y = y;
      New code:

      Code:
      	/* Track it */
      	*did_hit = true;
      The new code doesn't use the new location in case of teleport other. Then in project():

      Code:
      	/* Check monsters */
      	if (flg & (PROJECT_KILL)) {
      		bool was_obvious = false;
      		bool did_hit = false;
      		int num_hit = 0;
      		int last_hit_x = 0;
      		int last_hit_y = 0;
      
      		/* Scan for monsters */
      		for (i = 0; i < num_grids; i++) {
      			/* Get the grid location */
      			y = blast_grid[i].y;
      			x = blast_grid[i].x;
      			
      			/* Check this monster hasn't been processed already */
      			if (!square_isproject(cave, y, x)) continue;
      
      			/* Affect the monster in the grid */
      			project_m(who, distance_to_grid[i], y, x,
      			          dam_at_dist[distance_to_grid[i]], typ, flg,
      			          &did_hit, &was_obvious);
      			if (was_obvious)
      				notice = TRUE;
      			if (did_hit) {
      				num_hit++;
      				[B]last_hit_x = x; <-- old coordinates
      				last_hit_y = y;[/B]
      			}
      		}
      
      		/* Player affected one monster (without "jumping") */
      		if ((who < 0) && (num_hit == 1) && !(flg & (PROJECT_JUMP))) {
      			/* Location */
      			[B]x = last_hit_x; <-- old coordinates
      			y = last_hit_y;[/B]
      
      			[B]/* Track if possible */ <-- does nothing in case of teleport, since the coordinates have changed
      			if (cave->squares[y][x].mon > 0) {
      				struct monster *mon = square_monster(cave, y, x);
      
      				/* Recall and track */
      				if (mflag_has(mon->mflag, MFLAG_VISIBLE)) {
      					monster_race_track(player->upkeep, mon->race);
      					health_track(player->upkeep, mon);
      				}
      			}[/B]
      		}
      	}
      PWMAngband variant maintainer - check https://github.com/draconisPW/PWMAngband (or http://www.mangband.org/forum/viewforum.php?f=9) to learn more about this new variant!

      Comment

      • Nick
        Vanilla maintainer
        • Apr 2007
        • 9637

        #4
        Oh, right, it's the teleport effects of things like Nexus - I was just looking at the Teleport Other spell.
        One for the Dark Lord on his dark throne
        In the Land of Mordor where the Shadows lie.

        Comment

        Working...
        😀
        😂
        🥰
        😘
        🤢
        😎
        😞
        😡
        👍
        👎