diff --git a/include/eve-server/ship/Modules/ModuleDB.h b/include/eve-server/ship/Modules/ModuleDB.h index 5d8d26da..76a906f6 100644 --- a/include/eve-server/ship/Modules/ModuleDB.h +++ b/include/eve-server/ship/Modules/ModuleDB.h @@ -36,6 +36,7 @@ class ModuleDB : public ServiceDB static void GetDgmEffects(uint32 effectID, DBQueryResult &res); static void GetDgmEffectsInfo(uint32 effectID, DBQueryResult &res); + static void GetDgmEffectsActions(uint32 effectID, DBQueryResult &res); static void GetDgmTypeEffectsInformation(uint32 typeID, DBQueryResult &res); }; diff --git a/include/eve-server/ship/Modules/ModuleDefs.h b/include/eve-server/ship/Modules/ModuleDefs.h index 73159f3a..25a0e13c 100644 --- a/include/eve-server/ship/Modules/ModuleDefs.h +++ b/include/eve-server/ship/Modules/ModuleDefs.h @@ -84,11 +84,21 @@ enum ModuleEffectTargets // *** use these values to decode the 'effectApplicationType' field of the 'dgmEffectsInfo' database table enum ModuleApplicationTypes { + EFFECT_ONLINE_MAINTAIN, // applied by PASSIVE or ACTIVE modules where an effect is maintained; means the effect takes effect on the + // target (see below) upon entering the ONLINE state, then reversed when going out of ONLINE state EFFECT_ACTIVE_MAINTAIN, // applied by ACTIVE modules where an effect is maintained; means the effect takes effect on the // target (see below) upon entering the ACTIVATE state, then reversed when going out of ACTIVATE state EFFECT_ACTIVE_CONSUME // applied by ACTIVE modules where an effect is applied cumulatively on each cycle; means the effect takes }; // effect on the target (see below) one extra time when in ACTIVATE state after each CYCLE duration expires +// These are the methods by which module effects are applied to the designated target: +// *** use these values to decode the 'stackingPenaltyApplied' field of the 'dgmEffectsInfo' database table +enum ModuleStackingPenaltyState +{ + NO_PENALTY, + PENALTY +}; + //this may or may not be redundant...idk enum ModulePowerLevel { @@ -100,15 +110,19 @@ enum ModulePowerLevel }; //calculation types +// *** use these values to decode the 'calculationTypeID' and the 'reverseCalculationTypeID' fields of the 'dgmEffectsInfo' database table enum EVECalculationType { + NONE, AUTO, ADD, SUBTRACT, DIVIDE, MULTIPLY, ADD_PERCENT, + REV_ADD_PERCENT, SUBTRACT_PERCENT, + REV_SUBTRACT_PERCENT, ADD_AS_PERCENT, SUBTRACT_AS_PERCENT //more will show up, im sure @@ -141,10 +155,10 @@ static EvilNumber AddPercent(EvilNumber &val1, EvilNumber &val2) return val1 + ( val1 * val2 ); } -static EvilNumber AddAsPercent(EvilNumber &val1, EvilNumber &val2) +static EvilNumber ReverseAddPercent(EvilNumber &val1, EvilNumber &val2) { - EvilNumber val3 = 100; - return val1 + ( val1 * (val2 / val3) ); + EvilNumber val3 = 1; + return val1 / (val3 + val2); } static EvilNumber SubtractPercent(EvilNumber &val1, EvilNumber &val2) @@ -152,6 +166,18 @@ static EvilNumber SubtractPercent(EvilNumber &val1, EvilNumber &val2) return val1 - ( val1 * val2 ); } +static EvilNumber ReverseSubtractPercent(EvilNumber &val1, EvilNumber &val2) +{ + EvilNumber val3 = 1; + return val1 / ( val3 - val2 ); +} + +static EvilNumber AddAsPercent(EvilNumber &val1, EvilNumber &val2) +{ + EvilNumber val3 = 100; + return val1 + ( val1 * (val2 / val3) ); +} + static EvilNumber SubtractAsPercent(EvilNumber &val1, EvilNumber &val2) { EvilNumber val3 = 1; @@ -164,14 +190,18 @@ static EvilNumber CalculateNewAttributeValue(EvilNumber attrVal, EvilNumber attr { switch(type) { - case ADD : return Add(attrVal, attrMod); - case SUBTRACT : return Subtract(attrVal, attrMod); - case DIVIDE : return Divide(attrVal, attrMod); - case MULTIPLY : return Multiply(attrVal, attrMod); - case ADD_PERCENT : return AddPercent(attrVal, attrMod); - case ADD_AS_PERCENT : return AddAsPercent(attrVal, attrMod); - case SUBTRACT_PERCENT : return SubtractPercent(attrVal, attrMod); - case SUBTRACT_AS_PERCENT : return SubtractAsPercent(attrVal, attrMod); + case NONE : return attrVal; + case AUTO : return attrVal; // AUTO NOT SUPPORTED AT THIS TIME !!! + case ADD : return Add(attrVal, attrMod); + case SUBTRACT : return Subtract(attrVal, attrMod); + case DIVIDE : return Divide(attrVal, attrMod); + case MULTIPLY : return Multiply(attrVal, attrMod); + case ADD_PERCENT : return AddPercent(attrVal, attrMod); + case REV_ADD_PERCENT : return ReverseAddPercent(attrVal, attrMod); + case SUBTRACT_PERCENT : return SubtractPercent(attrVal, attrMod); + case REV_SUBTRACT_PERCENT : return ReverseSubtractPercent(attrVal, attrMod); + case ADD_AS_PERCENT : return AddAsPercent(attrVal, attrMod); + case SUBTRACT_AS_PERCENT : return SubtractAsPercent(attrVal, attrMod); } sLog.Error("CalculateNewAttributeValue", "Unknown EveCalculationType used"); diff --git a/include/eve-server/ship/Modules/ModuleEffects.h b/include/eve-server/ship/Modules/ModuleEffects.h index e2a9f33c..4205beed 100644 --- a/include/eve-server/ship/Modules/ModuleEffects.h +++ b/include/eve-server/ship/Modules/ModuleEffects.h @@ -64,14 +64,19 @@ class MEffect uint32 GetNpcActivationChanceAttributeID() { return (m_EffectID == 0) ? 0 : m_NpcActivationChanceAttributeID; } uint32 GetFittingUsageChanceAttributeID() { return (m_EffectID == 0) ? 0 : m_FittingUsageChanceAttributeID; } - //accessors for the effects targetAttributeID, sourceAttributeID and calculation type + //accessors for the effects targetAttributeID, sourceAttributeID and calculation type: uint32 GetSizeOfAttributeList() { return (m_EffectID == 0) ? 0 : m_numOfIDs; } uint32 GetTargetAttributeID(uint32 index) { return (m_EffectID == 0) ? 0 : m_TargetAttributeIDs[index]; } uint32 GetSourceAttributeID(uint32 index) { return (m_EffectID == 0) ? 0 : m_SourceAttributeIDs[index]; } EVECalculationType GetCalculationType(uint32 index) { return (m_EffectID == 0) ? (EVECalculationType)0 : (EVECalculationType)m_CalculationTypeIDs[index];} EVECalculationType GetReverseCalculationType(uint32 index) { return (m_EffectID == 0) ? (EVECalculationType)0 : (EVECalculationType)m_ReverseCalculationTypeIDs[index];} - uint32 GetModuleStateWhenEffectApplied(uint32 index) { return (m_EffectID == 0) ? 0 : m_EffectAppliedWhenIDs[index]; } - uint32 GetTargetTypeToWhichEffectApplied(uint32 index) { return (m_EffectID == 0) ? 0 : m_EffectAppliedTargetIDs[index]; } + + uint32 GetModuleStateWhenEffectApplied(uint32 index) { return (m_EffectID == 0) ? 0 : m_EffectAppliedWhenID; } + uint32 GetTargetTypeToWhichEffectApplied(uint32 index) { return (m_EffectID == 0) ? 0 : m_EffectAppliedTargetID; } + uint32 GetEffectApplicationType(uint32 index) { return (m_EffectID == 0) ? 0 : m_EffectApplicationTypeID; } + uint32 GetStackingPenaltyApplied(uint32 index) { return (m_EffectID == 0) ? 0 : m_StackingPenaltyAppliedID; } + uint32 GetNullifyOnlineEffectEnable(uint32 index) { return (m_EffectID == 0) ? 0 : m_NullifyOnlineEffectEnable; } + uint32 GetNullifiedOnlineEffectID(uint32 index) { return (m_EffectID == 0) ? 0 : m_NullifiedOnlineEffectID; } private: void _Populate(uint32 effectID); @@ -109,9 +114,12 @@ class MEffect int * m_SourceAttributeIDs; int * m_CalculationTypeIDs; int * m_ReverseCalculationTypeIDs; - int * m_EffectAppliedWhenIDs; - int * m_EffectAppliedTargetIDs; - int * m_EffectApplicationTypeIDs; + int m_EffectAppliedWhenID; + int m_EffectAppliedTargetID; + int m_EffectApplicationTypeID; + int m_StackingPenaltyAppliedID; + int m_NullifyOnlineEffectEnable; + int m_NullifiedOnlineEffectID; }; //class contained by all modules that is populated on construction of the module diff --git a/include/eve-server/ship/Modules/ModuleFactory.h b/include/eve-server/ship/Modules/ModuleFactory.h index 847a9791..348e6438 100644 --- a/include/eve-server/ship/Modules/ModuleFactory.h +++ b/include/eve-server/ship/Modules/ModuleFactory.h @@ -55,7 +55,7 @@ static GenericModule* ModuleFactory(InventoryItemRef item, ShipRef ship) case EVEDB::invGroups::Armor_Coating: return (new PassiveModule(item, ship)); break; case EVEDB::invGroups::Armor_Repair_Projector: return NULL; // Active case EVEDB::invGroups::Armor_Plating_Energized: return (new PassiveModule(item, ship)); break; - case EVEDB::invGroups::Armor_Hardener: return NULL; // Active + case EVEDB::invGroups::Armor_Hardener: return (new ActiveModule(item, ship)); break; // Active case EVEDB::invGroups::Armor_Reinforcer: return (new PassiveModule(item, ship)); break; case EVEDB::invGroups::Remote_Hull_Repairer: return NULL; // Active case EVEDB::invGroups::Expanded_Cargohold: return (new PassiveModule(item, ship)); break; diff --git a/sql/ofic-updates/dgmEffectsInfo.sql b/sql/ofic-updates/dgmEffectsInfo.sql index 88f2a21a..343bae44 100644 --- a/sql/ofic-updates/dgmEffectsInfo.sql +++ b/sql/ofic-updates/dgmEffectsInfo.sql @@ -13,25 +13,41 @@ SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; -- Table structure for table `dgmEffectsInfo` -- +DROP TABLE IF EXISTS `dgmEffectsInfo`; CREATE TABLE IF NOT EXISTS `dgmEffectsInfo` ( `effectID` int(11) NOT NULL, `targetAttributeID` int(11) NOT NULL, `sourceAttributeID` int(11) NOT NULL, `calculationTypeID` int(11) NOT NULL, - `reverseCalculationTypeID` int(11) NOT NULL, + `reverseCalculationTypeID` int(11) NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + +-- +-- Dumping data for table `dgmEffectsInfo` +-- + + + +-- +-- Table structure for table `dgmEffectsActions` +-- + +DROP TABLE IF EXISTS `dgmEffectsActions`; +CREATE TABLE IF NOT EXISTS `dgmEffectsActions` ( + `effectID` int(11) NOT NULL, `effectAppliedInState` int(11) NOT NULL, `effectAppliedTo` int(11) NOT NULL, `effectApplicationType` int(11) NOT NULL, + `stackingPenaltyApplied` int(11) NOT NULL, + `nullifyOnlineEffect` int(11) NOT NULL, + `nullifiedOnlineEffectID` int(11) NOT NULL, PRIMARY KEY (`effectID`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- --- Dumping data for table `dgmEffectsInfo` +-- Dumping data for table `dgmEffectsActions` -- -INSERT INTO `dgmEffectsInfo` (`effectID`, `targetAttributeID`, `sourceAttributeID`, `calculationTypeID`, `reverseCalculationTypeID`, `effectApplied`, `effectAppliedTo`) VALUES -(1959, 4, 796, 1, 2, 0, 1), -(2837, 265, 1159, 1, 2, 0, 1); /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; diff --git a/src/eve-server/ship/Modules/ModuleDB.cpp b/src/eve-server/ship/Modules/ModuleDB.cpp index 9dfc3a84..77ab4229 100644 --- a/src/eve-server/ship/Modules/ModuleDB.cpp +++ b/src/eve-server/ship/Modules/ModuleDB.cpp @@ -73,9 +73,6 @@ void ModuleDB::GetDgmEffectsInfo(uint32 effectID, DBQueryResult &res) " sourceAttributeID, " " calculationTypeID, " " reverseCalculationTypeID, " - " effectAppliedInState, " - " effectAppliedTo, " - " effectApplicationType " " FROM dgmEffectsInfo " " WHERE effectID = '%u' ", effectID)) @@ -84,6 +81,24 @@ void ModuleDB::GetDgmEffectsInfo(uint32 effectID, DBQueryResult &res) } } +void ModuleDB::GetDgmEffectsActions(uint32 effectID, DBQueryResult &res) +{ + if( !sDatabase.RunQuery(res, + " SELECT " + " effectAppliedInState, " + " effectAppliedTo, " + " effectApplicationType, " + " stackingPenaltyApplied, " + " nullifyOnlineEffect, " + " nullifiedOnlineEffectID, " + " FROM dgmEffectsActions " + " WHERE effectID = '%u' ", + effectID)) + { + _log(DATABASE__ERROR, "Error in query: %s", res.error.c_str()); + } +} + void ModuleDB::GetDgmTypeEffectsInformation(uint32 typeID, DBQueryResult &res) { if( !sDatabase.RunQuery(res, diff --git a/src/eve-server/ship/Modules/ModuleEffects.cpp b/src/eve-server/ship/Modules/ModuleEffects.cpp index 6a702f4a..58d86209 100644 --- a/src/eve-server/ship/Modules/ModuleEffects.cpp +++ b/src/eve-server/ship/Modules/ModuleEffects.cpp @@ -45,9 +45,10 @@ void MEffect::_Populate(uint32 effectID) DBQueryResult *res = new DBQueryResult(); ModuleDB::GetDgmEffects(effectID, *res); + // First, get all general info on this effectID from the dgmEffects table: DBResultRow row1; if( !res->GetRow(row1) ) - sLog.Error("MEffect","Could not populate effect information for effectID: %u", effectID); + sLog.Error("MEffect","Could not populate effect information for effectID: %u from the 'dgmEffects' table", effectID); else { //get all the data from the query @@ -95,21 +96,17 @@ void MEffect::_Populate(uint32 effectID) m_FittingUsageChanceAttributeID = row1.GetInt(25); } - //next get the info from the dgmEffectsInfo table + // Next, get the info from the dgmEffectsInfo table: ModuleDB::GetDgmEffectsInfo(effectID, *res); DBResultRow row2; - //initialize the new tables + // Initialize the new tables m_TargetAttributeIDs = new int[res->GetRowCount()]; m_SourceAttributeIDs = new int[res->GetRowCount()]; m_CalculationTypeIDs = new int[res->GetRowCount()]; m_ReverseCalculationTypeIDs = new int[res->GetRowCount()]; - m_EffectAppliedWhenIDs = new int[res->GetRowCount()]; - m_EffectAppliedTargetIDs = new int[res->GetRowCount()]; - m_EffectApplicationTypeIDs = new int[res->GetRowCount()]; - //counter int count = 0; while( res->GetRow(row2) ) @@ -118,14 +115,31 @@ void MEffect::_Populate(uint32 effectID) m_SourceAttributeIDs[count] = row2.GetInt(1); m_CalculationTypeIDs[count] = row2.GetInt(2); m_ReverseCalculationTypeIDs[count] = row2.GetInt(3); - m_EffectAppliedWhenIDs[count] = row2.GetInt(4); - m_EffectAppliedTargetIDs[count] = row2.GetInt(5); - m_EffectApplicationTypeIDs[count] = row2.GetInt(6); count++; } + if( count == 0 ) + sLog.Error("MEffect","Could not populate effect information for effectID: %u from the 'dgmEffectsInfo' table as the SQL query returned ZERO rows", effectID); + m_numOfIDs = count; + // Finally, get the info for this effectID from the dgmEffectsActions table: + ModuleDB::GetDgmEffectsActions(effectID, *res); + + DBResultRow row3; + + if( !(res->GetRow(row3)) ) + sLog.Error("MEffect","Could not populate effect information for effectID: %u from 'dgmEffectsActions table", effectID); + else + { + m_EffectAppliedWhenID = row3.GetInt(0); + m_EffectAppliedTargetID = row3.GetInt(1); + m_EffectApplicationTypeID = row3.GetInt(2); + m_StackingPenaltyAppliedID = row3.GetInt(3); + m_NullifyOnlineEffectEnable = row3.GetInt(4); + m_NullifiedOnlineEffectID = row3.GetInt(5); + } + delete res; res = NULL; } diff --git a/src/eve-server/ship/Ship.cpp b/src/eve-server/ship/Ship.cpp index 465fe8be..d5ecd98f 100644 --- a/src/eve-server/ship/Ship.cpp +++ b/src/eve-server/ship/Ship.cpp @@ -141,6 +141,12 @@ ShipRef Ship::Spawn(ItemFactory &factory, // Warp Speed Multiplier if( !(sShipRef.get()->HasAttribute(AttrWarpSpeedMultiplier)) ) sShipRef.get()->SetAttribute(AttrWarpSpeedMultiplier, 1.0f); + // CPU Load of the ship (new ships have zero load with no modules fitted, of course): + if( !(sShipRef.get()->HasAttribute(AttrCpuLoad)) ) + sShipRef.get()->SetAttribute(AttrCpuLoad, 0); + // Power Load of the ship (new ships have zero load with no modules fitted, of course): + if( !(sShipRef.get()->HasAttribute(AttrPowerLoad)) ) + sShipRef.get()->SetAttribute(AttrPowerLoad, 0); return sShipRef; }