ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/common/exp.C
(Generate patch)

Comparing deliantra/server/common/exp.C (file contents):
Revision 1.2 by root, Tue Aug 29 08:01:35 2006 UTC vs.
Revision 1.3 by root, Wed Aug 30 16:30:36 2006 UTC

1/* 1/*
2 * static char *rcsid_arch_c = 2 * static char *rcsid_arch_c =
3 * "$Id: exp.C,v 1.2 2006/08/29 08:01:35 root Exp $"; 3 * "$Id: exp.C,v 1.3 2006/08/30 16:30:36 root Exp $";
4 */ 4 */
5 5
6/* 6/*
7 CrossFire, A Multiplayer game for X-windows 7 CrossFire, A Multiplayer game for X-windows
8 8
28 28
29#include <stdio.h> 29#include <stdio.h>
30#include <global.h> 30#include <global.h>
31 31
32sint64 *levels; 32sint64 *levels;
33
34#define TRUE 1
35#define FALSE 0
36 33
37float exp_att_mult[NROFATTACKS+2] = { 34float exp_att_mult[NROFATTACKS+2] = {
38 0.0, /* AT_PHYSICAL */ 35 0.0, /* AT_PHYSICAL */
39 0.0, /* AT_MAGIC */ 36 0.0, /* AT_MAGIC */
40 0.0, /* AT_FIRE */ 37 0.0, /* AT_FIRE */
97 long mask = 1; 94 long mask = 1;
98 95
99 att_mult = prot_mult =spec_mult = 1.0; 96 att_mult = prot_mult =spec_mult = 1.0;
100 for(i=0;i<NROFATTACKS;i++) { 97 for(i=0;i<NROFATTACKS;i++) {
101 mask = 1<<i; 98 mask = 1<<i;
102 att_mult += (exp_att_mult[i] * ((ob->attacktype&mask) != FALSE)); 99 att_mult += (exp_att_mult[i] * ((ob->attacktype&mask) != 0));
103 /* We multiply & then divide to prevent roundoffs on the floats. 100 /* We multiply & then divide to prevent roundoffs on the floats.
104 * the doubling is to take into account the table and resistances 101 * the doubling is to take into account the table and resistances
105 * are lower than they once were. 102 * are lower than they once were.
106 */ 103 */
107 prot_mult += (exp_prot_mult[i] * 200*ob->resist[i]) / 100.0; 104 prot_mult += (exp_prot_mult[i] * 200*ob->resist[i]) / 100.0;
108 } 105 }
109 spec_mult += (0.3*(QUERY_FLAG(ob,FLAG_SEE_INVISIBLE)!= FALSE)) + 106 spec_mult += (0.3*(QUERY_FLAG(ob,FLAG_SEE_INVISIBLE)!= 0)) +
110 (0.5*(QUERY_FLAG(ob,FLAG_SPLITTING)!= FALSE))+ 107 (0.5*(QUERY_FLAG(ob,FLAG_SPLITTING)!= 0))+
111 (0.3*(QUERY_FLAG(ob,FLAG_HITBACK)!= FALSE)) + 108 (0.3*(QUERY_FLAG(ob,FLAG_HITBACK)!= 0)) +
112 (0.1*(QUERY_FLAG(ob,FLAG_REFL_MISSILE)!= FALSE)) + 109 (0.1*(QUERY_FLAG(ob,FLAG_REFL_MISSILE)!= 0)) +
113 (0.3*(QUERY_FLAG(ob,FLAG_REFL_SPELL)!= FALSE)) + 110 (0.3*(QUERY_FLAG(ob,FLAG_REFL_SPELL)!= 0)) +
114 (1.0*(QUERY_FLAG(ob,FLAG_NO_MAGIC)!= FALSE)) + 111 (1.0*(QUERY_FLAG(ob,FLAG_NO_MAGIC)!= 0)) +
115 (0.1*(QUERY_FLAG(ob,FLAG_PICK_UP)!= FALSE)) + 112 (0.1*(QUERY_FLAG(ob,FLAG_PICK_UP)!= 0)) +
116 (0.1*(QUERY_FLAG(ob,FLAG_USE_SCROLL)!= FALSE)) + 113 (0.1*(QUERY_FLAG(ob,FLAG_USE_SCROLL)!= 0)) +
117 (0.2*(QUERY_FLAG(ob,FLAG_USE_RANGE)!= FALSE)) + 114 (0.2*(QUERY_FLAG(ob,FLAG_USE_RANGE)!= 0)) +
118 (0.1*(QUERY_FLAG(ob,FLAG_USE_BOW)!= FALSE)); 115 (0.1*(QUERY_FLAG(ob,FLAG_USE_BOW)!= 0));
119 116
120 exp = (ob->stats.maxhp<5) ? 5 : ob->stats.maxhp; 117 exp = (ob->stats.maxhp<5) ? 5 : ob->stats.maxhp;
121 exp *= (QUERY_FLAG(ob,FLAG_CAST_SPELL) && has_ability(ob)) 118 exp *= (QUERY_FLAG(ob,FLAG_CAST_SPELL) && has_ability(ob))
122 ? (40+(ob->stats.maxsp>80?80:ob->stats.maxsp))/40 : 1; 119 ? (40+(ob->stats.maxsp>80?80:ob->stats.maxsp))/40 : 1;
123 exp *= (80.0/(70.0+ob->stats.wc)) * (80.0/(70.0+ob->stats.ac)) * (50.0+ob->stats.dam)/50.0; 120 exp *= (80.0/(70.0+ob->stats.wc)) * (80.0/(70.0+ob->stats.ac)) * (50.0+ob->stats.dam)/50.0;
137int has_ability(const object *ob) { 134int has_ability(const object *ob) {
138 object *tmp; 135 object *tmp;
139 136
140 for(tmp=ob->inv;tmp!=NULL;tmp=tmp->below) 137 for(tmp=ob->inv;tmp!=NULL;tmp=tmp->below)
141 if(tmp->type==SPELL||tmp->type==SPELLBOOK) 138 if(tmp->type==SPELL||tmp->type==SPELLBOOK)
142 return TRUE; 139 return true;
143 return FALSE; 140 return false;
144} 141}
145 142
146/* This loads the experience table from the exp_table 143/* This loads the experience table from the exp_table
147 * file. This tends to exit on any errors, since it 144 * file. This tends to exit on any errors, since it
148 * populates the table as it goes along, so if there 145 * populates the table as it goes along, so if there

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines