//-------------------------------------------------------------- // CCombatDefenderPlayer::getArmor //-------------------------------------------------------------- bool CCombatDefenderPlayer::getArmor( SLOT_EQUIPMENT::TSlotEquipment slot, CCombatArmor &armor ) const { CCharacter *character = PlayerManager.getChar(_RowId); if ( !character) { return false; } CGameItemPtr armorPtr = character->getItem(INVENTORIES::equipment, slot); if (armorPtr == NULL || armorPtr->getStaticForm() == NULL || armorPtr->getStaticForm()->Family != ITEMFAMILY::ARMOR) return false; armor.Quality = armorPtr->quality(); armor.Skill = armorPtr->getStaticForm()->Skill; if( armor.Skill < 0 ) { nlwarning("<CCombatDefenderPlayer::getArmor> armor.Skill negative !!!!"); armor.SkillValue = 0; } else if ( armor.Skill < SKILLS::NUM_SKILLS ) { armor.SkillValue = character->getSkills()._Skills[ armor.Skill ].Current; } else armor.SkillValue = 0; armor.MaxBluntProtection = armorPtr->getProtection(DMGTYPE::BLUNT).Max; armor.MaxPiercingProtection = armorPtr->getProtection(DMGTYPE::PIERCING).Max; armor.MaxSlashingProtection = armorPtr->getProtection(DMGTYPE::SLASHING).Max; armor.BluntProtectionFactor = armorPtr->getProtection(DMGTYPE::BLUNT).Factor; armor.PiercingProtectionFactor = armorPtr->getProtection(DMGTYPE::PIERCING).Factor; armor.SlashingProtectionFactor = armorPtr->getProtection(DMGTYPE::BLUNT).Factor; armor.ArmorType = armorPtr->getStaticForm()->Armor->ArmorType; return true; } // CCombatDefenderPlayer::getArmor //
//---------------------------------------------------------------------------- bool CPVPFaction::isTPValid( CCharacter* actor, CGameItemPtr TeleportTicket ) const { bool result = ! actor->getPvPRecentActionFlag(); if( TeleportTicket != 0 && TeleportTicket->getStaticForm() != 0 && result ) { // if character have is not PvP faction flagged (Tag PvP off), only recent PvP action can forbid TP usage if( actor->getPVPFlag() == false ) return true; // check if war occurs between player character allegiances and region destination clan owner uint16 idx = CZoneManager::getInstance().getTpSpawnZoneIdByName( TeleportTicket->getStaticForm()->Destination ); const CTpSpawnZone * zone = CZoneManager::getInstance().getTpSpawnZone( idx ); if( zone != 0 ) { PVP_CLAN::TPVPClan regionFactionOwner = CPVPFactionRewardManager::getInstance().getRegionOwner( zone->getRegion() ); pair<PVP_CLAN::TPVPClan, PVP_CLAN::TPVPClan> actorAllegiance = actor->getAllegiance(); if( regionFactionOwner == PVP_CLAN::Neutral ) return true; else { if( CPVPManager2::getInstance()->factionWarOccurs(actorAllegiance.first, regionFactionOwner) == false && CPVPManager2::getInstance()->factionWarOccurs(actorAllegiance.second, regionFactionOwner) == false ) return true; } } } return false; }
//-------------------------------------------------------------- // CCombatDefenderPlayer::getShield //-------------------------------------------------------------- bool CCombatDefenderPlayer::getShield(CCombatShield &shield) const { CCharacter *character = PlayerManager.getChar(_RowId); if ( !character) { return false; } CGameItemPtr shieldPtr = character->getLeftHandItem(); if (shieldPtr == NULL || shieldPtr->getStaticForm() == NULL || shieldPtr->getStaticForm()->Family != ITEMFAMILY::SHIELD ) return false; shield.Quality = shieldPtr->quality(); shield.Skill = shieldPtr->getStaticForm()->Skill; if ( shield.Skill < SKILLS::NUM_SKILLS ) { shield.SkillValue = character->getSkills()._Skills[ shield.Skill ].Current; } else shield.SkillValue = 0; shield.MaxBluntProtection = shieldPtr->getProtection(DMGTYPE::BLUNT).Max; shield.MaxPiercingProtection = shieldPtr->getProtection(DMGTYPE::PIERCING).Max; shield.MaxSlashingProtection = shieldPtr->getProtection(DMGTYPE::SLASHING).Max; shield.BluntProtectionFactor = shieldPtr->getProtection(DMGTYPE::BLUNT).Factor; shield.PiercingProtectionFactor = shieldPtr->getProtection(DMGTYPE::PIERCING).Factor; shield.SlashingProtectionFactor = shieldPtr->getProtection(DMGTYPE::BLUNT).Factor; shield.ShieldType = shieldPtr->getStaticForm()->Shield->ShieldType; shield.ArmorType = shieldPtr->getStaticForm()->Shield->ArmorType; return true; } // CCombatDefenderPlayer::getShield //
bool CInterShardExchangeValidator::isExchangeAllowed(const CGameItemPtr& theItem, TShardId shardId0, TShardId shardId1) const { // allow all exchanges between characters from the same shard if (shardId0==shardId1) return true; // allow all exchanges of plot items if ( theItem->getStaticForm()->Family == ITEMFAMILY::SCROLL_R2 ) return true; // determine the maximum level for items exchanged between the 2 shards TLevelCap levelLimit= std::min(getLevelCap(shardId0),getLevelCap(shardId1)); // if item is too high level then refuse if (theItem->quality()>levelLimit) return false; // if item is flagged as non-shardExchangeable then refuse if (theItem->getStaticForm()->ShardExchangeable==false) return false; // if item is named (and not a plot item) then refuse if (!theItem->getPhraseId().empty()) return false; // we've found no reason to refuse so return true return true; }
// **************************************************************************** void CInventoryBase::updateWeightAndBulk(const CGameItemPtr &item, sint32 deltaQt) { const CStaticItem *form = item->getStaticForm(); if (form != NULL) { _InventoryBulk = uint32(max(sint32(0), sint32(_InventoryBulk + form->Bulk*deltaQt))); _InventoryWeight = uint32(max(sint32(0), sint32(_InventoryWeight + item->weight()*deltaQt))); if (_InventoryWeight > getMaxWeight()) { nlwarning("Inventory '%s' : weight is overload", INVENTORIES::toString(_InventoryId).c_str()); } if (_InventoryBulk > getMaxBulk()) { nlwarning("Inventory '%s' : bulk is overload", INVENTORIES::toString(_InventoryId).c_str()); } } }
/* * Report the accumulated XP to a participant */ void CForageProgress::reportXPTo( CCharacter *player, float factor, CGameItemPtr toolUsed ) { H_AUTO(CForageProgress_reportXPTo); // Calculate delta level between obtained quality (level) and extractor's level, add bonus for quantity sint32 deltaLevel = player->getSkillBaseValue( _UsedSkill ) - ((sint32)quality()); deltaLevel -= (sint32)(((float)(amount() - 1)) * ForageQuantityXPDeltaLevelBonusRate.get()); // Action report for xp gain TReportAction report; report.ActorRowId = player->getEntityRowId(); report.ActionNature = ACTNATURE::SEARCH_MP; report.DeltaLvl = deltaLevel; report.factor = factor; // factor=10 and deltaLevel=0 => clientXP=1000 report.Skill = _UsedSkill; // send a message if tol is worned if ( (toolUsed != NULL) && (toolUsed->getItemWornState() == ITEM_WORN_STATE::Worned) ) { const CStaticItem * form = toolUsed->getStaticForm(); if( form ) { const string msgName = ITEM_WORN_STATE::getMessageForState(ITEM_WORN_STATE::Worned); if ( !msgName.empty()) { SM_STATIC_PARAMS_1(params, STRING_MANAGER::item); params[0].SheetId = toolUsed->getSheetId(); PHRASE_UTILITIES::sendDynamicSystemMessage( report.ActorRowId, msgName, params); } } } else { // compute wear of used tool (must be in right hand) if ( toolUsed != NULL ) player->wearRightHandItem(); // report Xp Gain unless used tool is worned PROGRESSIONPVE::CCharacterProgressionPVE::getInstance()->actionReport( report, true, false ); // don't scale delta level at low level PROGRESSIONPVP::CCharacterProgressionPVP::getInstance()->reportAction(report); } // wear armor, shield and jewels player->wearArmor(); player->wearShield(); player->wearJewels(); // Store stats about progression CSheetId hl, hr; uint32 qualityl, qualityr; CGameItemPtr item = player->getLeftHandItem(); if( item == 0 ) { qualityl = 0; } else { hl = item->getSheetId(); qualityl = item->quality(); } item = player->getRightHandItem(); if( item == 0 ) { qualityr = 0; } else { hr = item->getSheetId(); qualityr = item->quality(); } //Bsi.append( StatPath, NLMISC::toString("[EAE] %s %s %d %s %d %1.2f", player->getId().toString().c_str(), hl.toString().c_str(), qualityl, hr.toString().c_str(), qualityr, report.factor) ); //EgsStat.displayNL("[EAE] %s %s %d %s %d %1.2f", player->getId().toString().c_str(), hl.toString().c_str(), qualityl, hr.toString().c_str(), qualityr, report.factor); // EGSPD::executeActionMagic(player->getId(), hl.toString(), qualityl, hr.toString(), qualityr, report.factor); }
//-------------------------------------------------------------- // apply() //-------------------------------------------------------------- void CSpecialPowerEnchantWeapon::apply() { if (!_Phrase) return; CCharacter* actor = PlayerManager.getChar(_ActorRowId); if (!actor) { nlwarning("<CSpecialPowerEnchantWeapon::apply> Cannot find actor entity or not a player"); return; } CInventoryPtr inv = actor->getInventory(INVENTORIES::handling); nlassert(inv != NULL); // Test some cases that should be avoided on client (so don't bother adding an error message) // If we have no equipped item if (inv->getSlotCount()<=0) return; // If equipped item is invalid CGameItemPtr item = inv->getItem(0); if (item == NULL) return; // If item sheet is unknown CSheetId itemSheet = item->getSheetId(); if (itemSheet==CSheetId::Unknown) return; // If item sheet is invalid const CStaticItem * form = item->getStaticForm(); if (!form) return; // If item is not a melee weapon ITEMFAMILY::EItemFamily family = form->Family; if (family!=ITEMFAMILY::MELEE_WEAPON) return; // Here equipped item is valid. Enchant removal will be done on unequip. // disable power actor->forbidPower(_PowerType, _Phrase->getConsumableFamilyId(), CTickEventHandler::getGameCycle() + _DisablePowerTime + _Duration); // create effect and apply it on actor TGameCycle const endDate = _Duration + CTickEventHandler::getGameCycle(); float damageBonus = _DpsBonus * 10.f / item->hitRate(); CEnchantWeaponEffect* effect = new CEnchantWeaponEffect(_ActorRowId, _ActorRowId, _EffectFamily, _ParamValue, endDate, _DamageType, SCORES::hit_points, damageBonus, DMGTYPE::UNDEFINED); if (effect) { effect->endsAtCasterDeath(true); effect->stackable(true); actor->addSabrinaEffect(effect); } else return; // send messages // TVectorParamCheck params; // for actor if (actor->getId().getType() == RYZOMID::player) { SM_STATIC_PARAMS_1(params, STRING_MANAGER::power_type); params[0].Enum = _PowerType; PHRASE_UTILITIES::sendDynamicSystemMessage(_ActorRowId, "POWER_USE", params); } // for spectators // { // vector<CEntityId> excluded; // excluded.push_back(actor->getId()); // // params.resize(2); // params[0].Type = STRING_MANAGER::entity; // params[0].EId = actor->getId(); // params[1].Type = STRING_MANAGER::power_type; // params[1].Enum = _PowerType; // PHRASE_UTILITIES::sendDynamicGroupSystemMessage(_ActorRowId, excluded, "POWER_USE_SPECTATORS", params); // } }
//----------------------------------------------- // CFaberPhrase validate //----------------------------------------------- bool CFaberPhrase::validate() { H_AUTO(CFaberPhrase_validate); if ( !CraftSystemEnabled ) return false; CCharacter * c = (CCharacter *) CEntityBaseManager::getEntityBasePtr( _ActorRowId ); if( c == 0 ) { nlwarning("<CFaberPhrase::validate> Player character not found but his crafting action still running!!!"); return false; } // test entity can use action if (c->canEntityUseAction() == false) { return false; } // check right hand item is a crafting tool CGameItemPtr rightHandItem = c->getRightHandItem(); if (rightHandItem == NULL || rightHandItem->getStaticForm() == NULL || rightHandItem->getStaticForm()->Family != ITEMFAMILY::CRAFTING_TOOL) { PHRASE_UTILITIES::sendDynamicSystemMessage(_ActorRowId, "CRAFT_NEED_CRAFTING_TOOL"); return false; } // check tool is not worned if( rightHandItem->getItemWornState() == ITEM_WORN_STATE::Worned ) { PHRASE_UTILITIES::sendDynamicSystemMessage(_ActorRowId, "CRAFT_NEED_CRAFTING_TOOL"); return false; } // check quality of right hand item (need be >= Recommended (level of item)) if (rightHandItem->recommended()+49 < _Recommended) { PHRASE_UTILITIES::sendDynamicSystemMessage(_ActorRowId, "CRAFT_NEED_RECOMMENDED_CRAFTING_TOOL"); return false; } // entities cant craft if in combat /* commented as test of right hand item is now made... TDataSetRow entityRowId = CPhraseManager::getInstance().getEntityEngagedMeleeBy( _ActorRowId ); if (TheDataset.isAccessible(entityRowId)) { PHRASE_UTILITIES::sendDynamicSystemMessage(_ActorRowId, "CANT_CRAFT_ENGAGED_IN_MELEE"); return false; } */ const sint32 focus = c->getScores()._PhysicalScores[ SCORES::focus ].Current; if ( focus < _FocusCost ) { PHRASE_UTILITIES::sendDynamicSystemMessage(_ActorRowId, "CANT_CRAFT_NOT_ENOUGHT_FOCUS"); c->unlockFaberRms(); return false; } const sint32 hp = c->currentHp(); if (hp <= 0 || c->isDead()) { PHRASE_UTILITIES::sendDynamicSystemMessage(_ActorRowId, "CANT_CRAFT_WHEN_DEAD"); c->unlockFaberRms(); return false; } /// todo alain : test if on mount // store vector of pointer on raw material item if( state() == Evaluated ) { if( c->lockFaberRms() ) { _Mps.clear(); _MpsFormula.clear(); if( c->getFillFaberRms( _Mps, _MpsFormula, _LowerRmQuality ) == false ) //TODO check exec step { c->unlockFaberRms(); PHRASE_UTILITIES::sendDynamicSystemMessage(_ActorRowId, "CANT_FOUND_RM"); return false; } } else { c->unlockFaberRms(); PHRASE_UTILITIES::sendDynamicSystemMessage(_ActorRowId, "CANT_LOCK_RM"); return false; } } return true; }// CFaberPhrase validate
//----------------------------------------------- // CTimedActionPhrase build //----------------------------------------------- bool CTimedActionPhrase::build( const TDataSetRow & actorRowId, const std::vector< const CStaticBrick* >& bricks, bool buildToExecute ) { _ActorRowId = actorRowId; for (uint i = 0 ; i < bricks.size() ; ++i) { const CStaticBrick *brick = bricks[i]; nlassert(brick != NULL); if (i==0) _RootSheetId = brick->SheetId; // process params for ( uint j = 0 ; j < brick->Params.size() ; ++j) { TBrickParam::IId *param = brick->Params[j]; if (!param) continue; switch(param->id()) { case TBrickParam::TA_TELEPORT: { _TimedAction = new CTPTimedAction(); if (_TimedAction == NULL) { nlwarning("Error allocating new CTPTimedAction object"); return false; } _ExecutionDuration = DelayBeforeItemTP; _ActionType = CLIENT_ACTION_TYPE::Teleport; } break; case TBrickParam::TA_DISCONNECT: { _TimedAction = new CDisconnectTimedAction(); if (_TimedAction == NULL) { nlwarning("Error allocating new CTPTimedAction object"); return false; } _ExecutionDuration = TimeBeforeDisconnection; if (IsRingShard) { // Find out how much time to wait depending on the role of the character CCharacter* player = PlayerManager.getChar(_ActorRowId); if (player) { // In Ring edition and animation mode, take a short cut when Far Teleporting R2::TUserRole role = player->sessionUserRole(); if ((role == R2::TUserRole::ur_editor) || (role == R2::TUserRole::ur_animator)) _ExecutionDuration = 1; } } _ActionType = CLIENT_ACTION_TYPE::Disconnect; } break; case TBrickParam::TA_MOUNT: { _TimedAction = new CMountTimedAction(); if (_TimedAction == NULL) { nlwarning("Error allocating new CTPTimedAction object"); return false; } _ExecutionDuration = MountDuration; _ActionType = CLIENT_ACTION_TYPE::Mount; } break; case TBrickParam::TA_UNMOUNT: { _TimedAction = new CUnmountTimedAction(); if (_TimedAction == NULL) { nlwarning("Error allocating new CTPTimedAction object"); return false; } _ExecutionDuration = UnmountDuration; _ActionType = CLIENT_ACTION_TYPE::Unmount; } break; case TBrickParam::TA_CONSUME: { _TimedAction = new CConsumeItemTimedAction(); if (_TimedAction == NULL) { nlwarning("Error allocating new CConsumeItemTimedAction object"); return false; } // get item to consume to init consumption time CCharacter *player = PlayerManager.getChar(actorRowId); if (player) { CGameItemPtr item =player->getConsumedItem(); if (item != NULL) { const CStaticItem *form = item->getStaticForm(); if (form && form->ConsumableItem) { _ExecutionDuration = TGameCycle(form->ConsumableItem->ConsumptionTime / CTickEventHandler::getGameTimeStep()); } } } _ActionType = CLIENT_ACTION_TYPE::ConsumeItem; } break; default: ; }; } } return true; }// CTimedActionPhrase build