diff --git a/src/common/gamecode/economy.c b/src/common/gamecode/economy.c index c029ebfa2..461079b9c 100644 --- a/src/common/gamecode/economy.c +++ b/src/common/gamecode/economy.c @@ -1026,7 +1026,7 @@ forgetskill(unit * u) struct message * m = add_message(&u->faction->msgs, msg_message("forget", "unit skill", u, talent)); msg_release(m); - set_skill(u, talent, 0); + set_level(u, talent, 0); } } diff --git a/src/common/gamecode/laws.c b/src/common/gamecode/laws.c index b52e4cc33..31f845fc0 100644 --- a/src/common/gamecode/laws.c +++ b/src/common/gamecode/laws.c @@ -362,11 +362,10 @@ live(region * r) if (best > 0) { int value = get_effect(u, oldpotiontype[P_FOOL]); #if SKILLPOINTS - int k; + int k = get_skill(u, ibest); value = min(value, u->number) * 30; - k = get_skill(u, ibest) - value; - k = max(k, 0); - set_skill(u, ibest, k); + k = min(k, value); + change_skill(u, ibest, -k); #else /* Talent sinkt für max. 10 Personen um 1 Stufe */ int k = min(u->number, value); diff --git a/src/common/gamecode/monster.c b/src/common/gamecode/monster.c index c5e98fea7..78cb1d077 100644 --- a/src/common/gamecode/monster.c +++ b/src/common/gamecode/monster.c @@ -1096,15 +1096,11 @@ plan_monsters(void) un = createunit(r, findfaction(MONSTER_FACTION), ra, new_race[RC_DRACOID]); name_unit(un); change_money(u, -un->number * 50); -#if SKILLPOINTS - set_skill(un, SK_SPEAR, un->number * (level_days(3) + rand() % (level_days(6)-level_days(3)))); - set_skill(un, SK_SWORD, un->number * (level_days(3) + rand() % (level_days(6)-level_days(3)))); - set_skill(un, SK_LONGBOW, un->number * (level_days(2) + rand() % (level_days(4)-level_days(2)))); -#else - set_skill(un, SK_SPEAR, un->number * (3 + rand() % 4)); - set_skill(un, SK_SWORD, un->number * (3 + rand() % 4)); - set_skill(un, SK_LONGBOW, un->number * (2 + rand() % 3)); -#endif + + set_level(un, SK_SPEAR, (3 + rand() % 4)); + set_level(un, SK_SWORD, (3 + rand() % 4)); + set_level(un, SK_LONGBOW, (2 + rand() % 3)); + switch (rand() % 3) { case 0: set_item(un, I_LONGBOW, un->number); @@ -1174,7 +1170,6 @@ split_unit(region * r, unit *u) unit *u2; skill_t sk; int newsize; - int n; assert(u->number!=1); newsize = u->number/2; @@ -1185,15 +1180,23 @@ split_unit(region * r, unit *u) set_string(&u2->thisorder, "WARTEN"); set_string(&u2->lastorder, "WARTEN"); +#if SKILLPOINTS for(sk = 0; sk < MAXSKILLS; sk++) { - int i; - n = get_skill(u, sk); - i = (n / u->number) * newsize; + int n = get_skill(u, sk); + int i = (n / u->number) * newsize; i += (n % u->number) * newsize / u->number; set_skill(u2, sk, i); set_skill(u, sk, n-i); } set_number(u, u->number - newsize); +#else + scale_number(u, u->number - newsize); + for(sk = 0; sk < MAXSKILLS; sk++) { + int n = get_skill(u, sk); + int level = n / u->number; + set_level(u2, sk, level); + } +#endif } boolean diff --git a/src/common/gamecode/randenc.c b/src/common/gamecode/randenc.c index 7509f37fb..9b2ebb6ce 100644 --- a/src/common/gamecode/randenc.c +++ b/src/common/gamecode/randenc.c @@ -325,16 +325,16 @@ get_unit(region * r, unit * u) if (fval(u, FL_PARTEITARNUNG)) fset(newunit, FL_PARTEITARNUNG); switch (rand() % 4) { case 0: - set_skill(newunit, SK_MINING, skill_level(1) * newunit->number); + set_level(newunit, SK_MINING, 1); break; case 1: - set_skill(newunit, SK_LUMBERJACK, skill_level(1) * newunit->number); + set_level(newunit, SK_LUMBERJACK, 1); break; case 2: - set_skill(newunit, SK_CARTMAKER, skill_level(1) * newunit->number); + set_level(newunit, SK_CARTMAKER, 1); break; case 3: - set_skill(newunit, SK_QUARRYING, skill_level(1) * newunit->number); + set_level(newunit, SK_QUARRYING, 1); break; } set_item(newunit, I_WAGON, rand() % 2); @@ -358,19 +358,19 @@ get_allies(region * r, unit * u) switch (rand() % 4) { case 0: - set_skill(newunit, SK_SWORD, skill_level(1+rand()%3) * newunit->number); + set_level(newunit, SK_SWORD, 1+rand()%3); set_item(newunit, I_SWORD, newunit->number); break; case 1: - set_skill(newunit, SK_SPEAR, skill_level(1+rand()%3) * newunit->number); + set_level(newunit, SK_SPEAR, 1+rand()%3); set_item(newunit, I_SPEAR, newunit->number); break; case 2: - set_skill(newunit, SK_CROSSBOW, skill_level(1+rand()%3) * newunit->number); + set_level(newunit, SK_CROSSBOW, 1+rand()%3); set_item(newunit, I_CROSSBOW, newunit->number); break; case 3: - set_skill(newunit, SK_LONGBOW, skill_level(1+rand()%3) * newunit->number); + set_level(newunit, SK_LONGBOW, 1+rand()%3); set_item(newunit, I_LONGBOW, newunit->number); break; } @@ -379,7 +379,7 @@ get_allies(region * r, unit * u) } if (rand() % 100 < 30) { set_item(newunit, I_HORSE, newunit->number); - set_skill(newunit, SK_RIDING, skill_level(1+rand()%3) * newunit->number); + set_level(newunit, SK_RIDING, 1+rand()%3); } break; } else { @@ -391,12 +391,12 @@ get_allies(region * r, unit * u) newunit = createunit(r, u->faction, rand() % 6 + 2, u->faction->race); set_string(&newunit->name, "Waldbewohner"); set_money(newunit, (rand() % 20 + 10) * newunit->number); - set_skill(newunit, SK_LONGBOW, skill_level(2+rand()%3) * newunit->number); + set_level(newunit, SK_LONGBOW, 2+rand()%3); set_item(newunit, I_LONGBOW, newunit->number); - set_skill(newunit, SK_OBSERVATION, skill_level(2+rand()%2) * newunit->number); - set_skill(newunit, SK_STEALTH, skill_level(1+rand()%2) * newunit->number); + set_level(newunit, SK_OBSERVATION, 2+rand()%2); + set_level(newunit, SK_STEALTH, 1+rand()%2); if (rand() % 100 < 20) { - set_skill(newunit, SK_HERBALISM, skill_level(1+rand()%2) * newunit->number); + set_level(newunit, SK_HERBALISM, 1+rand()%2); } } break; @@ -408,9 +408,9 @@ get_allies(region * r, unit * u) newunit = createunit(r, u->faction, rand() % 6 + 2, u->faction->race); set_string(&newunit->name, "Sumpfbewohner"); set_money(newunit, (rand() % 20 + 10) * newunit->number); - set_skill(newunit, SK_SPEAR, skill_level(2+rand()%3) * newunit->number); + set_level(newunit, SK_SPEAR, 2+rand()%3); set_item(newunit, I_SPEAR, newunit->number); - set_skill(newunit, SK_STEALTH, skill_level(2+rand()%3) * newunit->number); + set_level(newunit, SK_STEALTH, 2+rand()%3); break; case T_DESERT: @@ -420,12 +420,12 @@ get_allies(region * r, unit * u) newunit = createunit(r, u->faction, rand() % 12 + 2, u->faction->race); set_string(&newunit->name, "Berber"); set_money(newunit, (rand() % 30 + 20) * newunit->number); - set_skill(newunit, SK_SWORD, skill_level(1+rand()%2) * newunit->number); + set_level(newunit, SK_SWORD, 1+rand()%2); set_item(newunit, I_SWORD, newunit->number); - set_skill(newunit, SK_TRADE, skill_level(1+rand()%3) * newunit->number); - set_skill(newunit, SK_RIDING, skill_level(2+rand()%2) * newunit->number); + set_level(newunit, SK_TRADE, 1+rand()%3); + set_level(newunit, SK_RIDING, 2+rand()%2); set_item(newunit, I_HORSE, newunit->number); - set_skill(newunit, SK_HORSE_TRAINING, skill_level(2+rand()%2) * newunit->number); + set_level(newunit, SK_HORSE_TRAINING, 2+rand()%2); break; case T_HIGHLAND: @@ -435,7 +435,7 @@ get_allies(region * r, unit * u) newunit = createunit(r, u->faction, rand() % 8 + 2, u->faction->race); set_string(&newunit->name, "Hochlandbarbaren"); set_money(newunit, (rand() % 10 + 20) * newunit->number); - set_skill(newunit, SK_SWORD, skill_level(1+rand()%2) * newunit->number); + set_level(newunit, SK_SWORD, 1+rand()%2); set_item(newunit, I_SWORD, newunit->number); break; @@ -447,10 +447,10 @@ get_allies(region * r, unit * u) newunit = createunit(r, u->faction, rand() % 6 + 2, u->faction->race); set_string(&newunit->name, "Bergbewohner"); set_money(newunit, (rand() % 40 + 60) * newunit->number); - set_skill(newunit, SK_SWORD, skill_level(2+rand()%2) * newunit->number); + set_level(newunit, SK_SWORD, 2+rand()%2); set_item(newunit, I_SWORD, newunit->number); - set_skill(newunit, SK_ARMORER, skill_level(2+rand()%2) * newunit->number); - set_skill(newunit, SK_TRADE, skill_level(1+rand()%3) * newunit->number); + set_level(newunit, SK_ARMORER, 2+rand()%2); + set_level(newunit, SK_TRADE, 1+rand()%3); if (rand() % 100 < 60) { set_item(newunit, I_PLATE_ARMOR, newunit->number); } @@ -464,9 +464,9 @@ get_allies(region * r, unit * u) newunit = createunit(r, u->faction, rand() % 4 + 2, u->faction->race); set_string(&newunit->name, "Eisleute"); set_money(newunit, (rand() % 20 + 20) * newunit->number); - set_skill(newunit, SK_SWORD, skill_level(2+rand()%2) * newunit->number); + set_level(newunit, SK_SWORD, 2+rand()%2); set_item(newunit, I_SWORD, newunit->number); - set_skill(newunit, SK_ARMORER, skill_level(2+rand()%2) * newunit->number); + set_level(newunit, SK_ARMORER, 2+rand()%2); break; } @@ -1333,10 +1333,10 @@ randomevents(void) unit * u; if (rterrain(r) == T_OCEAN && rand()%10000 < 1) { u = createunit(r, findfaction(MONSTER_FACTION), 1, new_race[RC_SEASERPENT]); - set_skill(u, SK_MAGIC, u->number * skill_level(4)); - set_skill(u, SK_OBSERVATION, u->number * skill_level(3)); - set_skill(u, SK_STEALTH, u->number * skill_level(2)); - set_skill(u, SK_AUSDAUER, u->number * skill_level(1)); + set_level(u, SK_MAGIC, 4); + set_level(u, SK_OBSERVATION, 3); + set_level(u, SK_STEALTH, 2); + set_level(u, SK_AUSDAUER, 1); set_string(&u->name, "Seeschlange"); } @@ -1361,10 +1361,10 @@ randomevents(void) } set_money(u, u->number * (rand() % 500 + 100)); - set_skill(u, SK_MAGIC, u->number * skill_level(4)); - set_skill(u, SK_OBSERVATION, u->number * skill_level(1+rand()%3)); - set_skill(u, SK_AUSDAUER, u->number * skill_level(1)); - set_skill(u, SK_STEALTH, u->number * skill_level(1)); + set_level(u, SK_MAGIC, 4); + set_level(u, SK_OBSERVATION, 1+rand()%3); + set_level(u, SK_STEALTH, 1); + set_level(u, SK_AUSDAUER, 1); log_printf("%d %s in %s.\n", u->number, LOC(default_locale, rc_name(u->race, u->number!=1)), regionname(r, NULL)); @@ -1437,7 +1437,7 @@ randomevents(void) for (i=0;i < MAXSKILLS;i++) { if (rc->bonus[i] >= 1) { - set_skill(u, i, skill_level(1) * u->number); + set_level(u, SK_AUSDAUER, 1); } } u->hp = unit_max_hp(u) * u->number; diff --git a/src/common/kernel/combatspells.c b/src/common/kernel/combatspells.c index 736cd372e..86fc18d28 100644 --- a/src/common/kernel/combatspells.c +++ b/src/common/kernel/combatspells.c @@ -539,7 +539,13 @@ sp_mindblast(fighter * fi, int level, int power, spell * sp) sk = random_skill(du); if (sk != NOSKILL) { /* Skill abziehen */ +#if SKILLPOINTS change_skill(du, sk, -(30+rand()%61)); +#else + if (learn_skill(du, sk, 30+rand()%61)) { + change_skill(du, sk, -1); + } +#endif --enemies; } else { troop t; @@ -632,22 +638,19 @@ sp_dragonodem(fighter * fi, int level, int power, spell * sp) int sp_wolfhowl(fighter * fi, int level, int power, spell * sp) { - unit *u; battle *b = fi->side->battle; region *r = b->region; unit *mage = fi->unit; attrib *a; - int force; + int force = get_force(power, 3)/2; + unit *u = createunit(r, mage->faction, force, new_race[RC_WOLF]); unused(sp); - force = get_force(power, 3)/2; - - u = createunit(r, mage->faction, force, new_race[RC_WOLF]); u->status = ST_FIGHT; set_string(&u->name, force == 1 ? "Wolf" : "Wölfe"); - set_skill(u, SK_WEAPONLESS, level_days(power/3) * u->number); - set_skill(u, SK_AUSDAUER, level_days(power/3) * u->number); + set_level(u, SK_WEAPONLESS, power/3); + set_level(u, SK_AUSDAUER, power/3); u->hp = u->number * unit_max_hp(u); if (fval(mage, FL_PARTEITARNUNG)) diff --git a/src/common/kernel/eressea.c b/src/common/kernel/eressea.c index a1d787af8..0f0065ae1 100644 --- a/src/common/kernel/eressea.c +++ b/src/common/kernel/eressea.c @@ -538,17 +538,6 @@ verify_data(void) #endif } -int -get_skill(const unit * u, skill_t id) -{ - skillvalue *i = u->skills; - - for (; i != u->skills + u->skill_size; ++i) - if (i->id == id) - return i->value; - return 0; -} - int distribute(int old, int new_value, int n) { @@ -706,7 +695,7 @@ scale_number (unit * u, int n) } for (skill = 0; skill < MAXSKILLS; skill++) { if (n==0 || u->number == 0) { - set_skill(u, skill, 0); + set_level(u, skill, 0); } else { int sval = get_skill(u, skill); int snew = sval / u->number * n; diff --git a/src/common/kernel/race.c b/src/common/kernel/race.c index 668081ee5..6a277b7e0 100644 --- a/src/common/kernel/race.c +++ b/src/common/kernel/race.c @@ -199,7 +199,7 @@ give_starting_equipment(struct region *r, struct unit *u) switch(old_race(u->race)) { case RC_DWARF: - set_skill(u, SK_SWORD, 30); + set_level(u, SK_SWORD, 1); set_item(u, I_AXE, 1); set_item(u, I_CHAIN_MAIL, 1); break; @@ -208,11 +208,11 @@ give_starting_equipment(struct region *r, struct unit *u) set_show_item(u->faction, I_FEENSTIEFEL); break; case RC_ORC: - set_skill(u, SK_SPEAR, 300); - set_skill(u, SK_SWORD, 300); - set_skill(u, SK_CROSSBOW, 300); - set_skill(u, SK_LONGBOW, 300); - set_skill(u, SK_CATAPULT, 300); + set_level(u, SK_SPEAR, 4); + set_level(u, SK_SWORD, 4); + set_level(u, SK_CROSSBOW, 4); + set_level(u, SK_LONGBOW, 4); + set_level(u, SK_CATAPULT, 4); break; case RC_GOBLIN: set_item(u, I_RING_OF_INVISIBILITY, 1); @@ -228,12 +228,12 @@ give_starting_equipment(struct region *r, struct unit *u) } break; case RC_TROLL: - set_skill(u, SK_BUILDING, 30); - set_skill(u, SK_OBSERVATION, 180); + set_level(u, SK_BUILDING, 1); + set_level(u, SK_OBSERVATION, 3); set_item(u, I_STONE, 50); break; case RC_DAEMON: - set_skill(u, SK_AUSDAUER, 3600); + set_level(u, SK_AUSDAUER, 15); u->hp = unit_max_hp(u); break; case RC_INSECT: @@ -241,8 +241,8 @@ give_starting_equipment(struct region *r, struct unit *u) i_change(&u->items, oldpotiontype[P_WARMTH]->itype, 9); break; case RC_HALFLING: - set_skill(u, SK_TRADE, 30); - set_skill(u, SK_RIDING, 90); + set_level(u, SK_TRADE, 1); + set_level(u, SK_RIDING, 2); set_item(u, I_HORSE, 2); set_item(u, I_WAGON, 1); set_item(u, I_BALM, 5); @@ -265,7 +265,7 @@ give_starting_equipment(struct region *r, struct unit *u) u->ship = sh; fset(u, FL_OWNER); } - set_skill(u, SK_SAILING, 30); + set_level(u, SK_SAILING, 1); break; case RC_CENTAUR: rsethorses(r, 250+rand()%51+rand()%51); @@ -275,29 +275,6 @@ give_starting_equipment(struct region *r, struct unit *u) set_money(u, 2000 + turn * 10); } -void -give_latestart_bonus(region *r, unit *u, int b) -{ - change_skill(u, SK_OBSERVATION, b*30*u->number); - change_money(u, 200*b); - - { - unit *u2 = createunit(r, u->faction, 1, u->race); - change_skill(u2, SK_TACTICS, ((b*30)/2) * u2->number); - u2->irace = u->irace; - fset(u2, FL_PARTEITARNUNG); - } - - { - unit *u2 = createunit(r, u->faction, 2*b, u->race); - change_skill(u2, SK_SPEAR, 180 * u2->number); - change_skill(u2, SK_TAXING, 180 * u2->number); - change_item(u2, I_SPEAR, u2->number); - u2->irace = u->irace; - fset(u2, FL_PARTEITARNUNG); - } -} - int unit_max_hp(const unit * u) { @@ -385,41 +362,41 @@ oldfamiliars(unit * familiar) switch(frt) { case RC_HOUSECAT: /* Kräu+1, Mag, Pfer+1, Spi+3, Tar+3, Wahr+4, Aus */ - set_skill(familiar, SK_MAGIC, 30); - set_skill(familiar, SK_SPY, 30); - set_skill(familiar, SK_STEALTH, 30); - set_skill(familiar, SK_OBSERVATION, 30); + set_level(familiar, SK_MAGIC, 1); + set_level(familiar, SK_SPY, 1); + set_level(familiar, SK_STEALTH, 1); + set_level(familiar, SK_OBSERVATION, 1); m = create_mage(familiar, M_GRAU); break; case RC_TUNNELWORM: /* Ber+50,Hol+50,Sbau+50,Aus+2*/ - set_skill(familiar, SK_MAGIC, 30); - set_skill(familiar, SK_MINING, 30); - set_skill(familiar, SK_LUMBERJACK, 30); - set_skill(familiar, SK_ROAD_BUILDING, 30); - set_skill(familiar, SK_AUSDAUER, 30); + set_level(familiar, SK_MAGIC, 1); + set_level(familiar, SK_MINING, 1); + set_level(familiar, SK_LUMBERJACK, 1); + set_level(familiar, SK_ROAD_BUILDING, 1); + set_level(familiar, SK_AUSDAUER, 1); m = create_mage(familiar, M_GRAU); break; case RC_EAGLE: /* Spi, Wahr+2, Aus */ - set_skill(familiar, SK_MAGIC, 30); - set_skill(familiar, SK_OBSERVATION, 30); + set_level(familiar, SK_MAGIC, 1); + set_level(familiar, SK_OBSERVATION, 1); m = create_mage(familiar, M_GRAU); break; case RC_RAT: /* Spionage+5, Tarnung+4, Wahrnehmung+2, Ausdauer */ - set_skill(familiar, SK_MAGIC, 30); - set_skill(familiar, SK_SPY, 30); - set_skill(familiar, SK_STEALTH, 30); - set_skill(familiar, SK_OBSERVATION, 30); - set_skill(familiar, SK_AUSDAUER, 50+rand()%500+rand()%500); + set_level(familiar, SK_MAGIC, 1); + set_level(familiar, SK_SPY, 1); + set_level(familiar, SK_STEALTH, 1); + set_level(familiar, SK_OBSERVATION, 1); + set_level(familiar, SK_AUSDAUER, 1+rand()%8); /* set_number(familiar, 50+rand()%500+rand()%500); */ m = create_mage(familiar, M_GRAU); break; case RC_PSEUDODRAGON: /* Magie+1, Spionage, Tarnung, Wahrnehmung, Ausdauer */ m = create_mage(familiar, M_GRAU); - set_skill(familiar, SK_MAGIC, 30); + set_level(familiar, SK_MAGIC, 1); addspell(familiar, SPL_FLEE); addspell(familiar, SPL_SLEEP); addspell(familiar, SPL_FRIGHTEN); @@ -430,15 +407,15 @@ oldfamiliars(unit * familiar) /* Alc, Arm, Bog+2, Han-2, Kräu+4, Mag+1, Pfer+5, Rei+5, * Rüs-2, Sbau, Seg-2, Sta, Spi+2, Tak-2, Tar+3, Unt+10, * Waf-2, Wag-2, Wahr+2, Steu-2, Aus-1 */ - set_skill(familiar, SK_MAGIC, 30); - set_skill(familiar, SK_LONGBOW, 30); - set_skill(familiar, SK_HERBALISM, 30); - set_skill(familiar, SK_HORSE_TRAINING, 30); - set_skill(familiar, SK_RIDING, 30); - set_skill(familiar, SK_SPY, 30); - set_skill(familiar, SK_STEALTH, 30); - set_skill(familiar, SK_ENTERTAINMENT, 30); - set_skill(familiar, SK_OBSERVATION, 30); + set_level(familiar, SK_MAGIC, 1); + set_level(familiar, SK_LONGBOW, 1); + set_level(familiar, SK_HERBALISM, 1); + set_level(familiar, SK_HORSE_TRAINING, 1); + set_level(familiar, SK_RIDING, 1); + set_level(familiar, SK_SPY, 1); + set_level(familiar, SK_STEALTH, 1); + set_level(familiar, SK_ENTERTAINMENT, 1); + set_level(familiar, SK_OBSERVATION, 1); m = create_mage(familiar, M_GRAU); addspell(familiar, SPL_SEDUCE); addspell(familiar, SPL_CALM_MONSTER); @@ -448,9 +425,9 @@ oldfamiliars(unit * familiar) break; case RC_UNICORN: /* Mag+2, Spi, Tak, Tar+4, Wahr+4, Aus */ - set_skill(familiar, SK_MAGIC, 30); - set_skill(familiar, SK_STEALTH, 30); - set_skill(familiar, SK_OBSERVATION, 30); + set_level(familiar, SK_MAGIC, 1); + set_level(familiar, SK_STEALTH, 1); + set_level(familiar, SK_OBSERVATION, 1); m = create_mage(familiar, M_GRAU); addspell(familiar, SPL_RESISTMAGICBONUS); addspell(familiar, SPL_SONG_OF_PEACE); @@ -461,13 +438,13 @@ oldfamiliars(unit * familiar) break; case RC_WARG: /* Spi, Tak, Tar, Wahri+2, Aus */ - set_skill(familiar, SK_MAGIC, 30); - set_skill(familiar, SK_OBSERVATION, 30); + set_level(familiar, SK_MAGIC, 1); + set_level(familiar, SK_OBSERVATION, 1); m = create_mage(familiar, M_GRAU); break; case RC_WRAITH: /* Mag+1, Rei-2, Hie, Sta, Spi, Tar, Wahr, Aus */ - set_skill(familiar, SK_MAGIC, 30); + set_level(familiar, SK_MAGIC, 1); m = create_mage(familiar, M_GRAU); addspell(familiar, SPL_STEALAURA); addspell(familiar, SPL_FRIGHTEN); @@ -475,28 +452,28 @@ oldfamiliars(unit * familiar) break; case RC_IMP: /* Mag+1,Rei-1,Hie,Sta,Spi+1,Tar+1,Wahr+1,Steu+1,Aus*/ - set_skill(familiar, SK_MAGIC, 30); - set_skill(familiar, SK_SPY, 30); - set_skill(familiar, SK_STEALTH, 30); - set_skill(familiar, SK_OBSERVATION, 30); - set_skill(familiar, SK_TAXING, 30); + set_level(familiar, SK_MAGIC, 1); + set_level(familiar, SK_SPY, 1); + set_level(familiar, SK_STEALTH, 1); + set_level(familiar, SK_OBSERVATION, 1); + set_level(familiar, SK_TAXING, 1); m = create_mage(familiar, M_GRAU); addspell(familiar, SPL_STEALAURA); break; case RC_DREAMCAT: /* Mag+1,Hie,Sta,Spi+1,Tar+1,Wahr+1,Steu+1,Aus*/ - set_skill(familiar, SK_MAGIC, 30); - set_skill(familiar, SK_SPY, 30); - set_skill(familiar, SK_STEALTH, 30); - set_skill(familiar, SK_OBSERVATION, 30); - set_skill(familiar, SK_TAXING, 30); + set_level(familiar, SK_MAGIC, 1); + set_level(familiar, SK_SPY, 1); + set_level(familiar, SK_STEALTH, 1); + set_level(familiar, SK_OBSERVATION, 1); + set_level(familiar, SK_TAXING, 1); m = create_mage(familiar, M_GRAU); addspell(familiar, SPL_ILL_SHAPESHIFT); addspell(familiar, SPL_TRANSFERAURA_TRAUM); break; case RC_FEY: /* Mag+1,Rei-1,Hie-1,Sta-1,Spi+2,Tar+5,Wahr+2,Aus */ - set_skill(familiar, SK_MAGIC, 30); + set_level(familiar, SK_MAGIC, 1); m = create_mage(familiar,M_GRAU); addspell(familiar, SPL_DENYATTACK); addspell(familiar, SPL_CALM_MONSTER); @@ -504,22 +481,22 @@ oldfamiliars(unit * familiar) break; case RC_OWL: /* Spi+1,Tar+1,Wahr+5,Aus */ - set_skill(familiar, SK_MAGIC, 30); - set_skill(familiar, SK_SPY, 30); - set_skill(familiar, SK_STEALTH, 30); - set_skill(familiar, SK_OBSERVATION, 30); + set_level(familiar, SK_MAGIC, 1); + set_level(familiar, SK_SPY, 1); + set_level(familiar, SK_STEALTH, 1); + set_level(familiar, SK_OBSERVATION, 1); m = create_mage(familiar,M_GRAU); break; case RC_HELLCAT: /* Spi, Tak, Tar, Wahr+1, Aus */ - set_skill(familiar, SK_MAGIC, 30); - set_skill(familiar, SK_OBSERVATION, 30); + set_level(familiar, SK_MAGIC, 1); + set_level(familiar, SK_OBSERVATION, 1); m = create_mage(familiar,M_GRAU); break; case RC_TIGER: /* Spi, Tak, Tar, Wahr+1, Aus */ - set_skill(familiar, SK_MAGIC, 30); - set_skill(familiar, SK_OBSERVATION, 30); + set_level(familiar, SK_MAGIC, 1); + set_level(familiar, SK_OBSERVATION, 1); m = create_mage(familiar,M_GRAU); break; } diff --git a/src/common/kernel/skill.c b/src/common/kernel/skill.c index 47a17fea4..2a45dfe55 100644 --- a/src/common/kernel/skill.c +++ b/src/common/kernel/skill.c @@ -298,15 +298,11 @@ level_days(int level) return 30 * ((level+1) * level / 2); } +#if SKILLPOINTS int level(int days) { int i; -#ifdef SLOW_SKILLS - /* that's just too many function calls, baby: */ - i = 0; - while (level_days(i+1) <= days) ++i; -#else static int ldays[64]; static boolean init = false; if (!init) { @@ -314,9 +310,9 @@ level(int days) for (i=0;i!=64;++i) ldays[i] = level_days(i+1); } for (i=0;i!=64;++i) if (ldays[i]>days) return i; -#endif return i; } +#endif int eff_skill(const unit * u, skill_t sk, const region * r) @@ -326,7 +322,11 @@ eff_skill(const unit * u, skill_t sk, const region * r) if (u->number==0) return 0; if (r->planep && sk == SK_STEALTH && fval(r->planep, PFL_NOSTEALTH)) return 0; +#if SKILLPOINTS result = level(get_skill(u, sk) / u->number); +#else + result = get_skill(u, sk) / u->number; +#endif if (result == 0) return 0; assert(r); @@ -366,7 +366,11 @@ pure_skill(unit * u, skill_t sk, region * r) if (u->number==0) return 0; +#if SKILLPOINTS result = level(get_skill(u, sk) / u->number); +#else + result = get_skill(u, sk) / u->number; +#endif return max(result, 0); } @@ -381,9 +385,8 @@ remove_zero_skills(void) for(r=regions; r; r=r->next) { for(u=r->units; u; u=u->next) { for (sk = 0; sk != MAXSKILLS; sk++) { - if(get_skill(u, sk) < u->number) { - set_skill(u, sk, 0); - + if (get_skill(u, sk) < u->number) { + set_level(u, sk, 0); } } } diff --git a/src/common/kernel/spell.c b/src/common/kernel/spell.c index f3a8f431b..e99fc4c88 100644 --- a/src/common/kernel/spell.c +++ b/src/common/kernel/spell.c @@ -147,7 +147,7 @@ do_shock(unit *u, char *reason) for (sk=0; sk < MAXSKILLS; sk++) { int n = get_skill(u, sk); if (n!=0 && rand()%10 < 2) { - change_skill(u, sk, -1); + change_level(u, sk, -1); } } #endif @@ -1467,8 +1467,8 @@ sp_create_irongolem(castorder *co) u2 = create_unit(r, mage->faction, force*8, new_race[RC_IRONGOLEM], 0, LOC(mage->faction->locale, rc_name(new_race[RC_IRONGOLEM], 1)), mage); - set_skill(u2, SK_ARMORER, skill_level(1)*u2->number); - set_skill(u2, SK_WEAPONSMITH, skill_level(1)*u2->number); + set_level(u2, SK_ARMORER, 1); + set_level(u2, SK_WEAPONSMITH, 1); a = a_new(&at_unitdissolve); a->data.ca[0] = 0; @@ -1527,8 +1527,8 @@ sp_create_stonegolem(castorder *co) u2 = create_unit(r, mage->faction, force*5, new_race[RC_STONEGOLEM], 0, LOC(mage->faction->locale, rc_name(new_race[RC_STONEGOLEM], 1)), mage); - set_skill(u2, SK_ROAD_BUILDING, skill_level(1)*u2->number); - set_skill(u2, SK_BUILDING, skill_level(1)*u2->number); + set_level(u2, SK_ROAD_BUILDING, 1); + set_level(u2, SK_BUILDING, 1); a = a_new(&at_unitdissolve); a->data.ca[0] = 0; @@ -3384,8 +3384,8 @@ sp_summonshadow(castorder *co) /* Bekommen Tarnung = (Magie+Tarnung)/2 und Wahrnehmung 1. */ val = (get_skill(mage, SK_MAGIC) + get_skill(mage, SK_STEALTH))/(2*mage->number); - set_skill(u, SK_STEALTH, u->number * val); - set_skill(u, SK_OBSERVATION, u->number * skill_level(1)); + set_level(u, SK_STEALTH, val); + set_level(u, SK_OBSERVATION, 1); sprintf(buf, "%s beschwört %d Dämonen aus dem Reich der Schatten.", unitname(mage), force*force); @@ -3429,12 +3429,8 @@ sp_summonshadowlords(castorder *co) fset(u, FL_PARTEITARNUNG); /* Bekommen Tarnung = Magie und Wahrnehmung 5. */ - set_skill(u, SK_STEALTH, (u->number * get_skill(mage, SK_MAGIC)/mage->number)); -#if SKILLPOINTS - set_skill(u, SK_OBSERVATION, u->number * level_days(5)); -#else - set_skill(u, SK_OBSERVATION, u->number * 5); -#endif + set_level(u, SK_STEALTH, get_level(mage, SK_MAGIC)); + set_level(u, SK_OBSERVATION, 5); sprintf(buf, "%s beschwört %d Schattenmeister.", unitname(mage), force*force); addmessage(0, mage->faction, buf, MSG_MAGIC, ML_INFO); @@ -4522,7 +4518,7 @@ sp_pump(castorder *co) u = createunit(rt, mage->faction, RS_FARVISION, new_race[RC_SPELL]); set_string(&u->name, "Zauber: Aushorchen"); u->age = 2; - set_skill(u, SK_OBSERVATION, eff_skill(target, SK_OBSERVATION, r)); + set_level(u, SK_OBSERVATION, eff_skill(target, SK_OBSERVATION, u->region)); return cast_level; } @@ -5251,7 +5247,7 @@ sp_dreamreading(castorder *co) set_number(u2, 1); set_string(&u2->name, "sp_dreamreading"); u2->age = 2; /* Nur für diese Runde. */ - set_skill(u2, SK_OBSERVATION, get_skill(u, SK_OBSERVATION)/u->number); + set_level(u2, SK_OBSERVATION, eff_skill(u, SK_OBSERVATION, u2->region)); sprintf(buf, "%s verliert sich in die Träume von %s und erhält einen " "Eindruck von %s.", unitname(mage), unitname(u), regionid(u->region)); diff --git a/src/common/kernel/teleport.c b/src/common/kernel/teleport.c index 7cc6e4bf7..b3ec57481 100644 --- a/src/common/kernel/teleport.c +++ b/src/common/kernel/teleport.c @@ -27,6 +27,7 @@ #include "unit.h" #include "region.h" #include "race.h" +#include "skill.h" #include "faction.h" #include "plane.h" @@ -130,8 +131,8 @@ random_in_teleport_plane(void) u = createunit(r, f0, 1+rand()%10+rand()%10, new_race[RC_HIRNTOETER]); set_string(&u->name, "Hirntöter"); set_string(&u->display, "Wabernde grüne Schwaden treiben durch den Nebel und verdichten sich zu einer unheimlichen Kreatur, die nur aus einem langen Ruderschwanz und einem riesigen runden Maul zu bestehen scheint."); - set_skill(u, SK_STEALTH, 30); - set_skill(u, SK_OBSERVATION, 30); + set_level(u, SK_STEALTH, 1); + set_level(u, SK_OBSERVATION, 1); break; } } diff --git a/src/common/kernel/unit.c b/src/common/kernel/unit.c index c431eb5e0..10683fb51 100644 --- a/src/common/kernel/unit.c +++ b/src/common/kernel/unit.c @@ -33,6 +33,7 @@ #include "race.h" #include "region.h" #include "ship.h" +#include "skill.h" #include @@ -494,7 +495,7 @@ u_geteffstealth(const struct unit * u) } int -change_skill (unit * u, skill_t id, int byvalue) +change_skill(unit * u, skill_t id, int byvalue) { skillvalue *i = u->skills; int wounds = 0; @@ -519,8 +520,8 @@ change_skill (unit * u, skill_t id, int byvalue) return byvalue; } -int -change_skill_transfermen (unit * u, skill_t id, int byvalue) +static int +change_skill_transfermen(unit * u, skill_t id, int byvalue) { skillvalue *i = u->skills; @@ -535,8 +536,47 @@ change_skill_transfermen (unit * u, skill_t id, int byvalue) return byvalue; } +int +get_skill(const unit * u, skill_t id) +{ + skillvalue *i = u->skills; + + for (; i != u->skills + u->skill_size; ++i) + if (i->id == id) + return i->value; + return 0; +} + +#if SKILLPOINTS +extern int level(int days); +#endif + +int +get_level(const unit * u, skill_t id) +{ + skillvalue *i = u->skills; + for (; i != u->skills + u->skill_size; ++i) + if (i->id == id) +#if SKILLPOINTS + return level(i->value/u->number); +#else + return i->value/u->number; +#endif + return 0; +} + +void +set_level(unit * u, skill_t id, int value) +{ +#if SKILLPOINTS + set_skill(u, id, level_days(value)*u->number); +#else + set_skill(u, id, u->number*value); +#endif +} + void -set_skill (unit * u, skill_t id, int value) +set_skill(unit * u, skill_t id, int value) { skillvalue *i = u->skills; @@ -836,3 +876,18 @@ set_number(unit * u, int count) u->debug_number = count; #endif } + +#if !SKILLPOINTS +boolean +learn_skill(const unit * u, skill_t sk, int days) +{ + int now = get_skill(u, sk); + int nowlvl = now / u->number; + int need = (nowlvl+1) * u->number - now; + int needdays = level_days(nowlvl+1) - level_days(nowlvl); + needdays = needdays * u->number / need; + if ((rand()%needdays) < days) return true; + return false; +} +#endif + diff --git a/src/common/kernel/unit.h b/src/common/kernel/unit.h index c2fe96e38..15eaf46fd 100644 --- a/src/common/kernel/unit.h +++ b/src/common/kernel/unit.h @@ -157,10 +157,13 @@ extern const struct unit u_unknown; extern struct unit * udestroy; -int change_skill(struct unit * u, skill_t id, int byvalue); -void set_skill(struct unit * u, skill_t id, int value); -int get_skill(const struct unit * u, skill_t id); -void transfermen(struct unit * u, struct unit * u2, int n); +extern int change_skill(struct unit * u, skill_t id, int byvalue); +extern int change_level(struct unit * u, skill_t id, int bylevel); +extern void set_skill(struct unit * u, skill_t id, int value); +extern void set_level(struct unit * u, skill_t id, int level); +extern int get_skill(const struct unit * u, skill_t id); +extern int get_level(const struct unit * u, skill_t id); +extern void transfermen(struct unit * u, struct unit * u2, int n); #undef DESTROY @@ -189,4 +192,9 @@ extern struct faction * dfindhash(int no); extern void u_setfaction(struct unit * u, struct faction * f); /* vorsicht Sprüche können u->number == 0 (RS_FARVISION) haben! */ extern void set_number(struct unit * u, int count); + +#if !SKILLPOINTS +extern boolean learn_skill(const struct unit * u, skill_t sk, int days); +#endif + #endif diff --git a/src/common/modules/gmcmd.c b/src/common/modules/gmcmd.c index 5c307bb9b..1346acd60 100644 --- a/src/common/modules/gmcmd.c +++ b/src/common/modules/gmcmd.c @@ -378,7 +378,7 @@ gm_skill(const char * str, void * data, const char * cmd) } else if (skill==NOSKILL || skill==SK_MAGIC || skill==SK_ALCHEMY) { /* unknown or not enough */ mistake(u, cmd, "Dieses Talent ist unbekannt, oder kann nicht erhöht werden.\n", 0); - } else if (num<0 || num>5000) { + } else if (num<0 || num>30) { /* sanity check failed */ mistake(u, cmd, "Der gewählte Wert ist nicht zugelassen.\n", 0); } else { @@ -388,7 +388,7 @@ gm_skill(const char * str, void * data, const char * cmd) mistake(u, cmd, "Unzureichende Rechte für diesen Befehl.\n", 0); } else { - set_skill(to, skill, num*to->number); + set_level(to, skill, num); } } } diff --git a/src/common/spells/alp.c b/src/common/spells/alp.c index 604014fc1..fe104bec3 100644 --- a/src/common/spells/alp.c +++ b/src/common/spells/alp.c @@ -17,6 +17,7 @@ #include #include +#include #include /* util includes */ @@ -104,7 +105,7 @@ sp_summon_alp(struct castorder *co) alp->building = mage->building; alp->ship = mage->ship; } - set_skill(alp, SK_STEALTH, alp->number * 840); /* 840 Tage = T7 */ + set_level(alp, SK_STEALTH, 7); set_string(&alp->name, "Alp"); alp->status = ST_FLEE; /* flieht */