Champion::Champion(const std::string& type, Map* map, uint32 id, uint32 playerId) : Unit(map, id, type, new Stats()), type(type), skillPoints(0), respawnTimer(0), playerId(playerId) { stats->setGold(475.0f); stats->setAttackSpeedMultiplier(1.0f); stats->setGoldPerSecond(map->getGoldPerSecond()); std::vector<unsigned char> iniFile; if(!RAFManager::getInstance()->readFile("DATA/Characters/"+type+"/"+type+".inibin", iniFile)) { printf("ERR : couldn't find champion stats for %s\n", type.c_str()); return; } Inibin inibin(iniFile); stats->setCurrentHealth(inibin.getFloatValue("Data", "BaseHP")); stats->setMaxHealth(inibin.getFloatValue("Data", "BaseHP")); stats->setCurrentMana(inibin.getFloatValue("Data", "BaseMP")); stats->setMaxMana(inibin.getFloatValue("Data", "BaseMP")); stats->setBaseAd(inibin.getFloatValue("DATA", "BaseDamage")); stats->setRange(inibin.getFloatValue("DATA", "AttackRange")); stats->setBaseMovementSpeed(inibin.getFloatValue("DATA", "MoveSpeed")); stats->setArmor(inibin.getFloatValue("DATA", "Armor")); stats->setMagicArmor(inibin.getFloatValue("DATA", "SpellBlock")); stats->setHp5(inibin.getFloatValue("DATA", "BaseStaticHPRegen")); stats->setMp5(inibin.getFloatValue("DATA", "BaseStaticMPRegen")); stats->setHealthPerLevel(inibin.getFloatValue("DATA", "HPPerLevel")); stats->setManaPerLevel(inibin.getFloatValue("DATA", "MPPerLevel")); stats->setAdPerLevel(inibin.getFloatValue("DATA", "DamagePerLevel")); stats->setArmorPerLevel(inibin.getFloatValue("DATA", "ArmorPerLevel")); stats->setMagicArmorPerLevel(inibin.getFloatValue("DATA", "SpellBlockPerLevel")); stats->setHp5RegenPerLevel(inibin.getFloatValue("DATA", "HPRegenPerLevel")); stats->setMp5RegenPerLevel(inibin.getFloatValue("DATA", "MPRegenPerLevel")); stats->setBaseAttackSpeed(0.625f/(1+inibin.getFloatValue("DATA", "AttackDelayOffsetPercent"))); spells.push_back(new Spell(this, inibin.getStringValue("Data", "Spell1"), 0)); spells.push_back(new Spell(this, inibin.getStringValue("Data", "Spell2"), 1)); spells.push_back(new Spell(this, inibin.getStringValue("Data", "Spell3"), 2)); spells.push_back(new Spell(this, inibin.getStringValue("Data", "Spell4"), 3)); setMelee(inibin.getBoolValue("DATA", "IsMelee")); iniFile.clear(); if(!RAFManager::getInstance()->readFile("DATA/Characters/"+type+"/Spells/"+type+"BasicAttack.inibin", iniFile)) { if(!RAFManager::getInstance()->readFile("DATA/Spells/"+type+"BasicAttack.inibin", iniFile)) { printf("ERR : couldn't find champion auto-attack data for %s\n", type.c_str()); return; } } Inibin autoAttack(iniFile); autoAttackDelay = autoAttack.getFloatValue("SpellData", "castFrame")/30.f; autoAttackProjectileSpeed = autoAttack.getFloatValue("SpellData", "MissileSpeed"); std::string scriptloc = "../../lua/champions/" + this->getType() + "/Passive.lua"; printf("Loading %s\n", scriptloc.c_str()); try{ unitScript = LuaScript(true);//fix unitScript.lua.set("me", this); unitScript.loadScript(scriptloc); unitScript.lua.set_function("dealMagicDamage", [this](Unit* target, float amount) { this->dealDamageTo(target,amount,DAMAGE_TYPE_MAGICAL,DAMAGE_SOURCE_SPELL); }); unitScript.lua.set_function("addBuff", [this](Unit* target, Buff b){ target->addBuff(new Buff(b)); return; }); unitScript.lua.set_function("addParticleTarget", [this](const std::string& particle, Target* u) { this->getMap()->getGame()->notifyParticleSpawn(this, u, particle); return; }); // unitScript.lua.set ("me", this); }catch(sol::error e){//lua error? don't crash the whole server printf("Champion passive load error: \n%s\n", e.what()); } }
Champion::Champion(const std::string& type, Map* map, uint32 id) : Unit(map, id, type, new Stats()), type(type), skillPoints(0), respawnTimer(0) { stats->setGold(475.0f); stats->setAttackSpeedMultiplier(1.0f); stats->setGoldPerSecond(map->getGoldPerSecond()); std::vector<unsigned char> iniFile; if(!RAFManager::getInstance()->readFile("DATA/Characters/"+type+"/"+type+".inibin", iniFile)) { printf("ERR : couldn't find champion stats for %s\n", type.c_str()); return; } Inibin inibin(iniFile); stats->setCurrentHealth(inibin.getFloatValue("Data", "BaseHP")); stats->setMaxHealth(inibin.getFloatValue("Data", "BaseHP")); stats->setCurrentMana(inibin.getFloatValue("Data", "BaseMP")); stats->setMaxMana(inibin.getFloatValue("Data", "BaseMP")); stats->setBaseAd(inibin.getFloatValue("DATA", "BaseDamage")); stats->setRange(inibin.getFloatValue("DATA", "AttackRange")); stats->setBaseMovementSpeed(inibin.getFloatValue("DATA", "MoveSpeed")); stats->setArmor(inibin.getFloatValue("DATA", "Armor")); stats->setMagicArmor(inibin.getFloatValue("DATA", "SpellBlock")); stats->setHp5(inibin.getFloatValue("DATA", "BaseStaticHPRegen")); stats->setMp5(inibin.getFloatValue("DATA", "BaseStaticMPRegen")); stats->setHealthPerLevel(inibin.getFloatValue("DATA", "HPPerLevel")); stats->setManaPerLevel(inibin.getFloatValue("DATA", "MPPerLevel")); stats->setAdPerLevel(inibin.getFloatValue("DATA", "DamagePerLevel")); stats->setArmorPerLevel(inibin.getFloatValue("DATA", "ArmorPerLevel")); stats->setMagicArmorPerLevel(inibin.getFloatValue("DATA", "SpellBlockPerLevel")); stats->setHp5RegenPerLevel(inibin.getFloatValue("DATA", "HPRegenPerLevel")); stats->setMp5RegenPerLevel(inibin.getFloatValue("DATA", "MPRegenPerLevel")); stats->setBaseAttackSpeed(0.625/(1+inibin.getFloatValue("DATA", "AttackDelayOffsetPercent"))); spells.push_back(new Spell(this, inibin.getStringValue("Data", "Spell1"), 0)); spells.push_back(new Spell(this, inibin.getStringValue("Data", "Spell2"), 1)); spells.push_back(new Spell(this, inibin.getStringValue("Data", "Spell3"), 2)); spells.push_back(new Spell(this, inibin.getStringValue("Data", "Spell4"), 3)); setMelee(inibin.getBoolValue("DATA", "IsMelee")); iniFile.clear(); if(!RAFManager::getInstance()->readFile("DATA/Characters/"+type+"/Spells/"+type+"BasicAttack.inibin", iniFile)) { if(!RAFManager::getInstance()->readFile("DATA/Spells/"+type+"BasicAttack.inibin", iniFile)) { printf("ERR : couldn't find champion auto-attack data for %s\n", type.c_str()); return; } } Inibin autoAttack(iniFile); autoAttackDelay = autoAttack.getFloatValue("SpellData", "castFrame")/30.f; autoAttackProjectileSpeed = autoAttack.getFloatValue("SpellData", "MissileSpeed"); std::string scriptloc = "../../lua/champions/" + this->getType() + "/Passive.lua"; printf("Loading %s\n", scriptloc.c_str()); try{ unitScript->loadScript(scriptloc); }catch(sol::error e){//lua error? don't crash the whole server printf("%s", e.what()); } }