コード例 #1
0
/* cause the morph to happen: universal thru this function to prevent errors */
void perform_morph(char_data *ch, ubyte form) {
	ACMD(do_dismount);
	double move_mod, health_mod, mana_mod;

	if (IS_NPC(ch)) {
		return;
	}

	if (IS_RIDING(ch) && form != MORPH_NONE) {
		do_dismount(ch, "", 0, 0);
	}

	// read current pools
	health_mod = (double) GET_HEALTH(ch) / GET_MAX_HEALTH(ch);
	move_mod = (double) GET_MOVE(ch) / GET_MAX_MOVE(ch);
	mana_mod = (double) GET_MANA(ch) / GET_MAX_MANA(ch);

	/* Remove his morph bonuses from his current form */
	update_morph_stats(ch, FALSE);

	/* Set the new form */
	GET_MORPH(ch) = form;

	/* Add new morph bonuses */
	update_morph_stats(ch, TRUE);
	
	// this fixes all the things
	affect_total(ch);

	// set new pools
	GET_HEALTH(ch) = (sh_int) (GET_MAX_HEALTH(ch) * health_mod);
	GET_MOVE(ch) = (sh_int) (GET_MAX_MOVE(ch) * move_mod);
	GET_MANA(ch) = (sh_int) (GET_MAX_MANA(ch) * mana_mod);

	/* check for claws */
	if (MORPH_FLAGGED(ch, MORPH_FLAG_NO_CLAWS) && AFF_FLAGGED(ch, AFF_CLAWS)) {
		affects_from_char_by_aff_flag(ch, AFF_CLAWS);
	}
}
コード例 #2
0
ファイル: graph.c プロジェクト: nawglan/ShadowWind
void hunt_victim(struct char_data * ch)
{
  extern struct char_data *character_list;
  ACMD(do_open);

  int dir;
  byte found;
  struct char_data *tmp;
  struct char_data *hunted_ch;
  char abuf[80];
  char doorname[80];

  if (!ch || !HUNTING(ch) || AFF2_FLAGGED(ch, AFF2_MINOR_PARALIZED) || AFF_FLAGGED(ch, AFF_MAJOR_PARALIZED)) {
    return;
  }

  hunted_ch = find_hunted_char(HUNTING(ch));
  /* make sure the char still exists */
  for (found = 0, tmp = character_list; tmp && !found && hunted_ch; tmp = tmp->next) {
    if (HUNTING(ch) == GET_IDNUM(tmp)) {
      found = 1;
    }
  }

  if (!found) {
    act("$n says, 'Damn!  My prey is gone!!'", TRUE, ch, 0, 0, TO_ROOM);
    /* don't forget vict until they die or I am dead
     HUNTING(ch) = 0;
     */
    return;
  }

  /* dez 19980805
   if (IS_NPC(ch) && MOB_FLAGGED(ch, MOB_SENTINEL)) {
   dir = find_first_step(ch->in_room, hunted_ch->in_room, 2);
   } else if (IS_NPC(ch) && MOB_FLAGGED(ch, MOB_STAY_ZONE)) {
   */

  if (IS_NPC(ch) && MOB_FLAGGED(ch, MOB_STAY_ZONE)) {
    dir = find_first_step(ch->in_room, hunted_ch->in_room, 1);
  } else {
    dir = find_first_step(ch->in_room, hunted_ch->in_room, 0);
  }

  if (dir < 0) {
    sprintf(buf, "$n says 'Damn!  Lost %s!'", HMHR(hunted_ch));
    act(buf, TRUE, ch, 0, 0, TO_ROOM);
    /* don't forget vict until they die or I am dead
     HUNTING(ch) = 0;
     */
    return;
  } else {
    if (IS_CLOSED(ch->in_room, dir)) {
      one_argument(EXIT(ch, dir)->keyword, doorname);
      sprintf(abuf, "%s %s", doorname, dirs[dir]);
      do_open(ch, abuf, 0, 0);
    }
    perform_move(ch, dir, 1);
    if (ch->in_room == hunted_ch->in_room && !ROOM_FLAGGED(hunted_ch->in_room, ROOM_PEACEFUL)) {
      if (CAN_SEE(ch, hunted_ch)) {
        hit(ch, hunted_ch, TYPE_UNDEFINED);
      }
    }
    return;
  }
}
コード例 #3
0
ファイル: handler.c プロジェクト: Calebros/aol
/* Extract a ch completely from the world, and leave his stuff behind */
void extract_char(struct char_data * ch)
{
  struct char_data *k, *temp;
  struct descriptor_data *t_desc;
  struct obj_data *obj;
  int i, freed = 0;
  //int j;

  extern struct char_data *combat_list;

  ACMD(do_return);

  void die_follower(struct char_data * ch);


  if (!IS_NPC(ch) && !ch->desc) {
    for (t_desc = descriptor_list; t_desc; t_desc = t_desc->next) {
      if (t_desc->original == ch) {
	do_return(t_desc->character, "", 0, 0);
      }
    }
  }

  if (ch->in_room == NOWHERE) {
    log("SYSERR: NOWHERE extracting char. (handler.c, extract_char)");
    exit(1);
  }

  if (ch->followers || ch->master) {
    die_follower(ch);
  }

  if (RIDING(ch) || RIDDEN_BY(ch))
   dismount_char(ch);

   REMOVE_BIT(PLR_FLAGS(ch), PLR_FISHING);

   REMOVE_BIT(PLR_FLAGS(ch), PLR_FISH_ON);

   REMOVE_BIT(PLR_FLAGS(ch), PLR_DIGGING);

   REMOVE_BIT(PLR_FLAGS(ch), PLR_DIG_ON);

   REMOVE_BIT(PLR_FLAGS(ch), PLR_FIRE_ON);

   REMOVE_BIT(PRF_FLAGS(ch), PRF_NOTSELF);

   //REMOVE_BIT(PRF_FLAGS(ch), PRF_DISGUISE);
   //REMOVE_BIT(PLR_FLAGS(ch), PLR_MAGE);
   //REMOVE_BIT(PLR_FLAGS(ch), PLR_MONK);
   //REMOVE_BIT(PLR_FLAGS(ch), PLR_KNIGHT);
   //REMOVE_BIT(PLR_FLAGS(ch), PLR_CLERIC);
   //REMOVE_BIT(PLR_FLAGS(ch), PLR_BARD);
   //REMOVE_BIT(PLR_FLAGS(ch), PLR_BEGGAR);
   REMOVE_BIT(PLR_FLAGS(ch), PLR_COURIER);
   REMOVE_BIT(PLR_FLAGS(ch), PLR_BEAR);
   REMOVE_BIT(PLR_FLAGS(ch), PLR_BIRD);
   REMOVE_BIT(PLR_FLAGS(ch), PLR_WOLF);
   REMOVE_BIT(PLR_FLAGS(ch), PLR_RABBIT);
   REMOVE_BIT(PLR_FLAGS(ch), PLR_CAT);

  /* Forget snooping, if applicable */
  if (ch->desc) {
    if (ch->desc->snooping) {
      ch->desc->snooping->snoop_by = NULL;
      ch->desc->snooping = NULL;
    }

    if (ch->desc->snoop_by) {
      SEND_TO_Q("Your victim is no longer among us.\r\n",
		ch->desc->snoop_by);
      ch->desc->snoop_by->snooping = NULL;
      ch->desc->snoop_by = NULL;
    }
  }

  /* transfer objects to room, if any */
  while (ch->carrying) {
    obj = ch->carrying;
    obj_from_char(obj);
    obj_to_room(obj, ch->in_room);
  }

  /* transfer equipment to room, if any */
  for (i = 0; i < NUM_WEARS; i++) {
    if (GET_EQ(ch, i)) {
      obj_to_room(unequip_char(ch, i), ch->in_room);
    }
  }

  if (FIGHTING(ch)) {
    stop_fighting(ch);
  }

  for (k = combat_list; k; k = temp) {
    temp = k->next_fighting;
    if (FIGHTING(k) == ch) {
      stop_fighting(k);
    }
  }

  char_from_room(ch);

  /* pull the char from the list */
  REMOVE_FROM_LIST(ch, character_list, next);

  if (ch->desc && ch->desc->original) {
    do_return(ch, NULL, 0, 0);
  }

  if (!IS_NPC(ch)) {
    save_char(ch, NOWHERE);
    Crash_delete_crashfile(ch);
  } else {
    if (GET_MOB_RNUM(ch) > -1) {     /* if mobile */
      mob_index[GET_MOB_RNUM(ch)].number--;
    }
    clearMemory(ch);		/* Only NPC's can have memory */

    if (SCRIPT(ch)) {
      extract_script(SCRIPT(ch));
    }

    free_char(ch);
    freed = 1;
  }

  if (!freed && ch->desc != NULL) {
    STATE(ch->desc) = CON_MENU;
    SEND_TO_Q(MENU, ch->desc);
  } else {  /* if a player gets purged from within the game */
    if (ch->master || ch->followers)
      die_follower(ch);
    if (!freed) {
      free_char(ch);
    }
  }
}
コード例 #4
0
ファイル: mobact.c プロジェクト: DalilaMud/Dalila-Mud
void mobile_activity(void)
{
  register struct char_data *ch, *next_ch, *vict;
  struct char_data *min_vict = NULL;
  struct obj_data *obj, *next_obj, *best_obj, *cont;
  int door, found, max, where;
  int casual, max_abil=0, curr_abil, gold;
  memory_rec *names;
  room_rnum target_room;

  extern int no_specials;
  ACMD(do_get);

  for (ch = character_list; ch; ch = next_ch) {
    next_ch = ch->next;
    
    if (!IS_MOB(ch))
      continue;
    
    //lance ripristina il master!
 	  if (IS_NPC(ch) && MOB_FLAGGED(ch, MOB_SAVE))
 		  chkmaster(ch);

    // Examine call for special procedure
    if (MOB_FLAGGED(ch, MOB_SPEC) && !no_specials) {
      if (mob_index[GET_MOB_RNUM(ch)].func == NULL) {
	      sprintf(buf, "SYSERR: %s (#%d): Attempting to call non-existing mob func", GET_NAME(ch), GET_MOB_VNUM(ch));
	      log(buf);
	      REMOVE_BIT(MOB_FLAGS(ch), MOB_SPEC);
      }
      else {
	      //(mob_index[GET_MOB_RNUM(ch)].func) (ch, ch, 0, "");
	      if ((mob_index[GET_MOB_RNUM(ch)].func) (ch, ch, 0, ""))
	        continue;	     /*  go to next char*/
      }
    }

// If the mob has no specproc, do the default actions
    if (FIGHTING(ch) || !AWAKE(ch))
      continue;

// Nuovo Scavenger (picking up objects) by Rusty 
    if (MOB_FLAGGED(ch, MOB_SCAVENGER))
	  if (world[ch->in_room].contents && (number(0, 10) > 5)) {
		  max = -1000;
		  best_obj = NULL;
		  for (obj = world[ch->in_room].contents; obj; obj = obj->next_content)
	  	if (CAN_GET_OBJ(ch, obj) && objlevel(obj) > max) {
			  best_obj = obj;
			  max = objlevel(obj);
			}
    
		  if (best_obj != NULL) {
			  obj_from_room(best_obj);
			  obj_to_char(best_obj, ch);
			  act("$n prende $p.", FALSE, ch, best_obj, 0, TO_ROOM);

// Orione, tolta la procedura che fa indossare l'eq raccolto ai mob scavenger
// Scavenger Plus:Mob wear the best object
/*
			  where=find_eq_pos(ch, best_obj, 0);
			  if (CAN_WEAR(best_obj, ITEM_WEAR_WIELD))
			    where=WEAR_WIELD;

			  if ( (where>0) && GET_EQ(ch,where)) {
				  // se ce l'ha gia!
				  if ((objlevel((ch)->equipment[where]))< objlevel(best_obj)) {
				    obj_to_char((obj=unequip_char(ch, where)), ch);
					  act("$n smette di usare $p.", FALSE, ch, obj, 0, TO_ROOM);
				  } 
				  else {
					  where = NUM_WEARS; // cioe' oggetto non indossabile
				  }

				  if (GET_LEVEL(ch)>=objlevel(best_obj)) {
					  if (where>=0 && where <NUM_WEARS) {
						  obj_from_char(best_obj);
						  equip_char(ch,best_obj,where);
						  wear_message(ch,best_obj,where);
					  }
				  }
			  }
*/
		  }
	  } //End ifif

// Mob BodyGuard !?       
    if (MOB_FLAGGED(ch, MOB_BGUARD) && (ch->master)) {
      if (   (FIGHTING(ch->master) && (npc_rescue(ch, ch->master) == FALSE))
	        || (ch->master && WHOKILLED(ch->master)) ) {
        act("$N Si schiera Prontamente al tuo fianco!", FALSE,ch->master, 0, ch, TO_CHAR);
	      act("$n Si schiera prontamente al fianco di $N", FALSE, ch, 0, ch->master, TO_ROOM);
	      if (WHOKILLED(ch->master))	
	        hit(ch, WHOKILLED(ch->master), TYPE_UNDEFINED);/*in ogni caso assiste*/
	      else
	        hit(ch, FIGHTING(ch->master), TYPE_UNDEFINED);/*in ogni caso assiste*/
	    }
     
      if (FIGHTING(ch)) {
	      npc_rescue(ch, ch->master);
		    if (WHOKILLED(ch->master))
		      hit(ch, WHOKILLED(ch->master), TYPE_UNDEFINED);  /*in ogni caso assiste*/
		    continue;
		  }	  
    }

//MOB_THIEF
    if (   MOB_FLAGGED(ch, MOB_CRIMINAL)  && (GET_POS(ch) == POS_RESTING)
        && IS_AFFECTED(ch, AFF_HIDE) && GET_HIT(ch) >= 2*GET_MAX_HIT(ch)/3) {
      appear(ch);
      GET_POS(ch)=POS_STANDING;
    }
    if (   MOB_FLAGGED(ch, MOB_CRIMINAL) 
        && ( GET_POS(ch) == POS_STANDING) 
        && ( (casual = number(0, 11)) < 6 ) ) {   // 50%  Rubare

      // cerca le vittime  1) Devono aver almeno 1 coin  
      //                   2) Deve aver una buona prob di farcela
      for (found=FALSE, min_vict = NULL, vict = world[ch->in_room].people; vict; vict = vict->next_in_room) {
	      if (CAN_SEE(ch, vict) && (vict != ch)) {
	        if ((min_vict == NULL) || (max_abil < 100)) {
	        //se ha il 100% tanto vale fermarsi
	        //Calcolo dell abilita:presa esattamente da D n'D

	          curr_abil = MIN(90, (10*(GET_LEVEL(ch)) - 5*GET_LEVEL(vict)));
	          curr_abil -=  dex_app[GET_DEX(vict)].reaction;
	          if (GET_POS(vict) < POS_STANDING)
	            curr_abil += 200;
	    // Se la vittima e' addormentata-stunned - incap o morta ovviamente
	    //  deruberai questa sicuramente

	          if (   (curr_abil >= 40) 
	              && (GET_GOLD(vict) != 0) 
	              && (curr_abil > max_abil) ) {
	            min_vict = vict;
	            max_abil = curr_abil;
	            found=TRUE;
	          }
	        }
	      }
      }
      // Se ha trovato la vittima
      if (found == TRUE) {
	      if ((casual = number(1, 100)) > max_abil) {
	        if (!IS_NPC(min_vict))
	          act(" $n cerca di prendere dei soldi dal tuo Borsello", FALSE, ch, 0, min_vict, TO_CHAR);
	        else {
	          act("Oops...", FALSE, ch, 0, min_vict, TO_ROOM);
	          act("$n cerca di rubare soldi a $N..Ma viene Scoperto! ", FALSE, ch, 0, min_vict, TO_ROOM);
	        }
	        
	        //Beccato ... fa 2 tentativi di fuga
	        if (((door = number(1, 7)) < NUM_OF_DIRS) && CAN_GO(ch, door) &&
	             !ROOM_FLAGGED(EXIT(ch, door)->to_room, ROOM_NOMOB | ROOM_DEATH) )
	          perform_move(ch,door,1,CAN_SHOW_ROOM);
	        if ((door -= 1) < NUM_OF_DIRS && CAN_GO(ch, door) &&
	             !ROOM_FLAGGED(EXIT(ch, door)->to_room, ROOM_NOMOB | ROOM_DEATH) )
	          perform_move(ch,door,1,CAN_SHOW_ROOM);
	        if ((door += 2) < NUM_OF_DIRS && CAN_GO(ch, door) &&
	             !ROOM_FLAGGED(EXIT(ch, door)->to_room, ROOM_NOMOB | ROOM_DEATH) )
	          perform_move(ch,door,1,CAN_SHOW_ROOM);
	        
	        if (IS_NPC(min_vict)) {
	          act("$n Urla: $N e' uno sporco LADRO!!!!", FALSE, min_vict, 0, ch, TO_ROOM);
	          hit(min_vict, ch, TYPE_UNDEFINED);
	        }
	      }
	      // Il Bastardo ce la fa!
	      else {
	        if (GET_POS(min_vict) < 5) {
	          GET_GOLD(ch) += GET_GOLD(min_vict);
	          GET_GOLD(min_vict) = 0;    //la ripulisce completamente
	        }
	        else {
	          gold = number((GET_GOLD(min_vict) / 10), (GET_GOLD(min_vict) / 2));
	          //gold = MIN(5000, gold);
	          if (gold > 0) {
	            GET_GOLD(ch) += gold;
	            GET_GOLD(min_vict) -= gold;
	            if (GET_GOLD(min_vict) < 0)
	              GET_GOLD(min_vict) = 0;
	          }
	        }
	        // Dopo il furto si allontana
	        if (((door = number(1, 6)) < NUM_OF_DIRS) && CAN_GO(ch, door) &&
	           !ROOM_FLAGGED(EXIT(ch, door)->to_room, ROOM_NOMOB | ROOM_DEATH) )
	          perform_move(ch,door,1,CAN_SHOW_ROOM);
	        if ((door -=1) < NUM_OF_DIRS && CAN_GO(ch, door) &&
	           !ROOM_FLAGGED(EXIT(ch, door)->to_room, ROOM_NOMOB | ROOM_DEATH) )
	          perform_move(ch,door,1,CAN_SHOW_ROOM);
	        if ((door +=2) < NUM_OF_DIRS && CAN_GO(ch, door) &&
	           !ROOM_FLAGGED(EXIT(ch, door)->to_room, ROOM_NOMOB | ROOM_DEATH) )
	          perform_move(ch,door,1,CAN_SHOW_ROOM);
	      }
      }
      else { // Nessuna vittima appetibile:se ne va!
	      
	      if (((door = number(0, 6)) < NUM_OF_DIRS) && CAN_GO(ch, door) &&
	          !ROOM_FLAGGED(EXIT(ch, door)->to_room, ROOM_NOMOB | ROOM_DEATH) )
	        perform_move(ch, door, 1, CAN_SHOW_ROOM);
      }
    }

// Mob Sciacalli indossano EQ    
    if (MOB_FLAGGED(ch, MOB_NECRO) && !FIGHTING(ch) && AWAKE(ch))
    if (world[ch->in_room].contents) {
	    max = -1000;
	    best_obj=NULL;
	    for (cont = world[ch->in_room].contents;cont;cont = cont->next_content)
	    if (GET_OBJ_TYPE(cont) == ITEM_CONTAINER) {
	      for (obj = cont->contains; obj; obj = next_obj) {
		      next_obj = obj->next_content;
		      if (obj != NULL) {
		        if (CAN_SEE_OBJ(ch, obj) && ( (max = objlevel(obj)) <= GET_LEVEL(ch)) ) {
		          perform_get_from_container(ch, obj, cont, FIND_OBJ_INV);
		          if (obj != NULL) {
		            where = find_eq_pos(ch, obj, 0);
		            if (CAN_WEAR(obj, ITEM_WEAR_HOLD))
			            where = WEAR_HOLD;
		            if (GET_OBJ_TYPE(obj)==ITEM_LIGHT)
			            where = WEAR_LIGHT;
		            if (CAN_WEAR(obj, ITEM_WEAR_WIELD))
			            where = WEAR_WIELD;
		            if (where < 0) {
			            sprintf(buf,"SYSERR:pos < 0 ,in cont %s obj %d %s In room %d", 
			                        cont->name, 
			                        GET_OBJ_RNUM(obj), 
			                        obj->name, 
			                        IN_ROOM(ch));
			            log(buf);
			            where = NUM_WEARS;
		            }
		            
		            if (GET_EQ(ch, where) && where < NUM_WEARS) {
			            if ((objlevel((ch)->equipment[where])) < objlevel(obj)) {
			              obj_to_char((best_obj = unequip_char(ch, where)), ch);
			              act("$n smette di usare $p.",FALSE, ch, best_obj, 0, TO_ROOM);
			            }
			            else
			              where = NUM_WEARS;
		            }
		            if (where >= 0 && where < NUM_WEARS) {
			            wear_message(ch, obj, where);
			            obj_from_char(obj);
			            equip_char(ch, obj, where);
		            }
		          }
		        }
		      }
	      }
	    } //End forif
	  } //End ifif

// Mob Movement
    if (HUNTING(ch)) 
      hunt_victim(ch);
    else {
	    if (MOB_FLAGGED(ch , MOB_SEARCHER)) {}
 	    else {
        if (ch->in_room != NOWHERE) {
          if (!IS_IN_WILD(ch)) {
            if (   !MOB_FLAGGED(ch, MOB_SENTINEL) 
                && (GET_POS(ch) == POS_STANDING) 
                && (   (door = number(0, 8)) < NUM_OF_DIRS) 
                    && CAN_GO(ch, door) 
                    && !ROOM_FLAGGED(EXIT(ch, door)->to_room, ROOM_NOMOB | ROOM_DEATH) 
                    && (   !MOB_FLAGGED(ch, MOB_STAY_ZONE) 
                        || (world[EXIT(ch, door)->to_room].zone == world[ch->in_room].zone))) {
              perform_move(ch, door, 1, CAN_SHOW_ROOM);
            }
          }
          else {  // E' in wilderness
            if (MOB_FLAGGED(ch, MOB_WILDHUNT)) 
              door = wild_mobhunter(ch);
            else 
              door = number(0, 8);
            
            if (door >= 0 && door < NUM_OF_DIRS) 
              target_room = wild_target_room(ch, door);
            else 
              target_room = -1;
            
            if (   !MOB_FLAGGED(ch, MOB_SENTINEL) 
                && (GET_POS(ch) == POS_STANDING) 
                && (target_room != -1) 
                && (   !MOB_FLAGGED(ch, MOB_STAY_ZONE) 
                    || (world[target_room].wild_rnum == world[ch->in_room].wild_rnum))) {
              perform_move(ch, door, 1, CAN_SHOW_ROOM);
            }
          }
        }	
      }
    }

// Aggressive Mobs
    if (MOB_FLAGGED(ch, MOB_AGGRESSIVE | MOB_AGGR_TO_ALIGN)) {
      found = FALSE;
      for (vict = world[ch->in_room].people; vict && !found; vict = vict->next_in_room) {
	      if (IS_NPC(vict) || !CAN_SEE(ch, vict) || PRF_FLAGGED(vict, PRF_NOHASSLE))
	        continue;
	      if (number(0, 3) < 2)
	        continue; // Simple simulate Random a Joke from Phantom ;P
	      if (GET_ABIL (vict, ABIL_TRATTATIVA) >= EXPERT_LIV)
	        continue; // I pg con trattativa ad esperto fanno pace con gli aggressivi (by Spini)
	      if (controllo_volo(ch, vict))
		continue;
	      if (affected_by_spell (vict, SPELLSKILL, DISEASE_PESTE))
		continue;

	      if (MOB_FLAGGED(ch, MOB_AGGR_NO_PROP) && (MASTER_ID(ch)==GET_IDNUM(vict)))
	        continue;
	      if (MOB_FLAGGED(ch, MOB_AGGR_NO_CLAN) && (CLAN_ID(ch)==GET_CLAN(vict)))
	        continue;
	      if (MOB_FLAGGED(ch, MOB_AGGR_NO_AL_CLAN) && (GET_CLAN_DIPLO(GET_CLAN(ch),GET_CLAN(vict)) == ALLIANCE))
	        continue;
	      if (MOB_FLAGGED(ch, MOB_AGGR_NO_EN_CLAN) && (GET_CLAN_DIPLO(GET_CLAN(ch),GET_CLAN(vict)) == WAR))
	        continue;
	      if (MOB_FLAGGED(ch, MOB_AGGR_NO_PC_CLAN) && (GET_CLAN_DIPLO(GET_CLAN(ch),GET_CLAN(vict)) == PEACE))
	        continue;
	      if (MOB_FLAGGED(ch, MOB_AGGR_VAS_CLAN) && (GET_CLAN_DIPLO(GET_CLAN(ch),GET_CLAN(vict)) == VASSALLO))
	  	    continue;

        if (   !MOB_FLAGGED(ch, MOB_AGGR_TO_ALIGN) 
            || (MOB_FLAGGED(ch, MOB_AGGR_EVIL) && IS_EVIL(vict)) 
            || (MOB_FLAGGED(ch, MOB_AGGR_NEUTRAL) && IS_NEUTRAL(vict)) 
            || (MOB_FLAGGED(ch, MOB_AGGR_GOOD) && IS_GOOD(vict)) ) {
	        if (GET_MOB_SPEC(ch)== thief)
	          npc_backstab(ch,vict);
	        else
	          hit(ch, vict, TYPE_UNDEFINED);
	        found = TRUE;
	      }
      }
    }

// Mob Memory
    if (MOB_FLAGGED(ch, MOB_MEMORY) && MEMORY(ch)) {
      found = FALSE;
      for (vict = world[ch->in_room].people; vict && !found; vict = vict->next_in_room) {
        if (!CAN_SEE(ch, vict) || PRF_FLAGGED(vict, PRF_NOHASSLE))
          continue;
        for (names = MEMORY(ch); names && !found; names = names->next)
        if (names->id == GET_IDNUM(vict)) {
          found = TRUE;
          act("$n esclama, 'Hey!! Tu sei il tipo che mi ha attaccato!!!'", FALSE, ch, 0, 0, TO_ROOM);
          hit(ch, vict, TYPE_UNDEFINED);
        } //End forif
      }
    }

// Helper Mobs Paladino del bene
    if (   MOB_FLAGGED(ch, MOB_HELPER)
        && !MOB_FLAGGED(ch, MOB_CRIMINALHELPER) ) {
      found = FALSE;
      for (vict = world[ch->in_room].people; vict && !found; vict = vict->next_in_room)
      if (   ch != vict 
          && IS_NPC(vict) 
          && FIGHTING(vict) 
          && !IS_NPC(FIGHTING(vict)) 
          && ch != FIGHTING(vict) ) {			
        if (   MOB_FLAGGED(vict, MOB_CRIMINAL)
            || (   (ch->master)
                && (FIGHTING(vict) == ch->master) ) ) {
	        hit(ch, vict, TYPE_UNDEFINED);
	        found = TRUE;
	      } 		
	      else { 
	        act("$n arriva in aiuto di $N!", FALSE, ch, 0, vict, TO_ROOM);
	        hit(ch, FIGHTING(vict), TYPE_UNDEFINED);
	        found = TRUE;
	      }
	    } //End forif
    }
	
// Helper Mobs Servo del male
    if (   MOB_FLAGGED(ch, MOB_CRIMINALHELPER)
        && !MOB_FLAGGED(ch, MOB_HELPER) ) {
      found = FALSE;
      for (vict = world[ch->in_room].people; vict && !found; vict = vict->next_in_room)
      if (   ch != vict 
          && IS_NPC(vict) 
          && FIGHTING(vict) 
          && !IS_NPC(FIGHTING(vict)) 
          && ch != FIGHTING(vict) ) {			
        if (   MOB_FLAGGED(vict, MOB_CRIMINAL)
            || (   (ch->master) 
                && (vict == ch->master) ) ) {
          act("$n arriva in aiuto di $N!", FALSE, ch, 0, vict, TO_ROOM);
          hit(ch, FIGHTING(vict), TYPE_UNDEFINED);
          found = TRUE;
        }
      } //End forif
    }
	
// Add new mobile actions here

  }				// end for()
}
コード例 #5
0
ファイル: sdtest.c プロジェクト: FreeRTOSHAL/testsystem
void sdtest_task(void *d) {
	struct sd_response res;
	int32_t ret;
	uint32_t arg;
	uint32_t rca;
	(void) data;
	ret = sd_sendCommand(sd, CMD(0), 0, NULL, 100 / portTICK_PERIOD_MS);
	CONFIG_ASSERT(ret == 0);
	{
		arg = 0;
		arg |= (0x1 << 8); /* Select 2.7 - 3.3 V */
		arg |= (0x42 << 0); /* 8 Bit Check Pattern */
		ret = sd_sendCommand(sd, CMD(8), arg, &res, 100 / portTICK_PERIOD_MS);
		/* Only Version >= 2.0 is suppored in this test */
		CONFIG_ASSERT(ret == 0);
		/* Voltage shall acceped and check pattern is 0x42 */
		CONFIG_ASSERT((res.data[3] & 0xFFF) == ((1 << 8) | (0x42 << 0)));
	}
	{
		arg = 0;
		arg |= BIT(19) | BIT(20) | BIT(31); /* aprox 3.3 is used */;
		arg |= BIT(28); /* Switch from Power Save to max perf */
		arg |= BIT(30); /* Acrivate SDHC or SDXC Support */
		do {
			/* Send ACMD41 -> CMD55 + ACMD41 */
			ret = sd_sendCommand(sd, CMD(55), 0, &res, 100 / portTICK_PERIOD_MS);
			CONFIG_ASSERT(ret == 0);
			ret = sd_sendCommand(sd, ACMD(41), arg, &res, 100 / portTICK_PERIOD_MS);
			CONFIG_ASSERT(ret == 0);
			
		} while (((res.data[3] >> 31) & 0x1) != 0x1);
	}
	{
		/* Ask for CID */
		ret = sd_sendCommand(sd, CMD(2), 0, &res, 100 / portTICK_PERIOD_MS);
		CONFIG_ASSERT(ret == 0);
		/* Set Card to ready mode and get RCA*/
		ret = sd_sendCommand(sd, CMD(3), 0, &res, 100 / portTICK_PERIOD_MS);
		CONFIG_ASSERT(ret == 0);
		rca = res.data[3] & 0xFFFF0000;
		/* Set Card is transver mode */
		ret = sd_sendCommand(sd, CMD(7), rca, 0, 100 / portTICK_PERIOD_MS);
		CONFIG_ASSERT(ret == 0);
	}
	testReadWrite();
	{
		arg = 0;
		arg |= 2;
		ret = sd_sendCommand(sd, CMD(55), rca, NULL, 100 / portTICK_PERIOD_MS);
		CONFIG_ASSERT(ret == 0);
		ret = sd_sendCommand(sd, ACMD(6), arg, NULL, 100 / portTICK_PERIOD_MS);
		CONFIG_ASSERT(ret == 0);
		ret = sd_setBusWide(sd, SD_BusWide_4b);
		CONFIG_ASSERT(ret == 0);
	}
	testReadWrite();
	{
		ret = sd_setClock(sd, 48000000);
		CONFIG_ASSERT(ret == 0);
	}
	testReadWrite();
	vTaskSuspend(NULL);
}