| 67 | } |
| 68 | |
| 69 | bool CreatureSkillMissileLaunch::tryUseFight(GameMap& gameMap, Creature* creature, float range, |
| 70 | GameEntity* attackedObject, Tile* attackedTile, bool ko, bool notifyPlayerIfHit) const |
| 71 | { |
| 72 | Tile* creatureTile = creature->getPositionTile(); |
| 73 | if(creatureTile == nullptr) |
| 74 | { |
| 75 | OD_LOG_ERR("creature=" + creature->getName() + ", pos=" + Helper::toString(creature->getPosition())); |
| 76 | return false; |
| 77 | } |
| 78 | |
| 79 | Ogre::Vector3 position; |
| 80 | position.x = static_cast<Ogre::Real>(creatureTile->getX()); |
| 81 | position.y = static_cast<Ogre::Real>(creatureTile->getY()); |
| 82 | position.z = CANNON_MISSILE_HEIGHT; |
| 83 | Ogre::Vector3 missileDirection(static_cast<Ogre::Real>(attackedTile->getX()), |
| 84 | static_cast<Ogre::Real>(attackedTile->getY()), CANNON_MISSILE_HEIGHT); |
| 85 | missileDirection = missileDirection - position; |
| 86 | missileDirection.normalise(); |
| 87 | |
| 88 | double level = static_cast<double>(creature->getLevel()); |
| 89 | double phyAtk = mPhyAtk + (level * mPhyAtkPerLvl); |
| 90 | double magAtk = mMagAtk + (level * mMagAtkPerLvl); |
| 91 | double eleAtk = mMagAtk + (level * mEleAtkPerLvl); |
| 92 | if(creature->getWeaponL() != nullptr) |
| 93 | { |
| 94 | phyAtk +=creature->getWeaponL()->getPhysicalDamage(); |
| 95 | magAtk +=creature->getWeaponL()->getMagicalDamage(); |
| 96 | eleAtk +=creature->getWeaponL()->getElementDamage(); |
| 97 | } |
| 98 | if(creature->getWeaponR() != nullptr) |
| 99 | { |
| 100 | phyAtk +=creature->getWeaponR()->getPhysicalDamage(); |
| 101 | magAtk +=creature->getWeaponR()->getMagicalDamage(); |
| 102 | eleAtk +=creature->getWeaponR()->getElementDamage(); |
| 103 | } |
| 104 | |
| 105 | MissileOneHit* missile = new MissileOneHit(&gameMap, creature->getSeat(), creature->getName(), |
| 106 | mMissileMesh, mMissilePartScript, missileDirection, mMissileSpeed, phyAtk, magAtk, eleAtk, |
| 107 | attackedObject, false, ko, notifyPlayerIfHit); |
| 108 | missile->addToGameMap(); |
| 109 | missile->createMesh(); |
| 110 | missile->setPosition(position); |
| 111 | // We don't want the missile to stay idle for 1 turn. Because we are in a doUpkeep context, |
| 112 | // we can safely call the missile doUpkeep as we know the engine will not call it the turn |
| 113 | // it has been added |
| 114 | missile->doUpkeep(); |
| 115 | |
| 116 | return true; |
| 117 | } |
| 118 | |
| 119 | CreatureSkillMissileLaunch* CreatureSkillMissileLaunch::clone() const |
| 120 | { |
nothing calls this directly
no test coverage detected