1 | /* |
1 | /* |
2 | * static char *rcsid_living_c = |
2 | * static char *rcsid_living_c = |
3 | * "$Id: living.c,v 1.1 2006/02/03 07:11:32 root Exp $"; |
3 | * "$Id: living.c,v 1.5 2006/02/22 18:53:48 elmex 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 | |
… | |
… | |
308 | /* |
308 | /* |
309 | * returns the specified stat. See also set_attr_value(). |
309 | * returns the specified stat. See also set_attr_value(). |
310 | */ |
310 | */ |
311 | |
311 | |
312 | sint8 |
312 | sint8 |
313 | get_attr_value(living *stats,int attr) { |
313 | get_attr_value(const living *stats,int attr) { |
314 | switch(attr) { |
314 | switch(attr) { |
315 | case STR: |
315 | case STR: |
316 | return(stats->Str); |
316 | return(stats->Str); |
317 | case DEX: |
317 | case DEX: |
318 | return(stats->Dex); |
318 | return(stats->Dex); |
… | |
… | |
1372 | * check if the stat becomes negative, thus this function |
1372 | * check if the stat becomes negative, thus this function |
1373 | * merely checks that all stats are 1 or more, and returns |
1373 | * merely checks that all stats are 1 or more, and returns |
1374 | * false otherwise. |
1374 | * false otherwise. |
1375 | */ |
1375 | */ |
1376 | |
1376 | |
1377 | int allowed_class(object *op) { |
1377 | int allowed_class(const object *op) { |
1378 | return op->stats.Dex>0&&op->stats.Str>0&&op->stats.Con>0&& |
1378 | return op->stats.Dex>0&&op->stats.Str>0&&op->stats.Con>0&& |
1379 | op->stats.Int>0&&op->stats.Wis>0&&op->stats.Pow>0&& |
1379 | op->stats.Int>0&&op->stats.Wis>0&&op->stats.Pow>0&& |
1380 | op->stats.Cha>0; |
1380 | op->stats.Cha>0; |
1381 | } |
1381 | } |
1382 | |
1382 | |
… | |
… | |
1388 | * Note that the title is written to 'own_title' in the |
1388 | * Note that the title is written to 'own_title' in the |
1389 | * player struct. This should be changed to 'ext_title' |
1389 | * player struct. This should be changed to 'ext_title' |
1390 | * as soon as clients support this! |
1390 | * as soon as clients support this! |
1391 | * Please, anyone, write support for 'ext_title'. |
1391 | * Please, anyone, write support for 'ext_title'. |
1392 | */ |
1392 | */ |
1393 | void set_dragon_name(object *pl, object *abil, object *skin) { |
1393 | void set_dragon_name(object *pl, const object *abil, const object *skin) { |
1394 | int atnr=-1; /* attacknumber of highest level */ |
1394 | int atnr=-1; /* attacknumber of highest level */ |
1395 | int level=0; /* highest level */ |
1395 | int level=0; /* highest level */ |
1396 | int i; |
1396 | int i; |
1397 | |
1397 | |
1398 | /* Perhaps do something more clever? */ |
1398 | /* Perhaps do something more clever? */ |
… | |
… | |
1685 | * adjustments based on permanent exp and the like. |
1685 | * adjustments based on permanent exp and the like. |
1686 | * This function should always be used for losing experience - |
1686 | * This function should always be used for losing experience - |
1687 | * the 'exp' value passed should be positive - this is the |
1687 | * the 'exp' value passed should be positive - this is the |
1688 | * amount that should get subtract from the player. |
1688 | * amount that should get subtract from the player. |
1689 | */ |
1689 | */ |
1690 | sint64 check_exp_loss(object *op, sint64 exp) |
1690 | sint64 check_exp_loss(const object *op, sint64 exp) |
1691 | { |
1691 | { |
1692 | sint64 del_exp; |
1692 | sint64 del_exp; |
1693 | |
1693 | |
1694 | if (exp > op->stats.exp) exp = op->stats.exp; |
1694 | if (exp > op->stats.exp) exp = op->stats.exp; |
1695 | if (settings.use_permanent_experience) { |
1695 | if (settings.use_permanent_experience) { |
… | |
… | |
1698 | if (exp > del_exp) exp=del_exp; |
1698 | if (exp > del_exp) exp=del_exp; |
1699 | } |
1699 | } |
1700 | return exp; |
1700 | return exp; |
1701 | } |
1701 | } |
1702 | |
1702 | |
1703 | sint64 check_exp_adjust(object *op, sint64 exp) |
1703 | sint64 check_exp_adjust(const object *op, sint64 exp) |
1704 | { |
1704 | { |
1705 | if (exp<0) return check_exp_loss(op, exp); |
1705 | if (exp<0) return check_exp_loss(op, exp); |
1706 | else return MIN(exp, MAX_EXPERIENCE - op->stats.exp); |
1706 | else return MIN(exp, MAX_EXPERIENCE - op->stats.exp); |
1707 | } |
1707 | } |
1708 | |
1708 | |
… | |
… | |
1824 | sint64 loss_3l; /* 3 level experience loss */ |
1824 | sint64 loss_3l; /* 3 level experience loss */ |
1825 | |
1825 | |
1826 | for(tmp=op->inv;tmp;tmp=tmp->below) |
1826 | for(tmp=op->inv;tmp;tmp=tmp->below) |
1827 | if(tmp->type==SKILL && tmp->stats.exp) { |
1827 | if(tmp->type==SKILL && tmp->stats.exp) { |
1828 | |
1828 | |
|
|
1829 | #ifdef COZY_SERVER |
|
|
1830 | loss_20p = tmp->stats.exp * 0.05; |
|
|
1831 | #else |
1829 | loss_20p = tmp->stats.exp * 0.20; |
1832 | loss_20p = tmp->stats.exp * 0.20; |
|
|
1833 | #endif |
1830 | loss_3l = tmp->stats.exp - levels[MAX(0,tmp->level -3)]; |
1834 | loss_3l = tmp->stats.exp - levels[MAX(0,tmp->level -3)]; |
1831 | |
1835 | |
1832 | /* With the revised exp system, you can get cases where |
1836 | /* With the revised exp system, you can get cases where |
1833 | * losing 3 levels would still require that you have more |
1837 | * losing 3 levels would still require that you have more |
1834 | * exp than you current have - this is true if the levels |
1838 | * exp than you current have - this is true if the levels |
… | |
… | |
1840 | |
1844 | |
1841 | tmp->stats.exp -= loss; |
1845 | tmp->stats.exp -= loss; |
1842 | player_lvl_adj(op,tmp); |
1846 | player_lvl_adj(op,tmp); |
1843 | } |
1847 | } |
1844 | |
1848 | |
|
|
1849 | #ifdef COZY_SERVER |
|
|
1850 | loss_20p = op->stats.exp * 0.05; |
|
|
1851 | #else |
1845 | loss_20p = op->stats.exp * 0.20; |
1852 | loss_20p = op->stats.exp * 0.20; |
|
|
1853 | #endif |
1846 | loss_3l = op->stats.exp - levels[MAX(0,op->level -3)]; |
1854 | loss_3l = op->stats.exp - levels[MAX(0,op->level -3)]; |
1847 | if (loss_3l < 0) loss_3l = 0; |
1855 | if (loss_3l < 0) loss_3l = 0; |
1848 | loss = check_exp_loss(op, MIN(loss_3l, loss_20p)); |
1856 | loss = check_exp_loss(op, MIN(loss_3l, loss_20p)); |
1849 | |
1857 | |
1850 | op->stats.exp -= loss; |
1858 | op->stats.exp -= loss; |
… | |
… | |
1856 | * save_throw table. level is the effective level to make |
1864 | * save_throw table. level is the effective level to make |
1857 | * the save at, and bonus is any plus/bonus (typically based on |
1865 | * the save at, and bonus is any plus/bonus (typically based on |
1858 | * resistance to particular attacktype. |
1866 | * resistance to particular attacktype. |
1859 | * Returns 1 if op makes his save, 0 if he failed |
1867 | * Returns 1 if op makes his save, 0 if he failed |
1860 | */ |
1868 | */ |
1861 | int did_make_save(object *op, int level, int bonus) |
1869 | int did_make_save(const object *op, int level, int bonus) |
1862 | { |
1870 | { |
1863 | if (level > MAX_SAVE_LEVEL) level = MAX_SAVE_LEVEL; |
1871 | if (level > MAX_SAVE_LEVEL) level = MAX_SAVE_LEVEL; |
1864 | |
1872 | |
1865 | if ((random_roll(1, 20, op, PREFER_HIGH) + bonus) < savethrow[level]) |
1873 | if ((random_roll(1, 20, op, PREFER_HIGH) + bonus) < savethrow[level]) |
1866 | return 0; |
1874 | return 0; |