コード例 #1
0
ファイル: reset.c プロジェクト: andycervantes/SMAUG-Pi
void add_obj_reset( ROOM_INDEX_DATA * room, char cm, OBJ_DATA * obj, int v2, int v3 )
{
	OBJ_DATA *inobj;
	static int iNest;

	if ( ( cm == 'O' || cm == 'P' ) && obj->pIndexData->vnum == OBJ_VNUM_TRAP )
	{
		if ( cm == 'O' )
			add_reset( room, 'T', obj->value[3], obj->value[1], obj->value[0], v3 );
		return;
	}
	add_reset( room, cm, ( cm == 'P' ? iNest : 0 ), obj->pIndexData->vnum, v2, v3 );
	if ( cm == 'O' && IS_OBJ_STAT( obj, ITEM_HIDDEN ) && !CAN_WEAR( obj, ITEM_TAKE ) )
		add_reset( room, 'H', 1, 0, 0, 0 );
	for ( inobj = obj->first_content; inobj; inobj = inobj->next_content )
	{
		if ( inobj->pIndexData->vnum == OBJ_VNUM_TRAP )
			add_obj_reset( room, 'O', inobj, 0, 0 );
	}
	if ( cm == 'P' )
		iNest++;
	for ( inobj = obj->first_content; inobj; inobj = inobj->next_content )
		add_obj_reset( room, 'P', inobj, inobj->count, obj->pIndexData->vnum );
	if ( cm == 'P' )
		iNest--;
	return;
}
コード例 #2
0
ファイル: bytecode.c プロジェクト: bagucode/Carp
void visit_form(Process *process, Obj *env, Obj *bytecodeObj, int *position, Obj *form) {
  if(eval_error) {
    return;
  }
  else if(form->tag == 'C') {
    if(form->car->car == NULL) {
      add_literal(bytecodeObj, position, nil);
    }
    else if(HEAD_EQ("quote")) {
      add_literal(bytecodeObj, position, form->car);
    }
    else if(HEAD_EQ("if")) {
      add_if(process, env, bytecodeObj, position, form);
    }
    else if(HEAD_EQ("while")) {
      add_while(process, env, bytecodeObj, position, form);
    }
    else if(HEAD_EQ("do")) {
      add_do(process, env, bytecodeObj, position, form);
    }
    else if(HEAD_EQ("let")) {
      add_let(process, env, bytecodeObj, position, form);
    }
    else if(HEAD_EQ("def")) {
      add_def(process, env, bytecodeObj, position, form);
    }
    else if(HEAD_EQ("reset!")) {
      add_reset(process, env, bytecodeObj, position, form);
    }
    else if(HEAD_EQ("ref")) {
      add_ref(process, env, bytecodeObj, position, form);
    }
    /* else if(HEAD_EQ("or")) { */
    /*   add_or(process, env, bytecodeObj, position, form); */
    /* } */
    else if(HEAD_EQ("not")) {
      add_not(process, env, bytecodeObj, position, form);
    }
    else if(HEAD_EQ("fn")) {
      Obj *lambda = obj_new_lambda(form->cdr->car, form_to_bytecode(process, env, form->cdr->cdr->car), env, form);
      add_literal(bytecodeObj, position, lambda);
    }
    else {
      add_call(process, env, bytecodeObj, position, form);
    }
  }
  else if(form->tag == 'Y') {
    add_lookup(bytecodeObj, position, form);
  }
  else {
    add_literal(bytecodeObj, position, form);
  }
  /* else { */
  /*   printf("Bytecode can't handle form: "); */
  /*   obj_print_cout(form); */
  /*   exit(1); */
  /* } */
}
コード例 #3
0
ファイル: reset.c プロジェクト: andycervantes/SMAUG-Pi
void instaroom( ROOM_INDEX_DATA * pRoom, bool dodoors )
{
	CHAR_DATA *rch;
	OBJ_DATA *obj;

	for ( rch = pRoom->first_person; rch; rch = rch->next_in_room )
	{
		if ( !IS_NPC( rch ) )
			continue;

		add_reset( pRoom, 'M', 1, rch->pIndexData->vnum, rch->pIndexData->count, pRoom->vnum );

		for ( obj = rch->first_carrying; obj; obj = obj->next_content )
		{
			if ( obj->wear_loc == WEAR_NONE )
				add_obj_reset( pRoom, 'G', obj, 1, 0 );
			else
				add_obj_reset( pRoom, 'E', obj, 1, obj->wear_loc );
		}
	}
	for ( obj = pRoom->first_content; obj; obj = obj->next_content )
		add_obj_reset( pRoom, 'O', obj, obj->count, pRoom->vnum );
	if ( dodoors )
	{
		EXIT_DATA *pexit;

		for ( pexit = pRoom->first_exit; pexit; pexit = pexit->next )
		{
			int state = 0;

			if ( !IS_SET( pexit->exit_info, EX_ISDOOR ) )
				continue;

			if ( IS_SET( pexit->exit_info, EX_CLOSED ) )
			{
				if ( IS_SET( pexit->exit_info, EX_LOCKED ) )
					state = 2;
				else
					state = 1;
			}
			add_reset( pRoom, 'D', 0, pRoom->vnum, pexit->vdir, state );
		}
	}
	return;
}
コード例 #4
0
ファイル: update.c プロジェクト: athanos/Forgotten-Legacy
void reset_update(void)
{
	char buf[MAX_BUFFER];
	CREATURE *crit=0;
	OBJECT *obj=0, *container=0;;
	RESET *reset=0, *reset_next=0, *orig=0;
	EXIT *exit=0;
	long min=0;

	for(reset = hash_reset[(current_time)%HASH_KEY]; reset; reset = reset_next)
	{
		reset_next = reset->next_hash;

		if(current_time < reset->poptime)
			continue;

		if( percent() < reset->chance
		|| (reset->max && reset->loaded >= reset->max))
		{
			add_reset(reset);
			continue;
		}
	
		obj = container = 0;
		crit = 0;

		for(orig = reset; reset; reset = reset->next)
		{
			// each reset has a chance to load.. don't have to calculate the first reset again though
			// hence the reset->prev
			if((reset->prev
			&&  percent() < reset->chance)
			|| (reset->max && reset->loaded >= reset->max))
				continue;

			min = reset->min;

			while(min > 0 && reset->loaded < reset->max)
			{
				switch(reset->loadtype)
				{
				case TYPE_CREATURE:
					crit		= new_creature(reset->crit->vnum);
					crit->reset	= reset;
					reset->loaded++;
					// trans crit to room
					trans(crit, reset->room);

					// if builder put in some command for the mob to do at spawn, put it here
					if(reset->command)
						interpret(crit, reset->command);

					// reset container to 0 in case more objects load on this mob
					container = 0;
					break;
				case TYPE_OBJECT:
					obj		= new_object(reset->obj->vnum);
					obj->reset	= reset;
					reset->loaded++;

					// trans obj to container, or crit, or room.. in that order
					trans(obj, container ? (void*)container : crit ? (void*)crit : (void*)reset->room);

					// when object pops on a mob the builder has the option to make the crit wear it...
					if(crit && ValidString(reset->command))
					{
						sprintf(buf, "wear %s", reset->command);
						interpret(crit, buf);
					}

					// if this is a container, set the pointer so stacking can occur
					if(obj->objtype == OBJ_CONTAINER)
						container = obj;
					break;
				case TYPE_EXIT:
					if(!(exit = find_exit(reset->room, reset->command)))
					{
						mudlog("RESET_UPDATE: no exit found for reset#%li",reset->id);	
						break;
					}
					exit->door = reset->loaded;
					break;
				}
				min--;
			}
		}

		add_reset(orig);
	}
}