Crossfire Mailing List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Help with invisibility




  Hello all.

 I'm trying to implement partial visibility for certain objects.
Something like that of stalkers.

  However, I want to do it in such a way, that the % of the time
that the object is visible depends on some parameter like its level,
sp, or hp.

  I thought I could do this by using the following code:
  It's embedded in the move_routine for this object ( which is called
by time.c.)  This code gets executed every tick.  (The speed of this object
is 1.0.)

    if(!RANDOM()%MIN(1,(op->level/2)))
        {
        op->invisible=0;  /* means it's visible */
        op->speed_left-=1;
        }
    else
	op->invisible=1; /* means it's invisible */

    update_object(op);  /* does this redraw the object? */


  the if statement boils down to "there's a 1 in op->level/2 chance of
the object being visible this round."

  However, the effect of this code is that the object is invisible ALL
the time.

  To my understanding, when I set the invisibility to 0, and then update_object,
the object should flash into view briefly, and then disappear the next
turn (unless I roll a zero again).

  I think I have a basic misunderstanding of how things are drawn on the
screen.  Can someone please straighten me out, and tell me how to make
what I want happen?

Thanks in advance,

Peter Mardahl
(One of the group of people at Soda who are hacking the server code.)

P.S., using the anim -- mina of the archetypes won't do at all,
because of the variable length of the visiblity time.