moving.c-Dateireferenz

#include <moving.h>
#include <defines.h>
#include <properties.h>
#include "/p/service/padreic/mnpc/mnpc.h"
#include <combat.h>
Include-Abhängigkeitsdiagramm für moving.c:

gehe zum Quellcode dieser Datei

Makrodefinitionen

#define ENV   environment
#define PO   previous_object()

Funktionen

mixed InFight ()
static void mnpc_create ()
static int _set_mnpc_flags (int flags)
static void mnpc_InsertEnemy (object enemy)
static void mnpc_reset ()
static int _query_mnpc_last_meet ()
static void mnpc_init ()
static void mnpc_move ()
static int PreventEnter (string file)
static int mnpc_PreventFollow (object dest)
static int direct_move (mixed dest, int method, string direction)
int Walk ()

Variablen

inherit std living moving
static int meet_last_player

Makro-Dokumentation

#define ENV   environment

Definiert in Zeile 26 der Datei moving.c.

#define PO   previous_object()

Definiert in Zeile 27 der Datei moving.c.


Dokumentation der Funktionen

static int _query_mnpc_last_meet (  )  [static]

Definiert in Zeile 113 der Datei moving.c.

Benutzt meet_last_player.

00114 {   return meet_last_player;   }

static int _set_mnpc_flags ( int  flags  )  [static]

Definiert in Zeile 53 der Datei moving.c.

Benutzt call_out(), ENV, MAX_MASTER_TIME, MNPC_DELAY, MNPC_FLAGS, MNPC_FOLLOW_PLAYER, MNPC_HOME, MNPC_PURSUER, MNPC_RANDOM, MNPC_WALK, Query(), QueryProp() und WALK_MASTER.

00054 {
00055   if (flags & MNPC_WALK) {
00056     if (!QueryProp(MNPC_HOME)) raise_error("unknown MNPC_HOME\n");
00057     //wenn die Flags neu gesetzt werden, wird der MNPC das zweite Mal im
00058     //Master angemeldet -> vorher abmelden (Zesstra)
00059     if (QueryProp(MNPC_FLAGS) & MNPC_WALK) {
00060                 if (WALK_MASTER->Registered())
00061                     WALK_MASTER->RemoveWalker();
00062                 else if (find_call_out("Walk")!=-1)
00063                     remove_call_out("Walk");
00064     }
00065     if ((Query(MNPC_DELAY)+Query(MNPC_RANDOM))<=MAX_MASTER_TIME)
00066       WALK_MASTER->RegisterWalker(Query(MNPC_DELAY), Query(MNPC_RANDOM));
00067     else call_out("Walk", Query(MNPC_DELAY)+random(Query(MNPC_RANDOM)));
00068   }
00069   // else nicht von Bedeutung, da in Walk() das flag getestet wird
00070   if (flags & MNPC_FOLLOW_PLAYER) {
00071     if (!Query(MNPC_PURSUER)) { // wurde dieses Flag neu eingeschaltet?
00072       if (environment()) { // Verfolgung aufnehmen...
00073         object *pursuer;
00074         pursuer=filter(all_inventory(ENV()), #'interactive);
00075         filter_objects(pursuer, "AddPursuer", ME);
00076         Set(MNPC_PURSUER, pursuer);
00077       }
00078       else Set(MNPC_PURSUER, ({}));
00079     }
00080   }
00081   else if (pointerp(Query(MNPC_PURSUER))) { // wird derzeit irgendwer verfolgt?
00082     // alle Verfolgungen abbrechen...
00083     filter_objects(Query(MNPC_PURSUER)-({ 0 }), "RemovePursuer", ME);
00084     Set(MNPC_PURSUER, 0); // Speicher freigeben...
00085   }
00086   else Set(MNPC_PURSUER, 0);
00087   // nur livings koennen command_me nutzen...
00088   if (!living(ME)) flags |= MNPC_DIRECT_MOVE;
00089   return Set(MNPC_FLAGS, flags);
00090 }

Hier ist ein Graph der zeigt, was diese Funktion aufruft:

static int direct_move ( mixed  dest,
int  method,
string  direction 
) [static]

Definiert in Zeile 189 der Datei moving.c.

Benutzt inv(), M_NOCHECK, M_TPORT, ME, mout, name, Name(), P_MMSGIN, P_MMSGOUT, P_MSGIN, P_MSGOUT, P_PARA, QueryProp() und WER.

00190 { 
00191    int res, para, tmp;
00192    string textout, textin, *mout, vc, fn;
00193    object oldenv, *inv;
00194 
00195    if (living(ME))
00196       return call_other(ME, "move", dest, method);
00197    else {
00198       oldenv = environment();
00199       para=QueryProp(P_PARA);
00200       if ((para>0) && stringp(dest)) {
00201          fn=dest+"^"+para;
00202 
00203          if (find_object(fn) || (file_size(fn+".c")>0))
00204             dest=fn;
00205          else if (file_size(vc=implode(explode(fn,"/")[0..<2],"/")+"/virtual_compiler.c")>0) {
00206             // wenn ein VC existiert, prüfen ob dieser ParaObjecte unterstuetzt
00207             // wenn ja, dann testen ob sich Raum laden laesst...
00208             if ((!catch(tmp=(int)call_other(vc,"NoParaObjects")) && (!tmp)) && 
00209                 (!catch(call_other( fn, "???" ))))
00210                 dest=fn;
00211          }
00212       }
00213       res = (int)call_other(ME, "move", dest, M_NOCHECK);
00214       if (oldenv==environment()) return res;
00215 
00216       // als erstes die Meldung fuer das Verlassen des Raumes...
00217       if ( method & M_TPORT )
00218          textout = (string) QueryProp(P_MMSGOUT) || (string) QueryProp(P_MSGOUT);
00219       else textout = (mout = explode( (string) QueryProp(P_MSGOUT) || "", "#" ))[0]
00220                      || (string) QueryProp(P_MMSGOUT);
00221 
00222       if (stringp(textout)) {
00223          if ( !strlen(direction) ) direction = 0;
00224 
00225          inv = all_inventory(oldenv) - ({ this_object() });
00226          inv = filter( inv, #'living);
00227          inv -= filter_objects( inv, "CannotSee", 1 );
00228  
00229          filter( inv, #'tell_object,
00230                        Name( WER, 2 ) + " " + textout +
00231                        (direction ? " " + direction : "") +
00232                        (sizeof(mout) > 1 ? mout[1] : "") + ".\n" );
00233       }
00234 
00235       // nun die Meldung für das "Betreten" des Raumes...
00236 
00237       if ( method & M_TPORT )
00238          textin = (string) QueryProp(P_MMSGIN);
00239       else textin = (string) QueryProp(P_MSGIN);
00240 
00241       if (stringp(textin)) {            
00242          inv = all_inventory(environment()) - ({ this_object() });
00243          inv = filter( inv, #'living);
00244          inv -= filter_objects( inv, "CannotSee", 1 );
00245          filter( inv, #'tell_object,
00246                        capitalize(name( WER, 0 )) + " " + textin + ".\n" );
00247       }
00248   }
00249 }

Hier ist ein Graph der zeigt, was diese Funktion aufruft:

mixed InFight (  ) 

Definiert in Zeile 1735 der Datei combat.c.

Benutzt EnemyPresent().

Wird benutzt von _query_hb(), ConfigureColors(), heart_beat() und Walk().

01736 {
01737   return EnemyPresent();
01738 }

Hier ist ein Graph der zeigt, was diese Funktion aufruft:

Hier ist ein Graph der zeigt, wo diese Funktion aufgerufen wird:

static void mnpc_create (  )  [static]

Definiert in Zeile 35 der Datei moving.c.

Benutzt ENV, meet_last_player, MNPC_AREA, MNPC_DELAY, MNPC_DFLT_DELAY, MNPC_DFLT_HOME, MNPC_DFLT_WALK, MNPC_FLAGS, MNPC_FUNC, MNPC_HOME, MNPC_RANDOM, MNPC_WALK_TIME, P_ENABLE_IN_ATTACK_OUT, P_MNPC, PL, PO, Set() und SetProp().

Wird benutzt von create().

00036 {
00037   if (PO && member(inherit_list(PO), "/std/room.c")!=-1)
00038     Set(MNPC_HOME, object_name(PO));
00039   else if (PL && ENV(PL))
00040     Set(MNPC_HOME, object_name(ENV(PL)));
00041   else Set(MNPC_HOME, MNPC_DFLT_HOME);
00042   Set(P_MNPC, 1);
00043   Set(MNPC_AREA, ({}));
00044   Set(MNPC_DELAY, MNPC_DFLT_DELAY);
00045   Set(MNPC_FUNC, 0);
00046   Set(MNPC_RANDOM, 0);
00047   Set(MNPC_WALK_TIME, MNPC_DFLT_WALK);
00048   SetProp(MNPC_FLAGS, 0);
00049   SetProp(P_ENABLE_IN_ATTACK_OUT, 1);
00050   meet_last_player=time();
00051 }

Hier ist ein Graph der zeigt, was diese Funktion aufruft:

Hier ist ein Graph der zeigt, wo diese Funktion aufgerufen wird:

static void mnpc_init (  )  [static]

Definiert in Zeile 116 der Datei moving.c.

Benutzt call_out(), IsEnemy(), MAX_MASTER_TIME, ME, meet_last_player, MNPC_DELAY, MNPC_FLAGS, MNPC_FOLLOW_ENEMY, MNPC_LAST_MEET, MNPC_PURSUER, MNPC_RANDOM, PL, Query(), Set() und WALK_MASTER.

Wird benutzt von init().

00117 {
00118   if (interactive(PL)) {
00119     if (meet_last_player<=0) {
00120       if ((Query(MNPC_DELAY)+Query(MNPC_RANDOM))<=MAX_MASTER_TIME)
00121         WALK_MASTER->RegisterWalker(Query(MNPC_DELAY), Query(MNPC_RANDOM));
00122       else call_out("Walk", Query(MNPC_DELAY)+random(Query(MNPC_RANDOM)));
00123     }
00124     if ( (Query(MNPC_FLAGS) & MNPC_FOLLOW_PLAYER) &&
00125          (member(Query(MNPC_PURSUER), PL)==-1) &&
00126         (!(Query(MNPC_FLAGS) & MNPC_FOLLOW_ENEMY) || IsEnemy(PL))) {
00127       PL->AddPursuer(ME);
00128       Set(MNPC_PURSUER, Query(MNPC_PURSUER)+({ PL }));
00129     }
00130     meet_last_player=time();
00131   }
00132   else {
00133     int lm;
00134     lm=PL->QueryProp(MNPC_LAST_MEET);
00135     if (meet_last_player<=0 && lm>0) {
00136        if ((Query(MNPC_DELAY)+Query(MNPC_RANDOM))<=MAX_MASTER_TIME)
00137           WALK_MASTER->RegisterWalker(Query(MNPC_DELAY), Query(MNPC_RANDOM));
00138        else call_out("Walk", Query(MNPC_DELAY)+random(Query(MNPC_RANDOM)));
00139        meet_last_player=lm;
00140     }
00141     else if (meet_last_player<lm) meet_last_player=lm;
00142   }
00143 }

Hier ist ein Graph der zeigt, was diese Funktion aufruft:

Hier ist ein Graph der zeigt, wo diese Funktion aufgerufen wird:

static void mnpc_InsertEnemy ( object  enemy  )  [static]

Definiert in Zeile 92 der Datei moving.c.

Wird benutzt von InsertEnemy().

00093 {
00094   if ( (Query(MNPC_FLAGS) & MNPC_FOLLOW_ENEMY) &&
00095          (member(Query(MNPC_PURSUER), PL)==-1)) {
00096      PL->AddPursuer(ME);
00097      Set(MNPC_PURSUER, Query(MNPC_PURSUER)+({ PL }));
00098   }
00099 }

Hier ist ein Graph der zeigt, wo diese Funktion aufgerufen wird:

static void mnpc_move (  )  [static]

Definiert in Zeile 145 der Datei moving.c.

Benutzt ME, MNPC_FLAGS, MNPC_FUNC, MNPC_PURSUER, Query() und Set().

Wird benutzt von move().

00146 {
00147   if (environment() && (Query(MNPC_FLAGS) & MNPC_FOLLOW_PLAYER)) {
00148     object *liv;
00149     liv=Query(MNPC_PURSUER) & all_inventory(environment());
00150     filter_objects(Query(MNPC_PURSUER)-liv-({ 0 }), "RemovePursuer", ME);
00151     Set(MNPC_PURSUER, liv);
00152   }
00153   if (Query(MNPC_FUNC)) call_other(ME, Query(MNPC_FUNC));
00154 }

Hier ist ein Graph der zeigt, was diese Funktion aufruft:

Hier ist ein Graph der zeigt, wo diese Funktion aufgerufen wird:

static int mnpc_PreventFollow ( object  dest  )  [static]

Definiert in Zeile 181 der Datei moving.c.

Benutzt PreventEnter().

Wird benutzt von PreventFollow().

00182 {
00183   if (dest && PreventEnter(object_name(dest)))
00184     return 2;
00185   return 0;
00186 }

Hier ist ein Graph der zeigt, was diese Funktion aufruft:

Hier ist ein Graph der zeigt, wo diese Funktion aufgerufen wird:

static void mnpc_reset (  )  [static]

Definiert in Zeile 101 der Datei moving.c.

Benutzt M_NOCHECK, M_TPORT, MAX_MASTER_TIME, meet_last_player, MNPC_HOME, MNPC_WALK_TIME, move() und Query().

Wird benutzt von reset().

00102 {
00103   if (!Query(MNPC_HOME) || !(Query(MNPC_FLAGS) & MNPC_WALK)) return;
00104   if (meet_last_player>=0 && Query(MNPC_WALK_TIME)+meet_last_player < time()
00105       && environment() && !sizeof(filter(
00106       all_inventory(environment()), #'query_once_interactive))) {
00107     if (Query(MNPC_WALK_TIME) > MAX_MASTER_TIME) remove_call_out("Walk");
00108     meet_last_player=-1;
00109     move(Query(MNPC_HOME), M_TPORT|M_NOCHECK); // ab nach Hause und dort warten
00110   }
00111 }

Hier ist ein Graph der zeigt, was diese Funktion aufruft:

Hier ist ein Graph der zeigt, wo diese Funktion aufgerufen wird:

static int PreventEnter ( string  file  )  [static]

Definiert in Zeile 156 der Datei moving.c.

Benutzt i, MNPC_AREA, MNPC_EXACT_AREA_MATCH, MNPC_FLAGS und Query().

Wird benutzt von mnpc_PreventFollow().

00158 {
00159   string *area;
00160 
00161   if (!sizeof(area=Query(MNPC_AREA)))
00162     return 0; // Raum darf betreten werden
00163   else {
00164     int i;
00165     status exactmatch;
00166     exactmatch=Query(MNPC_FLAGS) & MNPC_EXACT_AREA_MATCH;
00167     if ((i=strstr(file, "#"))!=-1) file=file[i+1..<1];
00168     for (i=sizeof(area)-1; i>=0; i--) {
00169       if (exactmatch) {
00170 
00171                 //exakter Vergleich, kein Substringvergleich gewuenscht
00172                 if (file==area[i]) return 0;  //betreten
00173       }
00174       else
00175                 if (strstr(file, area[i])==0) return 0; // Raum betreten
00176     }
00177     return 1; //  Raum darf nicht betreten werden
00178   }
00179 }

Hier ist ein Graph der zeigt, was diese Funktion aufruft:

Hier ist ein Graph der zeigt, wo diese Funktion aufgerufen wird:

int Walk (  ) 

Definiert in Zeile 251 der Datei moving.c.

Benutzt call_out(), destruct(), ex, exits, i, InFight(), MAX_MASTER_TIME, meet_last_player, MNPC_DELAY, MNPC_FLAGS, MNPC_NO_WALK_IN_FIGHT, MNPC_RANDOM, MNPC_WALK_TIME und Query().

00252 {
00253   int     i, flags;
00254   mapping exits;
00255   string  *rooms, *dirs, *ex, tmp;
00256 
00257   flags=Query(MNPC_FLAGS);
00258   if (!(flags & MNPC_WALK)) return 0;
00259 
00260   if ((flags & MNPC_NO_WALK_IN_FIGHT) && InFight()) {
00261     meet_last_player=time();
00262     if ((Query(MNPC_DELAY)+Query(MNPC_RANDOM))>MAX_MASTER_TIME)
00263       call_out("Walk", Query(MNPC_DELAY)+random(Query(MNPC_RANDOM)));
00264     return 1;
00265   }
00266 
00267   if (!environment()) {
00268     meet_last_player=-1;
00269     if (!clonep(this_object())) return 0; // Blueprints nicht destructen
00270     catch(remove());
00271     if (this_object()) destruct(this_object());
00272     return 0;
00273   }
00274 
00275   if (Query(MNPC_WALK_TIME)+meet_last_player < time() && !sizeof(
00276       filter(all_inventory(environment()), #'query_once_interactive))) {
00277     if (flags & MNPC_GO_HOME_WHEN_STOPPED) {
00278       meet_last_player=-1;
00279       move(Query(MNPC_HOME), M_TPORT|M_NOCHECK);
00280     }
00281     else meet_last_player=0;
00282     return 0;
00283   }
00284   
00285   // Ausgaenge ermitteln.
00286   exits = (environment()->QueryProp(P_EXITS));
00287   rooms = m_values(exits); dirs  = m_indices(exits); ex = ({});
00288   for (i=sizeof(rooms)-1; i>=0; i--)
00289     if (!PreventEnter(rooms[i])) ex += ({ dirs[i] });
00290 
00291   /* Hier muessen wir auf die Zuverlaessigkeit unserer Magier bauen ... */
00292   if (flags & MNPC_DIRECT_MOVE) {
00293     // im direct mode keine SEs benutzbar...
00294     if (sizeof(ex)) {
00295        tmp=ex[random(sizeof(ex))];
00296        direct_move(explode(exits[tmp], "#")[<1], M_GO, "nach "+capitalize(tmp));
00297     }
00298     else {
00299        // Hngl. Nach Hause...
00300        direct_move(Query(MNPC_HOME), M_TPORT|M_NOCHECK, 0);
00301      } 
00302   }
00303   else if (flags & MNPC_ONLY_EXITS) {
00304     // logischerweise auch keine SEs benutzen...
00305     if (sizeof(ex)) {
00306       command(ex[random(sizeof(ex))]); /* Irgendwohin gehen */
00307     }
00308     else {
00309       // Hngl. Nach Hause...
00310       move(Query(MNPC_HOME), M_TPORT|M_NOCHECK);
00311    }
00312   }
00313   else {
00314     // Special Exits mitbenutzen.
00315     ex += m_indices(ENV()->QueryProp(P_SPECIAL_EXITS));
00316     if (sizeof(ex)) {
00317       command(ex[random(sizeof(ex))]); /* Irgendwohin gehen */
00318     }
00319     else {
00320       // Hngl. Gar keine Ausgaenge. Nach Hause...
00321       move(Query(MNPC_HOME), M_TPORT|M_NOCHECK);
00322     }
00323   }
00324   // Aufrufe in zerstoerten Objekten verhindern, die beim Bewegen sterben.
00325   if ( objectp(this_object()) && 
00326        (Query(MNPC_DELAY)+Query(MNPC_RANDOM))>MAX_MASTER_TIME )
00327     call_out("Walk", Query(MNPC_DELAY)+random(Query(MNPC_RANDOM)));
00328   return 1;
00329 }

Hier ist ein Graph der zeigt, was diese Funktion aufruft:


Variablen-Dokumentation

int meet_last_player [static]

Definiert in Zeile 29 der Datei moving.c.

Wird benutzt von _query_mnpc_last_meet(), mnpc_create(), mnpc_init(), mnpc_reset() und Walk().

inherit std living moving

Definiert in Zeile 18 der Datei moving.c.

Erzeugt am Thu Jun 3 14:40:56 2010 für MorgenGrauen Mudlib von  doxygen 1.6.3