Source question

G

Guest

Guest
Archived from groups: rec.games.roguelike.nethack (More info?)

How do I force a redraw of the hero such as when he polymorphs. I've
tried newsym(u.ux, u.uy) and display_self without results.


--
Mark Healey
marknews(at)healeyonline(dot)com
 
Archived from groups: rec.games.roguelike.nethack (More info?)

Mark Healey <die@spammer.die> writes:
> How do I force a redraw of the hero such as when he polymorphs. I've
> tried newsym(u.ux, u.uy) and display_self without results.

newsym(u.ux,u.uy) will cause the square you're on to be remapped (and
will handle the display_self() call if there needs to be one); if
changes you want to display aren't showing up when you do this, then
it's a problem with those changes, not the redraw code, and we'd need
more information.

--
: Dylan O'Donnell http://www.spod-central.org/~psmith/ :
: "Nothing matters very much, and few things matter at all." :
: -- A.J. Balfour :
 
Archived from groups: rec.games.roguelike.nethack (More info?)

On Wed, 06 Apr 2005 17:50:59 +0100, Dylan O'Donnell wrote:

> Mark Healey <die@spammer.die> writes:
>> How do I force a redraw of the hero such as when he polymorphs. I've
>> tried newsym(u.ux, u.uy) and display_self without results.
>
> newsym(u.ux,u.uy) will cause the square you're on to be remapped (and
> will handle the display_self() call if there needs to be one); if
> changes you want to display aren't showing up when you do this, then
> it's a problem with those changes, not the redraw code, and we'd need
> more information.

I want to have the hero change color under certain emergency conditions
(fainting, really low hitpoints, slimed, etc). It is relatively easy to do
in mapglyph. The problem is that it only seems to be called when the hero
moves.

--
Mark Healey
marknews(at)healeyonline(dot)com
 
Archived from groups: rec.games.roguelike.nethack (More info?)

Mark Healey <die@spammer.die> writes:
> On Wed, 06 Apr 2005 17:50:59 +0100, Dylan O'Donnell wrote:
>
> > Mark Healey <die@spammer.die> writes:
> >> How do I force a redraw of the hero such as when he polymorphs. I've
> >> tried newsym(u.ux, u.uy) and display_self without results.
> >
> > newsym(u.ux,u.uy) will cause the square you're on to be remapped (and
> > will handle the display_self() call if there needs to be one); if
> > changes you want to display aren't showing up when you do this, then
> > it's a problem with those changes, not the redraw code, and we'd need
> > more information.
>
> I want to have the hero change color under certain emergency conditions
> (fainting, really low hitpoints, slimed, etc). It is relatively easy to do
> in mapglyph. The problem is that it only seems to be called when the hero
> moves.

newsym() for the hero's location will only usually be called when the
hero moves, or turns invisible, or polymorphs, or otherwise does
something needing remapping. If you decide that a condition leads to a
need for remapping, then you'll need to add newsym() calls manually at
the point that condition begins to apply. (You could do so in the main
game loop, but that wouldn't be quite accurate.) And didn't we have
this conversation some months ago?

--
: Dylan O'Donnell http://www.spod-central.org/~psmith/ :
: "Nothing matters very much, and few things matter at all." :
: -- A.J. Balfour :
 
Archived from groups: rec.games.roguelike.nethack (More info?)

On Wed, 06 Apr 2005 20:26:36 +0100, Dylan O'Donnell wrote:

> Mark Healey <die@spammer.die> writes:
>> On Wed, 06 Apr 2005 17:50:59 +0100, Dylan O'Donnell wrote:
>>
>> > Mark Healey <die@spammer.die> writes:
>> >> How do I force a redraw of the hero such as when he polymorphs. I've
>> >> tried newsym(u.ux, u.uy) and display_self without results.
>> >
>> > newsym(u.ux,u.uy) will cause the square you're on to be remapped (and
>> > will handle the display_self() call if there needs to be one); if
>> > changes you want to display aren't showing up when you do this, then
>> > it's a problem with those changes, not the redraw code, and we'd need
>> > more information.
>>
>> I want to have the hero change color under certain emergency conditions
>> (fainting, really low hitpoints, slimed, etc). It is relatively easy to do
>> in mapglyph. The problem is that it only seems to be called when the hero
>> moves.
>
> newsym() for the hero's location will only usually be called when the
> hero moves, or turns invisible, or polymorphs, or otherwise does
> something needing remapping. If you decide that a condition leads to a
> need for remapping, then you'll need to add newsym() calls manually at
> the point that condition begins to apply. (You could do so in the main
> game loop, but that wouldn't be quite accurate.)

Here's what I got.

check_alarm(){
if((u.uhp/u.uhp)*4 < 4)/*this isn't the condition*/
/*I'm really going to use.*/
{
pline("should change color");
newsym(u.ux, u.uy);
}
}

which is called from the "once per turn" secition of moveloop()

I have some temporary experimental code in mapglyph() that changes the
color.

I see the pline message when appropriate but the color change only happens
if I've moved.

And didn't we have
> this conversation some months ago?

Maybe a year or more. I got busy with real life stuff. I started again
and got sick of dying because of things that are indicated in the
periphery.

--
Mark Healey
marknews(at)healeyonline(dot)com
 
Archived from groups: rec.games.roguelike.nethack (More info?)

Mark Healey <die@spammer.die> writes:
>
> Here's what I got.
>
> check_alarm(){
> if((u.uhp/u.uhp)*4 < 4)/*this isn't the condition*/
> /*I'm really going to use.*/

Well, I'd hope not, since it's always false. Four is never less than
four. Try using something more obvious to test with, such as whether
your HP are even or odd.

--
: Dylan O'Donnell http://www.spod-central.org/~psmith/ :
: "Nothing matters very much, and few things matter at all." :
: -- A.J. Balfour :
 
Archived from groups: rec.games.roguelike.nethack (More info?)

On Thu, 07 Apr 2005 08:27:55 +0100, Dylan O'Donnell wrote:

> Mark Healey <die@spammer.die> writes:
>>
>> Here's what I got.
>>
>> check_alarm(){
>> if((u.uhp/u.uhp)*4 < 4)/*this isn't the condition*/
>> /*I'm really going to use.*/
>
> Well, I'd hope not, since it's always false. Four is never less than
> four. Try using something more obvious to test with, such as whether
> your HP are even or odd.

Oops that was a typo. What I have is (u.uhp/u.uhpmax)*4

--
Mark Healey
marknews(at)healeyonline(dot)com
 
Archived from groups: rec.games.roguelike.nethack (More info?)

Mark Healey <die@spammer.die> writes:
> On Thu, 07 Apr 2005 08:27:55 +0100, Dylan O'Donnell wrote:
>
> > Mark Healey <die@spammer.die> writes:
> >>
> >> Here's what I got.
> >>
> >> check_alarm(){
> >> if((u.uhp/u.uhp)*4 < 4)/*this isn't the condition*/
> >> /*I'm really going to use.*/
> >
> > Well, I'd hope not, since it's always false. Four is never less than
> > four. Try using something more obvious to test with, such as whether
> > your HP are even or odd.
>
> Oops that was a typo. What I have is (u.uhp/u.uhpmax)*4

Which, given the nature of integer arithmetic, is always going to
equal 0 unless you're at max HP, when it'll be 4. You probably want
'if (u.uhp*4 < u.uhpmax)' instead.

--
: Dylan O'Donnell http://www.spod-central.org/~psmith/ :
: "Peek-a-boo, I can't see you, everything must be grand; :
: Boo-ka-pee, you can't see me, as long as I've got me head in t'sand..." :
: -- Michael Flanders, "The Ostrich" :