//------------------------------------------------------------------------ void CItem::SetDualSlaveAccessory(bool noNetwork) { if(!gEnv->bMultiplayer || (GetOwnerActor() && GetOwnerActor()->IsClient())) { CItem *pSlave = static_cast<CItem *>(GetDualWieldSlave()); if (!pSlave) return; //Detach current accessories of the slave TAccessoryMap temp = pSlave->m_accessories; for (TAccessoryMap::const_iterator it=temp.begin(); it!=temp.end(); ++it) { if(m_accessories.find(it->first)==m_accessories.end()) pSlave->SwitchAccessory(it->first.c_str()); //Only remove if not in the master } //Attach on the slave same accessories as "parent" for (TAccessoryMap::const_iterator it=m_accessories.begin(); it!=m_accessories.end(); ++it) { if(pSlave->m_accessories.find(it->first)==pSlave->m_accessories.end()) { if(noNetwork) pSlave->AttachAccessory(it->first.c_str(), true, true, true); else pSlave->SwitchAccessory(it->first.c_str()); //Only add if not already attached } } } }
void CItem::AttachAccessory(const ItemString &name, bool attach, bool noanim, bool force, bool initialSetup) { if(!force && IsBusy()) return; bool anim = !noanim && m_stats.fp; SAccessoryParams *params = GetAccessoryParams(name); if(!params) return; if(attach) { if(!IsAccessoryHelperFree(params->attach_helper)) return; if(CItem *pAccessory = AddAccessory(name)) { pAccessory->Physicalize(false, false); pAccessory->SetViewMode(m_stats.viewmode); if(!initialSetup) pAccessory->m_bonusAccessoryAmmo.clear(); SetCharacterAttachment(eIGS_FirstPerson, params->attach_helper, pAccessory->GetEntity(), eIGS_FirstPerson, 0); SetBusy(true); AttachAction action(pAccessory, params); if(anim) { PlayAction(params->attach_action, 0, false, eIPAF_Default|eIPAF_NoBlend); m_scheduler.TimerAction(GetCurrentAnimationTime(eIGS_FirstPerson), CSchedulerAction<AttachAction>::Create(action), false); } else action.execute(this); } } else { if(CItem *pAccessory = GetAccessory(name)) { DetachAction action(pAccessory, params); if(anim) { StopLayer(params->attach_layer, eIPAF_Default|eIPAF_NoBlend); PlayAction(params->detach_action, 0, false, eIPAF_Default|eIPAF_NoBlend); m_scheduler.TimerAction(GetCurrentAnimationTime(eIGS_FirstPerson), CSchedulerAction<DetachAction>::Create(action), false); SetBusy(true); } else { SetBusy(true); action.execute(this); } } } //Skip all this for the offhand if(GetEntity()->GetClass()!=CItem::sOffHandClass) FixAccessories(params, attach); //Attach silencer to 2nd SOCOM ///////////////////////////////////////////////////////////// bool isDualWield = IsDualWieldMaster(); CItem *dualWield = 0; if(isDualWield) { IItem *slave = GetDualWieldSlave(); if(slave && slave->GetIWeapon()) dualWield = static_cast<CItem *>(slave); else isDualWield = false; } if(isDualWield) dualWield->AttachAccessory(name,attach,noanim); ////////////////////////////////////////////////////////////// //Luciano - send game event g_pGame->GetIGameFramework()->GetIGameplayRecorder()->Event(GetOwner(), GameplayEvent(eGE_AttachedAccessory, name, (float)attach, (void *)GetEntityId())); }