Difference for server/apply.c from version 1.46 to 1.47


version 1.46 version 1.47
Line 1
 
Line 1
 /*  /*
  * static char *rcsid_apply_c =   * static char *rcsid_apply_c =
  *   "$Id: apply.c,v 1.46 2001/09/26 21:34:08 garbled Exp $";   *   "$Id: apply.c,v 1.47 2001/10/14 07:57:14 gros Exp $";
  */   */
 /*  /*
     CrossFire, A Multiplayer game for X-windows      CrossFire, A Multiplayer game for X-windows
Line 846
 
Line 846
      CLEAR_FLAG (op->container, FLAG_WALK_OFF);       CLEAR_FLAG (op->container, FLAG_WALK_OFF);
      CLEAR_FLAG (op->container, FLAG_FLY_OFF);       CLEAR_FLAG (op->container, FLAG_FLY_OFF);
  }   }
   #ifdef PLUGINS
    /* GROS: Handle for plugin close event */
    if(tmp->event_hook[EVENT_CLOSE] != NULL)
    {
    CFParm CFP;
    CFParm* CFR;
    int k, l, m;
    int rtn_script = 0;
    m = 0;
    k = EVENT_CLOSE;
    l = SCRIPT_FIX_ALL;
    CFP.Value[0] = &k;
    CFP.Value[1] = op;
    CFP.Value[2] = tmp;
    CFP.Value[3] = NULL;
    CFP.Value[4] = NULL;
    CFP.Value[5] = &m;
    CFP.Value[6] = &m;
    CFP.Value[7] = &m;
    CFP.Value[8] = &l;
    CFP.Value[9] = tmp->event_hook[k];
    CFP.Value[10]= tmp->event_options[k];
    if (findPlugin(tmp->event_plugin[k])>=0)
    {
    CFR = (PlugList[findPlugin(tmp->event_plugin[k])].eventfunc) (&CFP);
    rtn_script = *(int *)(CFR->Value[0]);
    if (rtn_script!=0) return 1;
    }
    }
   #endif
  new_draw_info_format(NDI_UNIQUE, 0, op, "You close %s.",   new_draw_info_format(NDI_UNIQUE, 0, op, "You close %s.",
        query_name(op->container));         query_name(op->container));
  CLEAR_FLAG(op->container, FLAG_APPLIED);   CLEAR_FLAG(op->container, FLAG_APPLIED);
Line 1114
 
Line 1144
     return;      return;
   }    }
   recursion_depth++;    recursion_depth++;
   
   if (trap->head) trap=trap->head;    if (trap->head) trap=trap->head;
   #ifdef PLUGINS
     /* GROS: Handle for plugin close event */
     if(trap->event_hook[EVENT_TRIGGER] != NULL)
     {
       CFParm CFP;
       CFParm* CFR;
       int k, l, m;
       int rtn_script = 0;
       m = 0;
       k = EVENT_TRIGGER;
       l = SCRIPT_FIX_ALL;
       CFP.Value[0] = &k;
       CFP.Value[1] = trap;
       CFP.Value[2] = originator;
       CFP.Value[3] = victim;
       CFP.Value[4] = NULL;
       CFP.Value[5] = &m;
       CFP.Value[6] = &m;
       CFP.Value[7] = &m;
       CFP.Value[8] = &l;
       CFP.Value[9] = trap->event_hook[k];
       CFP.Value[10]= trap->event_options[k];
       if (findPlugin(trap->event_plugin[k])>=0)
       {
         CFR = (PlugList[findPlugin(trap->event_plugin[k])].eventfunc) (&CFP);
         rtn_script = *(int *)(CFR->Value[0]);
         if (rtn_script!=0) return;
       }
     }
   #endif
   switch (trap->type)    switch (trap->type)
   {    {
   case PLAYERMOVER:    case PLAYERMOVER:
Line 1235
 
Line 1294
   case TRIGGER_BUTTON:    case TRIGGER_BUTTON:
   case TRIGGER_PEDESTAL:    case TRIGGER_PEDESTAL:
   case TRIGGER_ALTAR:    case TRIGGER_ALTAR:
   /* GROS: Handle for script_trigger event */  #ifdef PLUGINS
     if (trap->script_trigger != NULL)    /* GROS: Handle for plugin trigger event */
     {      if(trap->event_hook[EVENT_TRIGGER] != NULL)
       guile_call_event(victim, trap, NULL, 0, NULL,0,0,trap->script_trigger, SCRIPT_FIX_ALL);      {
     }          CFParm CFP;
     else          int k, l, m;
     {          k = EVENT_TRIGGER;
       if (trap->script_str_trigger != NULL)          l = SCRIPT_FIX_ALL;
       {          m = 0;
         guile_call_event_str(victim, trap, NULL, 0, NULL,0,0,trap->script_str_trigger, SCRIPT_FIX_ALL);          CFP.Value[0] = &k;
           CFP.Value[1] = victim;
           CFP.Value[2] = trap;
           CFP.Value[3] = NULL;
           CFP.Value[4] = NULL;
           CFP.Value[5] = &m;
           CFP.Value[6] = &m;
           CFP.Value[7] = &m;
           CFP.Value[8] = &l;
           CFP.Value[9] = trap->event_hook[EVENT_TRIGGER];
           CFP.Value[10]= trap->event_options[EVENT_TRIGGER];
           if (findPlugin(trap->event_plugin[k])>=0)
               ((PlugList[findPlugin(trap->event_plugin[EVENT_TRIGGER])].eventfunc) (&CFP));
       }        }
       else        else
       {  #endif
         check_trigger (trap, victim);          check_trigger (trap, victim);
       }  
     };  
     goto leave;      goto leave;
   
   case DEEP_SWAMP:    case DEEP_SWAMP:
Line 1258
 
Line 1327
     goto leave;      goto leave;
   
   case CHECK_INV:    case CHECK_INV:
   /* GROS: Handle for script_trigger event */  #ifdef PLUGINS
     if (trap->script_trigger != NULL)    /* GROS: Handle for plugin trigger event */
     {      if(trap->event_hook[EVENT_TRIGGER] != NULL)
       guile_call_event(victim, trap, NULL, 0, NULL,0,0,trap->script_trigger, SCRIPT_FIX_ALL);      {
     }          CFParm CFP;
     else          int k, l, m;
     {          k = EVENT_TRIGGER;
       if (trap->script_str_trigger != NULL)          l = SCRIPT_FIX_ALL;
       {          m = 0;
         guile_call_event_str(victim, trap, NULL, 0, NULL,0,0,trap->script_str_trigger, SCRIPT_FIX_ALL);          CFP.Value[0] = &k;
           CFP.Value[1] = victim;
           CFP.Value[2] = trap;
           CFP.Value[3] = NULL;
           CFP.Value[4] = NULL;
           CFP.Value[5] = &m;
           CFP.Value[6] = &m;
           CFP.Value[7] = &m;
           CFP.Value[8] = &l;
           CFP.Value[9] = trap->event_hook[k];
           CFP.Value[10]= trap->event_options[k];
           if (findPlugin(trap->event_plugin[k])>=0)
               ((PlugList[findPlugin(trap->event_plugin[k])].eventfunc) (&CFP));
       }        }
       else        else
       {  #endif
         check_inv (victim, trap);          check_inv (victim, trap);
       }  
     };  
     goto leave;      goto leave;
   
   case HOLE:    case HOLE:
Line 1297
 
Line 1376
  */   */
  if (trap->msg && strncmp(EXIT_PATH(trap),"/!",2) && strncmp(EXIT_PATH(trap), "/random/", 8))   if (trap->msg && strncmp(EXIT_PATH(trap),"/!",2) && strncmp(EXIT_PATH(trap), "/random/", 8))
      new_draw_info (NDI_NAVY, 0, victim, trap->msg);       new_draw_info (NDI_NAVY, 0, victim, trap->msg);
       /* GROS: Handle for script_trigger event */  #ifdef PLUGINS
       if (trap->script_trigger != NULL)    /* GROS: Handle for plugin trigger event */
       {        if(trap->event_hook[EVENT_TRIGGER] != NULL)
         guile_call_event(victim, trap, NULL, 0, NULL,0,0,trap->script_trigger, SCRIPT_FIX_ALL);        {
       }          CFParm CFP;
       else          int k, l, m;
       {          k = EVENT_TRIGGER;
         if (trap->script_str_trigger != NULL)          l = SCRIPT_FIX_ALL;
         {          m = 0;
           guile_call_event_str(victim, trap, NULL, 0, NULL,0,0,trap->script_str_trigger, SCRIPT_FIX_ALL);          CFP.Value[0] = &k;
           CFP.Value[1] = victim;
           CFP.Value[2] = trap;
           CFP.Value[3] = NULL;
           CFP.Value[4] = NULL;
           CFP.Value[5] = &m;
           CFP.Value[6] = &m;
           CFP.Value[7] = &m;
           CFP.Value[8] = &l;
           CFP.Value[9] = trap->event_hook[k];
           CFP.Value[10]= trap->event_options[k];
           if (findPlugin(trap->event_plugin[k])>=0)
               ((PlugList[findPlugin(trap->event_plugin[k])].eventfunc) (&CFP));
         }          }
       };  #endif
       enter_exit (victim, trap);        enter_exit (victim, trap);
     }      }
     goto leave;      goto leave;
Line 1340
 
Line 1431
   case RUNE:    case RUNE:
     if (trap->level && QUERY_FLAG (victim, FLAG_ALIVE))      if (trap->level && QUERY_FLAG (victim, FLAG_ALIVE))
     {      {
       /* GROS: Handle for script_trigger event */  #ifdef PLUGINS
       if (trap->script_trigger != NULL)        /* GROS: Handle for plugin trigger event */
       {        if(trap->event_hook[EVENT_TRIGGER] != NULL)
         guile_call_event(victim, trap, NULL, 0, NULL,0,0,trap->script_trigger, SCRIPT_FIX_ALL);        {
           CFParm CFP;
           int k, l, m;
           k = EVENT_TRIGGER;
           l = SCRIPT_FIX_ALL;
           m = 0;
           CFP.Value[0] = &k;
           CFP.Value[1] = victim;
           CFP.Value[2] = trap;
           CFP.Value[3] = NULL;
           CFP.Value[4] = NULL;
           CFP.Value[5] = &m;
           CFP.Value[6] = &m;
           CFP.Value[7] = &m;
           CFP.Value[8] = &l;
           CFP.Value[9] = trap->event_hook[k];
           CFP.Value[10]= trap->event_options[k];
           if (findPlugin(trap->event_plugin[k])>=0)
               ((PlugList[findPlugin(trap->event_plugin[k])].eventfunc) (&CFP));
       }        }
       else        else
       {  #endif
         if (trap->script_str_trigger != NULL)  
         {  
           guile_call_event_str(victim, trap, NULL, 0, NULL,0,0,trap->script_str_trigger, SCRIPT_FIX_ALL);  
         }  
         else  
         {  
           spring_trap(trap, victim);            spring_trap(trap, victim);
         }  
       };  
     };      };
     goto leave;      goto leave;
   
Line 1411
 
Line 1512
   
     new_draw_info_format (NDI_UNIQUE, 0, op,      new_draw_info_format (NDI_UNIQUE, 0, op,
                           "You open the %s and start reading.", tmp->name);                            "You open the %s and start reading.", tmp->name);
   #ifdef PLUGINS
     /* GROS: Handling for reading scripted books */      /* GROS: Handle for plugin trigger event */
     if (tmp->script_apply != NULL)      if(tmp->event_hook[EVENT_APPLY] != NULL)
     {      {
       guile_call_event(op,tmp, NULL, 0, NULL,0,0,tmp->script_apply, SCRIPT_FIX_ALL);          CFParm CFP;
     }          int k, l, m;
     else          k = EVENT_APPLY;
     {          l = SCRIPT_FIX_ALL;
       if (tmp->script_str_apply != NULL)          m = 0;
       {          CFP.Value[0] = &k;
         guile_call_event_str(op,tmp, NULL, 0, NULL,0,0,tmp->script_str_apply, SCRIPT_FIX_ALL);          CFP.Value[1] = op;
           CFP.Value[2] = tmp;
           CFP.Value[3] = NULL;
           CFP.Value[4] = NULL;
           CFP.Value[5] = &m;
           CFP.Value[6] = &m;
           CFP.Value[7] = &m;
           CFP.Value[8] = &l;
           CFP.Value[9] = tmp->event_hook[k];
           CFP.Value[10]= tmp->event_options[k];
           if (findPlugin(tmp->event_plugin[k])>=0)
               ((PlugList[findPlugin(tmp->event_plugin[k])].eventfunc) (&CFP));
       }        }
       else        else
   #endif
         new_draw_info(NDI_UNIQUE | NDI_NAVY, 0, op, tmp->msg);          new_draw_info(NDI_UNIQUE | NDI_NAVY, 0, op, tmp->msg);
     };  
   
     /* gain xp from reading */      /* gain xp from reading */
     if(!QUERY_FLAG(tmp,FLAG_NO_SKILL_IDENT)) { /* only if not read before */      if(!QUERY_FLAG(tmp,FLAG_NO_SKILL_IDENT)) { /* only if not read before */
Line 1985
 
Line 2097
       return 0;   /* monsters just skip unpaid items */        return 0;   /* monsters just skip unpaid items */
     }      }
   }    }
   /* GROS: This is used to handle apply scripts */  #ifdef PLUGINS
   if (tmp->script_apply!=NULL)    /* GROS: Handle for plugin trigger event */
   {    if(tmp->event_hook[EVENT_APPLY] != NULL)
     rtn_script = guile_call_event(op,tmp, NULL, aflag, NULL,0,0,tmp->script_apply, SCRIPT_FIX_ALL);    {
     if (rtn_script!=0) return 1;      CFParm CFP;
   };      CFParm* CFR;
   if (tmp->script_str_apply!=NULL)      int k, l, m;
       m = 0;
       k = EVENT_APPLY;
       l = SCRIPT_FIX_ALL;
       CFP.Value[0] = &k;
       CFP.Value[1] = op;
       CFP.Value[2] = tmp;
       CFP.Value[3] = NULL;
       CFP.Value[4] = NULL;
       CFP.Value[5] = &aflag;
       CFP.Value[6] = &m;
       CFP.Value[7] = &m;
       CFP.Value[8] = &l;
       CFP.Value[9] = tmp->event_hook[k];
       CFP.Value[10]= tmp->event_options[k];
       if (findPlugin(tmp->event_plugin[k])>=0)
   {    {
     rtn_script = guile_call_event_str(op,tmp, NULL, aflag, NULL,0,0,tmp->script_str_apply, SCRIPT_FIX_ALL);          CFR = (PlugList[findPlugin(tmp->event_plugin[k])].eventfunc) (&CFP);
           rtn_script = *(int *)(CFR->Value[0]);
     if (rtn_script!=0) return 1;      if (rtn_script!=0) return 1;
   };      }
     }
   #endif
   switch (tmp->type)    switch (tmp->type)
   {    {
   case CF_HANDLE:    case CF_HANDLE:
Line 2293
 
Line 2422
   if(op->env!=who)    if(op->env!=who)
     return 1;   /* op is not in inventory */      return 1;   /* op is not in inventory */
   
   /* GROS: This is used to handle apply scripts */  
   if (op->script_apply!=NULL)  
   {  
       guile_call_event(who,op, NULL, aflags, NULL,0,0,op->script_apply, SCRIPT_FIX_ALL);  
   };  
   if (op->script_str_apply!=NULL)  
   {  
         guile_call_event_str(who,op, NULL, aflags, NULL,0,0,op->script_str_apply, SCRIPT_FIX_ALL);  
   };  
   
   buf[0]='\0';     /* Needs to be initialized */    buf[0]='\0';     /* Needs to be initialized */
   if (QUERY_FLAG(op,FLAG_APPLIED)) {    if (QUERY_FLAG(op,FLAG_APPLIED)) {
     /* always apply, so no reason to unapply */      /* always apply, so no reason to unapply */
Line 2459
 
Line 2578
          SET_FLAG(who, FLAG_READY_WEAPON);           SET_FLAG(who, FLAG_READY_WEAPON);
   
     (void) change_abil (who,op);      (void) change_abil (who,op);
     /* GROS: update the current_weapon_script field (used with script_attack for weapons) */  #ifdef PLUGINS
     if ((op->script_attack != NULL)|(op->script_str_attack != NULL))      /* GROS: update the current_weapon_script field (used with EVENT_ATTACK for weapons) */
       if (op->event_hook[EVENT_ATTACK] != NULL)
     {      {
         LOG(llevDebug, "Scripting Weapon wielded\n");          LOG(llevDebug, "Scripting Weapon wielded\n");
         if (who->current_weapon_script) free_string(who->current_weapon_script);          if (who->current_weapon_script) free_string(who->current_weapon_script);
         who->current_weapon_script=add_string(query_name(op));          who->current_weapon_script=add_string(query_name(op));
         who->current_weapon = op;          who->current_weapon = op;
     };      };
   #endif
     sprintf(buf,"You wield %s.",query_name(op));      sprintf(buf,"You wield %s.",query_name(op));
     break;      break;
   }    }


Legend:
line(s) removed in v.1.46 
line(s) changed
 line(s) added in v.1.47

File made using version 1.98 of cvs2html by leaf at 2011-07-21 17:23