void SpellShell::buff(const buffStruct* b, uint32_t, uint8_t dir) { // we only care about the server if (dir == DIR_CLIENT) return; // if this is the second server packet then ignore it if (b->spellid == 0xffffffff) return; #ifdef DIAG_SPELLSHELL printf("Dropping buff - id=%d from spawn=%d\n", b->spellid, b->spawnid); #endif // DIAG_SPELLSHELL // find the spell item SpellItem* item = FindSpell(b->spellid, b->spawnid); if (!item) return; if (b->changetype == 0x01) // removing buff DeleteSpell(item); else if (b->changetype == 0x02) UpdateSpell(item, b); }
//Overloaded InsertSpell for buffLoad SpellItem* SpellShell::InsertSpell(const spellBuff *c) { if (c) { SpellItem *item = FindSpell(c->spellid); if (item) { // exists UpdateSpell(item, c); emit changeSpell(item); return item; } else { // new spell item = new SpellItem(); UpdateSpell(item, c); m_spellList.append(item); if ((m_spellList.count() > 0) && (!m_timer->isActive())) m_timer->start(1000 * pSEQPrefs->getPrefInt("SpellTimer", "SpellList", 6)); emit addSpell(item); return item; } } return NULL; }
//================================================================================================= void Electro::Load(HANDLE file) { uint count; ReadFile(file, &count, sizeof(count), &tmp, NULL); lines.resize(count); for(vector<ElectroLine>::iterator it = lines.begin(), end = lines.end(); it != end; ++it) { ReadFile(file, &count, sizeof(count), &tmp, NULL); it->pts.resize(count); if(count) ReadFile(file, &it->pts[0], sizeof(VEC3)*count, &tmp, NULL); ReadFile(file, &it->t, sizeof(it->t), &tmp, NULL); } ReadFile(file, &count, sizeof(count), &tmp, NULL); hitted.resize(count); int refid; for(vector<Unit*>::iterator it = hitted.begin(), end = hitted.end(); it != end; ++it) { ReadFile(file, &refid, sizeof(refid), &tmp, NULL); *it = Unit::GetByRefid(refid); } ReadFile(file, &dmg, sizeof(dmg), &tmp, NULL); ReadFile(file, &refid, sizeof(refid), &tmp, NULL); owner = Unit::GetByRefid(refid); byte len; ReadFile(file, &len, sizeof(len), &tmp, NULL); BUF[len] = 0; ReadFile(file, BUF, len, &tmp, NULL); spell = FindSpell(BUF); ReadFile(file, &valid, sizeof(valid), &tmp, NULL); ReadFile(file, &hitsome, sizeof(hitsome), &tmp, NULL); ReadFile(file, &start_pos, sizeof(start_pos), &tmp, NULL); ReadFile(file, &netid, sizeof(netid), &tmp, NULL); }
void SpellShell::UpdateSpell(const castStruct *c) { if (c) { SpellItem *item = FindSpell(c->spellId, m_player->getPlayerID(), c->targetId); item->UpdateSpell(m_spawnShell, m_player->getPlayerID(), c); emit changeSpell(item); } }
void SpellShell::selfFinishSpellCast(const memSpellStruct *b) { if (b->param2 != 3) return; printf("selfFinishSpellCast - id=%d, by=%d\n", b->spellId, b->spawnId); SpellItem *item = FindSpell(b->spellId, m_player->getPlayerID(), b->spawnId); if (item) { struct spellInfoStruct *info = spell_info(b->spellId); item->setDuration(info->duration); } }
SpellItem* SpellShell::InsertSpell(const castStruct *c) { if (c) { SpellItem *item = FindSpell(c->spellId, m_player->getPlayerID(), c->targetId); if (item) { // exists UpdateSpell(c); return item; } else { // new spell item = new SpellItem(m_spawnShell, m_player->getPlayerID(), c); m_spellList.append(item); if ((m_spellList.count() > 0) && (!m_timer->isActive())) m_timer->start(1000 * SPELLTIMER); emit addSpell(item); return item; } } return NULL; }
void SpellShell::action(const actionStruct* a, uint32_t, uint8_t) { if (a->type != 0xe7) // only things to do if action is a spell return; SpellItem* item; // find a spell with a matching spellid and target - used for updating // buffs that we had cast previously that are now be updated by someone // else. item = FindSpell(a->spell, a->target); if (item) { #ifdef DIAG_SPELLSHELL printf("action - source=%d (lvl: %d) cast id=%d on target=%d causing %d damage\n", a->source, a->level, a->spell, a->target, a->damage); #endif // DIAG_SPELLSHELL UpdateSpell(item, a); emit changeSpell(item); return; } // otherwise check for spells cast on us if (a->target == m_player->id()) { #ifdef DIAG_SPELLSHELL printf("action - source=%d (lvl: %d) cast id=%d on target=%d causing %d damage\n", a->source, a->level, a->spell, a->target, a->damage); #endif // DIAG_SPELLSHELL // only way to get here is if there wasn't an existing spell, so... item = new SpellItem(); UpdateSpell(item, a); m_spellList.append(item); if ((m_spellList.count() > 0) && (!m_timer->isActive())) m_timer->start(1000 * pSEQPrefs->getPrefInt("SpellTimer", "SpellList", 6)); emit addSpell(item); } }
void SpellShell::buffDrop(const buffDropStruct* bd, uint32_t, uint8_t dir) { // we only care about the server if (dir == DIR_CLIENT) return; // if this is the second server packet then ignore it if (bd->spellid == 0xffffffff) return; #ifdef DIAG_SPELLSHELL printf("Dropping buff - id=%d from spawn=%d\n", bd->spellid, bd->spawnid); #endif // DIAG_SPELLSHELL // find the spell item SpellItem* item = FindSpell(bd->spellid, bd->spawnid); // if the spell item was found, then delete it if (item) DeleteSpell(item); }
void SpellManager::HandleAssembler(MsgEntry* me, Client* client) { psGlyphAssembleMessage mesg; mesg.FromClient(me); csArray<psItemStats*> assembler; for(size_t i = 0; i < GLYPH_ASSEMBLER_SLOTS; i++) { if(mesg.glyphs[i] != 0) { psItemStats* stats = cacheManager->GetBasicItemStatsByID(mesg.glyphs[i]); if(stats) assembler.Push(stats); } } if(assembler.GetSize() == 0) { psserver->SendSystemError(client->GetClientNum(), "There are no glyphs in the research slots."); return; } if(!client->GetCharacterData()->Inventory().HasPurifiedGlyphs(assembler)) { Error2("Client %i tried to research spell with glyphs he actually doesn't have", client->GetClientNum()); SendGlyphs(NULL,client); return; } // Is the Glyph Sequence a Valid one? psSpell* spell = FindSpell(client, assembler); csString description("Your research didn't result in a valid spell."); if(spell) { // Is this spell already in our spellbook? psSpell* knownSpell = client->GetCharacterData()->GetSpellByName(spell->GetName()); if(knownSpell) { if(mesg.info) { psGlyphAssembleMessage newmsginfo(client->GetClientNum(), knownSpell->GetName(), knownSpell->GetImage(), knownSpell->GetDescription()); newmsginfo.SendMessage(); } else { psserver->SendSystemInfo(client->GetClientNum(), "You know this spell already."); } return; } description = "A spell materializes for a second, but you then lose focus. Try again or increase your magic knowledge."; } if(mesg.info) return; csString name(" "); csString image(" "); const bool success = spell && psserver->GetRandom() * 100.0 < spell->ChanceOfResearchSuccess(client->GetCharacterData()); ProgressionScript* outcome = psserver->GetProgressionManager()->FindScript(success ? "ResearchSpellSuccess" : "ResearchSpellFailure"); if(outcome) { MathEnvironment env; env.Define("Actor", client->GetActor()); outcome->Run(&env); } if(success) { description = spell->GetDescription(); name = spell->GetName(); image = spell->GetImage(); SaveSpell(client, name); } // Clear the description, if this is not valid glyph sequence for our player: psGlyphAssembleMessage newmsg(client->GetClientNum(), name, image, description); newmsg.SendMessage(); }