static int slot_allocate(struct sbd_context *st, const char *name) { struct sector_header_s *s_header = NULL; struct sector_node_s *s_node = NULL; struct sector_mbox_s *s_mbox = NULL; int i; int rc = 0; if (!name) { cl_log(LOG_ERR, "slot_allocate(): No name specified.\n"); fprintf(stderr, "slot_allocate(): No name specified.\n"); rc = -1; goto out; } s_header = header_get(st); if (!s_header) { rc = -1; goto out; } s_node = sector_alloc(); s_mbox = sector_alloc(); while (1) { i = slot_lookup(st, s_header, name); if ((i >= 0) || (i == -2)) { /* -1 is "no slot found", in which case we * proceed to allocate a new one. * -2 is "read error during lookup", in which * case we error out too * >= 0 is "slot already allocated" */ rc = i; goto out; } i = slot_unused(st, s_header); if (i >= 0) { cl_log(LOG_INFO, "slot %d is unused - trying to own", i); fprintf(stdout, "slot %d is unused - trying to own\n", i); memset(s_node, 0, sizeof(*s_node)); s_node->in_use = 1; strncpy(s_node->name, name, sizeof(s_node->name)); if (slot_write(st, i, s_node) < 0) { rc = -1; goto out; } sleep(timeout_allocate); } else { cl_log(LOG_ERR, "No more free slots."); fprintf(stderr, "No more free slots.\n"); rc = -1; goto out; } } out: free(s_node); free(s_header); free(s_mbox); return(rc); }
bool install_slot(struct objc_object *obj, int offset, IMP method, char * types, uint32_t sel) { //Type must match selector type char * seltypes = types_for_selector(sel); if(safestrcmp(seltypes, types) != 0) { return false; } objc_lock_object(obj); if(SLOTS(obj) == NULL) { SLOTS(obj) = SparseArrayNew(); } struct objc_slot * oldSlot = SparseArrayLookup(SLOTS(obj), sel); if(oldSlot) { if(safestrcmp(types, oldSlot->types) != 0) { objc_unlock_object(obj); return false; } oldSlot->offset = offset; oldSlot->method = method; } else { //We are adding a new slot, not modifying an old one, so we need to //invalidate a load of caches. id object = obj; oldSlot = slot_lookup(&object, sel, nil); struct objc_slot * newslot = calloc(1, sizeof(struct objc_slot)); //TODO: Factor this out into a slot constructor newslot->offset = offset; newslot->method = method; if(types == NULL) { newslot->types = NULL; } else { newslot->types = strdup(types); } if(oldSlot != NULL) { oldSlot->version++; } SparseArrayInsert(SLOTS(obj), sel, newslot); } objc_unlock_object(obj); return true; }
struct objc_slot * slot_lookup(struct objc_object ** obj, uint32_t sel, id sender) { //0 is an invalid selector. if(sel == 0) { return NULL; } struct objc_slot * ret = real_slot_lookup(obj, sel, sender); if(ret == NULL && sel != forwardSelector) { return slot_lookup(obj, forwardSelector, sender); } return ret; }
static bool tprog_spell_check(int sn, CHAR_DATA * actor, OBJ_DATA * obj, void *vo, int type, TRAP_DATA * tprogs) { TRAP_DATA *tprg; for (tprg = tprogs; tprg != NULL; tprg = tprg->next_here) if ((tprg->type & type) && (is_sn(sn)) && (sn == slot_lookup(atoi(tprg->arglist)))) { mprog_driver(tprg->comlist, smob, actor, obj, vo); return TRUE; } return FALSE; }
affect_data *fread_fuss_affect( FILE * fp, const char *word ) { int pafmod; affect_data *paf = new affect_data; paf->location = APPLY_NONE; paf->type = -1; paf->duration = -1; paf->bit = 0; paf->modifier = 0; paf->rismod.reset( ); if( !strcmp( word, "Affect" ) ) { paf->type = fread_number( fp ); } else { int sn; sn = skill_lookup( fread_word( fp ) ); if( sn < 0 ) bug( "%s: unknown skill.", __func__ ); else paf->type = sn; } paf->duration = fread_number( fp ); pafmod = fread_number( fp ); paf->location = fread_number( fp ); fread_bitvector( fp ); // Bit conversions don't take for this. if( paf->location == APPLY_WEAPONSPELL || paf->location == APPLY_WEARSPELL || paf->location == APPLY_STRIPSN || paf->location == APPLY_REMOVESPELL || paf->location == APPLY_RECURRINGSPELL ) paf->modifier = slot_lookup( pafmod ); else paf->modifier = pafmod; ++top_affect; return paf; }
CHAR_DATA *load_mobile( FILE * fp ) { CHAR_DATA *mob = NULL; const char *word; bool fMatch; int inroom = 0; ROOM_INDEX_DATA *pRoomIndex = NULL; word = feof( fp ) ? "EndMobile" : fread_word( fp ); if( !str_cmp( word, "Vnum" ) ) { int vnum; vnum = fread_number( fp ); if( get_mob_index( vnum ) == NULL ) { bug( "%s: No index data for vnum %d", __FUNCTION__, vnum ); return NULL; } mob = create_mobile( get_mob_index( vnum ) ); if( !mob ) { for( ;; ) { word = feof( fp ) ? "EndMobile" : fread_word( fp ); /* * So we don't get so many bug messages when something messes up * * --Shaddai */ if( !str_cmp( word, "EndMobile" ) ) break; } bug( "%s: Unable to create mobile for vnum %d", __FUNCTION__, vnum ); return NULL; } } else { for( ;; ) { word = feof( fp ) ? "EndMobile" : fread_word( fp ); /* * So we don't get so many bug messages when something messes up * * --Shaddai */ if( !str_cmp( word, "EndMobile" ) ) break; } extract_char( mob, TRUE ); bug( "%s: Vnum not found", __FUNCTION__ ); return NULL; } for( ;; ) { word = feof( fp ) ? "EndMobile" : fread_word( fp ); fMatch = FALSE; switch ( UPPER( word[0] ) ) { case '*': fMatch = TRUE; fread_to_eol( fp ); break; case '#': if( !str_cmp( word, "#OBJECT" ) ) { mob->tempnum = -9999; /* Hackish, yes. Works though doesn't it? */ fread_obj( mob, fp, OS_CARRY ); } break; case 'A': if( !str_cmp( word, "Affect" ) || !str_cmp( word, "AffectData" ) ) { AFFECT_DATA *paf; CREATE( paf, AFFECT_DATA, 1 ); if( !str_cmp( word, "Affect" ) ) { paf->type = fread_number( fp ); } else { int sn; const char *sname = fread_word( fp ); if( ( sn = skill_lookup( sname ) ) < 0 ) { if( ( sn = herb_lookup( sname ) ) < 0 ) bug( "%s", "load_mobile: unknown skill." ); else sn += TYPE_HERB; } paf->type = sn; } paf->duration = fread_number( fp ); paf->modifier = fread_number( fp ); paf->location = fread_number( fp ); if( paf->location == APPLY_WEAPONSPELL || paf->location == APPLY_WEARSPELL || paf->location == APPLY_REMOVESPELL || paf->location == APPLY_STRIPSN ) paf->modifier = slot_lookup( paf->modifier ); paf->bitvector = fread_bitvector( fp ); LINK( paf, mob->first_affect, mob->last_affect, next, prev ); fMatch = TRUE; break; } KEY( "AffectedBy", mob->affected_by, fread_bitvector( fp ) ); break; #ifdef OVERLANDCODE case 'C': if( !str_cmp( word, "Coordinates" ) ) { mob->x = fread_number( fp ); mob->y = fread_number( fp ); mob->map = fread_number( fp ); fMatch = TRUE; break; } break; #endif case 'D': if( !str_cmp( word, "Description" ) ) { STRFREE( mob->description ); mob->description = fread_string( fp ); fMatch = TRUE; break; } break; case 'E': if( !str_cmp( word, "EndMobile" ) ) { if( inroom == 0 ) inroom = ROOM_VNUM_LIMBO; pRoomIndex = get_room_index( inroom ); if( !pRoomIndex ) pRoomIndex = get_room_index( ROOM_VNUM_LIMBO ); char_to_room( mob, pRoomIndex ); mob->tempnum = -9998; /* Yet another hackish fix! */ update_room_reset( mob, FALSE ); return mob; } if( !str_cmp( word, "End" ) ) /* End of object, need to ignore this. sometimes they creep in there somehow -- Scion */ fMatch = TRUE; /* Trick the system into thinking it matched something */ break; case 'F': KEY( "Flags", mob->act, fread_number( fp ) ); break; case 'G': KEY( "Gold", mob->gold, fread_number( fp ) ); break; case 'H': if( !str_cmp( word, "HpManaMove" ) ) { mob->hit = fread_number( fp ); mob->max_hit = fread_number( fp ); mob->mana = fread_number( fp ); mob->max_mana = fread_number( fp ); mob->move = fread_number( fp ); mob->max_move = fread_number( fp ); if( mob->max_move <= 0 ) mob->max_move = 150; fMatch = TRUE; break; } break; case 'L': if( !str_cmp( word, "Long" ) ) { STRFREE( mob->long_descr ); mob->long_descr = fread_string( fp ); fMatch = TRUE; break; } KEY( "Level", mob->top_level, fread_number( fp ) ); break; case 'M': if( !str_cmp( word, "Mobclan" ) ) { STRFREE( mob->mob_clan ); mob->mob_clan = fread_string( fp ); fMatch = TRUE; break; } break; case 'N': if( !str_cmp( word, "Name" ) ) { STRFREE( mob->name ); mob->name = fread_string( fp ); fMatch = TRUE; break; } break; case 'P': KEY( "Position", mob->position, fread_number( fp ) ); break; case 'R': KEY( "Room", inroom, fread_number( fp ) ); KEY( "Resetvnum", mob->resetvnum, fread_number( fp ) ); KEY( "Resetnum", mob->resetnum, fread_number( fp ) ); break; case 'S': if( !str_cmp( word, "Short" ) ) { STRFREE( mob->short_descr ); mob->short_descr = fread_string( fp ); fMatch = TRUE; break; } break; } if( !fMatch && str_cmp( word, "End" ) ) bug( "%s: no match: %s", __FUNCTION__, word ); } return NULL; }
/* * Snarf an obj section. old style */ void load_obj_circle( FILE *fp ) { OBJ_INDEX_DATA *pObjIndex; char *word; log_stringf(" OBJECTS"); if ( !area_last ) { /* OLC */ bug( "Load_obj_circle: no #AREA seen yet."); exit( 1 ); } for ( ; ; ) { int vnum; char letter; int iHash; int x1, x2, x3, x4, x5, x6; letter = fread_letter( fp ); if ( letter != '#' ) { bug( "Load_obj_circle: # not found."); exit( 1 ); } vnum = fread_number( fp ); if ( vnum == 0 ) break; fBootDb = FALSE; if ( get_obj_index( vnum ) != NULL ) { bug( "Load_obj_circle: vnum %d duplicated.", vnum ); exit( 1 ); } fBootDb = TRUE; pObjIndex = new_obj_index(); pObjIndex->vnum = vnum; pObjIndex->area = area_last; /* OLC */ pObjIndex->new_format = FALSE; pObjIndex->reset_num = 0; newobjs++; pObjIndex->name = fread_string( fp ); pObjIndex->short_descr = fread_string_lower( fp ); pObjIndex->description = fread_string_upper( fp ); fread_string( fp ); // unused: action desc pObjIndex->material = 0; pObjIndex->item_type = fread_number( fp ); pObjIndex->extra_flags = fread_flag_circle( fp ); pObjIndex->wear_flags = fread_flag_circle( fp ); fread_flag_circle(fp); // unused ? pObjIndex->size = SIZE_NOSIZE; pObjIndex->value[0] = fread_number(fp); pObjIndex->value[1] = fread_number(fp); pObjIndex->value[2] = fread_number(fp); pObjIndex->value[3] = fread_number(fp); pObjIndex->weight = UMAX( 1, fread_number( fp ) ); pObjIndex->cost = fread_number( fp ); fread_number( fp ); // unused: rent/day fread_number(fp); // unused ? pObjIndex->condition = 100; pObjIndex->level = 1; for ( ; ; ) { letter = fread_letter( fp ); if ( letter == 'A' ) { AFFECT_DATA *paf; paf = new_affect(); createaff(*paf,-1,20,-1,0,AFFECT_INHERENT); addaff2(*paf,AFTO_CHAR,fread_number( fp ),AFOP_ADD,fread_number( fp )); //paf->where = AFTO_CHAR; //paf->op = AFOP_ADD; //paf->type = -1; //paf->level = 20; /* RT temp fix */ //paf->duration = -1; //paf->location = fread_number( fp ); //paf->modifier = fread_number( fp ); convert_af_circle( paf ); paf->next = pObjIndex->affected; pObjIndex->affected = paf; } else if ( letter == 'E' ) { EXTRA_DESCR_DATA *ed; // ed = (EXTRA_DESCR_DATA *) alloc_perm( sizeof(*ed) ); ed = new_extra_descr(); ed->keyword = fread_string( fp ); ed->description = fread_string( fp ); ed->next = pObjIndex->extra_descr; pObjIndex->extra_descr = ed; } else if ( letter == 'T' ) { // script int scriptVnum = fread_number( fp ); char buf[MAX_STRING_LENGTH]; sprintf( buf, "obj%d", scriptVnum ); pObjIndex->program = hash_get_prog(buf); if (!pObjIndex->program) bug("Can't find program for obj vnum %d.", pObjIndex->vnum); else { if ( get_root_class( pObjIndex->program ) != default_obj_class ) { bug("program for obj vnum %d is not a mob program." ,pObjIndex->vnum); pObjIndex->program = NULL; } else if ( pObjIndex->program->isAbstract ) bug("program for Obj vnum %d is an ABSTRACT class.", pObjIndex->vnum ); } } else { ungetc( letter, fp ); break; } } switch ( pObjIndex->item_type ) { case CIRCLE_ITEM_POTION: case CIRCLE_ITEM_SCROLL: pObjIndex->value[1] = slot_lookup( pObjIndex->value[1] ); pObjIndex->value[2] = slot_lookup( pObjIndex->value[2] ); pObjIndex->value[3] = slot_lookup( pObjIndex->value[3] ); break; case CIRCLE_ITEM_STAFF: case CIRCLE_ITEM_WAND: pObjIndex->value[3] = slot_lookup( pObjIndex->value[3] ); break; } convert_obj_circle( pObjIndex ); iHash = vnum % MAX_KEY_HASH; pObjIndex->next = obj_index_hash[iHash]; obj_index_hash[iHash] = pObjIndex; top_vnum_obj = top_vnum_obj < vnum ? vnum : top_vnum_obj; /* OLC */ assign_area_vnum( vnum ); /* OLC */ } return; }
/* * Snarf an obj section. */ void load_objects( FILE *fp ) { OBJ_INDEX_DATA *pObjIndex; for ( ; ; ) { sh_int vnum; char letter; int iHash; letter = fread_letter( fp ); if ( letter != '#' ) { bug( "Load_objects: # not found.", 0 ); exit( 1 ); } vnum = fread_number( fp ); if ( vnum == 0 ) break; fBootDb = FALSE; if ( get_obj_index( vnum ) != NULL ) { bug( "Load_objects: vnum %d duplicated.", vnum ); exit( 1 ); } fBootDb = TRUE; pObjIndex = alloc_perm( sizeof(*pObjIndex) ); pObjIndex->vnum = vnum; pObjIndex->name = fread_string( fp ); pObjIndex->short_descr = fread_string( fp ); pObjIndex->description = fread_string( fp ); /* Action description */ fread_string( fp ); pObjIndex->short_descr[0] = LOWER(pObjIndex->short_descr[0]); pObjIndex->description[0] = UPPER(pObjIndex->description[0]); pObjIndex->item_type = fread_number( fp ); pObjIndex->extra_flags = fread_number( fp ); pObjIndex->wear_flags = fread_number( fp ); pObjIndex->value[0] = fread_number( fp ); pObjIndex->value[1] = fread_number( fp ); pObjIndex->value[2] = fread_number( fp ); pObjIndex->value[3] = fread_number( fp ); pObjIndex->weight = fread_number( fp ); pObjIndex->cost = fread_number( fp ); /* Unused */ /* Cost per day */ fread_number( fp ); if ( pObjIndex->item_type == ITEM_POTION ) SET_BIT(pObjIndex->extra_flags, ITEM_NODROP); for ( ; ; ) { char letter; letter = fread_letter( fp ); if ( letter == 'A' ) { AFFECT_DATA *paf; paf = alloc_perm( sizeof(*paf) ); paf->type = -1; paf->duration = -1; paf->location = fread_number( fp ); paf->modifier = fread_number( fp ); paf->bitvector = 0; paf->next = pObjIndex->affected; pObjIndex->affected = paf; top_affect++; } else if ( letter == 'E' ) { EXTRA_DESCR_DATA *ed; ed = alloc_perm( sizeof(*ed) ); ed->keyword = fread_string( fp ); ed->description = fread_string( fp ); ed->next = pObjIndex->extra_descr; pObjIndex->extra_descr = ed; top_ed++; } else { ungetc( letter, fp ); break; } } /* * Translate spell "slot numbers" to internal "skill numbers." */ switch ( pObjIndex->item_type ) { case ITEM_PILL: case ITEM_POTION: case ITEM_SCROLL: pObjIndex->value[1] = slot_lookup( pObjIndex->value[1] ); pObjIndex->value[2] = slot_lookup( pObjIndex->value[2] ); pObjIndex->value[3] = slot_lookup( pObjIndex->value[3] ); break; case ITEM_STAFF: case ITEM_WAND: pObjIndex->value[3] = slot_lookup( pObjIndex->value[3] ); break; } iHash = vnum % MAX_KEY_HASH; pObjIndex->next = obj_index_hash[iHash]; obj_index_hash[iHash] = pObjIndex; top_obj_index++; } return; }
static int slot_ping(struct sbd_context *st, const char *name) { struct sector_header_s *s_header = NULL; struct sector_mbox_s *s_mbox = NULL; int mbox; int waited = 0; int rc = 0; if (!name) { cl_log(LOG_ERR, "slot_ping(): No recipient specified.\n"); rc = -1; goto out; } s_header = header_get(st); if (!s_header) { rc = -1; goto out; } if (strcmp(name, "LOCAL") == 0) { name = local_uname; } mbox = slot_lookup(st, s_header, name); if (mbox < 0) { cl_log(LOG_ERR, "slot_msg(): No slot found for %s.", name); rc = -1; goto out; } s_mbox = sector_alloc(); s_mbox->cmd = SBD_MSG_TEST; strncpy(s_mbox->from, local_uname, sizeof(s_mbox->from)-1); DBGLOG(LOG_DEBUG, "Pinging node %s", name); if (mbox_write(st, mbox, s_mbox) < -1) { rc = -1; goto out; } rc = -1; while (waited <= timeout_msgwait) { if (mbox_read(st, mbox, s_mbox) < 0) break; if (s_mbox->cmd != SBD_MSG_TEST) { rc = 0; break; } sleep(1); waited++; } if (rc == 0) { cl_log(LOG_DEBUG, "%s successfully pinged.", name); } else { cl_log(LOG_ERR, "%s failed to ping.", name); } out: free(s_mbox); free(s_header); return rc; }
static int slot_msg(struct sbd_context *st, const char *name, const char *cmd) { struct sector_header_s *s_header = NULL; struct sector_mbox_s *s_mbox = NULL; int mbox; int rc = 0; char uuid[37]; if (!name || !cmd) { cl_log(LOG_ERR, "slot_msg(): No recipient / cmd specified.\n"); rc = -1; goto out; } s_header = header_get(st); if (!s_header) { rc = -1; goto out; } if (strcmp(name, "LOCAL") == 0) { name = local_uname; } if (s_header->minor_version > 0) { uuid_unparse_lower(s_header->uuid, uuid); cl_log(LOG_INFO, "Device UUID: %s", uuid); } mbox = slot_lookup(st, s_header, name); if (mbox < 0) { cl_log(LOG_ERR, "slot_msg(): No slot found for %s.", name); rc = -1; goto out; } s_mbox = sector_alloc(); s_mbox->cmd = cmd2char(cmd); if (s_mbox->cmd < 0) { cl_log(LOG_ERR, "slot_msg(): Invalid command %s.", cmd); rc = -1; goto out; } strncpy(s_mbox->from, local_uname, sizeof(s_mbox->from)-1); cl_log(LOG_INFO, "Writing %s to node slot %s", cmd, name); if (mbox_write_verify(st, mbox, s_mbox) < -1) { rc = -1; goto out; } if (strcasecmp(cmd, "exit") != 0) { cl_log(LOG_INFO, "Messaging delay: %d", (int)timeout_msgwait); sleep(timeout_msgwait); } cl_log(LOG_INFO, "%s successfully delivered to %s", cmd, name); out: free(s_mbox); free(s_header); return rc; }
/* * Apply or remove an affect to a character. */ void affect_modify( CHAR_DATA *ch, AFFECT_DATA *paf, bool fAdd ) { OBJ_DATA *wield; int mod,i; mod = paf->modifier; if ( fAdd ) { SET_BIT( ch->affected_by, paf->bitvector ); SET_BIT( ch->affected_by_2, paf->bitvector_2 ); } else { REMOVE_BIT( ch->affected_by, paf->bitvector ); REMOVE_BIT( ch->affected_by_2, paf->bitvector_2 ); mod = 0 - mod; } switch ( paf->location ) { default: bug( "Affect_modify: unknown location %d.", paf->location ); return; case APPLY_NONE: break; case APPLY_STR: ch->mod_stat[STAT_STR] += mod; break; case APPLY_DEX: ch->mod_stat[STAT_DEX] += mod; break; case APPLY_INT: ch->mod_stat[STAT_INT] += mod; break; case APPLY_WIS: ch->mod_stat[STAT_WIS] += mod; break; case APPLY_CON: ch->mod_stat[STAT_CON] += mod; break; case APPLY_CHR: ch->mod_stat[STAT_CHR] += mod; break; case APPLY_LUK: ch->mod_stat[STAT_LUK] += mod; break; case APPLY_AGI: ch->mod_stat[STAT_AGI] += mod; break; case APPLY_SEX: ch->sex += mod; break; case APPLY_CLASS: break; case APPLY_LEVEL: break; case APPLY_AGE: break; case APPLY_HEIGHT: break; case APPLY_WEIGHT: break; case APPLY_HIT: ch->max_hit += mod; break; case APPLY_STAMINA: ch->max_stamina += mod; break; case APPLY_GOLD: break; case APPLY_EXP: break; case APPLY_AC: for (i = 0; i < 4; i ++) ch->armor[i] += mod; break; case APPLY_HITROLL: ch->hitroll += mod; break; case APPLY_DAMROLL: ch->damroll += mod; break; case APPLY_SPELL: apply_spell( ch, mod ); break; case APPLY_SKILL: if ( !IS_NPC(ch) ) { if ( mod >= 0 ) { if ( ch->pcdata->skill_mod[slot_lookup(mod)] > 0 ) ch->pcdata->skill_mod[slot_lookup(mod)] += 5; } else { if ( ch->pcdata->skill_mod[slot_lookup(abs(mod))] > 0 ) ch->pcdata->skill_mod[slot_lookup(abs(mod))] -= 5; } } break; } /* * Check for weapon wielding. * Guard against recursion (for weapons with affects). */ if ( !IS_NPC(ch) && ( wield = get_eq_char( ch, WEAR_WIELD ) ) != NULL && get_obj_weight(wield) > str_app[get_curr_stat(ch,STAT_STR)].wield ) { static int depth; if ( depth == 0 ) { depth++; act( "You drop $p.", ch, wield, NULL, TO_CHAR ); act( "$n drops $p.", ch, wield, NULL, TO_ROOM ); obj_from_char( wield ); obj_to_room( wield, ch->in_room ); depth--; } } return; }
void apply_spell( CHAR_DATA *ch, int mod ) { if ( mod > 0 ) { if ( slot_lookup(mod) == gsn_haste ) { if ( !IS_SET(ch->affected_by, AFF_HASTE) ) { SET_BIT( ch->affected_by, AFF_HASTE ); act("$n begins moving more quickly.",ch,NULL,NULL,TO_ROOM); send_to_char( "You begins moving more quickly.\n\r", ch ); } } else if ( slot_lookup(mod) == gsn_invis ) { if ( !IS_SET( ch->affected_by, AFF_INVISIBLE) ) { SET_BIT( ch->affected_by, AFF_INVISIBLE ); act( "$n snaps out of existence.", ch, NULL,NULL, TO_ROOM ); send_to_char( "You snap out of existence.\n\r", ch ); } } else if ( slot_lookup(mod) == gsn_air_armor ) { if ( !IS_SET(ch->affected_by, AFF_AIR_ARMOR) ) { SET_BIT( ch->affected_by, AFF_AIR_ARMOR ); send_to_char( "Flows of air harden around you, forming armor.\n\r", ch ); } } else if ( slot_lookup(mod) == gsn_ward_person ) { if ( !IS_SET(ch->affected_by, AFF_WARDED) ) { SET_BIT( ch->affected_by, AFF_WARDED ); send_to_char( "Blue fills your vision for a moment.\n\r",ch ); } } else bug("Apply_spell: unusable slot number %d.", mod ); } else { if ( slot_lookup(abs( mod )) == gsn_haste ) { if ( IS_SET(ch->affected_by, AFF_HASTE) ) { REMOVE_BIT( ch->affected_by, AFF_HASTE ); act("$n slows down and moves more normally.",ch,NULL,NULL,TO_ROOM); send_to_char( "You feel yourself slowing down.\n\r", ch ); } } else if ( slot_lookup(abs( mod )) == gsn_invis ) { if ( IS_SET(ch->affected_by, AFF_INVISIBLE) ) { REMOVE_BIT( ch->affected_by, AFF_INVISIBLE ); act( "$n snaps into view.", ch, NULL, NULL, TO_ROOM ); send_to_char( "You snap into view.\n\r", ch ); } } else if ( slot_lookup(abs( mod )) == gsn_air_armor ) { if ( IS_SET(ch->affected_by, AFF_AIR_ARMOR) ) { REMOVE_BIT( ch->affected_by, AFF_AIR_ARMOR ); send_to_char( "Your armor of air dissipates.\n\r", ch ); } } else if ( slot_lookup(abs( mod )) == gsn_ward_person ) { if ( IS_SET(ch->affected_by, AFF_WARDED) ) { REMOVE_BIT( ch->affected_by, AFF_WARDED ); send_to_char( "You suddenly feel less safe.\n\r", ch ); } } else bug("Reset_char: unusable slot number %d.", mod ); } return; }
/* * Implementation stuff */ void check_gcast( CHAR_DATA * ch ) { CHAR_DATA * gch; int looper; int casters[ MAX_CLASS ]; int sn; int level = 0; int total = 0; if ( !ch->gspell || ch->gspell->timer <= 0 ) { return; } sn = ch->gspell->sn; for ( looper = 0; looper < MAX_CLASS; looper++ ) { casters[ looper ] = 0; } for ( gch = ch->in_room->people; gch; gch = gch->next_in_room ) { if ( is_same_gspell( ch, gch ) ) { casters[ prime_class( gch ) ]++; total++; level = ( level / 4 ) + gch->gspell->level; } } for ( looper = 0; looper < MAX_CLASS; looper++ ) { if ( casters[ looper ] < gskill_table[ gslot_lookup( sn ) ].casters[ looper ] ) { send_to_char( AT_BLUE, "Ok.\n\r", ch ); return; } } sn = slot_lookup( sn ); ( *skill_table[ sn ].spell_fun )( sn, level, ch->leader ? ch->leader : ch, ch->gspell->victim ); for ( gch = ch->in_room->people; gch; gch = gch->next_in_room ) { if ( is_same_gspell( ch, gch ) && ch != gch ) { end_gspell( gch ); } } switch ( skill_table[ sn ].target ) { case TAR_GROUP_OFFENSIVE: { CHAR_DATA * victim = (CHAR_DATA *)ch->gspell->victim; rprog_cast_sn_trigger( ch->in_room, ch, sn, victim ); if ( !victim->fighting ) { if ( IS_NPC( victim ) || ( ch->leader ? ch->leader : ch ) == victim ) { multi_hit( victim, ch->leader ? ch->leader : ch, TYPE_UNDEFINED ); } } } break; case TAR_GROUP_DEFENSIVE: rprog_cast_sn_trigger( ch->in_room, ch, sn, ch->gspell->victim ); break; case TAR_GROUP_ALL: rprog_cast_sn_trigger( ch->in_room, ch, sn, ch ); break; case TAR_GROUP_IGNORE: rprog_cast_sn_trigger( ch->in_room, ch, sn, ( ch->gspell->victim ? ch->gspell->victim : ch ) ); break; case TAR_GROUP_OBJ: if ( ch->gspell->victim ) { oprog_cast_sn_trigger( ch->gspell->victim, ch, sn, ch->gspell->victim ); rprog_cast_sn_trigger( ch->in_room, ch, sn, ch->gspell->victim ); } break; } end_gspell( ch ); return; }