当前位置: 首页>>代码示例>>C++>>正文


C++ SCRIPT函数代码示例

本文整理汇总了C++中SCRIPT函数的典型用法代码示例。如果您正苦于以下问题:C++ SCRIPT函数的具体用法?C++ SCRIPT怎么用?C++ SCRIPT使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了SCRIPT函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: extract_obj

/* Extract an object from the world */
void extract_obj(struct obj_data * obj)
{
  struct obj_data *temp;

  if (obj->worn_by != NULL)
    if (unequip_char(obj->worn_by, obj->worn_on) != obj)
      log("SYSERR: Inconsistent worn_by and worn_on pointers!!");
  if (obj->in_room != NOWHERE)
    obj_from_room(obj);
  else if (obj->carried_by)
    obj_from_char(obj);
  else if (obj->in_obj)
    obj_from_obj(obj);

  /* Get rid of the contents of the object, as well. */
  while (obj->contains)
    extract_obj(obj->contains);

  REMOVE_FROM_LIST(obj, object_list, next);

  if (GET_OBJ_RNUM(obj) >= 0)
    (obj_index[GET_OBJ_RNUM(obj)].number)--;

  if (SCRIPT(obj))
    extract_script(SCRIPT(obj));

  free_obj(obj);
}
开发者ID:Calebros,项目名称:aol,代码行数:29,代码来源:handler.c

示例2: SCRIPT_AddSection

ScriptSectionType * SCRIPT_AddSection(int32_t scripthandle, char * sectionname)
{
    ScriptSectionType *s,*s2;

    if (scripthandle < 0 || scripthandle >= MAXSCRIPTFILES) return NULL;
    if (!sectionname) return NULL;
    if (!SC(scripthandle)) return NULL;

    s = SCRIPT_SectionExists(scripthandle, sectionname);
    if (s) return s;

    AllocSection(s);
    s->name = Bstrdup(sectionname);
    if (!SCRIPT(scripthandle,script))
    {
        SCRIPT(scripthandle,script) = s;
    }
    else
    {
        s2 = SCRIPT(scripthandle,script);
        while (s2->nextsection != s2) s2=s2->nextsection;
        s2->nextsection = s;
        s->prevsection = s2;
    }

    return s;
}
开发者ID:Daedolon,项目名称:erampage,代码行数:27,代码来源:scriplib.c

示例3: SCRIPT_Section

char * SCRIPT_Section( int32 scripthandle, int32 which )
{
	ScriptSectionType *s,*ls=NULL;

	if (!SC(scripthandle)) return "";
	if (!SCRIPT(scripthandle,script)) return ""; 

	for (s = SCRIPT(scripthandle,script); which>0 && ls != s; ls=s, s=s->nextsection, which--) ;

	return s->name;
}
开发者ID:jonof,项目名称:jfmact,代码行数:11,代码来源:scriplib.c

示例4: SCRIPT_NumberSections

int32 SCRIPT_NumberSections( int32 scripthandle )
{
	int32 c=0;
	ScriptSectionType *s,*ls=NULL;

	if (!SC(scripthandle)) return 0;
	if (!SCRIPT(scripthandle,script)) return 0;

	for (s = SCRIPT(scripthandle,script); ls != s; ls=s,s=s->nextsection) c++;

	return c;
}
开发者ID:jonof,项目名称:jfmact,代码行数:12,代码来源:scriplib.c

示例5: SCRIPT_SectionExists

ScriptSectionType * SCRIPT_SectionExists( int32 scripthandle, const char * sectionname )
{
	ScriptSectionType *s, *ls=NULL;

	if (scripthandle < 0 || scripthandle >= MAXSCRIPTFILES) return NULL;
	if (!sectionname) return NULL;
	if (!SC(scripthandle)) return NULL;
	if (!SCRIPT(scripthandle,script)) return NULL;

	for (s = SCRIPT(scripthandle,script); ls != s; ls=s,s=s->nextsection)
		if (!Bstrcasecmp(s->name, sectionname)) return s;

	return NULL;
}
开发者ID:jonof,项目名称:jfmact,代码行数:14,代码来源:scriplib.c

示例6: cast_wtrigger

int cast_wtrigger(char_data *actor, char_data *vict, obj_data *obj, int spellnum) {
  room_data *room;
  trig_data *t;
  char buf[MAX_INPUT_LENGTH];

  if (!actor || !SCRIPT_CHECK(&world[IN_ROOM(actor)], WTRIG_CAST))
    return 1;

  room = &world[IN_ROOM(actor)];
  for (t = TRIGGERS(SCRIPT(room)); t; t = t->next) {
    if (TRIGGER_CHECK(t, WTRIG_CAST) &&
            (rand_number(1, 100) <= GET_TRIG_NARG(t))) {

      ADD_UID_VAR(buf, t, actor, "actor", 0);
      if (vict)
        ADD_UID_VAR(buf, t, vict, "victim", 0);
      if (obj)
        ADD_UID_VAR(buf, t, obj, "object", 0);
      sprintf(buf, "%d", spellnum);
      add_var(&GET_TRIG_VARS(t), "spell", buf, 0);
      add_var(&GET_TRIG_VARS(t), "spellname", skill_name(spellnum), 0);
      return script_driver(&room, t, WLD_TRIGGER, TRIG_NEW);
    }
  }

  return 1;
}
开发者ID:carriercomm,项目名称:LuminariMUD,代码行数:27,代码来源:dg_triggers.c

示例7: greet_mtrigger

int greet_mtrigger(char_data *actor, int dir)
{
  trig_data *t;
  char_data *ch;
  char buf[MAX_INPUT_LENGTH];
  int rev_dir[] = { SOUTH, WEST, NORTH, EAST, DOWN, UP };
  int intermediate, final=TRUE;
 
  for (ch = world[IN_ROOM(actor)].people; ch; ch = ch->next_in_room) {
    if (!SCRIPT_CHECK(ch, MTRIG_GREET | MTRIG_GREET_ALL) || 
	!AWAKE(ch) || FIGHTING(ch) || (ch == actor) || 
	AFF_FLAGGED(ch, AFF_CHARM))
      continue;
    
    for (t = TRIGGERS(SCRIPT(ch)); t; t = t->next) {
      if (((IS_SET(GET_TRIG_TYPE(t), MTRIG_GREET) && CAN_SEE(ch, actor)) ||
	   IS_SET(GET_TRIG_TYPE(t), MTRIG_GREET_ALL)) && 
	  !GET_TRIG_DEPTH(t) && (number(1, 100) <= GET_TRIG_NARG(t))) {
        if (dir>=0)
          add_var(&GET_TRIG_VARS(t), "direction", dirs[rev_dir[dir]], 0);
	ADD_UID_VAR(buf, t, actor, "actor", 0);
	intermediate =  script_driver(ch, t, MOB_TRIGGER, TRIG_NEW);
        if (!intermediate) final = FALSE;
	continue;
      }
    }
  }
  return final;
}
开发者ID:matthewbode,项目名称:mg2,代码行数:29,代码来源:dg_triggers.c

示例8: oedit_setup_existing

void oedit_setup_existing(struct descriptor_data *d, int real_num)
{
  struct obj_data *obj;

  /*
   * Allocate object in memory.
   */
  CREATE(obj, struct obj_data, 1);
  copy_object(obj, &obj_proto[real_num]);

  /*
   * Attach new object to player's descriptor.
   */
  OLC_OBJ(d) = obj;
  OLC_VAL(d) = 0;
  OLC_ITEM_TYPE(d) = OBJ_TRIGGER;
  dg_olc_script_copy(d);
  /*
   * The edited obj must not have a script.
   * It will be assigned to the updated obj later, after editing.
   */
  SCRIPT(obj) = NULL;
  OLC_OBJ(d)->proto_script = NULL;

  oedit_disp_menu(d);
}
开发者ID:mysidia,项目名称:circle31dgpy,代码行数:26,代码来源:oedit.c

示例9: cmd_otrig

/* checks for command trigger on specific object. assumes obj has cmd trig */
int cmd_otrig(obj_data *obj, char_data *actor, char *cmd,
        char *argument, int type) {
  trig_data *t;
  char buf[MAX_INPUT_LENGTH];

  if (obj && SCRIPT_CHECK(obj, OTRIG_COMMAND))
    for (t = TRIGGERS(SCRIPT(obj)); t; t = t->next) {
      if (!TRIGGER_CHECK(t, OTRIG_COMMAND))
        continue;

      if (IS_SET(GET_TRIG_NARG(t), type) &&
              (!GET_TRIG_ARG(t) || !*GET_TRIG_ARG(t))) {
        mudlog(NRM, LVL_BUILDER, TRUE, "SYSERR: O-Command Trigger #%d has no text argument!",
                GET_TRIG_VNUM(t));
        continue;
      }

      if (IS_SET(GET_TRIG_NARG(t), type) &&
              (*GET_TRIG_ARG(t) == '*' ||
              !strn_cmp(GET_TRIG_ARG(t), cmd, strlen(GET_TRIG_ARG(t))))) {

        ADD_UID_VAR(buf, t, actor, "actor", 0);
        skip_spaces(&argument);
        add_var(&GET_TRIG_VARS(t), "arg", argument, 0);
        skip_spaces(&cmd);
        add_var(&GET_TRIG_VARS(t), "cmd", cmd, 0);

        if (script_driver(&obj, t, OBJ_TRIGGER, TRIG_NEW))
          return 1;
      }
    }

  return 0;
}
开发者ID:carriercomm,项目名称:LuminariMUD,代码行数:35,代码来源:dg_triggers.c

示例10: consume_otrigger

int consume_otrigger(obj_data *obj, char_data *actor, int cmd) {
  trig_data *t;
  char buf[MAX_INPUT_LENGTH];
  int ret_val;

  if (!SCRIPT_CHECK(obj, OTRIG_CONSUME))
    return 1;

  for (t = TRIGGERS(SCRIPT(obj)); t; t = t->next) {
    if (TRIGGER_CHECK(t, OTRIG_CONSUME)) {
      ADD_UID_VAR(buf, t, actor, "actor", 0);
      switch (cmd) {
        case OCMD_EAT:
          add_var(&GET_TRIG_VARS(t), "command", "eat", 0);
          break;
        case OCMD_DRINK:
          add_var(&GET_TRIG_VARS(t), "command", "drink", 0);
          break;
        case OCMD_QUAFF:
          add_var(&GET_TRIG_VARS(t), "command", "quaff", 0);
          break;
      }
      ret_val = script_driver(&obj, t, OBJ_TRIGGER, TRIG_NEW);
      /* Don't allow a wear to take place, if the object is purged. */
      if (!obj)
        return 0;
      else
        return ret_val;
    }
  }

  return 1;
}
开发者ID:carriercomm,项目名称:LuminariMUD,代码行数:33,代码来源:dg_triggers.c

示例11: speech_mtrigger

void speech_mtrigger(char_data *actor, char *str)
{
  char_data *ch, *ch_next;
  trig_data *t;
  char buf[MAX_INPUT_LENGTH];

  for (ch = world[IN_ROOM(actor)].people; ch; ch = ch_next)
  {
    ch_next = ch->next_in_room;

    if (SCRIPT_CHECK(ch, MTRIG_SPEECH) && AWAKE(ch) &&
        !AFF_FLAGGED(ch, AFF_CHARM) && (actor!=ch))
      for (t = TRIGGERS(SCRIPT(ch)); t; t = t->next) {
        if (!TRIGGER_CHECK(t, MTRIG_SPEECH))
          continue;

        if (!GET_TRIG_ARG(t) || !*GET_TRIG_ARG(t)) {
          sprintf(buf,"SYSERR: Speech Trigger #%d has no text argument!",
            GET_TRIG_VNUM(t));
          mudlog(buf, NRM, LVL_BUILDER, TRUE);
          continue;
        }

        if (((GET_TRIG_NARG(t) && word_check(str, GET_TRIG_ARG(t))) ||
             (!GET_TRIG_NARG(t) && is_substring(GET_TRIG_ARG(t), str)))) {
          ADD_UID_VAR(buf, t, actor, "actor", 0);
          add_var(&GET_TRIG_VARS(t), "speech", str, 0);
          script_driver(ch, t, MOB_TRIGGER, TRIG_NEW);
          break;
        }
      }
  }
}
开发者ID:matthewbode,项目名称:mg2,代码行数:33,代码来源:dg_triggers.c

示例12: remove_otrigger

int remove_otrigger(obj_data *obj, char_data *actor) {
  trig_data *t;
  char buf[MAX_INPUT_LENGTH];
  int ret_val;

  if (!SCRIPT_CHECK(obj, OTRIG_REMOVE))
    return 1;

  if (!valid_dg_target(actor, 0))
    return 1;

  for (t = TRIGGERS(SCRIPT(obj)); t; t = t->next) {
    if (TRIGGER_CHECK(t, OTRIG_REMOVE)) {
      ADD_UID_VAR(buf, t, actor, "actor", 0);
      ret_val = script_driver(&obj, t, OBJ_TRIGGER, TRIG_NEW);
      /* Don't allow a remove to take place, if the object is purged. */
      if (!obj)
        return 0;
      else
        return ret_val;
    }
  }

  return 1;
}
开发者ID:carriercomm,项目名称:LuminariMUD,代码行数:25,代码来源:dg_triggers.c

示例13: leave_otrigger

int leave_otrigger(room_data *room, char_data *actor, int dir) {
  trig_data *t;
  char buf[MAX_INPUT_LENGTH];
  int temp, final = 1;
  obj_data *obj, *obj_next;

  if (!valid_dg_target(actor, DG_ALLOW_GODS))
    return 1;

  for (obj = room->contents; obj; obj = obj_next) {
    obj_next = obj->next_content;
    if (!SCRIPT_CHECK(obj, OTRIG_LEAVE))
      continue;

    for (t = TRIGGERS(SCRIPT(obj)); t; t = t->next) {
      if (TRIGGER_CHECK(t, OTRIG_LEAVE) &&
              (rand_number(1, 100) <= GET_TRIG_NARG(t))) {
        if (dir >= 0 && dir < DIR_COUNT)
          add_var(&GET_TRIG_VARS(t), "direction", dirs[dir], 0);
        else
          add_var(&GET_TRIG_VARS(t), "direction", "none", 0);
        ADD_UID_VAR(buf, t, actor, "actor", 0);
        temp = script_driver(&obj, t, OBJ_TRIGGER, TRIG_NEW);
        if (temp == 0)
          final = 0;
      }
    }
  }

  return final;
}
开发者ID:carriercomm,项目名称:LuminariMUD,代码行数:31,代码来源:dg_triggers.c

示例14: command_wtrigger

int command_wtrigger(char_data *actor, char *cmd, char *argument)
{
  struct room_data *room;
  trig_data *t;
  char buf[MAX_INPUT_LENGTH];

  if (!actor || !SCRIPT_CHECK(&world[IN_ROOM(actor)], WTRIG_COMMAND))
    return 0;

  room = &world[IN_ROOM(actor)];
  for (t = TRIGGERS(SCRIPT(room)); t; t = t->next) {
    if (!TRIGGER_CHECK(t, WTRIG_COMMAND))
      continue;

    if (!GET_TRIG_ARG(t) || !*GET_TRIG_ARG(t)) {
      sprintf(buf,"SYSERR: W-Command Trigger #%d has no text argument!",
        GET_TRIG_VNUM(t));
      mudlog(buf, NRM, LVL_BUILDER, TRUE);
      continue;
    }

    if (*GET_TRIG_ARG(t)=='*' ||
        !strn_cmp(GET_TRIG_ARG(t), cmd, strlen(GET_TRIG_ARG(t)))) {
      ADD_UID_VAR(buf, t, actor, "actor", 0);
      skip_spaces(&argument);
      add_var(&GET_TRIG_VARS(t), "arg", argument, 0);
      skip_spaces(&cmd);
      add_var(&GET_TRIG_VARS(t), "cmd", cmd, 0);
      
      return script_driver(room, t, WLD_TRIGGER, TRIG_NEW);
    }
  }
  
  return 0;
}
开发者ID:matthewbode,项目名称:mg2,代码行数:35,代码来源:dg_triggers.c

示例15: greet_mtrigger

int greet_mtrigger(char_data *actor, int dir) {
  trig_data *t = NULL;
  char_data *ch = NULL;
  char buf[MAX_INPUT_LENGTH] = {'\0'};
  int intermediate = 0, final = TRUE;

  if (!valid_dg_target(actor, DG_ALLOW_GODS))
    return TRUE;

  for (ch = world[IN_ROOM(actor)].people; ch; ch = ch->next_in_room) {
    if (!SCRIPT_CHECK(ch, MTRIG_GREET | MTRIG_GREET_ALL) ||
            !AWAKE(ch) || FIGHTING(ch) || (ch == actor) ||
            AFF_FLAGGED(ch, AFF_CHARM))
      continue;

    for (t = TRIGGERS(SCRIPT(ch)); t; t = t->next) {
      if (((IS_SET(GET_TRIG_TYPE(t), MTRIG_GREET) && CAN_SEE(ch, actor)) ||
              IS_SET(GET_TRIG_TYPE(t), MTRIG_GREET_ALL)) &&
              !GET_TRIG_DEPTH(t) && (rand_number(1, 100) <= GET_TRIG_NARG(t))) {
        if (dir >= 0 && dir < DIR_COUNT)
          add_var(&GET_TRIG_VARS(t), "direction", dirs[rev_dir[dir]], 0);
        else
          add_var(&GET_TRIG_VARS(t), "direction", "none", 0);
        ADD_UID_VAR(buf, t, actor, "actor", 0);
        intermediate = script_driver(&ch, t, MOB_TRIGGER, TRIG_NEW);
        if (!intermediate) final = FALSE;
        continue;
      }
    }
  }
  return final;
}
开发者ID:carriercomm,项目名称:LuminariMUD,代码行数:32,代码来源:dg_triggers.c


注:本文中的SCRIPT函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。