void fireOffSpellAnimation(spellcasting_animation_manager_t* animation_manager, Uint32 caster_uid, spell_t *spell) { //This function triggers the spellcasting animation and sets up everything. if (!animation_manager) { return; } Entity *caster = uidToEntity(caster_uid); if (!caster) { return; } if (!spell) { return; } if (!magicLeftHand) { return; } if (!magicRightHand) { return; } playSoundEntity(caster, 170, 128 ); stat_t *stat = caster->getStats(); //Save these two very important pieces of data. animation_manager->caster = caster->uid; animation_manager->spell = spell; animation_manager->active = TRUE; animation_manager->stage = CIRCLE; //Make the HUDWEAPON disappear, or somesuch? magicLeftHand->flags[INVISIBLE] = FALSE; magicRightHand->flags[INVISIBLE] = FALSE; animation_manager->lefthand_angle = 0; animation_manager->lefthand_movex = 0; animation_manager->lefthand_movey = 0; animation_manager->circle_count = 0; animation_manager->times_to_circle = (getCostOfSpell(spell) / 10) + 1; //Circle once for every 10 mana the spell costs. animation_manager->mana_left = getCostOfSpell(spell); if (stat->PROFICIENCIES[PRO_SPELLCASTING] < SPELLCASTING_BEGINNER) { //There's a chance that caster is newer to magic (and thus takes longer to cast a spell). int chance = rand()%10; if (chance >= stat->PROFICIENCIES[PRO_SPELLCASTING]/15) { int amount = (rand()%50)/std::max(stat->PROFICIENCIES[PRO_SPELLCASTING]+statGetINT(stat),1); amount = std::min(amount, CASTING_EXTRA_TIMES_CAP); animation_manager->times_to_circle += amount; } } animation_manager->consume_interval = (animation_manager->times_to_circle * ((2 * PI) / HANDMAGIC_CIRCLE_SPEED)) / getCostOfSpell(spell); animation_manager->consume_timer = animation_manager->consume_interval; }
bool addSpell(int spell, int player, bool ignoreSkill) { node_t* node = nullptr; // this is a local function if ( player != clientnum ) { return false; } spell_t* new_spell = nullptr; switch ( spell ) { case SPELL_FORCEBOLT: new_spell = copySpell(&spell_forcebolt); break; case SPELL_MAGICMISSILE: new_spell = copySpell(&spell_magicmissile); break; case SPELL_COLD: new_spell = copySpell(&spell_cold); break; case SPELL_FIREBALL: new_spell = copySpell(&spell_fireball); break; case SPELL_LIGHTNING: new_spell = copySpell(&spell_lightning); break; case SPELL_REMOVECURSE: new_spell = copySpell(&spell_removecurse); break; case SPELL_LIGHT: new_spell = copySpell(&spell_light); break; case SPELL_IDENTIFY: new_spell = copySpell(&spell_identify); break; case SPELL_MAGICMAPPING: new_spell = copySpell(&spell_magicmapping); break; case SPELL_SLEEP: new_spell = copySpell(&spell_sleep); break; case SPELL_CONFUSE: new_spell = copySpell(&spell_confuse); break; case SPELL_SLOW: new_spell = copySpell(&spell_slow); break; case SPELL_OPENING: new_spell = copySpell(&spell_opening); break; case SPELL_LOCKING: new_spell = copySpell(&spell_locking); break; case SPELL_LEVITATION: new_spell = copySpell(&spell_levitation); break; case SPELL_INVISIBILITY: new_spell = copySpell(&spell_invisibility); break; case SPELL_TELEPORTATION: new_spell = copySpell(&spell_teleportation); break; case SPELL_HEALING: new_spell = copySpell(&spell_healing); break; case SPELL_EXTRAHEALING: new_spell = copySpell(&spell_extrahealing); break; case SPELL_CUREAILMENT: new_spell = copySpell(&spell_cureailment); break; case SPELL_DIG: new_spell = copySpell(&spell_dig); break; case SPELL_STONEBLOOD: new_spell = copySpell(&spell_stoneblood); break; case SPELL_BLEED: new_spell = copySpell(&spell_bleed); break; case SPELL_SUMMON: new_spell = copySpell(&spell_summon); break; case SPELL_DOMINATE: new_spell = copySpell(&spell_dominate); break; case SPELL_REFLECT_MAGIC: new_spell = copySpell(&spell_reflectMagic); break; case SPELL_ACID_SPRAY: new_spell = copySpell(&spell_acidSpray); break; case SPELL_STEAL_WEAPON: new_spell = copySpell(&spell_stealWeapon); break; case SPELL_DRAIN_SOUL: new_spell = copySpell(&spell_drainSoul); break; case SPELL_VAMPIRIC_AURA: new_spell = copySpell(&spell_vampiricAura); break; case SPELL_CHARM_MONSTER: new_spell = copySpell(&spell_charmMonster); break; default: return false; } if ( spellInList(&spellList, new_spell) ) { messagePlayer(player, language[439], new_spell->name); spellDeconstructor((void*)new_spell); return false; } if ( !ignoreSkill && stats[player]->PROFICIENCIES[PRO_MAGIC] + statGetINT(stats[player]) < new_spell->difficulty ) { messagePlayer(player, language[440]); spellDeconstructor((void*)new_spell); return false; } messagePlayer(player, language[441], new_spell->name); node = list_AddNodeLast(&spellList); node->element = new_spell; node->size = sizeof(spell_t); node->deconstructor = &spellDeconstructor; players[player]->entity->increaseSkill(PRO_MAGIC); Item* item = newItem(SPELL_ITEM, SERVICABLE, 0, 1, spell, true, nullptr); itemPickup(player, item); free(item); return true; }
void addSpell(int spell, int player) { node_t *node = NULL; // this is a local function if( player != clientnum ) return; spell_t *new_spell = NULL; switch( spell ) { case SPELL_FORCEBOLT: new_spell = copySpell(&spell_forcebolt); break; case SPELL_MAGICMISSILE: new_spell = copySpell(&spell_magicmissile); break; case SPELL_COLD: new_spell = copySpell(&spell_cold); break; case SPELL_FIREBALL: new_spell = copySpell(&spell_fireball); break; case SPELL_LIGHTNING: new_spell = copySpell(&spell_lightning); break; case SPELL_REMOVECURSE: new_spell = copySpell(&spell_removecurse); break; case SPELL_LIGHT: new_spell = copySpell(&spell_light); break; case SPELL_IDENTIFY: new_spell = copySpell(&spell_identify); break; case SPELL_MAGICMAPPING: new_spell = copySpell(&spell_magicmapping); break; case SPELL_SLEEP: new_spell = copySpell(&spell_sleep); break; case SPELL_CONFUSE: new_spell = copySpell(&spell_confuse); break; case SPELL_SLOW: new_spell = copySpell(&spell_slow); break; case SPELL_OPENING: new_spell = copySpell(&spell_opening); break; case SPELL_LOCKING: new_spell = copySpell(&spell_locking); break; case SPELL_LEVITATION: new_spell = copySpell(&spell_levitation); break; case SPELL_INVISIBILITY: new_spell = copySpell(&spell_invisibility); break; case SPELL_TELEPORTATION: new_spell = copySpell(&spell_teleportation); break; case SPELL_HEALING: new_spell = copySpell(&spell_healing); break; case SPELL_EXTRAHEALING: new_spell = copySpell(&spell_extrahealing); break; case SPELL_CUREAILMENT: new_spell = copySpell(&spell_cureailment); break; case SPELL_DIG: new_spell = copySpell(&spell_dig); break; default: return; } if( spellInList(&spellList, new_spell) ) { messagePlayer(player, language[439],new_spell->name); spellDeconstructor((void *)new_spell); return; } if( stats[player]->PROFICIENCIES[PRO_MAGIC]+statGetINT(stats[player]) < new_spell->difficulty ) { messagePlayer(player, language[440]); spellDeconstructor((void *)new_spell); return; } messagePlayer(player,language[441],new_spell->name); node = list_AddNodeLast(&spellList); node->element = new_spell; node->size = sizeof(spell_t); node->deconstructor = &spellDeconstructor; players[player]->entity->increaseSkill(PRO_MAGIC); Item *item = newItem(SPELL_ITEM, SERVICABLE, 0, 1, spell, TRUE, NULL); itemPickup(player, item); free(item); }