/* Update PCs, NPCs, and objects */ void point_update(void) { struct char_data *i, *next_char; struct obj_data *j, *next_thing, *jj, *next_thing2; /* characters */ for (i = character_list; i; i = next_char) { next_char = i->next; gain_condition(i, FULL, -1); gain_condition(i, DRUNK, -1); gain_condition(i, THIRST, -1); if (GET_POS(i) >= POS_STUNNED) { GET_HIT(i) = MIN(GET_HIT(i) + hit_gain(i), GET_MAX_HIT(i)); GET_MANA(i) = MIN(GET_MANA(i) + mana_gain(i), GET_MAX_MANA(i)); GET_MOVE(i) = MIN(GET_MOVE(i) + move_gain(i), GET_MAX_MOVE(i)); if (AFF_FLAGGED(i, AFF_POISON)) if (damage(i, i, 2, SPELL_POISON) == -1) continue; /* Oops, they died. -gg 6/24/98 */ if (GET_POS(i) <= POS_STUNNED) update_pos(i); } else if (GET_POS(i) == POS_INCAP) { if (damage(i, i, 1, TYPE_SUFFERING) == -1) continue; } else if (GET_POS(i) == POS_MORTALLYW) { if (damage(i, i, 2, TYPE_SUFFERING) == -1) continue; } if (!IS_NPC(i)) { update_char_objects(i); if (GET_LEVEL(i) < idle_max_level) check_idling(i); } } /* objects */ for (j = object_list; j; j = next_thing) { next_thing = j->next; /* Next in object list */ /* If this is a corpse */ if (IS_CORPSE(j)) { /* timer count down */ if (GET_OBJ_TIMER(j) > 0) GET_OBJ_TIMER(j)--; if (!GET_OBJ_TIMER(j)) { if (j->carried_by) act("$p decays in your hands.", FALSE, j->carried_by, j, 0, TO_CHAR); else if ((IN_ROOM(j) != NOWHERE) && (world[IN_ROOM(j)].people)) { act("A quivering horde of maggots consumes $p.", TRUE, world[IN_ROOM(j)].people, j, 0, TO_ROOM); act("A quivering horde of maggots consumes $p.", TRUE, world[IN_ROOM(j)].people, j, 0, TO_CHAR); } for (jj = j->contains; jj; jj = next_thing2) { next_thing2 = jj->next_content; /* Next in inventory */ obj_from_obj(jj); if (j->in_obj) obj_to_obj(jj, j->in_obj); else if (j->carried_by) obj_to_room(jj, IN_ROOM(j->carried_by)); else if (IN_ROOM(j) != NOWHERE) obj_to_room(jj, IN_ROOM(j)); else core_dump(); } extract_obj(j); } } /* If the timer is set, count it down and at 0, try the trigger */ /* note to .rej hand-patchers: make this last in your point-update() */ else if (GET_OBJ_TIMER(j)>0) { GET_OBJ_TIMER(j)--; if (!GET_OBJ_TIMER(j)) timer_otrigger(j); } } }
/* * Update all chars, including mobs. */ void char_update( void ) { CHAR_DATA *ch; CHAR_DATA *ch_next; CHAR_DATA *ch_quit; ch_quit = NULL; /* update save counter */ save_number++; if (save_number > 29) save_number = 0; for ( ch = char_list; ch != NULL; ch = ch_next ) { AFFECT_DATA *paf; AFFECT_DATA *paf_next; ch_next = ch->next; if ( ch->timer > 30 ) ch_quit = ch; if ( ch->position >= POS_STUNNED ) { /* check to see if we need to go home */ if (IS_NPC(ch) && ch->zone != NULL && ch->zone != ch->in_room->area && ch->desc == NULL && ch->fighting == NULL && !IS_AFFECTED(ch,AFF_CHARM) && number_percent() < 5) { act("$n wanders on home.",ch,NULL,NULL,TO_ROOM); extract_char(ch,TRUE); continue; } if ( ch->hit < ch->max_hit ) ch->hit += hit_gain(ch); else ch->hit = ch->max_hit; if ( ch->mana < ch->max_mana ) ch->mana += mana_gain(ch); else ch->mana = ch->max_mana; if ( ch->move < ch->max_move ) ch->move += move_gain(ch); else ch->move = ch->max_move; } if ( ch->position == POS_STUNNED ) update_pos( ch ); if ( !IS_NPC(ch) && ch->level < LEVEL_IMMORTAL ) { OBJ_DATA *obj; if ( ( obj = get_eq_char( ch, WEAR_LIGHT ) ) != NULL && obj->item_type == ITEM_LIGHT && obj->value[2] > 0 ) { if ( --obj->value[2] == 0 && ch->in_room != NULL ) { --ch->in_room->light; act( "$p goes out.", ch, obj, NULL, TO_ROOM ); act( "$p flickers and goes out.", ch, obj, NULL, TO_CHAR ); extract_obj( obj ); } else if ( obj->value[2] <= 5 && ch->in_room != NULL) act("$p flickers.",ch,obj,NULL,TO_CHAR); } if (IS_IMMORTAL(ch)) ch->timer = 0; if ( ++ch->timer >= 12 ) { if ( ch->was_in_room == NULL && ch->in_room != NULL ) { ch->was_in_room = ch->in_room; if ( ch->fighting != NULL ) stop_fighting( ch, TRUE ); act( "$n disappears into the void.", ch, NULL, NULL, TO_ROOM ); send_to_char( "You disappear into the void.\n\r", ch ); if (ch->level > 1) save_char_obj( ch ); char_from_room( ch ); char_to_room( ch, get_room_index( ROOM_VNUM_LIMBO ) ); } } gain_condition( ch, COND_DRUNK, -1 ); gain_condition( ch, COND_FULL, ch->size > SIZE_MEDIUM ? -4 : -2 ); gain_condition( ch, COND_THIRST, -1 ); gain_condition( ch, COND_HUNGER, ch->size > SIZE_MEDIUM ? -2 : -1); } for ( paf = ch->affected; paf != NULL; paf = paf_next ) { paf_next = paf->next; if ( paf->duration > 0 ) { paf->duration--; if (number_range(0,4) == 0 && paf->level > 0) paf->level--; /* spell strength fades with time */ } else if ( paf->duration < 0 ) ; else { if ( paf_next == NULL || paf_next->type != paf->type || paf_next->duration > 0 ) { if ( paf->type > 0 && skill_table[paf->type].msg_off ) { send_to_char( skill_table[paf->type].msg_off, ch ); send_to_char( "\n\r", ch ); } } affect_remove( ch, paf ); } } /* * Careful with the damages here, * MUST NOT refer to ch after damage taken, * as it may be lethal damage (on NPC). */ if (is_affected(ch, gsn_plague) && ch != NULL) { AFFECT_DATA *af, plague; CHAR_DATA *vch; int dam; if (ch->in_room == NULL) continue; act("$n writhes in agony as plague sores erupt from $s skin.", ch,NULL,NULL,TO_ROOM); send_to_char("You writhe in agony from the plague.\n\r",ch); for ( af = ch->affected; af != NULL; af = af->next ) { if (af->type == gsn_plague) break; } if (af == NULL) { REMOVE_BIT(ch->affected_by,AFF_PLAGUE); continue; } if (af->level == 1) continue; plague.where = TO_AFFECTS; plague.type = gsn_plague; plague.level = af->level - 1; plague.duration = number_range(1,2 * plague.level); plague.location = APPLY_STR; plague.modifier = -5; plague.bitvector = AFF_PLAGUE; for ( vch = ch->in_room->people; vch != NULL; vch = vch->next_in_room) { if (!saves_spell(plague.level - 2,vch,DAM_DISEASE) && !IS_IMMORTAL(vch) && !IS_AFFECTED(vch,AFF_PLAGUE) && number_bits(4) == 0) { send_to_char("You feel hot and feverish.\n\r",vch); act("$n shivers and looks very ill.",vch,NULL,NULL,TO_ROOM); affect_join(vch,&plague); } } dam = UMIN(ch->level,af->level/5+1); ch->mana -= dam; ch->move -= dam; damage( ch, ch, dam, gsn_plague,DAM_DISEASE,FALSE); } else if ( IS_AFFECTED(ch, AFF_POISON) && ch != NULL && !IS_AFFECTED(ch,AFF_SLOW)) { AFFECT_DATA *poison; poison = affect_find(ch->affected,gsn_poison); if (poison != NULL) { act( "$n shivers and suffers.", ch, NULL, NULL, TO_ROOM ); send_to_char( "You shiver and suffer.\n\r", ch ); damage(ch,ch,poison->level/10 + 1,gsn_poison, DAM_POISON,FALSE); } } else if ( ch->position == POS_INCAP && number_range(0,1) == 0) { damage( ch, ch, 1, TYPE_UNDEFINED, DAM_NONE,FALSE); } else if ( ch->position == POS_MORTAL ) { damage( ch, ch, 1, TYPE_UNDEFINED, DAM_NONE,FALSE); } } /* * Autosave and autoquit. * Check that these chars still exist. */ for ( ch = char_list; ch != NULL; ch = ch_next ) { ch_next = ch->next; if (ch->desc != NULL && ch->desc->descriptor % 30 == save_number) { save_char_obj(ch); } if (ch == ch_quit) { do_function(ch, &do_quit, "" ); } } return; }
void regen_update( void ) { CharData *i, *next_char; int hit, mana, move; int vivify_level; for( i = character_list; i; i = next_char ) { next_char = i->next; if(affected_by_spell(i, SKILL_EMACIATED) && (GET_COND(i, HUNGER) != 0 || IS_VAMPIRE(i)) && GET_COND(i, THIRST) != 0) { if(!affected_by_spell(i, SKILL_EMACIATED_MANA) && !affected_by_spell(i, SKILL_EMACIATED_HIT)) affect_from_char(i, SKILL_EMACIATED); else if(percentSuccess(4)) { affect_from_char(i, SKILL_EMACIATED_MANA); affect_from_char(i, SKILL_EMACIATED_HIT); } } // Dwarves sober up 3x faster than most races (unless they drink more...) if(IS_DWARF(i) && !number(0, 35)) gain_condition(i, DRUNK, -1); vivify_level = spell_level(i, SPELL_VIVIFY); affect_from_char(i, SPELL_VIVIFY); if(GET_POS(i) <= POS_MEDITATING) { add_affect(i, i, SPELL_VIVIFY, MIN(vivify_level + 1, 100), APPLY_NONE, 0, -1, 0, FALSE, FALSE, FALSE, FALSE); } if(GET_POS(i) >= POS_MORTALLYW) { hit = hit_gain(i); mana = mana_gain(i); move = move_gain(i); if(affected_by_spell(i, SPELL_VIVIFY)) { if(hit > 0) hit += spell_level(i, SPELL_VIVIFY) * GET_MAX_HIT(i)/600; if(mana > 0) mana += spell_level(i, SPELL_VIVIFY) * GET_MAX_MANA(i)/600; if(move > 0) move += spell_level(i, SPELL_VIVIFY) * GET_MAX_MOVE(i)/600; } // Regeneration is increased on pvp holidays. If you're incapactitated, you will // eventually recover. if(pvpHoliday(i)) { if (GET_POS(i) < POS_SLEEPING) hit = 20; else { hit = (hit > 0) ? hit *3 : 20; mana = (mana > 0) ? mana*2 : 40; move = (move > 0) ? move*2 : 40; } } // 72 seconds per tick... if(hit < 0 || GET_HIT(i) < GET_MAX_HIT(i)) { if(hit>0) GET_HIT(i) += hit/72 + (hit % 72 > number(0, 71)? 1:0); else GET_HIT(i) = MAX(GET_HIT(i) + hit/72 + (-hit % 72 > number(0, 71)?-1:0), -9); } else { int surplus = (GET_HIT(i) - GET_MAX_HIT(i)); GET_HIT(i) -= surplus / 72 + (surplus % 72 > number(0, 71)? 1:0); } if(mana>0) GET_MANA(i) = MAX(MIN(GET_MANA(i) + mana/72 + (mana % 72 > number(0, 71)?1:0), GET_MAX_MANA(i)), 0); else GET_MANA(i) = MIN(GET_MANA(i) + mana/72 + (-mana % 72 > number(0, 71)?-1:0), GET_MAX_MANA(i)); if(move>0) GET_MOVE(i) = MIN(GET_MOVE(i) + move/72 + (move % 72 > number(0, 71)?1:0), GET_MAX_MOVE(i)); else GET_MOVE(i) = MAX(MIN(GET_MOVE(i) + move/72 + (-move % 72 > number(0, 71)?-1:0), GET_MAX_MOVE(i)), 0); update_pos(i); } } }
void beat_points_update(int pulse) { CHAR_DATA *i, *next_char; int restore; if (!UPDATE_PC_ON_BEAT) return; // only for PC's for (i = character_list; i; i = next_char) { next_char = i->next; if (IS_NPC(i)) continue; if (IN_ROOM(i) == NOWHERE) { log("SYSERR: Pulse character in NOWHERE."); continue; } if (RENTABLE(i) <= time(NULL)) { RENTABLE(i) = 0; AGRESSOR(i) = 0; AGRO(i) = 0; i->agrobd = false; } if (AGRO(i) < time(NULL)) AGRO(i) = 0; beat_punish(i); // This line is used only to control all situations when someone is // dead (POS_DEAD). You can comment it to minimize heartbeat function // working time, if you're sure, that you control these situations // everywhere. To the time of this code revision I've fix some of them // and haven't seen any other. // if (GET_POS(i) == POS_DEAD) // die(i, NULL); if (GET_POS(i) < POS_STUNNED) continue; // Restore hitpoints restore = hit_gain(i); restore = interpolate(restore, pulse); if (AFF_FLAGGED(i, AFF_BANDAGE)) { AFFECT_DATA* aff; for(aff = i->affected; aff; aff = aff->next) { if (aff->type == SPELL_BANDAGE) { restore += MIN(GET_REAL_MAX_HIT(i) / 10, aff->modifier); break; } } } if (GET_HIT(i) < GET_REAL_MAX_HIT(i)) GET_HIT(i) = MIN(GET_HIT(i) + restore, GET_REAL_MAX_HIT(i)); // Проверка аффекта !исступление!. Поместил именно здесь, // но если кто найдет более подходящее место переносите =) //Gorrah: перенес в handler::affect_total //check_berserk(i); // Restore PC caster mem if (!IS_MANA_CASTER(i) && !MEMQUEUE_EMPTY(i)) { restore = mana_gain(i); restore = interpolate(restore, pulse); GET_MEM_COMPLETED(i) += restore; if (AFF_FLAGGED(i, AFF_RECALL_SPELLS)) handle_recall_spells(i); while (GET_MEM_COMPLETED(i) > GET_MEM_CURRENT(i) && !MEMQUEUE_EMPTY(i)) { int spellnum; spellnum = MemQ_learn(i); GET_SPELL_MEM(i, spellnum)++; GET_CASTER(i) += spell_info[spellnum].danger; } if (MEMQUEUE_EMPTY(i)) { if (GET_RELIGION(i) == RELIGION_MONO) { send_to_char ("Наконец ваши занятия окончены. Вы с улыбкой захлопнули свой часослов.\r\n", i); act("Окончив занятия, $n с улыбкой захлопнул$g часослов.", FALSE, i, 0, 0, TO_ROOM); } else { send_to_char ("Наконец ваши занятия окончены. Вы с улыбкой убрали свои резы.\r\n", i); act("Окончив занятия, $n с улыбкой убрал$g резы.", FALSE, i, 0, 0, TO_ROOM); } } } if (!IS_MANA_CASTER(i) && MEMQUEUE_EMPTY(i)) { GET_MEM_TOTAL(i) = 0; GET_MEM_COMPLETED(i) = 0; } // Гейн маны у волхвов if (IS_MANA_CASTER(i) && GET_MANA_STORED(i) < GET_MAX_MANA(i)) { GET_MANA_STORED(i) += mana_gain(i); if (GET_MANA_STORED(i) >= GET_MAX_MANA(i)) { GET_MANA_STORED(i) = GET_MAX_MANA(i); send_to_char("Ваша магическая энергия полностью восстановилась\r\n", i); } } if (IS_MANA_CASTER(i) && GET_MANA_STORED(i) > GET_MAX_MANA(i)) { GET_MANA_STORED(i) = GET_MAX_MANA(i); } // Restore moves restore = move_gain(i); restore = interpolate(restore, pulse); // GET_MOVE(i) = MIN(GET_MOVE(i) + restore, GET_REAL_MAX_MOVE(i)); //MZ.overflow_fix if (GET_MOVE(i) < GET_REAL_MAX_MOVE(i)) GET_MOVE(i) = MIN(GET_MOVE(i) + restore, GET_REAL_MAX_MOVE(i)); //-MZ.overflow_fix } }