forked from github/server
- zauber sind mehrfach in der zauberliste
This commit is contained in:
parent
8dfe5ae9a1
commit
e135dc7728
|
@ -202,7 +202,6 @@ read_mage(attrib * a, FILE * F)
|
||||||
{
|
{
|
||||||
int i, mtype;
|
int i, mtype;
|
||||||
sc_mage * mage = (sc_mage*)a->data.v;
|
sc_mage * mage = (sc_mage*)a->data.v;
|
||||||
spell_ptr ** sp = &mage->spellptr;
|
|
||||||
|
|
||||||
fscanf(F, "%d %d %d", &mtype, &mage->spellpoints, &mage->spchange);
|
fscanf(F, "%d %d %d", &mtype, &mage->spellpoints, &mage->spchange);
|
||||||
mage->magietyp = (magic_t)mtype;
|
mage->magietyp = (magic_t)mtype;
|
||||||
|
@ -213,15 +212,16 @@ read_mage(attrib * a, FILE * F)
|
||||||
mage->combatspell[i] = (spellid_t)spid;
|
mage->combatspell[i] = (spellid_t)spid;
|
||||||
}
|
}
|
||||||
for (;;) {
|
for (;;) {
|
||||||
int spid;
|
int i;
|
||||||
|
|
||||||
fscanf (F, "%d", &spid);
|
fscanf (F, "%d", &i);
|
||||||
if (spid < 0) break;
|
if (i < 0) break;
|
||||||
if (find_spellbyid((spellid_t)spid)==NULL) continue;
|
else {
|
||||||
|
spellid_t spid = (spellid_t)i;
|
||||||
|
|
||||||
*sp = calloc (sizeof(spell_ptr), 1);
|
if (find_spellbyid(spid)==NULL) continue;
|
||||||
(*sp)->spellid = (spellid_t)spid;
|
add_spell(mage, spid);
|
||||||
sp = &(*sp)->next;
|
}
|
||||||
}
|
}
|
||||||
return AT_READ_OK;
|
return AT_READ_OK;
|
||||||
}
|
}
|
||||||
|
@ -302,7 +302,7 @@ createspelllist(unit *u, magic_t mtyp)
|
||||||
spell * sp = slist->data;
|
spell * sp = slist->data;
|
||||||
if (sp->magietyp == mtyp && sp->level <= sk) {
|
if (sp->magietyp == mtyp && sp->level <= sk) {
|
||||||
if (!has_spell(u, sp)) {
|
if (!has_spell(u, sp)) {
|
||||||
addspell(u, sp->id);
|
add_spell(get_mage(u), sp->id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -313,9 +313,9 @@ createspelllist(unit *u, magic_t mtyp)
|
||||||
sc_mage *
|
sc_mage *
|
||||||
create_mage(unit * u, magic_t mtyp)
|
create_mage(unit * u, magic_t mtyp)
|
||||||
{
|
{
|
||||||
sc_mage *mage;
|
sc_mage *mage;
|
||||||
attrib *a;
|
attrib *a;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
a = a_find(u->attribs, &at_mage);
|
a = a_find(u->attribs, &at_mage);
|
||||||
if (a==NULL) {
|
if (a==NULL) {
|
||||||
|
@ -326,16 +326,16 @@ create_mage(unit * u, magic_t mtyp)
|
||||||
mage = a->data.v;
|
mage = a->data.v;
|
||||||
}
|
}
|
||||||
|
|
||||||
mage->magietyp = mtyp;
|
mage->magietyp = mtyp;
|
||||||
mage->spellpoints = 0;
|
mage->spellpoints = 0;
|
||||||
mage->spchange = 0;
|
mage->spchange = 0;
|
||||||
mage->spellcount = 0;
|
mage->spellcount = 0;
|
||||||
for (i=0;i<MAXCOMBATSPELLS;i++) {
|
for (i=0;i<MAXCOMBATSPELLS;i++) {
|
||||||
mage->combatspell[i] = SPL_NOSPELL;
|
mage->combatspell[i] = SPL_NOSPELL;
|
||||||
}
|
}
|
||||||
mage->spellptr = NULL;
|
mage->spellptr = NULL;
|
||||||
createspelllist(u, mtyp);
|
createspelllist(u, mtyp);
|
||||||
return mage;
|
return mage;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------- */
|
/* ------------------------------------------------------------- */
|
||||||
|
@ -366,19 +366,20 @@ updatespelllist(unit * u)
|
||||||
int sk = eff_skill(u, SK_MAGIC, u->region);
|
int sk = eff_skill(u, SK_MAGIC, u->region);
|
||||||
spell_list * slist;
|
spell_list * slist;
|
||||||
spell * sp;
|
spell * sp;
|
||||||
|
struct sc_mage * mage = get_mage(u);
|
||||||
magic_t gebiet = find_magetype(u);
|
magic_t gebiet = find_magetype(u);
|
||||||
boolean ismonster = u->faction->no==MONSTER_FACTION;
|
boolean ismonster = u->faction->no==MONSTER_FACTION;
|
||||||
|
|
||||||
/* Nur Orkmagier bekommen den Keuschheitsamulettzauber */
|
/* Nur Orkmagier bekommen den Keuschheitsamulettzauber */
|
||||||
sp = find_spellbyid(SPL_ARTEFAKT_CHASTITYBELT);
|
sp = find_spellbyid(SPL_ARTEFAKT_CHASTITYBELT);
|
||||||
if (old_race(u->race)==RC_ORC && !has_spell(u, sp) && sp->level<=sk) {
|
if (old_race(u->race)==RC_ORC && !has_spell(u, sp) && sp->level<=sk) {
|
||||||
addspell(u, SPL_ARTEFAKT_CHASTITYBELT);
|
add_spell(mage, SPL_ARTEFAKT_CHASTITYBELT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Nur Wyrm-Magier bekommen den Wyrmtransformationszauber */
|
/* Nur Wyrm-Magier bekommen den Wyrmtransformationszauber */
|
||||||
sp = find_spellbyid(SPL_BECOMEWYRM);
|
sp = find_spellbyid(SPL_BECOMEWYRM);
|
||||||
if (fspecial(u->faction, FS_WYRM) && !has_spell(u, sp) && sp->level<=sk) {
|
if (fspecial(u->faction, FS_WYRM) && !has_spell(u, sp) && sp->level<=sk) {
|
||||||
addspell(u, SPL_BECOMEWYRM);
|
add_spell(mage, SPL_BECOMEWYRM);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Transformierte Wyrm-Magier bekommen Drachenodem */
|
/* Transformierte Wyrm-Magier bekommen Drachenodem */
|
||||||
|
@ -389,17 +390,17 @@ updatespelllist(unit * u)
|
||||||
case RC_WYRM:
|
case RC_WYRM:
|
||||||
sp = find_spellbyid(SPL_WYRMODEM);
|
sp = find_spellbyid(SPL_WYRMODEM);
|
||||||
if (sp!=NULL && !has_spell(u, sp) && sp->level<=sk) {
|
if (sp!=NULL && !has_spell(u, sp) && sp->level<=sk) {
|
||||||
addspell(u, sp->id);
|
add_spell(mage, sp->id);
|
||||||
}
|
}
|
||||||
case RC_DRAGON:
|
case RC_DRAGON:
|
||||||
sp = find_spellbyid(SPL_DRAGONODEM);
|
sp = find_spellbyid(SPL_DRAGONODEM);
|
||||||
if (sp!=NULL && !has_spell(u, sp) && sp->level<=sk) {
|
if (sp!=NULL && !has_spell(u, sp) && sp->level<=sk) {
|
||||||
addspell(u, sp->id);
|
add_spell(mage, sp->id);
|
||||||
}
|
}
|
||||||
case RC_FIREDRAGON:
|
case RC_FIREDRAGON:
|
||||||
sp = find_spellbyid(SPL_FIREDRAGONODEM);
|
sp = find_spellbyid(SPL_FIREDRAGONODEM);
|
||||||
if (sp!=NULL && has_spell(u, sp) && sp->level<=sk) {
|
if (sp!=NULL && has_spell(u, sp) && sp->level<=sk) {
|
||||||
addspell(u, sp->id);
|
add_spell(mage, sp->id);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -417,7 +418,7 @@ updatespelllist(unit * u)
|
||||||
if (know || (gebiet!=M_GRAU && sp->magietyp == gebiet)) {
|
if (know || (gebiet!=M_GRAU && sp->magietyp == gebiet)) {
|
||||||
faction * f = u->faction;
|
faction * f = u->faction;
|
||||||
|
|
||||||
if (!know) addspell(u, sp->id);
|
if (!know) add_spell(mage, sp->id);
|
||||||
if (!ismonster && !already_seen(u->faction, sp->id)) {
|
if (!ismonster && !already_seen(u->faction, sp->id)) {
|
||||||
a_add(&f->attribs, a_new(&at_reportspell))->data.i = sp->id;
|
a_add(&f->attribs, a_new(&at_reportspell))->data.i = sp->id;
|
||||||
a_add(&f->attribs, a_new(&at_seenspell))->data.i = sp->id;
|
a_add(&f->attribs, a_new(&at_seenspell))->data.i = sp->id;
|
||||||
|
@ -431,20 +432,25 @@ updatespelllist(unit * u)
|
||||||
/* Funktionen für die Bearbeitung der List-of-known-spells */
|
/* Funktionen für die Bearbeitung der List-of-known-spells */
|
||||||
|
|
||||||
void
|
void
|
||||||
addspell(unit *u, spellid_t spellid)
|
add_spell(sc_mage* m, spellid_t spellid)
|
||||||
{
|
{
|
||||||
sc_mage *m;
|
if (m==NULL) {
|
||||||
spell_ptr *newsp;
|
log_error(("add_spell: unit is not a mage.\n"));
|
||||||
|
} else {
|
||||||
m = get_mage(u);
|
spell_ptr *newsp;
|
||||||
if (!m) {
|
spell_ptr **spinsert = &m->spellptr;
|
||||||
return;
|
while (*spinsert && (*spinsert)->spellid<spellid) spinsert=&(*spinsert)->next;
|
||||||
}
|
newsp = *spinsert;
|
||||||
newsp = calloc(1, sizeof(spell_ptr));
|
if (newsp && newsp->spellid==spellid) {
|
||||||
newsp->spellid = spellid;
|
log_error(("add_spell: unit already has spell %d.\n", spellid));
|
||||||
|
return;
|
||||||
addlist(&m->spellptr, newsp);
|
}
|
||||||
return;
|
newsp = calloc(1, sizeof(spell_ptr));
|
||||||
|
newsp->spellid = spellid;
|
||||||
|
newsp->next = *spinsert;
|
||||||
|
*spinsert = newsp;
|
||||||
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean
|
boolean
|
||||||
|
@ -455,9 +461,9 @@ has_spell(const unit *u, const spell * sp)
|
||||||
|
|
||||||
if (m==NULL) return false;
|
if (m==NULL) return false;
|
||||||
|
|
||||||
for (spt = m->spellptr; spt; spt = spt->next) {
|
spt = m->spellptr;
|
||||||
if (spt->spellid == sp->id) return true;
|
while (spt && spt->spellid<sp->id) spt = spt->next;
|
||||||
}
|
if (spt && spt->spellid==sp->id) return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -111,15 +111,15 @@ typedef struct spell_ptr {
|
||||||
} spell_ptr;
|
} spell_ptr;
|
||||||
|
|
||||||
typedef struct sc_mage {
|
typedef struct sc_mage {
|
||||||
magic_t magietyp;
|
magic_t magietyp;
|
||||||
int spellpoints;
|
int spellpoints;
|
||||||
int spchange;
|
int spchange;
|
||||||
int spellcount;
|
int spellcount;
|
||||||
spellid_t combatspell[MAXCOMBATSPELLS];
|
spellid_t combatspell[MAXCOMBATSPELLS];
|
||||||
int combatspelllevel[MAXCOMBATSPELLS];
|
int combatspelllevel[MAXCOMBATSPELLS];
|
||||||
int precombataura; /* Merker, wieviel Aura in den Präcombatzauber
|
int precombataura; /* Merker, wieviel Aura in den Präcombatzauber
|
||||||
gegangen ist. Nicht speichern. */
|
gegangen ist. Nicht speichern. */
|
||||||
struct spell_ptr *spellptr;
|
struct spell_ptr *spellptr;
|
||||||
} sc_mage;
|
} sc_mage;
|
||||||
|
|
||||||
/* ------------------------------------------------------------- */
|
/* ------------------------------------------------------------- */
|
||||||
|
@ -279,7 +279,7 @@ void set_combatspell(struct unit *u, spell *sp, struct order * ord, int level);
|
||||||
/* setzt Kampfzauber */
|
/* setzt Kampfzauber */
|
||||||
void unset_combatspell(struct unit *u, spell *sp);
|
void unset_combatspell(struct unit *u, spell *sp);
|
||||||
/* löscht Kampfzauber */
|
/* löscht Kampfzauber */
|
||||||
void addspell(struct unit *u, spellid_t spellid);
|
void add_spell(struct sc_mage *mage, spellid_t spellid);
|
||||||
/* fügt den Spruch mit der Id spellid der Spruchliste der Einheit hinzu. */
|
/* fügt den Spruch mit der Id spellid der Spruchliste der Einheit hinzu. */
|
||||||
boolean has_spell(const struct unit *u, const struct spell * sp);
|
boolean has_spell(const struct unit *u, const struct spell * sp);
|
||||||
/* prüft, ob der Spruch in der Spruchliste der Einheit steht. */
|
/* prüft, ob der Spruch in der Spruchliste der Einheit steht. */
|
||||||
|
|
|
@ -494,7 +494,7 @@ oldfamiliars(unit * familiar)
|
||||||
if (m!=NULL) {
|
if (m!=NULL) {
|
||||||
spell_list * fspells = familiarspells(familiar->race);
|
spell_list * fspells = familiarspells(familiar->race);
|
||||||
while (fspells!=NULL) {
|
while (fspells!=NULL) {
|
||||||
addspell(familiar, fspells->data->id);
|
add_spell(m, fspells->data->id);
|
||||||
fspells=fspells->next;
|
fspells=fspells->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1160,7 +1160,7 @@ readunit(FILE * F)
|
||||||
csp++;
|
csp++;
|
||||||
}
|
}
|
||||||
while ((i = ri(F)) != -1) {
|
while ((i = ri(F)) != -1) {
|
||||||
addspell(u, (spellid_t) i);
|
add_spell(mage, (spellid_t) i);
|
||||||
}
|
}
|
||||||
mage->spellcount = 0;
|
mage->spellcount = 0;
|
||||||
a = a_add(&u->attribs, a_new(&at_mage));
|
a = a_add(&u->attribs, a_new(&at_mage));
|
||||||
|
|
|
@ -7219,33 +7219,33 @@ sp_destroy_curse(castorder *co)
|
||||||
int
|
int
|
||||||
sp_becomewyrm(castorder *co)
|
sp_becomewyrm(castorder *co)
|
||||||
{
|
{
|
||||||
unit *mage = (unit *)co->magician;
|
unit *u = (unit *)co->magician;
|
||||||
int wyrms_already_created = 0;
|
int wyrms_already_created = 0;
|
||||||
int wyrms_allowed;
|
int wyrms_allowed;
|
||||||
attrib *a;
|
attrib *a;
|
||||||
|
|
||||||
wyrms_allowed = fspecial(mage->faction, FS_WYRM);
|
wyrms_allowed = fspecial(u->faction, FS_WYRM);
|
||||||
a = a_find(mage->faction->attribs, &at_wyrm);
|
a = a_find(u->faction->attribs, &at_wyrm);
|
||||||
if(a) wyrms_already_created = a->data.i;
|
if(a) wyrms_already_created = a->data.i;
|
||||||
|
|
||||||
if(wyrms_already_created >= wyrms_allowed) {
|
if(wyrms_already_created >= wyrms_allowed) {
|
||||||
cmistake(mage, co->order, 262, MSG_MAGIC);
|
cmistake(u, co->order, 262, MSG_MAGIC);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!a) {
|
if(!a) {
|
||||||
a_add(&mage->faction->attribs, a_new(&at_wyrm));
|
a_add(&u->faction->attribs, a_new(&at_wyrm));
|
||||||
a->data.i = 1;
|
a->data.i = 1;
|
||||||
} else {
|
} else {
|
||||||
a->data.i++;
|
a->data.i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
mage->race = new_race[RC_WYRM];
|
u->race = new_race[RC_WYRM];
|
||||||
addspell(mage, SPL_WYRMODEM);
|
add_spell(get_mage(u), SPL_WYRMODEM);
|
||||||
|
|
||||||
ADDMSG(&mage->faction->msgs, msg_message("becomewyrm", "mage", mage));
|
ADDMSG(&u->faction->msgs, msg_message("becomewyrm", "u", u));
|
||||||
|
|
||||||
return co->level;
|
return co->level;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef WDW_PYRAMIDSPELL
|
#ifdef WDW_PYRAMIDSPELL
|
||||||
|
|
|
@ -199,8 +199,9 @@ unit_addspell(unit& u, const char * name)
|
||||||
while (slist!=NULL) {
|
while (slist!=NULL) {
|
||||||
spell * sp = slist->data;
|
spell * sp = slist->data;
|
||||||
if (strcmp(name, sp->sname)==0) {
|
if (strcmp(name, sp->sname)==0) {
|
||||||
|
struct sc_mage * mage = get_mage(&u);
|
||||||
if (add) log_error(("two spells are called %s.\n", name));
|
if (add) log_error(("two spells are called %s.\n", name));
|
||||||
addspell(&u, sp->id);
|
add_spell(mage, sp->id);
|
||||||
add = true;
|
add = true;
|
||||||
}
|
}
|
||||||
slist=slist->next;
|
slist=slist->next;
|
||||||
|
|
Loading…
Reference in New Issue