Exemple #1
0
/* Calculates experience to next level from current experience and the
   points2rank() function. As no inverse function is supplied we use a
   binary search to determine the experience for the next level.
   If the given number of points corresponds to the highest level,
   return 0. */
int points_tolevel(int curr_exp)
{
        int curr_level, next_level, p0, p5, p9, r, j;

        curr_level = points2rank(curr_exp);
        if (curr_level == 23) return 0;
        next_level = curr_level + 1;

        p0 = 1;
        p5 = 1;
        p9 = 20 * curr_exp;
        for (j=0; p0<p9 && j<100; j++) {
                p5 = (p0 + p9) / 2;
                r = points2rank(curr_exp + p5);
                if (r < next_level) {
                        p0 = p5 + 1;
                } else {
                        p9 = p5 - 1;
                }
        }
        if (p0 > (20*curr_exp)) return 0;       // Can't do it
        p5++;
        return p5;
}
Exemple #2
0
int scale_exps2(int cn,int co_rank,int exp)
{
        static float scale_tab[49]={
        //       -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13, -12, -11, -10,  -9,  -8,  -7,  -6,  -5,  -4,  -3,  -2,  -1,   0,
                 0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.02,0.03,0.04,0.05,0.06,0.07,0.10,0.15,0.20,0.25,0.33,0.50,0.70,0.80,0.90,1.00,

        //         1,   2,   3,   4,   5,   6,   7,   8,   9 , 10,  11,  12,  13,  14,  15,  16,  17,  18,  19,  20,  21,  22,  23,  24
                1.02,1.04,1.08,1.16,1.32,1.50,1.75,2.00,2.25,2.50,2.75,3.00,3.25,3.50,3.75,4.00,4.00,4.00,4.00,4.00,4.00,4.00,4.00,4.00};
        int diff;

        diff=co_rank-points2rank(ch[cn].points_tot);

        diff+=24;
        if (diff<0) diff=0;
        if (diff>48) diff=48;

//      xlog("scale %d to %d: diff=%d, scale=%f",points2rank(ch[cn].points_tot),co_rank,diff,scale_tab[diff]);

        return (int)(exp*scale_tab[diff]);

}
Exemple #3
0
static void dtop(int srank)
{
	int n, m;
	int b[25], nr[25];

	for (m = 0; m<25; m++)
	{
		b[m]  = 99999999;
		nr[m] = -1;
	}

	printf("<b>Top Characters</b><br><br>\n");
	for (n = 1; n<MAXCHARS; n++)
	{
		if (ch[n].used==USE_EMPTY)
		{
			continue;
		}
		if (!(ch[n].flags & (CF_PLAYER)))
		{
			continue;
		}
		if (ch[n].flags & (CF_GOD | CF_NOLIST))
		{
			continue;
		}
		if (srank && points2rank(ch[n].points_tot)!=srank)
		{
			continue;
		}

		for (m = 0; m<25; m++)
		{
			if (ch[n].data[14] + ch[n].data[44]<b[m])
			{
				if (m<24)
				{
					memmove(&b[m + 1], &b[m], (24 - m) * sizeof(int));
					memmove(&nr[m + 1], &nr[m], (24 - m) * sizeof(int));
				}
				b[m]  = ch[n].data[14] + ch[n].data[44];
				nr[m] = n;
				break;
			}
		}
	}

	printf("<table cellpadding=0 cellspacing=0 border=0>\n");
	printf("<tr><td>Name &nbsp; &nbsp;</td><td>Race &nbsp; &nbsp;</td><td>Rank &nbsp; &nbsp;</td><td>Active &nbsp; &nbsp; </td><td>Deaths+Saves</td></tr>\n");
	printf("<tr><td colspan=5><hr></td></tr>");
	for (m = 0; m<25; m++)
	{
		if (nr[m]==-1)
		{
			continue;
		}
		printf("<tr><td><a href=\"/cgi-bin/info.cgi?cn=%d\">%s</a> &nbsp; &nbsp; </td><td>%s &nbsp; &nbsp; </td><td>%s &nbsp; &nbsp; </td><td>%s &nbsp; &nbsp; </td><td>%d</td></tr>\n",
		       nr[m], ch[nr[m]].name, racename(ch[nr[m]].kindred), rank(ch[nr[m]].points_tot),
		       (ch[nr[m]].used==USE_ACTIVE && !(ch[nr[m]].flags & CF_INVISIBLE) ? "Yes" : "No"), ch[nr[m]].data[14] + ch[nr[m]].data[44]);
	}
	printf("</table><br>\n");
}
Exemple #4
0
static char *rank(int pts)
{
	return(_rank[points2rank(pts)]);
}
Exemple #5
0
/*	Added by SoulHunter  04.04.2000	*/
int pop_create_bonus_belt(int cn)
{
	int n = 1106;   // value to store id-number of created belt
	                // at start it contains template of 'rainbow_belt'
	int i, j;
	int rank, skill_value, skill_number;


//	item will be created with chance 1 from 10000
//	if (RANDOM(10000)) return 0;
//      it is moved outside the function cause item is rarely created
//      but function is called each time when NPC respawning.
//	so it will be much faster if it will check for chances before
//	the function call

	// MAX_POWER = rank
	// MAX_SKILLS = rank
	rank = points2rank(ch[cn].points_tot);  // private wont get this belt
	if(!rank)
	{
		return( 0);                     //

	}
	if (n)
	{
		n = god_create_item(n);   // creating belt from template
		if(!n)
		{
			return( 0);     // return if failed
		}
		// problem is if we keep template for newly created and
		// then changed item, it sometimes doesnt keep changes
		// we need template number for is_belt() function
		// but seems there is some checks by template so we reset it
		// and people wont notice belt :)
		it[n].temp = 0; // clearing template
		it[n].sprite[0] = 16964;
		strcpy(it[n].name, "Rainbow Belt");
		strcpy(it[n].description, "An ancient belt. It seems to be highly magical");
		strcpy(it[n].reference, "rainbow belt");
		// putting message about created belt into log-file
		chlog(cn, ", with rank %d, got %s (t=%d)", rank, it[n].name, it[n].temp);
	}

	j = RANDOM(rank); // how many skills will be in belt?
	if(j==0)
	{
		j = 1;          //
	}
	it[n].power += 5 * j;     // counting power of item, *remind* power = 10 in template
	it[n].value += 10000 * j; // counting price value, value = 100 in template
	// here we decide which skills will be in belt, not more than rank
	for(i = 0; i < j; i++)
	{
		skill_number = RANDOM(39); // which skill it will be
		skill_value  = RANDOM(rank);    // with that value of skill
		skill_value  = skill_value >> 1; // divide it by 2, cause it cant be more than 12 (max_rank/2)
		if(skill_value == 0)
		{
			skill_value = 1;              // and cant be zero
		}
		// the following code put all these skills in belt
		// sometimes requirements are zeroed, cause if we have, in example,
		// dagger and sword skills in belt, this belt can be used only by
		// templar/seyan, but i dont want this
		switch(skill_number)
		{
		case 0:
			// this line is how much it will raise attribute
			it[n].attrib[AT_BRAVE][0] += skill_value;
			// this will check for max level = 12
			// and if it is reached, will down it back to 12
			if(it[n].attrib[AT_BRAVE][0] > 12)
			{
				it[n].attrib[AT_BRAVE][0] = 12;
			}
			// this line will set requirements
			it[n].attrib[AT_BRAVE][2] = 10 +
			                            (it[n].attrib[AT_BRAVE][0] * RANDOM(7));
			break;
		case 1:
			it[n].attrib[AT_WILL][0] += skill_value;
			if(it[n].attrib[AT_WILL][0] > 12)
			{
				it[n].attrib[AT_WILL][0] = 12;
			}
			it[n].attrib[AT_WILL][2] = 10 +
			                           (it[n].attrib[AT_WILL][0] * RANDOM(7));
			break;
		case 2:
			it[n].attrib[AT_INT][0] += skill_value;
			if(it[n].attrib[AT_INT][0] > 12)
			{
				it[n].attrib[AT_INT][0] = 12;
			}
			it[n].attrib[AT_INT][2] = 10 +
			                          (it[n].attrib[AT_INT][0] * RANDOM(7));
			break;
		case 3:
			it[n].attrib[AT_AGIL][0] += skill_value;
			if(it[n].attrib[AT_AGIL][0] > 12)
			{
				it[n].attrib[AT_AGIL][0] = 12;
			}
			it[n].attrib[AT_AGIL][2] = 10 +
			                           (it[n].attrib[AT_AGIL][0] * RANDOM(7));
			break;
		case 4:
			it[n].attrib[AT_STREN][0] += skill_value;
			if(it[n].attrib[AT_STREN][0] > 12)
			{
				it[n].attrib[AT_STREN][0] = 12;
			}
			it[n].attrib[AT_STREN][2] = 10 +
			                            (it[n].attrib[AT_STREN][0] * RANDOM(7));
			break;
		case 5:
			it[n].hp[0] += (skill_value * 5);
			if(it[n].hp[0] > 60)
			{
				it[n].hp[0] = 60;
			}
			it[n].hp[2] = 50 +
			              (it[n].hp[0] * RANDOM(7));
			break;
		case 6:
			it[n].end[0] += (skill_value * 5);
			if(it[n].end[0] > 60)
			{
				it[n].end[0] = 60;
			}
			it[n].end[2] = 50 +
			               (it[n].end[0] * RANDOM(7));
			break;
		case 7:
			it[n].mana[0] += (skill_value * 5);
			if(it[n].mana[0] > 60)
			{
				it[n].mana[0] = 60;
			}
			it[n].mana[2] = 50 +
			                (it[n].mana[0] * RANDOM(7));
			break;
		case 8:
			it[n].armor[0] += skill_value;
			if(it[n].armor[0] > 12)
			{
				it[n].armor[0] = 12;
			}
			break;
		case 9:
			it[n].skill[SK_WARCRY][0] += skill_value;
			if(it[n].skill[SK_WARCRY][0] > 12)
			{
				it[n].skill[SK_WARCRY][0] = 12;
			}
			break;
		case 10:
			it[n].skill[SK_HAND][0] += skill_value;
			if(it[n].skill[SK_HAND][0] > 12)
			{
				it[n].skill[SK_HAND][0] = 12;
			}
			it[n].skill[SK_HAND][2] =
				(it[n].skill[SK_HAND][0] * RANDOM(7));
			break;
		case 11:
			it[n].skill[SK_SWORD][0] += skill_value;
			if(it[n].skill[SK_SWORD][0] > 12)
			{
				it[n].skill[SK_SWORD][0] = 12;
			}
			break;
		case 12:
			it[n].skill[SK_DAGGER][0] += skill_value;
			if(it[n].skill[SK_DAGGER][0] > 12)
			{
				it[n].skill[SK_DAGGER][0] = 12;
			}
			break;
		case 13:
			it[n].skill[SK_TWOHAND][0] += skill_value;
			if(it[n].skill[SK_TWOHAND][0] > 12)
			{
				it[n].skill[SK_TWOHAND][0] = 12;
			}
			break;
		case 14:
			it[n].skill[SK_LOCK][0] += skill_value;
			if(it[n].skill[SK_LOCK][0] > 12)
			{
				it[n].skill[SK_LOCK][0] = 12;
			}
			it[n].skill[SK_LOCK][2] =
				(it[n].skill[SK_LOCK][0] * RANDOM(7));
			break;
		case 15:
			it[n].skill[SK_STEALTH][0] += skill_value;
			if(it[n].skill[SK_STEALTH][0] > 12)
			{
				it[n].skill[SK_STEALTH][0] = 12;
			}
			break;
		case 16:
			it[n].skill[SK_PERCEPT][0] += skill_value;
			if(it[n].skill[SK_PERCEPT][0] > 12)
			{
				it[n].skill[SK_PERCEPT][0] = 12;
			}
			it[n].skill[SK_PERCEPT][2] =
				(it[n].skill[SK_PERCEPT][0] * RANDOM(7));
			break;
		case 17:
			it[n].skill[SK_MSHIELD][0] += skill_value;
			if(it[n].skill[SK_MSHIELD][0] > 12)
			{
				it[n].skill[SK_MSHIELD][0] = 12;
			}
			break;
		case 18:
			it[n].skill[SK_BARTER][0] += skill_value;
			if(it[n].skill[SK_BARTER][0] > 12)
			{
				it[n].skill[SK_BARTER][0] = 12;
			}
			it[n].skill[SK_BARTER][2] =
				(it[n].skill[SK_BARTER][0] * RANDOM(7));
			break;
		case 19:
			it[n].skill[SK_REPAIR][0] += skill_value;
			if(it[n].skill[SK_REPAIR][0] > 12)
			{
				it[n].skill[SK_REPAIR][0] = 12;
			}
			it[n].skill[SK_REPAIR][2] =
				(it[n].skill[SK_REPAIR][0] * RANDOM(7));
			break;
		case 20:
			it[n].skill[SK_LIGHT][0] += skill_value;
			if(it[n].skill[SK_LIGHT][0] > 12)
			{
				it[n].skill[SK_LIGHT][0] = 12;
			}
			it[n].skill[SK_LIGHT][2] =
				(it[n].skill[SK_LIGHT][0] * RANDOM(7));
			break;
		case 21:
			it[n].skill[SK_RECALL][0] += skill_value;
			if(it[n].skill[SK_RECALL][0] > 12)
			{
				it[n].skill[SK_RECALL][0] = 12;
			}
			it[n].skill[SK_RECALL][2] =
				(it[n].skill[SK_RECALL][0] * RANDOM(7));
			break;
		case 22:
			it[n].skill[SK_PROTECT][0] += skill_value;
			if(it[n].skill[SK_PROTECT][0] > 12)
			{
				it[n].skill[SK_PROTECT][0] = 12;
			}
			it[n].skill[SK_PROTECT][2] =
				(it[n].skill[SK_PROTECT][0] * RANDOM(7));
			break;
		case 23:
			it[n].skill[SK_ENHANCE][0] += skill_value;
			if(it[n].skill[SK_ENHANCE][0] > 12)
			{
				it[n].skill[SK_ENHANCE][0] = 12;
			}
			it[n].skill[SK_ENHANCE][2] =
				(it[n].skill[SK_ENHANCE][0] * RANDOM(7));
			break;
		case 24:
			it[n].skill[SK_STUN][0] += skill_value;
			if(it[n].skill[SK_STUN][0] > 12)
			{
				it[n].skill[SK_STUN][0] = 12;
			}
			break;
		case 25:
			it[n].skill[SK_CURSE][0] += skill_value;
			if(it[n].skill[SK_CURSE][0] > 12)
			{
				it[n].skill[SK_CURSE][0] = 12;
			}
			break;
		case 26:
			it[n].skill[SK_BLESS][0] += skill_value;
			if(it[n].skill[SK_BLESS][0] > 12)
			{
				it[n].skill[SK_BLESS][0] = 12;
			}
			it[n].skill[SK_BLESS][2] =
				(it[n].skill[SK_BLESS][0] * RANDOM(7));
			break;
		case 27:
			it[n].skill[SK_IDENT][0] += skill_value;
			if(it[n].skill[SK_IDENT][0] > 12)
			{
				it[n].skill[SK_IDENT][0] = 12;
			}
			it[n].skill[SK_IDENT][2] =
				(it[n].skill[SK_IDENT][0] * RANDOM(7));
			break;
		case 28:
			it[n].skill[SK_RESIST][0] += skill_value;
			if(it[n].skill[SK_RESIST][0] > 12)
			{
				it[n].skill[SK_RESIST][0] = 12;
			}
			it[n].skill[SK_RESIST][2] =
				(it[n].skill[SK_RESIST][0] * RANDOM(7));
			break;
		case 29:
			it[n].skill[SK_BLAST][0] += skill_value;
			if(it[n].skill[SK_BLAST][0] > 12)
			{
				it[n].skill[SK_BLAST][0] = 12;
			}
			break;
		case 30:
			it[n].skill[SK_DISPEL][0] += skill_value;
			if(it[n].skill[SK_DISPEL][0] > 12)
			{
				it[n].skill[SK_DISPEL][0] = 12;
			}
			break;
		case 31:
			it[n].skill[SK_HEAL][0] += skill_value;
			if(it[n].skill[SK_HEAL][0] > 12)
			{
				it[n].skill[SK_HEAL][0] = 12;
			}
			it[n].skill[SK_HEAL][2] =
				(it[n].skill[SK_HEAL][0] * RANDOM(7));
			break;
		case 32:
			it[n].skill[SK_GHOST][0] += skill_value;
			if(it[n].skill[SK_GHOST][0] > 12)
			{
				it[n].skill[SK_GHOST][0] = 12;
			}
			break;
		case 33:
			it[n].skill[SK_REGEN][0] += skill_value;
			if(it[n].skill[SK_REGEN][0] > 12)
			{
				it[n].skill[SK_REGEN][0] = 12;
			}
			break;
		case 34:
			it[n].skill[SK_REST][0] += skill_value;
			if(it[n].skill[SK_REST][0] > 12)
			{
				it[n].skill[SK_REST][0] = 12;
			}
			it[n].skill[SK_REST][2] =
				(it[n].skill[SK_REST][0] * RANDOM(7));
			break;
		case 35:
			it[n].skill[SK_MEDIT][0] += skill_value;
			if(it[n].skill[SK_MEDIT][0] > 12)
			{
				it[n].skill[SK_MEDIT][0] = 12;
			}
			break;
		case 36:
			it[n].skill[SK_SENSE][0] += skill_value;
			if(it[n].skill[SK_SENSE][0] > 12)
			{
				it[n].skill[SK_SENSE][0] = 12;
			}
			it[n].skill[SK_SENSE][2] =
				(it[n].skill[SK_SENSE][0] * RANDOM(7));
			break;
		case 37:
			it[n].skill[SK_IMMUN][0] += skill_value;
			if(it[n].skill[SK_IMMUN][0] > 12)
			{
				it[n].skill[SK_IMMUN][0] = 12;
			}
			break;
		case 38:
			it[n].skill[SK_SURROUND][0] += skill_value;
			if(it[n].skill[SK_SURROUND][0] > 12)
			{
				it[n].skill[SK_SURROUND][0] = 12;
			}
			break;
		case 39:
			it[n].skill[SK_CONCEN][0] += skill_value;
			if(it[n].skill[SK_CONCEN][0] > 12)
			{
				it[n].skill[SK_CONCEN][0] = 12;
			}
			break;
// this will be created in future, right now it is not needed
/*		case 40:
                        it[n].weapon[0] += skill_value;
                        if(it[n].weapon[0] > 12)
                        {
                                it[n].weapon[0] = 12;
                        }
                        break; */
		default:
			break;
		}
	}

	return(n);

}
Exemple #6
0
int scale_exps(int cn,int co,int exp)
{
        return scale_exps2(cn,points2rank(ch[co].points_tot),exp);
}
Exemple #7
0
int rankdiff(int cn,int co)
{
        return points2rank(ch[co].points_tot)-points2rank(ch[cn].points_tot);
}
Exemple #8
0
int use_soulstone(int cn,int in)
{
	int in2,rank;
	
	if (!IS_SANECHAR(cn)) return 0;
	if (!IS_SANEITEM(in)) return 0;
	
	if (!(in2=ch[cn].citem)) {
		do_char_log(cn,1,"Try using something with the soulstone. That is, click on the stone with an item under your cursor.\n");
		return 0;
	}
	
	if (!IS_SANEITEM(in2)) return 0;
	
	if (it[in2].driver==68) {
		it[in].data[1]+=RANDOM(it[in2].data[1]+1)	;
		rank=points2rank(it[in].data[1]);
		it[in].data[0]=rank;
		sprintf(it[in].description,"Level %d soulstone, holding %d exp.",rank,it[in].data[1]);
		
		if (rank>20) do_char_log(cn,1,"That's as high as they go.\n");
		
		souldestroy(cn,in2);
		
		return 1;
	}
	
	switch(it[in2].temp) {
		case 18:	in=soultransform(cn,in,in2,101); it[in].hp[0]+=10; return 1;	// red flower
		case 46:	in=soultransform(cn,in,in2,102); it[in].mana[0]+=10; return 1;	// purple flower
		case 91:	in=soulrepair(cn,in,in2); it[in].max_age[1]*=4; return 1;	// torch
		case 100:	in=soultransform(cn,in,in2,102); return 1;			// flask
		
		case 101:	souldestroy(cn,in); it[in].hp[0]+=10; return 1;			// healing potion
		case 102:	souldestroy(cn,in); it[in].mana[0]+=10; return 1;		// mana potion
				
		case 27:
		case 28:
		case 29:
		case 30:
		case 31:
		case 32:
		case 33:
		case 34:
		case 35:
		case 36:
		case 37:
		case 38:
		case 39:
		case 40:
		case 41:
		case 42:
		case 43:
		case 44:
		case 51:
		case 52:
		case 53:
		case 54:
		case 55:
		case 56:
		case 57:
		case 58:
		case 59:
		case 60:
		case 61:
		case 62:
		case 63:
		case 64:
		case 65:
		case 66:
		case 67:
		case 68:
		case 69:
		case 70:
		case 71:
		case 72:
		case 73:
		case 74:
		case 75:
		case 76:
		case 77:
		case 78:
		case 79:
		case 80:
		case 94:
		case 95:
		case 96:
		case 97:
		case 98:
		case 99:
		case 116:
		case 125:
		case 158:
		case 501:
		case 502:
		case 503:
		case 523:
		case 524:
		case 813:
		case 981:
		case 982:
		case 983:
		case 984:
		case 985:
		case 986:	soultrans_equipment(cn,in,in2); return 1;
		default:	do_char_log(cn,1,"Nothing happened.\n"); return 0;
	}
}