[an error occurred while processing this directive]
[<a href="index.shtml">Package Index</a></code> | <a href="index_std.shtml">Mudlib Index</a></code> | <a href="index_eff.shtml">Effect Index</a></code>]<br><h2>File /std/basic/effects.c</h2>
Basic effects module.
Extracted from Ember's living effects code by Deutha.<p><b>See also:</b><br>help::effects
.c<h2>Includes</h2>
This class includes the following files <a href="include.effect.h.shtml">/include/effect.h</a><h2>Class Index</h2>
<ul><li><a href="#class_effect_data">effect_data</a>
<br/>
This class stores all the data for the effects inheritable.
<li><a href="#class_effect_event">effect_event</a>
<li><a href="#class_effect_shadow">effect_shadow</a>
</ul><h2>Method index</h2>
<dl><ul>
<li><a href="#add_effect">add_effect</a>(string, mixed)<br/>
This method adds an effect onto the object.
<li><a href="#affected_object">affected_object</a>()<br/>
This method returns the outer most shadow on this object.
<li><a href="#all_expected_ees">all_expected_ees</a>(string, int *)<br/>
Returns the time until the next event that will call func_name.
<li><a href="#arg_of">arg_of</a>(int)<br/>
This method returns the current argument associated with the
given effect number.
<li><a href="#delete_effect">delete_effect</a>(int)<br/>
This removes an effect from the player.
<li><a href="#eff_of">eff_of</a>(int)<br/>
This method returns the effect object for the given effect number.
<li><a href="#effect_freeze">effect_freeze</a>()<br/>
This method freezes all the current effects so that they do
not continue to be processed.
<li><a href="#effect_unfreeze">effect_unfreeze</a>()<br/>
This restarts the internal call_out.
<li><a href="#effects_desting">effects_desting</a>()<br/>
Called when an object is dested.
<li><a href="#effects_matching">effects_matching</a>(string)<br/>
This method returns an array of effects matching the
classification.
<li><a href="#effects_quiting">effects_quiting</a>()<br/>
Called when a player actually quits.
<li><a href="#effects_thru_death">effects_thru_death</a>()<br/>
This method removes all the effects as we die.
<li><a href="#enum_to_sid">enum_to_sid</a>(int)<br/>
This method turns an effect number into an effect id.
<li><a href="#expected_ee">expected_ee</a>(string, int)<br/>
Returns the time until the next event that will call func_name.
<li><a href="#expected_tt">expected_tt</a>(int, int)<br/>
This method returns the time until any EE_REMOVE effect
is expected to occur.
<li><a href="#query_current_effect_enum">query_current_effect_enum</a>()<br/>
This method returns the current enum.
<li><a href="#query_logging_effects">query_logging_effects</a>()<li><a href="#reset_effects">reset_effects</a>()<br/>
This method removes all the current effects off the object
and sets everything back to the initial state.
<li><a href="#set_arg_of">set_arg_of</a>(int, mixed)<br/>
This sets the argument of the given effect to a new value.
<li><a href="#set_eeq">set_eeq</a>(mixed *)<br/>
This method is used to force the effects setup in the object to be a
specified value.
<li><a href="#set_effs">set_effs</a>(mixed *)<br/>
This method is used to force the effects setup in the object to be a
specified value.
<li><a href="#set_logging_effects">set_logging_effects</a>(int)<li><a href="#sid_to_enum">sid_to_enum</a>(int)<br/>
This method returns the effect number for the given effect id.
<li><a href="#submit_ee">submit_ee</a>(mixed, mixed, int, mixed)<br/>
This submits an effect event schedule.
<li><a href="#submit_ee2">submit_ee2</a>(int, mixed, mixed, int, mixed)<br/>
This submits an effect event for a specific effect.
</ul><h2>Public Functions</h2>
These are functions that everyone can access.<p>
.<ul><a name="add_effect">
add_effect</a><pre>
void add_effect(string eff,
                mixed arg)
</pre></br>
This method adds an effect onto the object.  RThe arg is passed
directly onto the function 'begining' on the effect
object.  If the result is non-zero then the return
value of the begining function is used instead of the
arg and stored away.  If an effect of the same
type is already on the object then the function 'merge_effects'
will be called.  If it returns a non-zero value then the arg for the
initial effect will be updated to the new value, otherwise both effects
will run
with different arguments.
<br/><ul>
<li><b>See also:</b>
<br/>help::effects.c and <a href="#submit_ee">submit_ee()
</a></dl>

<ul><a name="affected_object">
affected_object</a><pre>
object affected_object()
</pre></br>
This method returns the outer most shadow on this object.  This is useful
for making sure functions get calklked right through the shadow
list.  If there are no objects being shadows, this_object()
is returned.
<br/><ul>
<li><b>Returns:</b>
<br/>the outermost shadow object

</dl>

<ul><a name="all_expected_ees">
all_expected_ees</a><pre>
varargs int * all_expected_ees(string func_name,
                               int * enums)
</pre></br>
Returns the time until the next event that will call func_name.
If enums is undefined, the event is searched for in this effect,
otherwise the event is searched for in the specified effect(s).

This returns the a list of the time in seconds until the function
will be called in the effect(s) specified.  NB: this is not the
time *between* calls, but the time from Right Now until each call.
If no outstanding calls to the function are found, an empty array
is returned.

<br/><ul>
<li><b>Parameters:</b>
<br/>func_name - - the name of the function the ee will call.
<br/>enum - - the enums of the effect to check in.
<li><b>Returns:</b>
<br/>time - array containing the seconds until each outstanding
call to func_name for the effect(s) specified.
<li><b>See also:</b>
<br/><a href="#expected_ee">expected_ee()</a>, <a href="#expected_tt">expected_tt()</a> and <a href="#submit_ee">submit_ee()
</a></dl>

<ul><a name="arg_of">
arg_of</a><pre>
mixed arg_of(int enum)
</pre></br>
This method returns the current argument associated with the
given effect number.
<br/><ul>
<li><b>Parameters:</b>
<br/>enum - the effect number
<li><b>Returns:</b>
<br/>the argument associated with the effect
<li><b>See also:</b>
<br/><a href="#add_effect">add_effect()</a>, <a href="#set_arg_of">set_arg_of()</a> and <a href="#sid_to_enum">sid_to_enum()
</a></dl>

<ul><a name="delete_effect">
delete_effect</a><pre>
void delete_effect(int i)
</pre></br>
This removes an effect from the player.  It uses the enum as
returned from sid to enum.  This is the number you see in
the stat of the object next to the effect.
<br/><ul>
<li><b>Parameters:</b>
<br/>i - the enum to remove
<li><b>See also:</b>
<br/><a href="#add_effect">add_effect()
</a></dl>

<ul><a name="eff_of">
eff_of</a><pre>
string eff_of(int enum)
</pre></br>
This method returns the effect object for the given effect number.
<br/><ul>
<li><b>Parameters:</b>
<br/>enum - the effect number
<li><b>Returns:</b>
<br/>the effect object
<li><b>See also:</b>
<br/><a href="#arg_of">arg_of()</a>, <a href="#add_effect">add_effect()</a> and <a href="#sid_to_enum">sid_to_enum()
</a></dl>

<ul><a name="effect_freeze">
effect_freeze</a><pre>
void effect_freeze()
</pre></br>
This method freezes all the current effects so that they do
not continue to be processed.  Basicly it removes the call_out
for the effect_timer().  It also ensures the intrval for the
immediately pending effect
is correct.
<br/><ul>
<li><b>See also:</b>
<br/><a href="#effect_timer">effect_timer()</a> and <a href="#add_effect">add_effect()
</a></dl>

<ul><a name="effect_unfreeze">
effect_unfreeze</a><pre>
void effect_unfreeze()
</pre></br>
This restarts the internal call_out.
<br/><ul>
<li><b>See also:</b>
<br/><a href="#effects_freeze">effects_freeze()</a> and <a href="#add_effect">add_effect()
</a></dl>

<ul><a name="effects_desting">
effects_desting</a><pre>
void effects_desting()
</pre></br>
Called when an object is dested.  Calls the desting method on
all the effects.


<ul><a name="effects_matching">
effects_matching</a><pre>
int * effects_matching(string eff)
</pre></br>
This method returns an array of effects matching the
classification.  The start part of the classification is
used to match, so passing "npc." into this function will
match all the effects which modify how an
npc functions.
<br/><ul>
<li><b>Parameters:</b>
<br/>eff - the classification to match
<li><b>Returns:</b>
<br/>the array of enums corresponding to the effects
<li><b>See also:</b>
<br/><a href="#add_effect">add_effect()
</a></dl>

<ul><a name="effects_quiting">
effects_quiting</a><pre>
void effects_quiting()
</pre></br>
Called when a player actually quits.  Calls the quitting method on
all the effects.


<ul><a name="effects_thru_death">
effects_thru_death</a><pre>
void effects_thru_death()
</pre></br>
This method removes all the effects as we die.  It calls the function
survive_death() on the effect objects themselves to determine if
they should be kept when the living dies.


<ul><a name="enum_to_sid">
enum_to_sid</a><pre>
int enum_to_sid(int enum)
</pre></br>
This method turns an effect number into an effect id.
<br/><ul>
<li><b>Parameters:</b>
<br/>enum - the effect number
<li><b>Returns:</b>
<br/>the effect id

<li><b>See also:</b>
<br/><a href="#sid_to_enum">sid_to_enum()</a> and <a href="#add_effect">add_effect()</a></dl>

<ul><a name="expected_ee">
expected_ee</a><pre>
varargs int expected_ee(string func_name,
                        int enum)
</pre></br>
Returns the time until the next event that will call func_name.
If enum is undefined, the event is searched for in this effect,
otherwise the event is searched for in the specified effect.

If no outstanding calls to the function are found, -1 is returned.

<br/><ul>
<li><b>Parameters:</b>
<br/>func_name - - the name of the function the ee will call.
<br/>enum - - the enum of the effect to check in.
<li><b>Returns:</b>
<br/>time - the seconds until the next call to func_name for
the effect specified.
<li><b>See also:</b>
<br/><a href="#all_expected_ees">all_expected_ees()</a>, <a href="#expected_tt">expected_tt()</a> and <a href="#submit_ee">submit_ee()
</a></dl>

<ul><a name="expected_tt">
expected_tt</a><pre>
int expected_tt(int flag,
                int new_enum)
</pre></br>
This method returns the time until any EE_REMOVE effect
is expected to occur.  It will return --1 if no remove
event is scheduled.  If the flag is not
set to true, the the current enum is checked, otherwise
the new_enum is checked.
<br/><ul>
<li><b>Parameters:</b>
<br/>flag - itrue, use new_enum not current_enum
<li><b>Returns:</b>
<br/>the time until the remove event will occur
<li><b>See also:</b>
<br/><a href="#submit_ee">submit_ee()</a>, <a href="#add_effect">add_effect()</a>, <a href="#expected_ee">expected_ee()</a> and <a href="#all_expected_ees">all_expected_ees()
</a></dl>

<ul><a name="query_current_effect_enum">
query_current_effect_enum</a><pre>
int query_current_effect_enum()
</pre></br>
This method returns the current enum.


<ul><a name="query_logging_effects">
query_logging_effects</a><pre>
int query_logging_effects()
</pre>
<ul><a name="reset_effects">
reset_effects</a><pre>
void reset_effects()
</pre></br>
This method removes all the current effects off the object
and sets everything back to the initial state.
<br/><ul>
<li><b>See also:</b>
<br/><a href="#add_effect">add_effect()
</a></dl>

<ul><a name="set_arg_of">
set_arg_of</a><pre>
void set_arg_of(int enum,
                mixed newarg)
</pre></br>
This sets the argument of the given effect to a new value.
<br/><ul>
<li><b>Parameters:</b>
<br/>enum - the effect number to change
<br/>newarg - the new argument value
<li><b>See also:</b>
<br/><a href="#sid_to_enum">sid_to_enum()</a>, <a href="#arg_of">arg_of()</a> and <a href="#add_effect">add_effect()
</a></dl>

<ul><a name="set_logging_effects">
set_logging_effects</a><pre>
void set_logging_effects(int i)
</pre>
<ul><a name="sid_to_enum">
sid_to_enum</a><pre>
int sid_to_enum(int sid)
</pre></br>
This method returns the effect number for the given effect id.  The
effect number is an internal nhandle used by delete_effect()
arg_of() set_arg_of() functions.  "id" is passed into the
begining/end etc functions on the effect object.
<br/><ul>
<li><b>Parameters:</b>
<br/>sid - the effect id
<li><b>Returns:</b>
<br/>the effect number
<li><b>See also:</b>
<br/><a href="#submit_ee2">submit_ee2()</a>, <a href="#delete_effect">delete_effect()</a>, <a href="#add_effect">add_effect()</a>, <a href="#arg_of">arg_of()</a> and <a href="#set_arg_of">set_arg_of()
</a></dl>

<ul><a name="submit_ee">
submit_ee</a><pre>
varargs void submit_ee(mixed fun,
                       mixed interval,
                       int flags,
                       mixed event_args)
</pre></br>
This submits an effect event schedule.  It will call "function name" in your
effect object after the interval specified in interval_spec, with behaviour
modified by flags.  Addtional args may optionally be sent to "function name"
as well.  If none are passed, args == 0.
interval_spec can be one of:
<dl><dt>n
<dd>time in seconds
<dt>({ m, n })
<dd>minimum time m seconds, maximum time n seconds, simple random
    distribution
<dt>({ m, n, r })
<dd>as for the ({ m, n }) case, except the random factor is effectively
    "rolled" r times ... the higher r is, the more likely the interval
    is to be close to (m + n)/2.
</dl>
flags may be:
<dl>
<dt>EE_REMOVE
<dd> remove the effect from the player aftert the function call
<dt>EE_CONTINUOUS
<dd>do it repeatedly.  Default (EE_ONCE) is only do it once.
<dt>EE_ONCE
<dd>do it once
</dl>
These are defined in /include/effect.h
<p>
Only one EE_REMOVE can be in place at a time.  Subsequent EE_REMOVEs
will wipe previous ones.
<p>
NB:  submit_ee can ONLY be called from the effect object itself in the
course of a beginning/handler/end call, or from the effect shadow.
<br/><ul>
<li><b>Parameters:</b>
<br/>fun - the function to call
<br/>interval - the interval specifier
<br/>flags - the flags for the event
<br/>event_args - additional (optional) args passed to fun

<li><b>See also:</b>
<br/><a href="#submit_ee2">submit_ee2()</a>, <a href="include.effect.h.shtml">/include/effect.h</a> and <a href="#add_effect">add_effect()</a></dl>

<ul><a name="submit_ee2">
submit_ee2</a><pre>
varargs void submit_ee2(int enum,
                        mixed fun,
                        mixed interval,
                        int flags,
                        mixed event_args)
</pre></br>
This submits an effect event for a specific effect.
Apart from this it is the same as submit_ee()
<br/><ul>
<li><b>Parameters:</b>
<br/>enum - the enum of the effecrt
<br/>fun - the function to call
<br/>interval - the interval specifier
<br/>flags - the flagds associated with the event
<br/>event_args - additional (optional) args passed to fun

</dl>


<h2>Protected Functions</h2>
These are functions that only objects inheriting the class can access.<p>
<ul><a name="set_eeq">
set_eeq</a><pre>
void set_eeq(mixed * args)
</pre></br>
This method is used to force the effects setup in the object to be a
specified value.  THis is used in the effects effect which sets up
effects on someone using a shadow.  This should only be used on startup.
<br/><ul>
<li><b>Parameters:</b>
<br/>args - the effects array to overwrite the old one with.

</dl>

<ul><a name="set_effs">
set_effs</a><pre>
void set_effs(mixed * args)
</pre></br>
This method is used to force the effects setup in the object to be a
specified value.  THis is used in the effects effect which sets up
effects on someone using a shadow.  This should only be used on startup.
<br/><ul>
<li><b>Parameters:</b>
<br/>args - the effects array to overwrite the old one with.

</dl>


<h2>Classes</h2>
These are nice data types for dealing with...  Data!<p>
<ul>
<li><a name="class_effect_data">
effect_data</a><pre>
class effect_data {
                    int current_enum;
                    int next_id;
                    int next_event_time;
                    class effect_shadow * shadows;
}

</pre><br/>
This class stores all the data for the effects inheritable.<p>
<dl>
<dt><b>Members:</b>
<br/>current_enum - used to keep track of the effect being called;
        beginning/end etc.
<br/>next_id - the next id to assign to an effect
<br/>next_event_time - when the next effect is due to go off
<br/>shadows - the shaodws on the object

</dl>

<li><a name="class_effect_event">
effect_event</a><pre>
class effect_event {
                     int inctime;
                     mixed func;
                     int eff_ob_num;
                     mixed interval;
                     int flags;
                     mixed eff_ev_args;
}

</pre>
<li><a name="class_effect_shadow">
effect_shadow</a><pre>
class effect_shadow {
                      object shad_ob;
                      int idnum;
}

</pre>
</ul>
[an error occurred while processing this directive]

