コード例 #1
0
ファイル: healmagic.cpp プロジェクト: RealmsMud/RealmsCode
int splRoomVigor(Creature* player, cmd* cmnd, SpellData* spellData) {
    int      heal=0;

    if(spellData->how == CastType::POTION) {
        player->print("The spell fizzles.\n");
        return(0);
    }

    if(player->getClass() !=  CreatureClass::CLERIC && !player->isCt()) {
        player->print("Only clerics may cast that spell.\n");
        return(0);
    }

    player->print("You cast vigor on everyone in the room.\n");
    broadcast(player->getSock(), player->getParent(), "%M casts vigor on everyone in the room.\n", player);

    heal = mrand(1, 6) + bonus((int) player->piety.getCur());

    if(player->getRoomParent()->magicBonus()) {
        heal += mrand(1, 3);
        player->print("\nThe room's magical properties increase the power of your spell\n");
    }

    for(Player* ply : player->getRoomParent()->players) {
        if(canCastHealing(player, ply, false, false, false)) {
            if(ply != player)
                ply->print("%M casts vigor on you.\n", player);
            player->doHeal(ply, heal);
            if(ply->inCombat(false))
                player->smashInvis();
        }
    }

    return(1);
}
コード例 #2
0
void clinterface::sendwinddelta()
{
   msrand(time(NULL));
   char buf[100];
   int speed=mrand()%11-5;
   int direction=mrand()%21-10;
   sprintf(buf,"SERVER:*:%d:%d", speed, direction);
   sendpacket(NULL, NULL, NULL, CLIENT_ALL, -1, CL_WDELTA, buf);
}
コード例 #3
0
ファイル: bm_matrix.cpp プロジェクト: wangyongcong/fancystar
void rand_matrix(MATRIX_T &mat)
{
	for(int i=0; i<R; ++i) {
		for(int j=0; j<C; ++j) {
			mat(i,j)=mrand();
		}
	}
}
コード例 #4
0
ファイル: 15131_1.c プロジェクト: B-Rich/osf_db
void BOcrypt(unsigned char *buff, int len)
{
int y;

if (!len)
return;

msrand(getkey());
for (y = 0; y < len; y++)
buff[y] = buff[y] ^ (mrand()%256);
}
コード例 #5
0
ファイル: creature.cpp プロジェクト: RealmsMud/RealmsCode
Exit* Creature::getFleeableExit() {
    int     i=0, exit=0;
    bool    skipScary=false;

    // count exits so we can randomly pick one

    for(Exit* ext : getRoomParent()->exits) {
        if(canFleeToExit(ext))
            i++;
    }

    if(i) {
        // pick a random exit
        exit = mrand(1, i);
    } else if(isPlayer()) {
        // force players to skip the scary list
        skipScary = true;
        i=0;

        for(Exit* ext : getRoomParent()->exits) {
            if(canFleeToExit(ext, true))
                i++;
        }
        if(i)
            exit = mrand(1, i);
    }

    if(!exit)
        return(0);

    i=0;
    for(Exit* ext : getRoomParent()->exits) {
        if(canFleeToExit(ext, skipScary))
            i++;
        if(i == exit)
            return(ext);
    }

    return(0);
}
コード例 #6
0
ファイル: creature.cpp プロジェクト: RealmsMud/RealmsCode
Creature *enm_in_group(Creature *target) {
    Creature *enemy=0;
    int     chosen=0;


    if(!target || mrand(1,100) <= 50)
        return(target);

    Group* group = target->getGroup();

    if(!group)
        return(target);

    chosen = mrand(1, group->getSize());

    enemy = group->getMember(chosen);
    if(!enemy || !enemy->inSameRoom(target))
        enemy = target;

    return(enemy);

}
コード例 #7
0
ファイル: Meteorite.cpp プロジェクト: cookierama/game
void CMeteorite::InitBody()
{
	m_body.append( QPoint( 0, 0 ) );
	m_body.append( QPoint( mrand(  meteo_size/2, meteo_size ), -mrand( meteo_size/2, meteo_size ) ) );
	m_body.append( QPoint( meteo_size/2 - mrand( meteo_size/3, meteo_size/1.5 ), -mrand( meteo_size/2, meteo_size ) ) );
	m_body.append( QPoint( -mrand( meteo_size/2, meteo_size ), -mrand( 0, meteo_size/1.5 ) ) );
	m_body.append( QPoint( 0, 0 ) );
}
コード例 #8
0
ファイル: healmagic.cpp プロジェクト: RealmsMud/RealmsCode
int splRestore(Creature* player, cmd* cmnd, SpellData* spellData) {
    Creature* target=0;

    if(spellData->how == CastType::CAST && player->isPlayer() && !player->isStaff()) {
        player->print("You may not cast that spell.\n");
        return(0);
    }

    // Cast restore on self
    if(cmnd->num == 2) {
        target = player;

        if(spellData->how == CastType::CAST || spellData->how == CastType::WAND) {
            player->print("Restore spell cast.\n");
            broadcast(player->getSock(), player->getParent(), "%M casts restore on %sself.", player, player->himHer());
        } else if(spellData->how == CastType::POTION)
            player->print("You feel restored.\n");

    // Cast restore on another player
    } else {
        if(player->noPotion( spellData))
            return(0);

        cmnd->str[2][0] = up(cmnd->str[2][0]);
        target = player->getParent()->findCreature(player, cmnd->str[2], cmnd->val[2], false);

        if(!target) {
            player->print("That person is not here.\n");
            return(0);
        }


        player->print("Restore spell cast on %N.\n", target);
        target->print("%M casts a restore spell on you.\n", player);
        broadcast(player->getSock(), target->getSock(), player->getParent(), "%M casts a restore spell on %N.",
            player, target);

        logCast(player, target, "restore");
    }
    player->doHeal(target, dice(2, 10, 0));

    if(mrand(1, 100) < 34)
        target->mp.restore();

    if(player->isStaff()) {
        target->mp.restore();
        target->hp.restore();
    }

    return(1);
}
コード例 #9
0
ファイル: init.c プロジェクト: windlight31/gstat
/* smrand -- set seed for mrand() */
void smrand(int seed)
{
    int		i;

    mrand_list[0] = (123413*seed) % MODULUS;
    for ( i = 1; i < 55; i++ )
	mrand_list[i] = (123413*mrand_list[i-1]) % MODULUS;

    started = TRUE;

    /* run mrand() through the list sufficient times to
       thoroughly randomise the array */
    for ( i = 0; i < 55*55; i++ )
	mrand();
}
コード例 #10
0
ファイル: creature2.cpp プロジェクト: RealmsMud/RealmsCode
Creature *getRandomMonster(BaseRoom *inRoom) {
    Creature *foundCrt=0;
    int         count=0, roll=0, num=0;

    num = inRoom->countCrt();
    if(!num)
        return(0);

    roll = mrand(1, num);
    for(Monster* mons : inRoom->monsters) {
        if(mons->isPet())
            continue;
        if(++count == roll) {
            foundCrt = mons;
            break;
        }
    }

    if(foundCrt)
        return(foundCrt);
    return(0);
}
コード例 #11
0
ファイル: creature2.cpp プロジェクト: RealmsMud/RealmsCode
Creature *getRandomPlayer(BaseRoom *inRoom) {
    Creature *foundPly=0;
    int         count=0, roll=0, num=0;

    num = inRoom->countVisPly();
    if(!num)
        return(0);
    roll = mrand(1, num);
    for(Player* ply : inRoom->players) {
        if(ply->flagIsSet(P_DM_INVIS)) {
            continue;
        }
        count++;
        if(count == roll) {
            foundPly = ply;
            break;
        }
    }

    if(foundPly)
        return(foundPly);
    return(0);
}
コード例 #12
0
ファイル: CRex.cpp プロジェクト: gitkobaya/ABC
void CRex::vSelectGens( double **pplfChildren, int *pi1stGenLoc, int *pi2ndGenLoc )
{
	unsigned int i;
	double lfProb = 0.0;
	double lfPrevProb = 0.0;
	double lfRes = 0.0;
	double lf1stGen = DBL_MAX;
	double lfRand = 0.0;
	int i1stGenLoc = INT_MAX;
	int i2ndGenLoc = INT_MAX;
	int iRank = 0;
	std::vector<Rank_t> stlFitProb;
	Rank_t tTempRankData;
	// まず、適応度関数の値を計算します。
	lfRes = 0.0;
	for( i = 0;i < (unsigned int)iChildrenNumber; i++ )
	{
		tTempRankData.lfFitProb = pflfConstraintFunction( pplfChildren[i], iGenVector );
		tTempRankData.iLoc = i;
		stlFitProb.push_back( tTempRankData );
		lfRes += stlFitProb[i].lfFitProb;
		if( stlFitProb[i].lfFitProb < lf1stGen )
		{
			lf1stGen = stlFitProb[i].lfFitProb;
			i1stGenLoc = i;
		}
	}
	// 目的関数値によるソートを実施します。
	std::sort( stlFitProb.begin(), stlFitProb.end(), CCompareToRank() );
	// ランクに基づくルーレット選択を実行。
	iRank = mrand() % ( iChildrenNumber-1 ) + 1;
	i2ndGenLoc = stlFitProb[iRank].iLoc;
	// 最良個体の位置とそれ以外でルーレット選択により選ばれた位置を返却します。
	*pi1stGenLoc = i1stGenLoc;
	*pi2ndGenLoc = i2ndGenLoc;
}
コード例 #13
0
ファイル: healmagic.cpp プロジェクト: RealmsMud/RealmsCode
int splVigor(Creature* player, cmd* cmnd, SpellData* spellData) {
    return(castHealingSpell(player, cmnd, spellData, "vigor", "You feel better.", S_VIGOR, mrand(1, 8)));
}
コード例 #14
0
ファイル: CRex.cpp プロジェクト: gitkobaya/rcga
void CRex::vRexStar()
{
	CRexException cre;
	int i,j,k;
	int iLoc;
	int iMaxSize = 0;
	int iOverLapLoc = 0;
	double lfSigma = 0.0;
	std::vector<Rank_t> stlFitProb;
	Rank_t tTempRankData;
	std::vector<int> stlSelectParentLoc;
	
/* JGGモデル */

	try
	{
		// 親をランダムにNp個選択します。
		for(;;)
		{
			iLoc = mrand() % iGenNumber;
			// 選択した親と重なっていないか調査します。
			iOverLapLoc = -1;
			for( i = 0;i < (unsigned int)stlSelectParentLoc.size(); i++ )
			{
				if( stlSelectParentLoc.at(i) == iLoc )
				{
					iOverLapLoc = i;
					break;
				}
			}
			// 重なっていなければ、位置を追加します。
			if( iOverLapLoc == -1 )
			{
				stlSelectParentLoc.push_back( iLoc );
				iMaxSize++;
			}
			// 指定した親の数になったら終了します。
			if( iMaxSize == iParentNumber ) break;
		}
		// 重心を算出します。
		for( i = 0;i < iGenVector; i++ )
		{
			plfCentroid[i] = 0.0;
		}
		for( i = 0;i < iParentNumber; i++ )
		{
			for( j = 0;j < iGenVector; j++ )
			{
				plfCentroid[j] += ( pplfGens[stlSelectParentLoc.at(i)][j] );
			}
		}
		for( i = 0;i < iParentNumber; i++ )
		{
			plfCentroid[j] /= (double)iParentNumber;
		}
	// REX(RealCoded Emsanble )を実行します。交叉回数Nc回実行し、Nc個の子供を生成します。
		// 統計量遺伝における普遍分散を算出します。
		lfSigma = 1.0/(double)sqrt( (double)iParentNumber );
		
		for( i = 0;i < iChildrenNumber; i++ )
		{
			// 正規乱数により乱数を発生させます。
			for( j = 0;j < iParentNumber; j++ )
			{
				plfNormalizeRand[j] = grand(lfSigma, 0.0);
			}
			for( j = 0;j < iGenVector; j++ )
			{
				plfTempVector[j] = 0.0;
				plfChildVector[j] = 0.0;
			}
			for( j = 0;j < iParentNumber; j++ )
			{
			// REXを実行して、子供を生成します。
				for( k = 0;k < iGenVector; k++ )
				{
					plfTempVector[k] += plfNormalizeRand[j] * ( pplfGens[stlSelectParentLoc.at(j)][k] - plfCentroid[k] );
				}
			}
			for( k = 0;k < iGenVector; k++ )
			{
				plfChildVector[k] = plfCentroid[k] + plfTempVector[k];
			}
			for( j = 0;j < iGenVector; j++ )
			{
				pplfChildren[i][j] = plfChildVector[j];
			}
		}
		
		// 評価値をNp個算出します。
		for( i = 0;i < iChildrenNumber; i++ )
		{
			tTempRankData.lfFitProb = pflfConstraintFunction( pplfChildren[i], iGenVector );
			tTempRankData.iLoc = i;
			stlFitProb.push_back( tTempRankData );
		}
		// 目的関数値によるソートを実施します。
		std::sort( stlFitProb.begin(), stlFitProb.end(), CCompareToRank() );
		// 親を入れ替えます。(JGGモデルの場合は親はすべて変更するものとします。)
		for( i = 0; i < iParentNumber; i++ )
		{
			for( j = 0;j < iGenVector; j++ )
			{
				pplfGens[stlSelectParentLoc.at(i)][j] = pplfChildren[stlFitProb[i].iLoc][j];
			}
		}
	}
	catch(...)
	{
		cre.SetErrorInfo( REX_ARRAY_INDEX_ERROR, "vImplement", "CRex", "配列範囲外参照をしました。", __LINE__ );
		throw( cre );
	}
	stlSelectParentLoc.clear();
}
コード例 #15
0
enum plugin_status plugin_start(const void* parameter)
{
    int i;
    int f_width, f_height;
    int score_x;

    bool quit = false;
    int button;
    
    int cycletime = 300;
    int end;

    int pos_cur_brick = 0;
    int type_cur_brick = 0;
    int type_next_brick = 0;
    
    unsigned long int score = 34126;
    
    (void)parameter;

#if LCD_DEPTH > 1
    rb->lcd_set_backdrop(NULL);
    rb->lcd_set_background(LCD_BLACK);
    rb->lcd_set_foreground(LCD_WHITE);
#endif

    rb->lcd_setfont(FONT_SYSFIXED);
    
    rb->lcd_getstringsize("100000000", &f_width, &f_height);
    
    rb->lcd_clear_display();
    
    /***********
    ** Draw EVERYTHING
    */
    
    /* Playing filed box */
    rb->lcd_vline(CENTER_X-2, CENTER_Y, CENTER_Y + (WIDTH*TILES+TILES));
    rb->lcd_vline(CENTER_X + WIDTH + 1, CENTER_Y,
                  CENTER_Y + (WIDTH*TILES+TILES));
    rb->lcd_hline(CENTER_X-2, CENTER_X + WIDTH + 1, 
                  CENTER_Y + (WIDTH*TILES+TILES));

    /* Score box */
#if (LCD_WIDTH > LCD_HEIGHT)
    rb->lcd_drawrect(SCORE_X-4, SCORE_Y-5, f_width+8, f_height+9);
    rb->lcd_putsxy(SCORE_X-4, SCORE_Y-6-f_height, "score");
#else
    rb->lcd_hline(0, LCD_WIDTH, SCORE_Y-5);
    rb->lcd_putsxy(2, SCORE_Y-6-f_height, "score");
#endif
    score_x = SCORE_X;
    
    /* Next box */
    rb->lcd_getstringsize("next", &f_width, NULL);
#if (LCD_WIDTH > LCD_HEIGHT) && !(LCD_WIDTH > 132)
    rb->lcd_drawrect(NEXT_X-5, NEXT_Y-5, WIDTH+10, NEXT_H+10);
    rb->lcd_putsxy(score_x-4, NEXT_Y-5, "next");
#else
    rb->lcd_drawrect(NEXT_X-5, NEXT_Y-5, WIDTH+10, NEXT_H+10);
    rb->lcd_putsxy(NEXT_X-5, NEXT_Y-5-f_height-1, "next");
#endif

    /***********
    ** GAMELOOP
    */
    rb->srand( *rb->current_tick );
    
    type_cur_brick = 2 + mrand(3);
    type_next_brick = 2 + mrand(3);
    
    do {
        end = *rb->current_tick + (cycletime * HZ) / 1000;
        
        draw_brick(pos_cur_brick, type_cur_brick);

        /* Draw next brick */
        rb->lcd_set_drawmode(DRMODE_BG|DRMODE_INVERSEVID);
        rb->lcd_fillrect(NEXT_X, NEXT_Y, WIDTH, WIDTH * 4 + 4);
        rb->lcd_set_drawmode(DRMODE_SOLID);

        for (i = 0; i < type_next_brick; ++i) {
            rb->lcd_fillrect(NEXT_X, 
                             NEXT_Y + ((type_next_brick % 2) ? (int)(WIDTH/2) : ((type_next_brick == 2) ? (WIDTH+1) : 0)) + (WIDTH*i) + i,
                             WIDTH, WIDTH);
        } 

        /* Score box */
        rb->lcd_putsxyf(score_x, SCORE_Y, "%8ld0", score);

        rb->lcd_update();

        button = rb->button_status();

        switch(button) {
            case ONEDROCKBLOX_DOWN:
            case (ONEDROCKBLOX_DOWN|BUTTON_REPEAT):
                cycletime = 100;
                break;
            case ONEDROCKBLOX_QUIT:
                quit = true;
                break;
            default:
                cycletime = 300;
                if(rb->default_event_handler(button) == SYS_USB_CONNECTED) {
                    quit = true;
                }
        }
        
        if ((pos_cur_brick + type_cur_brick) > 10) {
             type_cur_brick = type_next_brick;
             type_next_brick = 2 + mrand(3);
             score += (type_cur_brick - 1) * 2;
             pos_cur_brick = 1 - type_cur_brick;
        } else {
            ++pos_cur_brick;
        }

        if (TIME_BEFORE(*rb->current_tick, end))
            rb->sleep(end-*rb->current_tick);
        else
            rb->yield();

    } while (!quit);
 
    return PLUGIN_OK;
}
コード例 #16
0
ファイル: abjuration.cpp プロジェクト: RealmsMud/RealmsCode
void Creature::doDispelMagic(int num) {
    EffectInfo* effect=0;
    std::list<bstring> effList;
    std::list<bstring>::const_iterator it;

    // create a list of possible effects
    effList.push_back("anchor");
    effList.push_back("hold-person");
    effList.push_back("strength");
    effList.push_back("haste");
    effList.push_back("fortitude");
    effList.push_back("insight");
    effList.push_back("prayer");
    effList.push_back("enfeeblement");
    effList.push_back("slow");
    effList.push_back("weakness");
    effList.push_back("prayer");
    effList.push_back("damnation");
    effList.push_back("confusion");

    effList.push_back("enlarge");
    effList.push_back("reduce");
    effList.push_back("darkness");
    effList.push_back("infravision");
    effList.push_back("invisibility");
    effList.push_back("detect-invisible");
    effList.push_back("undead-ward");
    effList.push_back("bless");
    effList.push_back("detect-magic");
    effList.push_back("protection");
    effList.push_back("tongues");
    effList.push_back("comprehend-languages");
    effList.push_back("true-sight");
    effList.push_back("fly");
    effList.push_back("levitate");
    effList.push_back("drain-shield");
    effList.push_back("resist-magic");
    effList.push_back("know-aura");
    effList.push_back("warmth");
    effList.push_back("breathe-water");
    effList.push_back("earth-shield");
    effList.push_back("reflect-magic");
    effList.push_back("camouflage");
    effList.push_back("heat-protection");
    effList.push_back("farsight");
    effList.push_back("pass-without-trace");
    effList.push_back("resist-earth");
    effList.push_back("resist-air");
    effList.push_back("resist-fire");
    effList.push_back("resist-water");
    effList.push_back("resist-cold");
    effList.push_back("resist-electricity");
    effList.push_back("wind-protection");
    effList.push_back("static-field");

    effList.push_back("illusion");
    effList.push_back("blur");
    effList.push_back("fire-shield");
    effList.push_back("greater-invisibility");

    // true we'll show, false don't remove perm effects

    // num = -1 means dispel all effects
    if(num <= -1) {
        for(it = effList.begin() ; it != effList.end() ; it++)
            removeEffect(*it, true, false);
        return;
    }

    int numEffects=0, choice=0;
    while(num > 0) {
        // how many effects are we under?
        for(it = effList.begin() ; it != effList.end() ; it++) {
            effect = getEffect(*it);
            if(effect && !effect->isPermanent())
                numEffects++;
        }

        // none? we're done
        if(!numEffects)
            return;
        // which effect shall we dispel?
        choice = mrand(1, numEffects);
        numEffects = 0;

        // find it and get rid of it!
        for(it = effList.begin() ; it != effList.end() && choice ; it++) {
            effect = getEffect(*it);
            if(effect && !effect->isPermanent()) {
                numEffects++;
                if(choice == numEffects) {
                    removeEffect(*it, true, false);
                    // stop the loop!
                    choice = 0;
                }
            }
        }

        num--;
    }
}
コード例 #17
0
ファイル: abjuration.cpp プロジェクト: RealmsMud/RealmsCode
int splDispelMagic(Creature* player, cmd* cmnd, SpellData* spellData) {
    return(doDispelMagic(player, cmnd, spellData, "dispel-magic", mrand(3,5)));
}
コード例 #18
0
ファイル: testpmi2.c プロジェクト: A1ve5/slurm
int
main(int argc, char **argv)
{
	int rank;
	int size;
	int appnum;
	int spawned;
	int flag;
	int len;
	int i;
	struct timeval tv;
	struct timeval tv2;
	char jobid[128];
	char key[128];
	char val[128];
	char buf[128];

	{
		int x = 1;
		while (x == 0) {
			sleep(2);
		}
	}

	gettimeofday(&tv, NULL);
	srand(tv.tv_sec);

	PMI2_Init(&spawned, &size, &rank, &appnum);

	PMI2_Job_GetId(jobid, sizeof(buf));

	memset(val, 0, sizeof(val));
	PMI2_Info_GetJobAttr("mpi_reserved_ports",
			     val,
			     PMI2_MAX_ATTRVALUE,
			     &flag);

	sprintf(key, "mpi_reserved_ports");
	PMI2_KVS_Put(key, val);

	memset(val, 0, sizeof(val));
	sprintf(buf, "PMI_netinfo_of_task");
	PMI2_Info_GetJobAttr(buf,
			     val,
			     PMI2_MAX_ATTRVALUE,
			     &flag);
	sprintf(key, buf);
	PMI2_KVS_Put(key, val);

	memset(val, 0, sizeof(val));
	sprintf(key, "david@%d", rank);
	sprintf(val, "%s", mrand(97, 122));
	PMI2_KVS_Put(key, val);

	PMI2_KVS_Fence();

	for (i = 0; i < size; i++) {

		memset(val, 0, sizeof(val));
		sprintf(key, "PMI_netinfo_of_task");
		PMI2_KVS_Get(jobid,
			     PMI2_ID_NULL,
			     key,
			     val,
			     sizeof(val),
			     &len);
		printf("rank: %d key:%s val:%s\n", rank, key, val);

		memset(val, 0, sizeof(val));
		sprintf(key, "david@%d", rank);
		PMI2_KVS_Get(jobid,
			     PMI2_ID_NULL,
			     key,
			     val,
			     sizeof(val),
			     &len);
		printf("rank: %d key:%s val:%s\n", rank, key, val);

		memset(val, 0, sizeof(val));
		sprintf(key, "mpi_reserved_ports");
		PMI2_KVS_Get(jobid,
			     PMI2_ID_NULL,
			     key,
			     val,
			     sizeof(val),
			     &len);
		printf("rank: %d key:%s val:%s\n", rank, key, val);
	}

	PMI2_Finalize();

	gettimeofday(&tv2, NULL);
	printf("%f\n",
	       ((tv2.tv_sec - tv.tv_sec) * 1000.0
		+ (tv2.tv_usec - tv.tv_usec) / 1000.0));

	return 0;
}
コード例 #19
0
ファイル: combat.c プロジェクト: FuzzyHobbit/mordor
int update_combat( creature *crt_ptr )
{
   creature *att_ptr;
   room     *rom_ptr;
   etag     *ep;
   char     *enemy;
   int      n = 0,rtn = 0,p = 0,fd,t = 0;
   int		victim_is_monster = 0, circled=0, tried_circle=0;
   
	ASSERTLOG( crt_ptr );

	rom_ptr = crt_ptr->parent_rom;
	ep = crt_ptr->first_enm;
	while(1)
	{
		enemy = ep->enemy;
		if(!enemy)
			ep = ep->next_tag;
		if(!ep)
			return 0;
		if(enemy)
			break;
	}


	/* keep looking till we find one that is an exact match */
	/* and is not the monster itself */
	n = 1;
	do 
	{

		att_ptr = find_exact_crt(crt_ptr, rom_ptr->first_ply,enemy, n);
		if(!att_ptr)
			att_ptr = find_exact_crt(crt_ptr, rom_ptr->first_mon,enemy, n);
		if(!att_ptr)
		{	
#ifdef OLD_CODE
			/* with this code commented out, a monster will remember it is
			attacking a player even if he logs out and logs back in unlike
			now where he can get someone else to stadn there and attack,
			disconnect, login attack again etc. */
			if(!find_who(enemy))
				del_enm_crt(enemy, crt_ptr);
			else
#endif
				end_enm_crt(enemy, crt_ptr);
			return 0;
		}

		n++;

	} while ( att_ptr != NULL && att_ptr == crt_ptr );

  
	if ( att_ptr->type == MONSTER)
	{
		victim_is_monster = 1;
	}
 
	/* I think this check is redundanct now */
	if(att_ptr != crt_ptr) 
	{
       if(is_charm_crt(crt_ptr->name, att_ptr)&& F_ISSET(crt_ptr, MCHARM))
	       p = 1;
		crt_ptr->NUMHITS++;
		n=20;
		if(F_ISSET(crt_ptr, MMAGIO))
			n=crt_ptr->proficiency[0];
	         
		if(F_ISSET(crt_ptr, MMAGIC) && mrand(1, 100) <= n && !p) 
		{
			rtn = crt_spell(crt_ptr, att_ptr );
			if(rtn == 2) 
			{
				/* spell killed the victim */
				return 1; 
			}
			else if(rtn == 1)
			{
				/* spell hurt the victim but did not kill */
				n = 21;
				if ( !victim_is_monster )
				{
					if ( check_for_ply_flee( att_ptr ))
					{
						return(1);
					}
				}
			}
			else 
			{
				/* spell was not cast or did not hurt the victim */
      			n = crt_ptr->thaco - att_ptr->armor/10;
			}
		}
		else 
		{
			n = crt_ptr->thaco - att_ptr->armor/10;
			n = MAX(n, 1);
		}
   
   
		if(mrand(1,20) >= n && !p) 
		{
			if ( !victim_is_monster )
			{
				fd = att_ptr->fd;
				ANSI(fd, ATTACKCOLOR); 
			}
			else
			{
				fd = -1;
			}
			
			if((crt_ptr->class==BARBARIAN||crt_ptr->class==FIGHTER)
				&& (mrand(1,30)<20 &&
				crt_ptr->level > (att_ptr->level - 3))) {
			   circled = (crt_ptr->level - att_ptr->level) +
				mrand(1,4);
			   if(circled>1) {
				mprint(fd, "%M circles you.\n", m1arg(crt_ptr));
			
				if(F_ISSET(crt_ptr, MNOPRE)) { 
				  if(F_ISSET(att_ptr, MNOPRE)) {
					sprintf(g_buffer, "%s circles %s.", crt_ptr->name, att_ptr->name);
				  } else {
					sprintf(g_buffer, "%s circles the %s.", crt_ptr->name, att_ptr->name);
				  }
				} 
				else { /* !F_ISSET(crt_ptr,MNOPRE) */
				  if(F_ISSET(att_ptr, MNOPRE)) {
					sprintf(g_buffer, "The %s circles %s.", crt_ptr->name, att_ptr->name);
				  } else {
					sprintf(g_buffer, "The %s circles the %s.", crt_ptr->name, att_ptr->name);
				  }
				}
				broadcast_dam(fd, crt_ptr->fd, att_ptr->rom_num, 
					g_buffer, NULL);

				att_ptr->lasttime[LT_ATTCK].ltime = time(0);
				att_ptr->lasttime[LT_ATTCK].interval = mrand(5,8) - 
					bonus[(int)att_ptr->dexterity];
				circled=1;
			   }
			   else {
				mprint(fd, "%M tried to circle you.\n", m1arg(crt_ptr));
				if(F_ISSET(crt_ptr, MNOPRE)) {
				   if(F_ISSET(att_ptr,MNOPRE)) {
					sprintf(g_buffer, "%s tried to circle %s.", crt_ptr->name, att_ptr->name);
				   } else {
					sprintf(g_buffer, "%s tried to circle the %s.", crt_ptr->name, att_ptr->name);
				   }
				}
				else { /*!F_ISSET(crt_ptr, MNOPRE) */
				   if(F_ISSET(att_ptr,MNOPRE)) {
					sprintf(g_buffer, "The %s tried to circle %s.", crt_ptr->name, att_ptr->name);
				   } else {
					sprintf(g_buffer, "The %s tried to circle the %s.", crt_ptr->name, att_ptr->name);
				   }
				}
				broadcast_dam(fd, crt_ptr->fd, att_ptr->rom_num, 
					g_buffer, NULL);

				circled=0;
				tried_circle=1;
			   }
				
			}
		
			if(F_ISSET(crt_ptr, MBRETH) && mrand(1,30)<5)
			{
				if (F_ISSET(crt_ptr, MBRWP1) && !F_ISSET(crt_ptr, MBRWP2))
					n = bw_spit_acid(crt_ptr,att_ptr);
				else if (F_ISSET(crt_ptr, MBRWP1) && F_ISSET(crt_ptr, MBRWP2))
					n = bw_poison(crt_ptr,att_ptr);
				else if (!F_ISSET(crt_ptr, MBRWP1) && F_ISSET(crt_ptr, MBRWP2))
					n = bw_cone_frost(crt_ptr,att_ptr);
				else
					n = bw_cone_fire(crt_ptr,att_ptr);
			}
			
			else if(F_ISSET(crt_ptr, MENEDR) && mrand(1,100)< 25) 
				n = power_energy_drain(crt_ptr,att_ptr);
			else {
			    if(circled==0) {
				n = mdice(crt_ptr);		     
			    }
			}
    
            
		if(circled==0 && tried_circle==0) {
			att_ptr->hpcur -= n;

			if ( !victim_is_monster )
			{
				sprintf(g_buffer, "%%M hit you for %d damage.\n", n);
				mprint(fd, g_buffer, m1arg(crt_ptr));
				add_enm_dmg(att_ptr->name, crt_ptr,n);
			
				// added for damage descriptions 
				if(F_ISSET(crt_ptr, MNOPRE))
					sprintf(g_buffer, "%s %s %s!",crt_ptr->name , 
						hit_description(n), att_ptr->name);
				else
					sprintf(g_buffer,"The %s %s %s!", crt_ptr->name,
						hit_description(n), att_ptr->name);
				
				broadcast_dam(crt_ptr->fd, att_ptr->fd, att_ptr->rom_num, g_buffer, NULL);


			}
			
			else
			{ 
				/* Output only when monster v. monster */

				broadcast_rom(-1,crt_ptr->rom_num, "%M hits %m.", m2args(crt_ptr, att_ptr));
				
				add_enm_crt(crt_ptr->name, att_ptr);
			}
		}

			if(F_ISSET(crt_ptr, MPOISS) && mrand(1,100) <= 15) 
			{
				if ( victim_is_monster )
				{
        			broadcast_rom(-1, att_ptr->rom_num,"%M poisoned %m.", 
						m2args(crt_ptr, att_ptr));
				}
				else
				{
					ANSI(fd, POISONCOLOR);
					mprint(fd, "%M poisoned you.\n", m1arg(crt_ptr));
				}
				F_SET(att_ptr, PPOISN);
			}

			if(F_ISSET(crt_ptr, MDISEA) && mrand(1,100) <= 15) 
			{

				if ( victim_is_monster )
				{
        			broadcast_rom(-1, att_ptr->rom_num,"%M infects %m.", 
						m2args(crt_ptr, att_ptr));
				}
				else
				{
					ANSI(fd, DISEASECOLOR);
					mprint(fd, "%M infects you.\n", m1arg(crt_ptr));
				}
				F_SET(att_ptr, PDISEA);
			}
		
			if(F_ISSET(crt_ptr, MBLNDR) && mrand(1,100) <= 15) 
			{
				if ( victim_is_monster )
				{
        			broadcast_rom(-1, att_ptr->rom_num,"%M blinds %m.", 
						m2args(crt_ptr, att_ptr));
				}
				else
				{
					ANSI(fd, BLINDCOLOR);
					mprint(fd, "%M  blinds your eyes.\n", m1arg(crt_ptr));
				}
				F_SET(att_ptr, PBLIND);
			}
  
			if(F_ISSET(crt_ptr, MDISIT) && mrand(1,100) <= 15) 
				dissolve_item(att_ptr,crt_ptr);
                
			if ( !victim_is_monster )
			{
				ANSI(fd, MAINTEXTCOLOR);

				n = choose_item(att_ptr);

				if(n) 
				{
					if(--att_ptr->ready[n-1]->shotscur<1) 
					{
						sprintf(g_buffer,"Your %s fell apart.\n",att_ptr->ready[n-1]->name);
						output(fd, g_buffer);
						sprintf(g_buffer, "%%M's %s fell apart.", att_ptr->ready[n-1]->name);
						broadcast_rom(fd,att_ptr->rom_num, g_buffer,
							  m1arg(att_ptr));
						add_obj_crt(att_ptr->ready[n-1],att_ptr);
						dequip(att_ptr,att_ptr->ready[n-1]);
						att_ptr->ready[n-1] = 0;
						compute_ac(att_ptr);
					}
				}
			}
        
			if(!victim_is_monster && !F_ISSET(att_ptr, PNOAAT) && !p)
			{      
				rtn = attack_crt(att_ptr, crt_ptr);
				if(rtn) 
					return 1;
			}
			else 
			{      
				if(LT(att_ptr,LT_ATTCK) < t)
				{				   
					rtn = attack_crt(att_ptr, crt_ptr);
					att_ptr->lasttime[LT_ATTCK].ltime = t;
					if(rtn) 
						return 1;
				}
			}
                
			if(att_ptr->hpcur < 1) 
			{
				if ( !victim_is_monster )
				{
					msprint(att_ptr, g_buffer, "%M killed you.\n", m1arg(crt_ptr));
					output_wc(att_ptr->fd, g_buffer, ATTACKCOLOR); 
				}
				else
				{
					broadcast_rom(-1,att_ptr->rom_num,"%M killed %m.",
                       				m2args(crt_ptr, att_ptr));
				}
				die(att_ptr, crt_ptr);
				return 1;
			}
			else if ( !victim_is_monster )
			{
				if ( check_for_ply_flee( att_ptr ))
				{
					return(1);
				}
			}
		}
		else if(n <= 20 && !p) 
		{
			if ( !victim_is_monster )
			{
				msprint(att_ptr, g_buffer, "%M missed you.\n", 
					m1arg(crt_ptr));
				output_wc(att_ptr->fd, g_buffer, MISSEDCOLOR);
			}
			else
			{
				/* Output only when monster v. monster */
				broadcast_rom(-1, att_ptr->rom_num, "%M misses %m.", 
					m2args(crt_ptr, att_ptr));
				add_enm_crt(crt_ptr->name, att_ptr);
			}
			if(!victim_is_monster && !F_ISSET(att_ptr, PNOAAT))
			{      
				rtn = attack_crt(att_ptr, crt_ptr);
				if(rtn) 
					return 1;
			}
			else 
			{      
				if(LT(att_ptr,LT_ATTCK) < t)
				{			
					rtn = attack_crt(att_ptr, crt_ptr);
					att_ptr->lasttime[LT_ATTCK].ltime = t;
					if(rtn) 
						return 1;
				}
			}
		}
	}
コード例 #20
0
ファイル: g_world_map.c プロジェクト: Abstrusle/LCTourn
// sets up map_init with details for a map randomly scattered with data wells.
void generate_scattered_map(int area_index,
																												int size_blocks,
																					       int players,
																					       unsigned int map_seed)
{

//fpr("\n gsm area %i size %i [%i] pl %i [%i] ms %i", area_index, size_blocks, w_init.map_size_blocks, players, w_init.players, map_seed);

	seed_mrand(map_seed);

 reset_map_init(size_blocks,
																area_index,
																players);


 map_gen_state.base_data_wells = 0;

#define DATA_WELL_EDGE_DISTANCE 12
#define DATA_WELL_SEPARATION 12

 int base_min_x = DATA_WELL_EDGE_DISTANCE;
 int base_min_y = DATA_WELL_EDGE_DISTANCE;
 int base_max_x;
 int base_max_y;
 int total_base_data_wells;
 int base_var_x;
 int base_var_y;
 int symmetry_mode = 0; // currently only used for 2 players


 switch(w_init.players)
 {
 	default:
 	 case 2:
 	 	total_base_data_wells = 2 + mrand(DATA_WELLS / 2 - 2);
    symmetry_mode = mrand(4);
    if (symmetry_mode < 2) // left/right
				{
 	 	 base_max_x = (map_init.map_size_blocks / 2) - DATA_WELL_EDGE_DISTANCE;
 	 	 base_max_y = map_init.map_size_blocks - base_min_y;
     base_var_x = base_max_x - base_min_x;
     base_var_y = base_max_y - base_min_y;
     map_gen_state.base_spawn_position_x = base_min_x + mrand((base_var_x / 3) * 2);
     map_gen_state.base_spawn_position_y = base_min_y + mrand(base_var_y - 4);
				}
				 else // up/down
					{
 	 	  base_max_x = map_init.map_size_blocks - base_min_x;
 	 	  base_max_y = (map_init.map_size_blocks / 2) - DATA_WELL_EDGE_DISTANCE;
      base_var_x = base_max_x - base_min_x;
      base_var_y = base_max_y - base_min_y;
      map_gen_state.base_spawn_position_x = base_min_x + mrand(base_var_x - 4);
      map_gen_state.base_spawn_position_y = base_min_y + mrand((base_var_y / 3) * 2);
					}
 	 	break;
 	 case 3:
 	 	base_max_x = (map_init.map_size_blocks / 2) - DATA_WELL_EDGE_DISTANCE;
 	 	base_max_y = (map_init.map_size_blocks / 2) - DATA_WELL_EDGE_DISTANCE;
 	 	total_base_data_wells = 2 + mrand(DATA_WELLS / 3 - 1);
    base_var_x = base_max_x - base_min_x;
    base_var_y = base_max_y - base_min_y;
    map_gen_state.base_spawn_position_x = base_min_x + mrand((base_var_x / 3) * 2);
    map_gen_state.base_spawn_position_y = base_min_y + mrand((base_var_y / 3) * 2);
 	 	break;
 	 case 4:
 	 	base_max_x = (map_init.map_size_blocks / 2) - DATA_WELL_EDGE_DISTANCE;
 	 	base_max_y = (map_init.map_size_blocks / 2) - DATA_WELL_EDGE_DISTANCE;
 	 	total_base_data_wells = 2 + mrand(DATA_WELLS / 4 - 1);
    base_var_x = base_max_x - base_min_x;
    base_var_y = base_max_y - base_min_y;
    map_gen_state.base_spawn_position_x = base_min_x + mrand((base_var_x / 3) * 2);
    map_gen_state.base_spawn_position_y = base_min_y + mrand((base_var_y / 3) * 2);
 	 	break;
 }


// now place the initial data well next to the spawn point:
	map_gen_state.base_data_well_x [0] = map_gen_state.base_spawn_position_x;
	map_gen_state.base_data_well_y [0] = map_gen_state.base_spawn_position_y;

 if (map_gen_state.base_spawn_position_x < base_min_x + 4)
		map_gen_state.base_data_well_x [0] = map_gen_state.base_spawn_position_x + 4;
		 else
			{
    if (map_gen_state.base_spawn_position_y < base_min_y + 4)
		   map_gen_state.base_data_well_y [0] = map_gen_state.base_spawn_position_y + 4;
		    else
						{
       if (map_gen_state.base_spawn_position_y > base_max_y - 5)
		      map_gen_state.base_data_well_y [0] = map_gen_state.base_spawn_position_y - 4;
		       else
									{
										// default position (if not near any other edge edge) is to put data well to left of spawn position:
		        map_gen_state.base_data_well_x [0] = map_gen_state.base_spawn_position_x - 4;
									}
						}
			}

// if (mrand(6) != 0)
	{
  map_gen_state.base_data_well_reserve_data [map_gen_state.base_data_wells] [0] = 1500;
  map_gen_state.base_data_well_reserve_data [map_gen_state.base_data_wells] [1] = 1000;
  map_gen_state.base_data_well_reserve_squares [map_gen_state.base_data_wells] = 4;
  map_gen_state.base_data_well_spin [map_gen_state.base_data_wells] = 0.003; // okay to use float as this doesn't affect anything
	}

 map_gen_state.base_data_wells = 1;

 int attempt_counter = 0;

 while (map_gen_state.base_data_wells < total_base_data_wells)
	{
		while(TRUE)
		{
			int new_block_x = base_min_x + mrand(base_var_x);
			int new_block_y = base_min_y + mrand(base_var_y);
		 if (abs(new_block_x - map_gen_state.base_spawn_position_x) >= 8
				|| abs(new_block_y - map_gen_state.base_spawn_position_y) >= 8)
		 {

				 	if (check_map_gen_state_data_well_position(new_block_x, new_block_y))
						{

       map_gen_state.base_data_well_x [map_gen_state.base_data_wells] = new_block_x;
       map_gen_state.base_data_well_y [map_gen_state.base_data_wells] = new_block_y;
       map_gen_state.base_data_well_reserve_data [map_gen_state.base_data_wells] [0] = 500 + mrand(1000);
       map_gen_state.base_data_well_reserve_data [map_gen_state.base_data_wells] [1] = 500 + mrand(1000);
       map_gen_state.base_data_well_reserve_squares [map_gen_state.base_data_wells] = 2 + mrand(4);
       map_gen_state.base_data_well_spin [map_gen_state.base_data_wells] = 0.002 + mrand(10) * 0.0001; // okay to use float as this doesn't affect anything
	      if (mrand(2))
		      map_gen_state.base_data_well_spin [map_gen_state.base_data_wells] *= -1;

							map_gen_state.base_data_wells ++;
							attempt_counter = 0;
							break; // out of while(TRUE) loop
						}
		 }

  			attempt_counter ++;

			if (attempt_counter > 1000) // unlikely but let's check anyway (could happen on small 4 player maps, I guess)
 			break;
		}; // end while(TRUE) loop
		if (attempt_counter > 1000)
			break;
	} // end for i data wells loop



 switch(map_init.players)
 {
 	default: // should never happen
 	case 2:
   place_player_on_map_init(0, map_gen_state.base_spawn_position_x, map_gen_state.base_spawn_position_y, 1, 1);
   switch(symmetry_mode)
   {
   	case 0: // left/right mirror
     place_player_on_map_init(1, map_init.map_size_blocks - map_gen_state.base_spawn_position_x, map_gen_state.base_spawn_position_y, -1, 1);
     break;
    case 1: // L/R rotation
     place_player_on_map_init(1, map_init.map_size_blocks - map_gen_state.base_spawn_position_x, map_init.map_size_blocks - map_gen_state.base_spawn_position_y, -1, -1);
					break;
    case 2: // U/D mirror
     place_player_on_map_init(1, map_gen_state.base_spawn_position_x, map_init.map_size_blocks - map_gen_state.base_spawn_position_y, 1, -1);
     break;
    case 3: // U/D rotation
     place_player_on_map_init(1, map_init.map_size_blocks - map_gen_state.base_spawn_position_x, map_init.map_size_blocks - map_gen_state.base_spawn_position_y, -1, -1);
     break;
   }
   break;
 	case 3:
// for now, 3-player maps are just 4-player maps with one player missing
   {
   	int missing_position = mrand(4);
   	int player_index = 0;
   	if (missing_position != 0)
     place_player_on_map_init(player_index++, map_gen_state.base_spawn_position_x, map_gen_state.base_spawn_position_y, 1, 1);
   	if (missing_position != 1)
     place_player_on_map_init(player_index++, map_init.map_size_blocks - map_gen_state.base_spawn_position_x, map_gen_state.base_spawn_position_y, -1, 1);
   	if (missing_position != 2)
     place_player_on_map_init(player_index++, map_init.map_size_blocks - map_gen_state.base_spawn_position_x, map_init.map_size_blocks - map_gen_state.base_spawn_position_y, -1, -1);
   	if (missing_position != 3)
     place_player_on_map_init(player_index++, map_gen_state.base_spawn_position_x, map_init.map_size_blocks - map_gen_state.base_spawn_position_y, 1, -1);
   }
   break;
 	case 4:
// for now, 4-player maps are always mirrored (implement rotation later)
   place_player_on_map_init(0, map_gen_state.base_spawn_position_x, map_gen_state.base_spawn_position_y, 1, 1);
   place_player_on_map_init(1, map_init.map_size_blocks - map_gen_state.base_spawn_position_x, map_gen_state.base_spawn_position_y, -1, 1);
   place_player_on_map_init(2, map_init.map_size_blocks - map_gen_state.base_spawn_position_x, map_init.map_size_blocks - map_gen_state.base_spawn_position_y, -1, -1);
   place_player_on_map_init(3, map_gen_state.base_spawn_position_x, map_init.map_size_blocks - map_gen_state.base_spawn_position_y, 1, -1);
   break;
 }


}
コード例 #21
0
ファイル: creature2.cpp プロジェクト: RealmsMud/RealmsCode
void Monster::adjust(int buffswitch) {
    int     buff=0, crthp=0;
    long    xpmod=0;

    if(buffswitch == -1)
        buff = mrand(1,3)-1;
    else
        buff = MAX(0, MIN(buffswitch, 2));


    /*          Web Editor
     *           _   _  ____ _______ ______
     *          | \ | |/ __ \__   __|  ____|
     *          |  \| | |  | | | |  | |__
     *          | . ` | |  | | | |  |  __|
     *          | |\  | |__| | | |  | |____
     *          |_| \_|\____/  |_|  |______|
     *
     *      If you change anything here, make sure the changes are reflected in the web
     *      editor! Either edit the PHP yourself or tell Dominus to make the changes.
     */
    if(!flagIsSet(M_CUSTOM)) {
        if(level >= 1 && level <= MAXALVL) {
            setArmor(balancedStats[level].armor);
            weaponSkill = (level-1)*10;
            defenseSkill = (level-1)*10;
            setExperience(balancedStats[level].experience);
            damage.setNumber(balancedStats[level].ndice);
            damage.setSides(balancedStats[level].sdice);
            damage.setPlus(balancedStats[level].pdice);
        } else {
            setArmor(100);
            weaponSkill = 1;
            defenseSkill = 1;
            setExperience(6);
            damage.setNumber(1);
            damage.setSides(4);
            damage.setPlus(0);
        }


        if(cClass == CreatureClass::NONE)
            hp.setInitial(level * monType::getHitdice(type));
        else {
            crthp = class_stats[(int) cClass].hpstart + (level*class_stats[(int) cClass].hp);
            hp.setInitial(MAX(crthp, (level * monType::getHitdice(type))));
        }

        hp.restore();

        xpmod = experience / 10;
        xpmod *= monType::getHitdice(type) - monType::getHitdice(HUMANOID);

        if(xpmod > 0)
            addExperience(xpmod);
        else
            subExperience(xpmod*-1);
    }


    switch(buff) {
    case 1:         // Mob is weak.
        hp.setInitial( hp.getMax() - hp.getMax()/5);
        hp.restore();
        coins.set(coins[GOLD] * 4 / 5, GOLD);

        subExperience(experience / 5);
        setArmor(armor - 100);
        damage.setNumber(damage.getNumber() * 9 / 10);
        damage.setPlus(damage.getPlus() * 9 / 10);
        break;
    case 2:         // Mob is stronger
        hp.setInitial( hp.getMax() + hp.getMax()/5);
        hp.restore();
        coins.set(coins[GOLD] * 6 / 5, GOLD);

        addExperience(experience / 5);
        defenseSkill += 5;
        weaponSkill += 5;
        setArmor(armor + 100);

        damage.setNumber(damage.getNumber() * 11 / 10);
        damage.setPlus(damage.getPlus() * 11 / 10);
        break;
    default:
        break;
    }

    armor = MAX<unsigned int>(MIN(armor, MAX_ARMOR), 0);

    if(level >= 7)
        setFlag(M_BLOCK_EXIT);

}
コード例 #22
0
ファイル: creature2.cpp プロジェクト: RealmsMud/RealmsCode
int Monster::doHarmfulAuras() {
    int         a=0,dmg=0,aura=0, saved=0;
    long        i=0,t=0;
    BaseRoom    *inRoom=0;
    Creature* player=0;

    if(isPet())
        return(0);
    if(hp.getCur() < hp.getMax()/10)
        return(0);
    if(flagIsSet(M_CHARMED))
        return(0);

    for(a=0;a<MAX_AURAS;a++) {
        if(flagIsSet(M_FIRE_AURA + a))
            aura++;
    }

    if(!aura)
        return(0);

    i = lasttime[LT_M_AURA_ATTACK].ltime;
    t = time(0);

    if(t - i < 20L) // Mob has to wait 20 seconds.
        return(0);
    else {
        lasttime[LT_M_AURA_ATTACK].ltime = t;
        lasttime[LT_M_AURA_ATTACK].interval = 20L;
    }

    inRoom = getRoomParent();
    if(!inRoom)
        return(0);

    for(a=0;a<MAX_AURAS;a++) {

        if(!flagIsSet(M_FIRE_AURA + a))
            continue;
        PlayerSet::iterator pIt = inRoom->players.begin();
        PlayerSet::iterator pEnd = inRoom->players.end();
        while(pIt != pEnd) {
            player = (*pIt++);

            if(player->isEffected("petrification") || player->isCt())
                continue;

            dmg = mrand(level/2, (level*3)/2);

            dmg = MAX(2,dmg);

            switch(a+M_FIRE_AURA) {
            case M_FIRE_AURA:
                if(player->isEffected("heat-protection") || player->isEffected("alwayswarm"))
                    continue;

                saved = player->chkSave(BRE, this, 0);
                if(saved)
                    dmg /=2;
                player->printColor("^R%M's firey aura singes you for %s%d^R damage!\n", this, player->customColorize("*CC:DAMAGE*").c_str(), dmg);
                break;
            case M_COLD_AURA:
                if(player->isEffected("warmth") || player->isEffected("alwayscold"))
                    continue;

                saved = player->chkSave(BRE, this, 0);
                if(saved)
                    dmg /=2;
                player->printColor("^C%M's freezing aura chills you for %s%d^C damage!\n", this, player->customColorize("*CC:DAMAGE*").c_str(), dmg);
                break;
            case M_NAUSEATING_AURA:
                if(player->immuneToPoison())
                    continue;

                saved = player->chkSave(POI, this, 0);
                if(saved)
                    dmg /=2;
                player->printColor("^g%M's foul stench chokes and nauseates you for %s%d^g damage.\n", this, player->customColorize("*CC:DAMAGE*").c_str(), dmg);
                break;
            case M_NEGATIVE_LIFE_AURA:
                if(player->isUndead() || player->isEffected("drain-shield"))
                    continue;

                saved = player->chkSave(DEA, this, 0);
                if(saved)
                    dmg /=2;
                player->printColor("^m%M's negative aura taps your life for %s%d^m damage.\n", this, player->customColorize("*CC:DAMAGE*").c_str(), dmg);
                break;
            case M_TURBULENT_WIND_AURA:
                if(player->isEffected("wind-protection"))
                    continue;

                saved = player->chkSave(BRE, this, 0);
                if(saved)
                    dmg /=2;
                player->printColor("^W%M's turbulent winds buff you about for %s%d^W damage.\n", this, player->customColorize("*CC:DAMAGE*").c_str(), dmg);
                break;
            }

            player->hp.decrease(dmg);
            if(player->checkDie(this))
                return(1);

        }// End while
    }// End for

    return(0);
}
コード例 #23
0
ファイル: realms.cpp プロジェクト: RealmsMud/RealmsCode
int getRandomRealm() {
    return(mrand(EARTH,COLD));
}
コード例 #24
0
ファイル: healmagic.cpp プロジェクト: RealmsMud/RealmsCode
int getHeal(Creature *healer, Creature* target, int spell) {
    Player  *pHealer = healer->getAsPlayer();
    int     level=0, statBns=0, base=0, mod=0, heal=0, dmg=0;
    int     vigPet=0;

    if(target) {
        /* Mobs with intelligence > 12 do not like people vigging their enemies and
           will attack them. -TC */
        if(target != healer && target->isPlayer() && target->inCombat()) {
            for(Monster* mons : target->getRoomParent()->monsters) {
                if(mons->intelligence.getCur() > 120 && mons->getAsMonster()->isEnemy(target))
                    mons->getAsMonster()->addEnemy(healer);

            }
        }

        if(target == healer)
            target = 0;
    }

    level = healer->getLevel();
    if( pHealer &&
        pHealer->getClass() == CreatureClass::CLERIC &&
        (   pHealer->getSecondClass() == CreatureClass::FIGHTER ||
            pHealer->getSecondClass() == CreatureClass::ASSASSIN
        )
    )
        level /= 2;

    if(target)
        vigPet = target->isPet() && target->getMaster() == healer;

    switch(spell) {
    case S_VIGOR:
        base = mrand(1,8); //1d8
        break;
    case S_MEND_WOUNDS:
        base = dice(2,7,0); //2d7
        break;
    case S_REJUVENATE:
        base = dice(1,6,1); // 1d6+1
        break;
    }

    switch(healer->getClass()) {
    case CreatureClass::CLERIC:
        statBns = bonus((int)healer->piety.getCur());

        switch(healer->getDeity()) {
        case CERIS:
            if(healer->getAdjustedAlignment() == BLOODRED || healer->getAdjustedAlignment() == ROYALBLUE) {
                healer->print("Your healing is not as effective while so far out of natural balance.\n");
                level /= 2;
            }


            mod = level / 2 + mrand(1, 1 + level / 2);
            if(healer->getAdjustedAlignment() == NEUTRAL) {
                if(spell != S_REJUVENATE)
                    healer->print("Your harmonial balance gains you power with Ceris.\n");
                mod += mrand(1,4);
            }

            if(spell == S_MEND_WOUNDS)
                mod += level / 2;

            if(spell == S_REJUVENATE)
                mod = level / 3 + mrand(1, 1 + level / 3);

            break;
        case ARES:
            level /= 2; // Ares clerics vig as if 1/2 their level

            if(healer->getAdjustedAlignment() >= BLUISH || healer->getAdjustedAlignment() <= REDDISH) {
                healer->print("Your soul is too far out of balance.\n");
                level /= 2;
            }

            mod = level / 2 + mrand(1, 1 + level / 2);

            if(spell == S_MEND_WOUNDS)
                mod += level / 2;

            break;
        case KAMIRA:
            level = (level*3)/4;
            if(healer->getAdjustedAlignment() < PINKISH) {
                healer->print("Being evil at heart is distorting your healing magic.\n");
                level /= 2;
            }
            mod = level / 2 + mrand(1, 1 + level / 2);

            if(spell == S_MEND_WOUNDS)
                mod += level / 2;
            break;
        case JAKAR:
            if(healer->getAdjustedAlignment() != NEUTRAL) {
                healer->print("Your soul is out of balance.\n");
                level /= 2;
            }

            mod = level / 2 + mrand(1, 1 + level / 2);
            if(spell == S_MEND_WOUNDS)
                mod += level / 2;

            mod = (mod*3)/4;
            break;
        }// end deity switch
        break;

    case CreatureClass::DRUID:
        statBns = MAX(bonus((int)healer->intelligence.getCur()), bonus((int)healer->constitution.getCur()));
        mod = level/4 + mrand(1, 1 + level / 5);
        break;
    case CreatureClass::THIEF:
    case CreatureClass::ASSASSIN:
    case CreatureClass::ROGUE:
    case CreatureClass::FIGHTER:
    case CreatureClass::BERSERKER:

    case CreatureClass::WEREWOLF:
        statBns = bonus((int)healer->constitution.getCur());
        mod = 0;
        break;
    case CreatureClass::MONK:
        statBns = bonus((int)healer->constitution.getCur());
        mod = mrand(1,6);
        break;

    case CreatureClass::RANGER:
    case CreatureClass::BARD:
    case CreatureClass::PUREBLOOD:
        statBns = MAX(bonus((int)healer->piety.getCur()), bonus((int)healer->intelligence.getCur()));
        mod = mrand(1,6);
        break;
    case CreatureClass::MAGE:
        statBns = MAX(bonus((int)healer->piety.getCur()), bonus((int)healer->intelligence.getCur()));
        mod = 0;
        break;

    case CreatureClass::CARETAKER:
    case CreatureClass::DUNGEONMASTER:
        statBns = MAX(bonus((int)healer->piety.getCur()), bonus((int)healer->intelligence.getCur()));
        mod = mrand(level/2, level);
        break;

    default:
        statBns = 0;
        mod = 0;
        break;
    } // end class switch



    // ----------------------------------------------------------------------
    // ----------------------------------------------------------------------

    // clerics and paladins of Gradius
    if(healer->getDeity() == GRADIUS) {
        statBns = bonus((int)healer->piety.getCur());

        if(pHealer && !pHealer->alignInOrder()) {
            healer->print("You are out of balance with the earth. Your healing is weakened.\n");
            level /= 2;
        }

        if(target && target->isAntiGradius()) {
            healer->print("%s is very puzzled by your healing beings of vile races.\n", gConfig->getDeity(healer->getDeity())->getName().c_str());
            mod /= 2;
        }

        if(healer->getClass() == CreatureClass::CLERIC) {
            mod = level / 2 + mrand(1, 1 + level / 2);
            if(spell == S_MEND_WOUNDS)
                mod += level / 2;
            mod = (mod*3)/4;
        } else {
            if(spell == S_VIGOR)
                mod = level / 3 + mrand(1, 1 + level / 4);
            else
                mod = level / 2 + mrand(1, 1 + level / 3);
        }

    // clerics and paladins of Enoch and Linothan
    } else if(healer->getDeity() == ENOCH || healer->getDeity() == LINOTHAN) {
        statBns = bonus((int)healer->piety.getCur());

        if(pHealer && !pHealer->alignInOrder()) {
            healer->print("Your healing magic is weakened from lack of faith in %s.\n", gConfig->getDeity(healer->getDeity())->getName().c_str());
            level /= 2;
        }

        if(target && target->getAdjustedAlignment() < NEUTRAL && healer != target) {
            healer->print("It concerns %s that you heal the unrighteous and impure of heart.\n", gConfig->getDeity(healer->getDeity())->getName().c_str());
            healer->subAlignment(1);
            mod /= 2;
        }

        if(healer->getClass() == CreatureClass::CLERIC) {
            mod = level / 2 + mrand(1, 1 + level / 2);
            if(spell == S_MEND_WOUNDS)
                mod += level / 2;
        } else {
            if(spell == S_VIGOR)
                mod = level / 3 + mrand(1, 1 + level / 4);
            else
                mod = level / 2 + mrand(1, 1 + level / 3);
        }

    // clerics and deathknights of Aramon and Arachnus
    } else if(healer->getDeity() == ARAMON || healer->getDeity() == ARACHNUS) {
        statBns = bonus((int)healer->piety.getCur());

        if(pHealer && !pHealer->alignInOrder())
            level /= 2;

        if(healer->getAdjustedAlignment() >= LIGHTBLUE) {

            healer->print("FOOL! You dare turn from %s's evil ways!\n", gConfig->getDeity(healer->getDeity())->getName().c_str());
            dmg = mrand(1,10);
            healer->print("You are shocked for %d damage by %s's wrath!\n", dmg, gConfig->getDeity(healer->getDeity())->getName().c_str());
            broadcast(healer->getSock(), healer->getRoomParent(), "%M doubles over in pain and wretches.\n", healer);
            healer->hp.decrease(dmg);
            mod = 0;

        } else if(target && healer != target && !vigPet) {

            if(target->getAdjustedAlignment() > LIGHTBLUE) {
                healer->print("How DARE you heal the righteous and good of heart!\n");
                dmg = mrand(1,10);
                healer->print("You are shocked for %d damage by %s's wrath!\n", dmg, gConfig->getDeity(healer->getDeity())->getName().c_str());
                broadcast(healer->getSock(), healer->getRoomParent(), "%M doubles over in pain and wretches.\n", healer);
                healer->hp.decrease(dmg);
                mod = 0;
            } else if(  healer->getDeity() == ARAMON || (
                healer->getDeity() == ARACHNUS &&
                (healer->willIgnoreIllusion() ? target->getRace() : target->getDisplayRace()) != DARKELF
            )) {
                if(healer->getDeity() == ARAMON)
                    healer->print("%s disapproves of healing others than yourself.\n", gConfig->getDeity(healer->getDeity())->getName().c_str());
                else
                    healer->print("%s disapproves of healing non-dark-elves.\n", gConfig->getDeity(healer->getDeity())->getName().c_str());
                mod = mrand(1, (1 + level / 5));
            }

        } else {

            if(healer->getClass() == CreatureClass::CLERIC) {
                mod = level / 2 + mrand(1, 1 + level / 2);
                if(spell == S_MEND_WOUNDS)
                    mod += level / 2;
            } else {
                mod = level / 4 + mrand(1, 1 + level / 4);
            }

        }

    }

    // ----------------------------------------------------------------------
    // ----------------------------------------------------------------------


    heal = base + statBns + mod;

    if(healer->getRoomParent()->magicBonus()) {
        if(spell == S_MEND_WOUNDS)
            heal += mrand(1, 6);
        else
            heal += mrand(1, 3);
        healer->print("The room's magical properties increase the power of your spell.\n");
    }

    if(target && healer != target) {
        if(target->isPlayer()) {
            if(target->isEffected("stoneskin"))
                heal /= 2;

            if(target->flagIsSet(P_POISONED_BY_PLAYER))
                heal = mrand(1,4);

            if(target->flagIsSet(P_OUTLAW) && target->getRoomParent()->isOutlawSafe())
                heal = mrand(1,3);

        }
    } else {
        if(healer->isEffected("stoneskin"))
            heal /= 2;
        if(healer->flagIsSet(P_OUTLAW) && healer->getRoomParent()->isOutlawSafe())
            heal = mrand (1,3);
    }

    return(MAX(1, heal));
}
コード例 #25
0
ファイル: abjuration.cpp プロジェクト: RealmsMud/RealmsCode
int splDispelAlign(Creature* player, cmd* cmnd, SpellData* spellData, const char* spell, int align) {
    Creature* target=0;
    Damage damage;


    if((target = player->findMagicVictim(cmnd->str[2], cmnd->val[2], spellData, true, false, "Cast on what?\n", "You don't see that here.\n")) == nullptr)
        return(0);

    if(player == target) {
        // mobs can't cast on themselves!
        if(!player->getAsPlayer())
            return(0);

        // turn into a boolean!
        // are they in alignment?
        if(align == PINKISH)
            align = player->getAlignment() <= align;
        else
            align = player->getAlignment() >= align;

        if(spellData->how == CastType::CAST || spellData->how == CastType::SCROLL || spellData->how == CastType::WAND)
            player->print("You cannot cast that spell on yourself.\n");
        else if(spellData->how == CastType::POTION && !align)
            player->print("Nothing happens.\n");
        else if(spellData->how == CastType::POTION && align) {
            player->smashInvis();

            damage.set(mrand(spellData->level * 2, spellData->level * 4));
            damage.add(MAX(0, bonus((int) player->piety.getCur())));
            player->modifyDamage(player, MAGICAL, damage);

            player->print("You feel as if your soul is savagely ripped apart!\n");
            player->printColor("You take %s%d^x points of damage!\n", player->customColorize("*CC:DAMAGE*").c_str(), damage.get());
            broadcast(player->getSock(), player->getParent(), "%M screams and doubles over in pain!", player);
            player->hp.decrease(damage.get());
            if(player->hp.getCur() < 1) {
                player->print("Your body explodes. You're dead!\n");
                broadcast(player->getSock(), player->getParent(), "%M's body explodes! %s's dead!", player,
                        player->upHeShe());
                player->getAsPlayer()->die(EXPLODED);
            }
        }

    } else {
        if(player->spellFail( spellData->how))
            return(0);

        cmnd->str[2][0] = up(cmnd->str[2][0]);
        target = player->getParent()->findCreature(player, cmnd->str[2], cmnd->val[2], false);

        if(!target) {
            player->print("That's not here.\n");
            return(0);
        }

        if(!player->canAttack(target))
            return(0);

        if( (target->getLevel() > spellData->level + 7) ||
            (!player->isStaff() && target->isStaff())
        ) {
            player->print("Your magic would be too weak to harm %N.\n", target);
            return(0);
        }

        player->smashInvis();
        // turn into a boolean!
        // are they in alignment?
        if(align == PINKISH)
            align = target->getAlignment() <= align;
        else
            align = target->getAlignment() >= align;



        if(spellData->how == CastType::CAST || spellData->how == CastType::SCROLL || spellData->how == CastType::WAND) {
            player->print("You cast %s on %N.\n", spell, target);
            broadcast(player->getSock(), target->getSock(), player->getParent(), "%M casts a %s spell on %N.", player, spell, target);

            if(target->getAsPlayer()) {
                target->wake("Terrible nightmares disturb your sleep!");
                target->print("%M casts a %s spell on you.\n", player, spell);
            }

            if(!align) {
                player->print("Nothing happens.\n");
            } else {
                damage.set(mrand(spellData->level * 2, spellData->level * 4));
                damage.add(abs(player->getAlignment()/100));
                damage.add(MAX(0, bonus((int) player->piety.getCur())));
                target->modifyDamage(player, MAGICAL, damage);

                if(target->chkSave(SPL, player,0))
                    damage.set(damage.get() / 2);

                player->printColor("The spell did %s%d^x damage.\n", player->customColorize("*CC:DAMAGE*").c_str(), damage.get());
                player->print("%M screams in agony as %s soul is ripped apart!\n",
                    target, target->hisHer());
                target->printColor("You take %s%d^x points of damage as your soul is ripped apart!\n", target->customColorize("*CC:DAMAGE*").c_str(), damage.get());
                broadcastGroup(false, target, "%M cast a %s spell on ^M%N^x for *CC:DAMAGE*%d^x damage, %s%s\n",
                    player, spell, target, damage.get(), target->heShe(), target->getStatusStr(damage.get()));

                broadcast(player->getSock(), target->getSock(), player->getParent(), "%M screams and doubles over in pain!", target);

                // if the target is reflecting magic, force printing a message (it will say 0 damage)
                player->doReflectionDamage(damage, target, target->isEffected("reflect-magic") ? REFLECTED_MAGIC : REFLECTED_NONE);

                if(spellData->how == CastType::CAST && player->isPlayer())
                    player->getAsPlayer()->statistics.offensiveCast();

                player->doDamage(target, damage.get(), NO_CHECK);
                if(target->hp.getCur() < 1) {
                    target->print("Your body explodes! You die!\n");
                    broadcast(player->getSock(), target->getSock(), player->getParent(),
                        "%M's body explodes! %s's dead!", target, target->upHeShe());
                    player->print("%M's body explodes! %s's dead!\n", target, target->upHeShe());
                    target->die(player);
                    return(2);
                }
            }

        }
    }

    return(1);
}
コード例 #26
0
ファイル: creature2.cpp プロジェクト: RealmsMud/RealmsCode
// Initializes last times, inventory, scrolls, etc
int Monster::initMonster(bool loadOriginal, bool prototype) {
    int n=0, alnum=0, x=0;
    long t=0;
    Object* object=0;

    t = time(0);
    // init the timers
    lasttime[LT_MON_SCAVANGE].ltime =
    lasttime[LT_MON_WANDER].ltime =
    lasttime[LT_MOB_THIEF].ltime =
    lasttime[LT_TICK].ltime = t;
    lasttime[LT_TICK_SECONDARY].ltime = t;
    lasttime[LT_TICK_HARMFUL].ltime = t;

    // Make sure armor is set properly
    if(armor < (unsigned)(balancedStats[MIN<short>(level, MAXALVL)].armor - 150)) {
        armor = balancedStats[MIN<short>(level, MAXALVL)].armor;
    }

    if(dexterity.getCur() < 200)
        setAttackDelay(30);
    else
        setAttackDelay(20);

    if(flagIsSet(M_FAST_TICK))
        lasttime[LT_TICK].interval = lasttime[LT_TICK_SECONDARY].interval = 15L;
    else if(flagIsSet(M_REGENERATES))
        lasttime[LT_TICK].interval = lasttime[LT_TICK_SECONDARY].interval = 15L;
    else
        lasttime[LT_TICK].interval = lasttime[LT_TICK_SECONDARY].interval = 60L - (2*bonus((int)constitution.getCur()));

    lasttime[LT_TICK_HARMFUL].interval = 30;
    // Randomize alignment and gold unless we don' want it
    if(!loadOriginal) {
        if(flagIsSet(M_ALIGNMENT_VARIES) && alignment != 0) {
            alnum = mrand(1,100);
            if(alnum == 1)
                alignment = 0;
            else if(alnum < 51)
                alignment = mrand((short)1, (short)std::abs(alignment)) * -1;
            else
                alignment = mrand((short)1, (short)std::abs(alignment));
        }

        if(!flagIsSet(M_NO_RANDOM_GOLD) && coins[GOLD])
            coins.set(mrand(coins[GOLD]/10, coins[GOLD]), GOLD);
    }
    // Check for loading of random scrolls
    if(checkScrollDrop()) {
        n = new_scroll(level, &object);
        if(n > 0) {
            object->value.zero();
            addObj(object);
            object->setFlag(O_JUST_LOADED);
        }
    }

    // Now load up any always drop objects (Trading perms don't drop inventory items)
    if(!flagIsSet(M_TRADES)) {
        for(x=0;x<10;x++) {
            if(!loadObject(carry[x].info, &object))
                continue;
            object->init(!prototype);
            if( object->flagIsSet(O_ALWAYS_DROPPED) &&
                !object->getName().empty() &&
                object->getName()[0] != ' ' )
            {
                addObj(object);
                object->setFlag(O_JUST_LOADED);
            } else {
                delete object;
                continue;
            }
        }

        object = 0;

        int numDrops = mrand(1,100), whichDrop=0;

             if(numDrops<90)    numDrops=1;
        else if(numDrops<96)    numDrops=2;
        else                    numDrops=3;

        if(prototype)
            numDrops = 10;
        for(x=0; x<numDrops; x++) {
            if(prototype)
                whichDrop=x;
            else
                whichDrop = mrand(0,9);
            if(carry[whichDrop].info.id && !flagIsSet(M_TRADES)) {
                if(!loadObject(carry[whichDrop].info, &object))
                    continue;
                if( object->getName().empty() || object->getName()[0] == ' ')
                {
                    delete object;
                    continue;
                }

                object->init(!prototype);

                // so we don't get more than one always drop item.
                if(object->flagIsSet(O_ALWAYS_DROPPED)) {
                    delete object;
                    continue;
                }

                object->value.set(mrand((object->value[GOLD]*9)/10,(object->value[GOLD]*11)/10), GOLD);

                addObj(object);
                object->setFlag(O_JUST_LOADED);
            }
        }
    }

    if(weaponSkill < (level * 3))
        weaponSkill = (level-1) * mrand(9,11);
    return(1);
}
コード例 #27
0
ファイル: healmagic.cpp プロジェクト: RealmsMud/RealmsCode
int splRejuvenate(Creature* player, cmd* cmnd, SpellData* spellData) {
    Creature* target=0;
    int     heal=0, mpHeal=0;

    if(!(player->getClass() == CreatureClass::CLERIC && player->getDeity() == CERIS) && spellData->how == CastType::CAST && !player->isCt()) {
        player->print("%s does not grant you the power to cast that spell.\n", gConfig->getDeity(player->getDeity())->getName().c_str());
        return(0);
    }



    if(player->getLevel() < 13 && !player->isCt()) {
        player->print("You are not high enough in your order to cast that spell.\n");
        return(0);
    }

    if(player->mp.getCur() < 8 && spellData->how == CastType::CAST) {
        player->print("Not enough magic points.\n");
        return(0);
    }


    if(player->flagIsSet(P_NO_TICK_MP)) {
        player->print("You cannot cast that spell right now.\n");
        return(0);
    }

    // Rejuvenate self
    if(cmnd->num == 2) {

        if( player->hp.getCur() >= player->hp.getMax() &&
            player->mp.getCur() >= player->mp.getMax() &&
            !player->checkStaff("You are already at full health and magic right now.\n") )
            return(0);

        if(spellData->how == CastType::CAST) {

            if(player->isPlayer())
                player->getAsPlayer()->statistics.healingCast();
            heal = getHeal(player, 0, S_REJUVENATE);
            mpHeal = getHeal(player, 0, S_REJUVENATE);

            if(!player->isCt()) {
                player->lasttime[LT_SPELL].ltime = time(0);
                player->lasttime[LT_SPELL].interval = 24L;
            }
            player->mp.decrease(8);

        } else {
            heal = mrand(1,8);
            mpHeal = mrand(1,8);
        }

        player->doHeal(player, heal);
        player->mp.increase(mpHeal);

        if(spellData->how == CastType::CAST || spellData->how == CastType::SCROLL) {

            player->print("Rejuvenate spell cast.\n");
            broadcast(player->getSock(), player->getParent(), "%M casts a rejuvenate spell on %sself.",
                player, player->himHer());

        } else {
            player->print("You feel revitalized.\n");
        }

    // Cast rejuvenate on another player or monster
    } else {
        if(player->noPotion( spellData))
            return(0);

        cmnd->str[2][0] = up(cmnd->str[2][0]);
        target = player->getParent()->findCreature(player, cmnd->str[2], cmnd->val[2], false);
        if(!target) {
            player->print("That person is not here.\n");
            return(0);
        }

        if(!canCastHealing(player, target, true))
            return(0);

        if(target->hp.getCur() >= target->hp.getMax() && target->mp.getCur() >= target->mp.getMax()) {
            player->print("%M is at full health and magic right now.\n", target);
            return(0);
        }

        if(target->flagIsSet(P_NO_TICK_MP) || target->flagIsSet(P_NO_TICK_HP)) {
            player->print("Your rejuvinating magic is ineffective.\n");
            return(0);
        }

        if(target->inCombat(false))
            player->smashInvis();

        if(spellData->how == CastType::CAST && !player->isCt()) {
            player->lasttime[LT_SPELL].ltime = time(0);
            player->lasttime[LT_SPELL].interval = 24L;
        }


        if(spellData->how == CastType::CAST) {
            if(player->isPlayer())
                player->getAsPlayer()->statistics.healingCast();
            player->mp.decrease(8);
            heal = getHeal(player, target, S_REJUVENATE);
            mpHeal = getHeal(player, target, S_REJUVENATE);

        } else {
            heal = mrand(1,8);
            mpHeal = mrand(1,8);
        }

        heal = player->doHeal(target, heal);
        mpHeal = target->mp.increase(mpHeal);

        if(spellData->how == CastType::CAST || spellData->how == CastType::SCROLL || spellData->how == CastType::WAND) {

            player->print("Rejuvenate spell cast on %N.\n", target);
            target->print("%M casts a rejuvenate spell on you.\n", player);
            broadcast(player->getSock(), target->getSock(), player->getParent(), "%M casts a rejuvenate spell on %N.",
                player, target);

            niceExp(player, target, (heal+mpHeal)/2, spellData->how);
        }
    }

    return(1);
}
コード例 #28
0
ファイル: abjuration.cpp プロジェクト: RealmsMud/RealmsCode
int doDispelMagic(Creature* player, cmd* cmnd, SpellData* spellData, const char* spell, int numDispel) {
    Creature* target=0;
    int     chance=0;

    if(spellData->how == CastType::CAST &&
        player->getClass() !=  CreatureClass::MAGE &&
        player->getClass() !=  CreatureClass::LICH &&
        player->getClass() !=  CreatureClass::CLERIC &&
        player->getClass() !=  CreatureClass::DRUID &&
        !player->isStaff()
    ) {
        player->print("Only mages, liches, clerics, and druids may cast that spell.\n");
        return(0);
    }

    if(cmnd->num == 2) {
        target = player;
        broadcast(player->getSock(), player->getParent(), "%M casts a %s spell on %sself.", player, spell, player->himHer());


        player->print("You cast a %s spell on yourself.\n", spell);
        player->print("Your spells begin to dissolve away.\n");


        player->doDispelMagic(numDispel);
    } else {
        if(player->noPotion( spellData))
            return(0);

        cmnd->str[2][0] = up(cmnd->str[2][0]);
        target = player->getParent()->findPlayer(player, cmnd, 2);
        if(!target) {
            // dispel-magic on an exit
            cmnd->str[2][0] = low(cmnd->str[2][0]);
            Exit* exit = findExit(player, cmnd, 2);

            if(exit) {
                player->printColor("You cast a %s spell on the %s^x.\n", spell, exit->getCName());
                broadcast(player->getSock(), player->getParent(), "%M casts a %s spell on the %s^x.", player, spell, exit->getCName());

                if(exit->flagIsSet(X_PORTAL))
                    Move::deletePortal(player->getRoomParent(), exit);
                else
                    exit->doDispelMagic(player->getRoomParent());
                return(0);
            }

            player->print("You don't see that player here.\n");
            return(0);
        }

        if(player->isPlayer() && player->getRoomParent()->isPkSafe() && (!player->isCt()) && !target->flagIsSet(P_OUTLAW)) {
            player->print("That spell is not allowed here.\n");
            return(0);
        }

        if(!target->isEffected("petrification")) {
            if(!player->canAttack(target))
                return(0);
        } else {
            player->print("You cast a %s spell on %N.\n%s body returns to flesh.\n",
                spell, target, target->upHisHer());
            if(mrand(1,100) < 50) {

                target->print("%M casts a %s spell on you.\nYour body returns to flesh.\n", player, spell);
                broadcast(player->getSock(), target->getSock(), player->getParent(),
                    "%M casts a %s spell on %N.\n%s body returns to flesh.\n",
                    player, spell, target, target->upHisHer());
                target->removeEffect("petrification");
                return(1);
            } else {
                target->print("%M casts a dispel-magic spell on you.\n", player);
                broadcast(player->getSock(), target->getSock(), player->getParent(), "%M casts a dispel-magic spell on %N.\n",player, target);
                return(0);
            }


        }


        chance = 50 - (10*(bonus((int) player->intelligence.getCur()) -
            bonus((int) target->intelligence.getCur())));

        chance += (spellData->level - target->getLevel())*10;

        chance = MIN(chance, 90);

        if((target->isEffected("resist-magic")) && target->isPlayer())
            chance /=2;




        if( player->isCt() ||
            (mrand(1,100) <= chance && !target->chkSave(SPL, player, 0)))
        {
            player->print("You cast a %s spell on %N.\n", spell, target);

            logCast(player, target, spell);

            broadcast(player->getSock(), target->getSock(), player->getParent(), "%M casts a %s spell on %N.", player, spell, target);
            target->print("%M casts a %s spell on you.\n", player, spell);
            target->print("Your spells begin to dissolve away.\n");


            target->doDispelMagic(numDispel);

            for(Monster* pet : target->pets) {
                if(pet) {
                    if(player->isCt() || !pet->chkSave(SPL, player, 0)) {
                        player->print("Your spell bansished %N's %s!\n", target, pet->getCName());
                        target->print("%M's spell banished your %s!\n%M fades away.\n", player, pet->getCName(), pet);
                        gServer->delActive(pet);
                        pet->die(pet->getMaster());
                    }
                }
            }
        } else {
            player->printColor("^yYour spell fails against %N.\n", target);
            target->print("%M tried to cast a dispel-magic spell on you.\n", player);
            broadcast(player->getSock(), target->getSock(), player->getParent(), "%M tried to cast a dispel-magic spell on %N.", player, target);
            return(0);
        }
    }
    return(1);
}
コード例 #29
0
ファイル: healmagic.cpp プロジェクト: RealmsMud/RealmsCode
int splHeal(Creature* player, cmd* cmnd, SpellData* spellData) {
    Creature* creature=0;


    if(spellData->how == CastType::CAST && !player->isStaff()) {
        if(player->getClass() !=  CreatureClass::CLERIC && player->getClass() !=  CreatureClass::PALADIN && !player->isCt()) {
            player->print("Your class prohibits you from casting that spell.\n");
            return(0);
        }

        switch(player->getDeity()) {
        case ARACHNUS:
        case JAKAR:
        case GRADIUS:
        case ARES:
        case ARAMON:
        case KAMIRA:
            player->print("%s does not allow you to cast that spell.\n", gConfig->getDeity(player->getDeity())->getName().c_str());
            return(0);
        default:
            break;
        }
    }


    // Heal self
    if(cmnd->num == 2) {

        if(!dec_daily(&player->daily[DL_FHEAL]) && spellData->how == CastType::CAST && !player->isCt() && player->isPlayer()) {
            player->print("You have been granted that spell enough today.\n");
            return(0);
        }

        //addhp(player, player->hp.getMax());
        player->doHeal(player, (player->hp.getMax() - player->hp.getCur()));
        //player->hp.restore();

        if(spellData->how == CastType::CAST || spellData->how == CastType::SCROLL) {
            if(player->isPlayer())
                player->getAsPlayer()->statistics.healingCast();
            player->print("Heal spell cast.\n");
            broadcast(player->getSock(), player->getParent(), "%M casts a heal spell on %sself.", player,
                player->himHer());
            return(1);
        } else {
            player->print("You feel incredibly better.\n");
            return(1);
        }

    // Cast heal on another player or monster
    } else {
        if(player->noPotion( spellData))
            return(0);

        creature = player->getParent()->findCreature(player,  cmnd->str[2], cmnd->val[2], false);

        if(!creature) {
            player->print("That person is not here.\n");
            return(0);
        }

        if( !dec_daily(&player->daily[DL_FHEAL]) &&
            spellData->how == CastType::CAST &&
            !player->isCt() &&
            player->isPlayer()
        ) {
            player->print("You have been granted that spell enough times for today.\n");
            return(0);
        }

        if(spellData->how == CastType::CAST || spellData->how == CastType::SCROLL || spellData->how == CastType::WAND) {

            if(!canCastHealing(player, creature, false, true))
                return(0);

            //      addhp(creature, creature->hp.getMax());


            if(creature->isPlayer() && creature->getClass() == CreatureClass::LICH) {

                if(!player->canAttack(creature))
                    return(0);

                if(player->getRoomParent()->isPkSafe() && !creature->flagIsSet(P_OUTLAW)) {
                    player->print("Your heal spell will harm a lich.\n");
                    player->print("No killing is allowed here.\n");
                    return(0);
                }
                if(creature->isEffected("resist-magic")) {
                    player->print("Your spell fizzles.\n");
                    if(spellData->how == CastType::CAST)
                        player->subMp(20);
                    return(0);
                }
            } else if(creature->isMonster() && creature->getClass() == CreatureClass::LICH) {

                if(creature->isEffected("resist-magic")) {
                    player->print("Your spell fizzles.\n");
                    if(spellData->how == CastType::CAST)
                        player->subMp(20);
                    return(0);
                }
            }
            if(creature->getClass() == CreatureClass::LICH) {
                int dmg;
                if(creature->hp.getCur() >= 4)
                    dmg = creature->hp.getCur() - mrand(2,4);
                else
                    dmg = creature->hp.getCur() - 1;

                creature->hp.decrease(dmg);

                player->print("The heal spell nearly kills %N!\n",creature);

                if(creature->isPlayer())
                    creature->print("%M's heal spell sucks away your life force!\n", player);

                broadcast(player->getSock(), creature->getSock(), player->getRoomParent(), "%M's heal spell nearly kills %N!",
                    player, creature);
                player->smashInvis();
                if(creature->isMonster())
                    creature->getAsMonster()->adjustThreat(player, dmg);
                return(1);
            }

            if(creature->inCombat(false))
                player->smashInvis();

            if(player->isPlayer())
                player->getAsPlayer()->statistics.healingCast();
            int healed = MAX(creature->hp.getMax() - creature->hp.getCur() - mrand(1,4), 0);
            player->doHeal(creature, healed, 0.33);
            //creature->hp.setCur(MAX(1, creature->hp.getMax() - mrand(1,4)));

            player->print("Heal spell cast on %N.\n", creature);
            creature->print("%M casts a heal spell on you.\n", player);
            broadcast(player->getSock(), creature->getSock(), player->getRoomParent(), "%M casts a heal spell on %N.",
                player, creature);

            logCast(player, creature, "heal");
            return(1);
        }
    }

    return(1);
}
コード例 #30
0
ファイル: abjuration.cpp プロジェクト: RealmsMud/RealmsCode
int splCancelMagic(Creature* player, cmd* cmnd, SpellData* spellData) {
    return(doDispelMagic(player, cmnd, spellData, "cancel-magic", mrand(1,2)));
}