int PlayerObject::update(long elapsedTime) { if (isKeyDown(IM_W)) walkForward(); if (isKeyDown(IM_S)) walkBackward(); if (isKeyDown(IM_A)) walkLeft(); if (isKeyDown(IM_D)) walkRight(); //if (isKeyPressed(IM_SPACE)) jump(); if (isKeyDown(IM_SPACE)) jump(); if (isKeyPressed(IM_M1)) primaryClick(); if (isKeyReleased(IM_M1)) primaryRelease(); if (isKeyDown(IM_M1)) primaryDown(); if (isKeyUp(IM_M1)) primaryUp(); if (isKeyPressed(IM_M2)) secondaryClick(); if (isKeyReleased(IM_M2)) secondaryRelease(); if (isKeyDown(IM_M2)) secondaryDown(); if (isKeyUp(IM_M2)) secondaryUp(); if (isKeyPressed(IM_1)) changeSpell(0); if (isKeyPressed(IM_2)) changeSpell(1); if (isKeyPressed(IM_3)) changeSpell(2); if (isKeyPressed(IM_4)) changeSpell(3); if (isKeyPressed(IM_5)) changeSpell(4); if (getNetworkState() == NETWORK_STATE_OFFLINE) { if (isMouseScrollUp()) { PropObject * temp = new PropObject("sword.obj", "error.tga", "default.glsl", camera->getPos() + camera->getLookAtVector(), camera->getLookAtVector(), camera->getUpVector(), "sword.prop"); //RagdollObject * temp = new RagdollObject(box, t, s, camera->getPos(), camera->getLookAtVector(), camera->getUpVector()); temp->setVelocity(camera->getLookAtVector()*10.0f); temp->setRotation(camera->getLookAtVector(), camera->getUpVector()); } if (isMouseScrollDown()) { PropObject * temp = new PropObject("box.obj", "error.tga", "default.glsl", camera->getPos() + camera->getLookAtVector(), camera->getLookAtVector(), camera->getUpVector(), "box1x1.prop"); //RagdollObject * temp = new RagdollObject(box, t, s, camera->getPos(), camera->getLookAtVector(), camera->getUpVector()); temp->setVelocity(camera->getLookAtVector()*10.0f); temp->setRotation(camera->getLookAtVector(), camera->getUpVector()); } } POINT p = inputManager->getMouseMovement(); turn(p.x*0.05f, p.y*0.05f); int ret = CharacterObject::update(elapsedTime); //setDirection(camera->getLookAtVector()); camera->setPosition(btToGLM3(&getBTPosition()) + glm::vec3(0,1,0)); camera->setLookAtVector(getDirection()); //camera->update(elapsedTime); return ret; }
void SpellShell::timeout() { int count = 0; SpellItem *delList[256]; for(QValueList<SpellItem*>::Iterator it = m_spellList.begin(); it != m_spellList.end(); it++) { if (*it) { int d = (*it)->duration() - SPELLTIMER; // check if target have despawned /* if ( (d > 0) && (*it)->targetId() && (!m_spawnShell->findID( tSpawn, (*it)->targetId())) ) { printf("timeout - caster/target died, stopping '%s'.\n", (*it)->spellName().latin1()); d = d > 0 ? 0 : d; } */ if (d > -20) { (*it)->setDuration(d); emit changeSpell(*it); } else { printf("SpellItem '%s' finished.\n", (*it)->spellName().latin1()); delList[count++] = *it; } } } while (count) DeleteSpell(delList[--count]); }
//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 SpellShell::timeout() { SpellItem* spell; QValueList<SpellItem*>::Iterator it = m_spellList.begin(); while (it != m_spellList.end()) { spell = *it; int d = spell->duration() - pSEQPrefs->getPrefInt("SpellTimer", "SpellList", 6); if (d > -6) { spell->setDuration(d); emit changeSpell(spell); it++; } else { seqInfo("SpellItem '%s' finished.", (*it)->spellName().latin1()); if (m_lastPlayerSpell == spell) m_lastPlayerSpell = 0; emit delSpell(spell); it = m_spellList.remove(it); delete spell; } } if (m_spellList.count() == 0) m_timer->stop(); }
//slot for loading buffs when main char struct is loaded void SpellShell::buffLoad(const spellBuff* c) { #ifdef DIAG_SPELLSHELL seqDebug("Loading buff - id=%d.",c->spellid); #endif // DIAG_SPELLSHELL const Spell* spell = m_spells->spell(c->spellid); int duration = c->duration * 6; SpellItem *item = findSpell(c->spellid, m_player->id(), m_player->name()); if (item) { // exists item->update(c->spellid, spell, duration, 0, "Buff", m_player->id(), m_player->name()); emit changeSpell(item); } else { // new spell item = new SpellItem(); item->update(c->spellid, spell, duration, 0, "Buff", m_player->id(), m_player->name()); 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::action(const uint8_t* data, size_t, uint8_t) { const actionStruct* a = (const actionStruct*)data; if (a->type != 0xe7) // only things to do if action is a spell return; const Item* s; QString targetName; if (a->target && ((s = m_spawnShell->findID(tSpawn, a->target)))) targetName = s->name(); SpellItem *item = findSpell(a->spell, a->target, targetName); if (item || (a->target == m_player->id())) { int duration = 0; const Spell* spell = m_spells->spell(a->spell); if (spell) duration = spell->calcDuration(a->level) * 6; QString casterName; if (a->source && ((s = m_spawnShell->findID(tSpawn, a->source)))) casterName = s->name(); if (item) { #ifdef DIAG_SPELLSHELL seqDebug("action - found - source=%d (lvl: %d) cast id=%d on target=%d causing %d damage", a->source, a->level, a->spell, a->target, a->damage); #endif // DIAG_SPELLSHELL item->update(a->spell, spell, duration, a->source, casterName, a->target, targetName); emit changeSpell(item); } else { // otherwise check for spells cast on us #ifdef DIAG_SPELLSHELL seqDebug("action - new - source=%d (lvl: %d) cast id=%d on target=%d causing %d damage", 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(); item->update(a->spell, spell, duration, a->source, casterName, a->target, targetName); 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::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::selfStartSpellCast(const uint8_t* data) { const startCastStruct *c = (const startCastStruct *)data; #ifdef DIAG_SPELLSHELL seqDebug("selfStartSpellCast - id=%d (slot=%d, inv=%d) on spawnid=%d", c->spellId, c->slot, c->inventorySlot, c->targetId); #endif // DIAG_SPELLSHELL // get the target const Item* s; QString targetName; int duration = 0; const Spell* spell = m_spells->spell(c->spellId); SpellItem *item; if (spell) duration = spell->calcDuration(m_player->level()) * 6; if (!spell || spell->targetType() != 6) { if (c->targetId && ((s = m_spawnShell->findID(tSpawn, c->targetId)))) targetName = s->name(); item = findSpell(c->spellId, c->targetId, targetName); } else { targetName = m_player->name(); item = findSpell(c->spellId); } if (item) { // exists item->update(c->spellId, spell, duration, m_player->id(), m_player->name(), c->targetId, targetName); emit changeSpell(item); } else { // new spell item = new SpellItem(); item->update(c->spellId, spell, duration, m_player->id(), m_player->name(), c->targetId, targetName); m_spellList.append(item); if ((m_spellList.count() > 0) && (!m_timer->isActive())) m_timer->start(1000 * pSEQPrefs->getPrefInt("SpellTimer", "SpellList", 6)); emit addSpell(item); m_lastPlayerSpell = item; } }
void SpellShell::buff(const uint8_t* data, size_t, uint8_t dir) { // we only care about the server if (dir == DIR_Client) return; const buffStruct* b = (const buffStruct*)data; // if this is the second server packet then ignore it if (b->spellid == 0xffffffff) return; #ifdef DIAG_SPELLSHELL seqDebug("Changing buff - id=%d from spawn=%d", b->spellid, b->spawnid); #endif // DIAG_SPELLSHELL const Spell* spell = m_spells->spell(b->spellid); // find the spell item SpellItem* item; const Item* s; QString targetName; if (!spell || spell->targetType() != 6) { if (b->spawnid && ((s = m_spawnShell->findID(tSpawn, b->spawnid)))) targetName = s->name(); item = findSpell(b->spellid, b->spawnid, targetName); } else item = findSpell(b->spellid); if (!item) return; if (b->changetype == 0x01) // removing buff deleteSpell(item); else if (b->changetype == 0x02) { // right now we only know how to find the updated duration item->setDuration(b->duration * 6); emit changeSpell(item); } }
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::timeout() { int count = 0; SpellItem *delList[256]; for(QValueList<SpellItem*>::Iterator it = m_spellList.begin(); it != m_spellList.end(); it++) { if (*it) { int d = (*it)->duration() - pSEQPrefs->getPrefInt("SpellTimer", "SpellList", 6); if (d > -20) { (*it)->setDuration(d); emit changeSpell(*it); } else { printf("SpellItem '%s' finished.\n", (*it)->spellName().latin1()); delList[count++] = *it; } } } while (count) DeleteSpell(delList[--count]); }