void CASW_Game_Resource::RememberLeaderID() { if (GetLeader()) { SetLastLeaderNetworkID(GetLeader()->GetASWNetworkID()); } }
bool CParty::SetRole(DWORD dwPID, BYTE bRole, bool bSet) { TMemberMap::iterator it = m_memberMap.find(dwPID); if (it == m_memberMap.end()) { return false; } LPCHARACTER ch = it->second.pCharacter; if (bSet) { if (m_anRoleCount[bRole] >= m_anMaxRole[bRole]) return false; if (it->second.bRole != PARTY_ROLE_NORMAL) return false; it->second.bRole = bRole; if (ch && GetLeader()) ComputeRolePoint(ch, bRole, true); if (bRole < PARTY_ROLE_MAX_NUM) { ++m_anRoleCount[bRole]; } else { sys_err("ROLE_COUNT_INC_ERROR: INDEX(%d) > MAX(%d)", bRole, PARTY_ROLE_MAX_NUM); } } else { if (it->second.bRole == PARTY_ROLE_LEADER) return false; if (it->second.bRole == PARTY_ROLE_NORMAL) return false; it->second.bRole = PARTY_ROLE_NORMAL; if (ch && GetLeader()) ComputeRolePoint(ch, PARTY_ROLE_NORMAL, false); if (bRole < PARTY_ROLE_MAX_NUM) { --m_anRoleCount[bRole]; } else { sys_err("ROLE_COUNT_DEC_ERROR: INDEX(%d) > MAX(%d)", bRole, PARTY_ROLE_MAX_NUM); } } SendPartyInfoOneToAll(dwPID); return true; }
/* * Packet Functions Start */ void Raid::SendRaidCreate(Client *to){ if(!to) return; EQApplicationPacket* outapp = new EQApplicationPacket(OP_RaidJoin,sizeof(RaidCreate_Struct)); RaidCreate_Struct *rc = (RaidCreate_Struct*)outapp->pBuffer; rc->action = raidCreate; strn0cpy(rc->leader_name, leadername, 64); rc->leader_id = (GetLeader()?GetLeader()->GetID():0); to->QueuePacket(outapp); safe_delete(outapp); }
//Get a bounding box. This is used for when we display the formation continously. void FormationBhvr::GetWorldBoundBox(TimeValue t, ViewExp *vpt, Box3& box) { if ( ! vpt || ! vpt->IsAlive() ) { box.Init(); return; } //make sure we have everything we need... if(DisplayFormation(t)==FALSE) return; if(GetFollowerCount(t)<=0) return; if(GetFollowerMatrixCount(t)<=0) return; //possible to not have this set when the follower is set.. INode *leaderNode; leaderNode = GetLeader(t); if(leaderNode==NULL) return; //for each follower we need to increase the bounding box by it's //world position location... for(int i =0;i<GetFollowerCount(t);i++) { if(GetFollower(t,i)) //if we have a a node... { Matrix3 worldSpace = GetFollowerMatrix(t,i)*GetCurrentMatrix(leaderNode,t); Point3 trans(worldSpace.GetTrans()); //expand the box by the worldposition... box += trans; } } }
//called every frame. Here we set up the target paramters so that they //can be used by each node passed into the perform function. void FormationBhvr::InitAtThisTime(TimeValue t) { INode *leaderNode = GetLeader(t); if(leaderNode) { if(prevPosTime==TIME_NegInfinity||prevPosTime != t - GetTicksPerFrame()) { //get the right leaderPrevPos. leaderPrevPos = GetCurrentMatrix(leaderNode,t-GetTicksPerFrame()).GetTrans(); } leaderPos = GetCurrentMatrix(leaderNode,t).GetTrans(); leaderVel = leaderPos - leaderPrevPos;//use the preivous position to get the velocity. leaderSpeed = leaderVel.FLength(); //normalize the velocity. if(leaderSpeed!=0.0f) leaderVel /= leaderSpeed; else { leaderVel.x = leaderVel.y = leaderVel.z = 0.0f; } //set up the previous for the next time. leaderPrevPos = leaderPos; prevPosTime = t; } }
//The display function that is used to display the formation. int FormationBhvr::Display(TimeValue t, ViewExp *vpt) { // setup int i,j; if(DisplayFormation(t)==FALSE) return FALSE; if(GetFollowerCount(t)<=0) return FALSE; if(GetFollowerMatrixCount(t)<=0) return FALSE; INode *leaderNode; leaderNode = GetLeader(t); if(leaderNode==NULL) return FALSE; //check tgo see if we have created a default sphere for drawing yet... //if we haven't then create it.. if (numpts == 0) GetSpherePoints(Point3(0.0f,0.0f,0.0f), 1.0, SpherePts); GraphicsWindow *gw = vpt->getGW(); //set the identity matrix... Matrix3 idMat; idMat.IdentityMatrix(); gw->setTransform(idMat); gw->setColor(LINE_COLOR,.815f,.976f,1.0f); float scaleRadius = GetDisplayScale(t); //set the drawing radius values based upon what the radius size is. for (i=0; i<NUMAROUND * 3; i++) ScaledPts[i] = ((SpherePts[i] * scaleRadius)); //for each follower we need to increase the bounding box by it's //world position location... for(i =0;i<GetFollowerCount(t);i++) { INode *followerNode = GetFollower(t,i); if(followerNode) //if we have a a node... { Matrix3 leaderMat = GetCurrentMatrix(leaderNode,t); leaderMat.NoScale(); Matrix3 followerMat = GetFollowerMatrix(t,i); Matrix3 worldSpace = followerMat *leaderMat; for (j=0; j<NUMAROUND * 3; j++) CurPts[j] = worldSpace*ScaledPts[j]; //adding the center to the point positions gw->polyline(NUMAROUND,&CurPts[0],NULL,NULL,TRUE,NULL); gw->polyline(NUMAROUND,&CurPts[NUMAROUND],NULL,NULL,TRUE,NULL); gw->polyline(NUMAROUND,&CurPts[NUMAROUND * 2],NULL,NULL,TRUE,NULL); } } return TRUE; }
void Group::ChangeLeader(Mob* newleader) { // this changes the current group leader, notifies other members, and updates leadship AA // if the new leader is invalid, do nothing if (!newleader) return; Mob* oldleader = GetLeader(); EQApplicationPacket* outapp = new EQApplicationPacket(OP_GroupUpdate,sizeof(GroupJoin_Struct)); GroupJoin_Struct* gu = (GroupJoin_Struct*) outapp->pBuffer; gu->action = groupActMakeLeader; strcpy(gu->membername, newleader->GetName()); strcpy(gu->yourname, oldleader->GetName()); SetLeader(newleader); database.SetGroupLeaderName(GetID(), newleader->GetName()); for (uint32 i = 0; i < MAX_GROUP_MEMBERS; i++) { if (members[i] && members[i]->IsClient()) { members[i]->CastToClient()->QueuePacket(outapp); } } safe_delete(outapp); }
//----------------------------------------------------------------------------- // Purpose: Try to get one of a contiguous range of slots // Input : slotIDStart - start of slot range // slotIDEnd - end of slot range // hEnemy - enemy this slot is for // Output : Returns true on success, false on failure. //----------------------------------------------------------------------------- bool CAI_Squad::OccupyStrategySlotRange( CBaseEntity *pEnemy, int slotIDStart, int slotIDEnd, int *pSlot ) { #ifndef PER_ENEMY_SQUADSLOTS // FIXME: combat slots need to be per enemy, not per squad. // As it is, once a squad is occupied it stops making even simple attacks to other things nearby. // This code may make soldiers too aggressive if (GetLeader() && pEnemy != GetLeader()->GetEnemy()) { *pSlot = SQUAD_SLOT_NONE; return true; } #endif // If I'm already occupying this slot if ( *pSlot >= slotIDStart && *pSlot <= slotIDEnd) return true; for ( int i = slotIDStart; i <= slotIDEnd; i++ ) { // Check enemy to see if slot already occupied if (!IsSlotOccupied(pEnemy, i)) { // Clear any previous spot; if (*pSlot != SQUAD_SLOT_NONE) { // As a debug measure check to see if slot was filled if (!IsSlotOccupied(pEnemy, *pSlot)) { DevMsg( "ERROR! Vacating an empty slot!\n"); } // Free the slot VacateSlot(pEnemy, *pSlot); } // Fill the slot OccupySlot(pEnemy, i); *pSlot = i; return true; } } return false; }
//This will set the formation void FormationBhvr::SetFormation(TimeValue t) { INode *node; Matrix3 tempMatrix; //Make sure that the leader is not part of the follower array.. RemoveLeaderFromFormation(t); INode *leader = GetLeader(t); if(leader==NULL) return; Matrix3 leaderPosition = GetCurrentMatrix(leader,t); leaderPosition.NoScale(); //kill any scale if we have it leaderPosition.Invert(); //it's inverted... int numDelegates = GetFollowerCount(t); //zero out the formation matrix that's used for saving it out. pblock->ZeroCount(follower_matrix1); pblock->ZeroCount(follower_matrix2); pblock->ZeroCount(follower_matrix3); pblock->ZeroCount(follower_matrix4); for(int i =0;i<numDelegates;i++) { node = GetFollower(t,i); if(node) { tempMatrix = GetCurrentMatrix(node,t); tempMatrix.NoScale(); Matrix3 leaderMat =tempMatrix*leaderPosition; AppendFollowerMatrix(t,leaderMat); //killed because matrix3 wasn't working ...pblock->Append(follower_matrix,1,&leaderMat); } else { //we still set up follower_matrix so that the counts //of the follower_matrix tab and the follower tab are equal. tempMatrix.IdentityMatrix(); AppendFollowerMatrix(t,tempMatrix); //pblock->Append(follower_matrix,1,&tempMat); } } }
void Group::SendLootUpdates( Object *o ){ // Build the actual update. ByteBuffer buf( 500 ); uint32 Flags = o->GetUInt32Value( UNIT_DYNAMIC_FLAGS ); Flags |= U_DYN_FLAG_LOOTABLE; Flags |= U_DYN_FLAG_TAPPED_BY_PLAYER; o->BuildFieldUpdatePacket( &buf, UNIT_DYNAMIC_FLAGS, Flags ); Lock(); switch( m_LootMethod ){ case PARTY_LOOT_RR: case PARTY_LOOT_FFA: case PARTY_LOOT_GROUP: case PARTY_LOOT_NBG:{ SubGroup *sGrp = NULL; GroupMembersSet::iterator itr2; for( uint32 Index = 0; Index < GetSubGroupCount(); ++Index ){ sGrp = GetSubGroup( Index ); itr2 = sGrp->GetGroupMembersBegin(); for( ; itr2 != sGrp->GetGroupMembersEnd(); ++itr2 ){ PlayerInfo *p = *itr2; if( p->m_loggedInPlayer != NULL && p->m_loggedInPlayer->IsVisible( o->GetGUID() ) ) // Save updates for non-existent creatures p->m_loggedInPlayer->PushUpdateData( &buf, 1 ); } } break;} case PARTY_LOOT_MASTER:{ Player * pLooter = GetLooter() ? GetLooter()->m_loggedInPlayer : NULL; if( pLooter == NULL ) pLooter = GetLeader()->m_loggedInPlayer; if( pLooter->IsVisible( o->GetGUID() ) ){ Unit *victim = static_cast< Unit* >( o ); victim->Tag( pLooter->GetGUID() ); pLooter->PushUpdateData( &buf, 1 ); } break;} } Unlock(); }
void Raid::UpdateRaidAAs() { Client *rl = GetLeader(); if (rl) rl->GetRaidAAs(&raid_aa); else memset(&raid_aa, 0, sizeof(RaidLeadershipAA_Struct)); SaveRaidLeaderAA(); }
bool CAI_Squad::IsLeader( CAI_BaseNPC *pNPC ) { if ( IsSilentMember( pNPC ) ) return false; if ( !pNPC ) return false; if ( GetLeader() == pNPC ) return true; return false; }
void CBotSquad::UpdateAngles ( void ) { edict_t *pLeader = GetLeader(); Vector velocity; CClassInterface::getVelocity(pLeader,&velocity); if ( velocity.Length2D() > 1.0f ) { VectorAngles(velocity,m_vLeaderAngle); } }
/** * Look around at various interesting things */ void C_CHostage::LookAround( void ) { if (GetLeader() == NULL && m_lookAroundTimer.IsElapsed()) { m_lookAroundTimer.Start( RandomFloat( 3.0f, 15.0f ) ); Vector forward; QAngle angles = GetAbsAngles(); angles[ YAW ] += RandomFloat( m_headYawMin, m_headYawMax ); angles[ PITCH ] += RandomFloat( m_headPitchMin, m_headPitchMax ); AngleVectors( angles, &forward ); m_lookAt = EyePosition() + 100.0f * forward; } }
//actions //make sure the leader isn't in the formation itself. void FormationBhvr::RemoveLeaderFromFormation(TimeValue t) { INode *leader = GetLeader(t); int numDelegates = GetFollowerCount(t); //we count backwards so we can simply remove it. for(int i=numDelegates-1;i>-1;--i) { if(GetFollower(t,i)==leader) { DeleteFollower(t,i); break;//only one } } }
void Group::MemberZoned(Mob* removemob) { uint32 i; if (removemob == nullptr) return; if(removemob == GetLeader()) SetLeader(nullptr); for (i = 0; i < MAX_GROUP_MEMBERS; i++) { if (members[i] == removemob) { members[i] = nullptr; //should NOT clear the name, it is used for world communication. break; } } }
void CBotSquad::Init () { edict_t *pLeader; m_theDesiredFormation = SQUAD_FORM_WEDGE; // default wedge formation m_fDesiredSpread = SQUAD_DEFAULT_SPREAD; m_CombatType = COMBAT_COMBAT; bCanFire = true; if ( (pLeader = GetLeader()) != NULL ) { IPlayerInfo *p = playerinfomanager->GetPlayerInfo(pLeader); m_vLeaderAngle = p->GetLastUserCommand().viewangles; } }
//create a group which should allready exist in the database Group::Group(uint32 gid) : GroupIDConsumer(gid) { leader = nullptr; memset(members,0,sizeof(Mob*) * MAX_GROUP_MEMBERS); uint32 i; for(i=0;i<MAX_GROUP_MEMBERS;i++) { memset(membername[i],0,64); MemberRoles[i] = 0; } if(gid != 0) { if(!LearnMembers()) SetID(0); if(GetLeader() != nullptr) { SetOldLeaderName(GetLeaderName()); } } }
void CParty::GetPoint( int nTotalLevel, int nMemberSize, int nDeadLeavel ) { #ifdef __WORLDSERVER #ifndef __PARTYDEBUG if( (nTotalLevel / nMemberSize) - nDeadLeavel < 5 ) #endif // __PARTYDEBUG { BOOL bExpResult = TRUE; BOOL bSuperLeader = FALSE; #if __VER >= 12 // __JHMA_VER12_1 //12차 극단유료아이템 BOOL bLeaderSMExpUp = FALSE; #endif // //12차 극단유료아이템 if( m_nKindTroup == 0 && m_nLevel >= MAX_PARTYLEVEL ) bExpResult = FALSE; CMover* pMover = GetLeader(); if( pMover && pMover->HasBuff( BUFF_ITEM, II_SYS_SYS_SCR_SUPERLEADERPARTY ) ) { bSuperLeader = TRUE; } #if __VER >= 12 // __JHMA_VER12_1 //12차 극단유료아이템 #define II_SYS_SYS_SCR_PARTYEXPUP01_01 20296 #define II_SYS_SYS_SCR_PARTYSKILLUP01_01 20297 if( pMover && ( pMover->HasBuff( BUFF_ITEM2, II_SYS_SYS_SCR_PARTYEXPUP01 ) || pMover->HasBuff( BUFF_ITEM2, II_SYS_SYS_SCR_PARTYEXPUP02 ) || pMover->HasBuff( BUFF_ITEM2, II_SYS_SYS_SCR_PARTYEXPUP01_01 ) ) ) { bLeaderSMExpUp = TRUE; } #endif // //12차 극단유료아이템 if( bExpResult ) #if __VER >= 12 // __JHMA_VER12_1 //12차 극단유료아이템 g_DPCoreClient.SendAddPartyExp( m_uPartyId, nDeadLeavel, bSuperLeader , bLeaderSMExpUp ); #else // //12차 극단유료아이템 g_DPCoreClient.SendAddPartyExp( m_uPartyId, nDeadLeavel, bSuperLeader ); #endif // //12차 극단유료아이템 } #endif // __WORLDSERVER }
void CParty::SetSyncTarget(CBattleEntity* PEntity, uint16 message) { if (map_config.level_sync_enable) { if (PEntity && PEntity->objtype == TYPE_PC) { CCharEntity* PChar = (CCharEntity*)PEntity; //enable level sync if (PChar->GetMLevel() < 10 ) { ((CCharEntity*)GetLeader())->pushPacket(new CMessageBasicPacket((CCharEntity*)GetLeader(), (CCharEntity*)GetLeader(), 0, 10, 541)); return; } else if (PChar->getZone() != GetLeader()->getZone()) { ((CCharEntity*)GetLeader())->pushPacket(new CMessageBasicPacket((CCharEntity*)GetLeader(), (CCharEntity*)GetLeader(), 0, 0, 542)); return; } else { for (uint32 i = 0; i < members.size(); ++i) { if(members.at(i)->StatusEffectContainer->HasStatusEffect(EFFECT_LEVEL_RESTRICTION)) { ((CCharEntity*)GetLeader())->pushPacket(new CMessageBasicPacket((CCharEntity*)GetLeader(), (CCharEntity*)GetLeader(), 0, 0, 543)); return; } } m_PSyncTarget = PChar; for (uint32 i = 0; i < members.size(); ++i) { if(members.at(i)->objtype != TYPE_PC) continue; CCharEntity* member = (CCharEntity*)members.at(i); if (member->status != STATUS_DISAPPEAR && member->getZone() == PChar->getZone() ) { member->pushPacket(new CMessageStandardPacket(PChar->GetMLevel(), 0, 0, 0, message)); member->StatusEffectContainer->AddStatusEffect(new CStatusEffect( EFFECT_LEVEL_SYNC, EFFECT_LEVEL_SYNC, PChar->GetMLevel(), 0, 0), true); member->StatusEffectContainer->DelStatusEffectsByFlag(EFFECTFLAG_DISPELABLE); member->loc.zone->PushPacket(member, CHAR_INRANGE, new CCharSyncPacket(member)); } } } } else { if (m_PSyncTarget != NULL) { //disable level sync for (uint32 i = 0; i < members.size(); ++i) { if(members.at(i)->objtype != TYPE_PC) continue; CCharEntity* member = (CCharEntity*)members.at(i); if (member->status != STATUS_DISAPPEAR && member->getZone() == m_PSyncTarget->getZone() ) { CStatusEffect* sync = member->StatusEffectContainer->GetStatusEffect(EFFECT_LEVEL_SYNC); if (sync && sync->GetDuration() == 0) { member->pushPacket(new CMessageBasicPacket(member, member, 10, 30, message)); sync->SetStartTime(gettick()); sync->SetDuration(30000); } } } } } } }
bool Group::DelMember(Mob* oldmember,bool ignoresender) { if (oldmember == nullptr){ return false; } for (uint32 i = 0; i < MAX_GROUP_MEMBERS; i++) { if (members[i] == oldmember) { members[i] = nullptr; membername[i][0] = '\0'; memset(membername[i],0,64); MemberRoles[i] = 0; break; } } //handle leader quitting group gracefully if (oldmember == GetLeader() && GroupCount() >= 2) { for(uint32 nl = 0; nl < MAX_GROUP_MEMBERS; nl++) { if(members[nl]) { ChangeLeader(members[nl]); break; } } } ServerPacket* pack = new ServerPacket(ServerOP_GroupLeave, sizeof(ServerGroupLeave_Struct)); ServerGroupLeave_Struct* gl = (ServerGroupLeave_Struct*)pack->pBuffer; gl->gid = GetID(); gl->zoneid = zone->GetZoneID(); gl->instance_id = zone->GetInstanceID(); strcpy(gl->member_name, oldmember->GetName()); worldserver.SendPacket(pack); safe_delete(pack); EQApplicationPacket* outapp = new EQApplicationPacket(OP_GroupUpdate,sizeof(GroupLeader_Struct)); GroupLeader_Struct* gu = (GroupLeader_Struct*) outapp->pBuffer; gu->action = groupActLeave; strcpy(gu->membername, oldmember->GetCleanName()); strcpy(gu->yourname, oldmember->GetCleanName()); for (uint32 i = 0; i < MAX_GROUP_MEMBERS; i++) { if (members[i] == nullptr) { //if (DEBUG>=5) LogFile->write(EQEMuLog::Debug, "Group::DelMember() null member at slot %i", i); continue; } if (members[i] != oldmember) { strcpy(gu->yourname, members[i]->GetCleanName()); if(members[i]->IsClient()) members[i]->CastToClient()->QueuePacket(outapp); } } if (!ignoresender) { strcpy(gu->yourname,oldmember->GetCleanName()); strcpy(gu->membername,oldmember->GetCleanName()); gu->action = groupActLeave; if(oldmember->IsClient()) oldmember->CastToClient()->QueuePacket(outapp); } if(oldmember->IsClient()) database.SetGroupID(oldmember->GetCleanName(), 0, oldmember->CastToClient()->CharacterID()); oldmember->SetGrouped(false); disbandcheck = true; safe_delete(outapp); return true; }
Vector CBotSquad :: GetFormationVector ( edict_t *pEdict ) { Vector vLeaderOrigin; Vector vBase; Vector v_forward; Vector v_right; QAngle angle_right; // vBase = first : offset from leader origin without taking into consideration spread and position int iPosition; trace_t *tr = CBotGlobals::getTraceResult(); edict_t *pLeader = GetLeader(); iPosition = GetFormationPosition(pEdict); vLeaderOrigin = CBotGlobals::entityOrigin(pLeader); int iMod = iPosition % 2; AngleVectors(m_vLeaderAngle,&v_forward); // leader body angles as base angle_right = m_vLeaderAngle; angle_right.y += 90.0f; CBotGlobals::fixFloatAngle(&(angle_right.y)); AngleVectors(angle_right,&v_right); // leader body angles as base // going to have members on either side. switch ( m_theDesiredFormation ) { case SQUAD_FORM_VEE: { if ( iMod ) vBase = (v_forward-v_right); else vBase = (v_forward+v_right); } break; case SQUAD_FORM_WEDGE: { if ( iMod ) vBase = -(v_forward-v_right); else vBase = -(v_forward+v_right); } break; case SQUAD_FORM_LINE: { // have members on either side of leader if ( iMod ) vBase = v_right; else vBase = -v_right; } break; case SQUAD_FORM_COLUMN: { vBase = -v_forward; } break; case SQUAD_FORM_ECH_LEFT: { vBase = -v_forward - v_right; } break; case SQUAD_FORM_ECH_RIGHT: { vBase = -v_forward + v_right; } break; } vBase = (vBase * m_fDesiredSpread) * iPosition; CBotGlobals::quickTraceline(pLeader,vLeaderOrigin,vLeaderOrigin+vBase); if ( tr->fraction < 1.0 ) { return vLeaderOrigin + (vBase*tr->fraction*0.5f); } return vLeaderOrigin+vBase; }
void Event() { switch(m_pInstance->GetEvent(m_creature->GetEntry())) { case 24: m_pInstance->DoOpenDoor(GO_IMPENETRABLE_DOOR); m_pInstance->SetNextEvent(25,GetLeader(),1000); break; case 25: m_creature->GetMotionMaster()->MovePoint(0, 5314.881f, 2012.496f, 709.341f); m_pInstance->SetNextEvent(26,m_creature->GetEntry(),3000); break; case 26: m_pInstance->DoCloseDoor(GO_IMPENETRABLE_DOOR); m_pInstance->SetNextEvent(27,m_creature->GetEntry(),7000); break; case 27: DoScriptText(SAY_LICH_KING_17, m_creature); if (Creature* pUther = (m_pInstance->GetSingleCreatureFromStorage(NPC_UTHER))) pUther->CastSpell(pUther, SPELL_UTHER_DESPAWN, false); m_pInstance->SetNextEvent(28,m_creature->GetEntry(),1500); break; case 28: if (Creature* pUther = (m_pInstance->GetSingleCreatureFromStorage(NPC_UTHER))) pUther->ForcedDespawn(); m_pInstance->SetNextEvent(29,m_creature->GetEntry(),10000); break; case 29: DoScriptText(SAY_LICH_KING_18, m_creature); m_pInstance->SetNextEvent(30,m_creature->GetEntry(),5000); break; case 30: m_creature->CastSpell(m_creature, SPELL_TAKE_FROSTMOURNE, false); m_pInstance->DoCloseDoor(GO_FROSTMOURNE); m_pInstance->SetNextEvent(31,m_creature->GetEntry(),1500); break; case 31: if (GameObject* pFrostmourne = m_pInstance->GetSingleGameObjectFromStorage(GO_FROSTMOURNE)) pFrostmourne->SetPhaseMask(0, true); m_creature->CastSpell(m_creature, SPELL_FROSTMOURNE_VISUAL, false); m_pInstance->SetNextEvent(31,GetLeader(),500); break; case 32: DoScriptText(SAY_LICH_KING_19, m_creature); m_pInstance->SetNextEvent(33,m_creature->GetEntry(),9000); break; case 33: if (Creature* pFalric = (m_pInstance->GetSingleCreatureFromStorage(NPC_FALRIC))) { pFalric->SetVisibility(VISIBILITY_ON); pFalric->CastSpell(pFalric, SPELL_BOSS_SPAWN_AURA, false); pFalric->GetMotionMaster()->MovePoint(0, 5283.309f, 2031.173f, 709.319f); } if (Creature* pMarwyn = (m_pInstance->GetSingleCreatureFromStorage(NPC_MARWYN))) { pMarwyn->SetVisibility(VISIBILITY_ON); pMarwyn->CastSpell(pMarwyn, SPELL_BOSS_SPAWN_AURA, false); pMarwyn->GetMotionMaster()->MovePoint(0, 5335.585f, 1981.439f, 709.319f); } m_creature->GetMotionMaster()->MovePoint(0, 5402.286f, 2104.496f, 707.695f); m_pInstance->SetNextEvent(34,m_creature->GetEntry(),1000); break; case 34: if (Creature* pFalric = (m_pInstance->GetSingleCreatureFromStorage(NPC_FALRIC))) DoScriptText(SAY_FALRIC_INTRO, pFalric); if (Creature* pMarwyn = (m_pInstance->GetSingleCreatureFromStorage(NPC_MARWYN))) DoScriptText(SAY_MARWYN_INTRO, pMarwyn); m_pInstance->SetData(TYPE_EVENT, 5); m_pInstance->SetNextEvent(35,m_creature->GetEntry(),3000); break; case 35: if (GameObject* pGate = m_pInstance->GetSingleGameObjectFromStorage(GO_IMPENETRABLE_DOOR)) pGate->SetGoState(GO_STATE_ACTIVE); if (Creature* pFalric = m_pInstance->GetSingleCreatureFromStorage(NPC_FALRIC)) DoScriptText(SAY_FALRIC_INTRO2, pFalric); m_pInstance->SetData(TYPE_FALRIC, SPECIAL); m_pInstance->SetNextEvent(36,GetLeader(),4000); break; case 37: m_creature->GetMotionMaster()->MovementExpired(false); m_creature->SetWalk(false); m_creature->GetMotionMaster()->MovePoint(0, 5443.880f, 2147.095f, 707.695f); if (GetLeader() == NPC_JAINA) DoScriptText(SAY_LICH_KING_A_21, m_creature); else if (GetLeader() == NPC_SYLVANA) DoScriptText(SAY_LICH_KING_H_21, m_creature); m_pInstance->SetNextEvent(38,m_creature->GetEntry(),8000); break; case 38: m_pInstance->DoCloseDoor(GO_IMPENETRABLE_DOOR); m_pInstance->SetNextEvent(39,m_creature->GetEntry(),5000); break; case 39: m_creature->SetVisibility(VISIBILITY_OFF); m_pInstance->SetNextEvent(39,GetLeader(),1000); break; case 40: m_pInstance->SetData(TYPE_PHASE, 2); m_pInstance->SetNextEvent(0,0); m_creature->ForcedDespawn(); break; default: break; } }
int FormationBhvr::Perform(INode *node, TimeValue t, int numsubsamples, BOOL DisplayHelpers, float BhvrWeight, PerformOut &out) { Object *o = node->GetObjectRef(); if (o->ClassID() != DELEG_CLASSID) return FALSE; // this should never happen IDelegate *IDeleg = (IDelegate *) o->GetInterface(I_DELEGINTERFACE); Point3 vel= IDeleg->GetCurrentVelocity(); Point3 pos = IDeleg->GetCurrentPosition(); INode *leader = GetLeader(t); if(leader==NULL) return 0; Matrix3 formationMat; //Get the local formation matrix and check if(FindFollowerMatrix(t,node,formationMat)==FALSE) return 0; //that node doesn't exist in the formation so exit. //returned values. Point3 frc,goal; float speedwt, speedAtGoalwt; //Find the Formation Position Target in World Space. Matrix3 currentLeaderMat = GetCurrentMatrix(leader,t); currentLeaderMat.NoScale(); Matrix3 worldSpace = formationMat*currentLeaderMat; Point3 target = worldSpace.GetTrans(); //set the goal as the target goal = target; //set the force as the direction to move towards the target frc = goal - pos; float length = frc.FLength(); if(length!=0.0f) //we are not at the goal { frc /=length; //set up the leader Vector Point3 leaderVec = leaderVel*leaderSpeed; //If the target is behind you but moving towards you don't turn around to //go toward it. Instead move in the direction of the leader. if(frc%vel<0.0f && //if you are behind it length/IDeleg->GetAverageSpeed(t)<10 && //AND less than 20 frames vel%leaderVel>0.0f) //AND it is going toward you. { //set frc as leader's Velocity. frc = leaderVel; //move at half the leaderSpeed. Leader will still catch //up to you and you'll have some speed when it does. //set the speewt speedwt = (leaderSpeed*0.5f)/IDeleg->GetAverageSpeed(t); } else //we should just move towards the target. { //We need to find the speed to be it. We do this by //finding the time we will intersect our target based //upon the leader's velocity and our own velocity. vel -= leaderVec; //find time to intersect.. float newSpeed = vel.FLength(); float timeToIntersect = length/newSpeed; //from that time.. figure out what it speed should be.. newSpeed = timeToIntersect * IDeleg->GetMaxAccel(t); if(newSpeed>IDeleg->GetAverageSpeed(t)) newSpeed = IDeleg->GetAverageSpeed(t); //check to see if we will move past the goal.. if so //move the goal along the leader vec. This reduces overshooting //the goal and decreases wobbling. if((newSpeed+leaderSpeed)>length) { goal += leaderVel*(leaderSpeed); frc = goal -pos; float newLength = frc.FLength(); if(newLength!=0.0f) //check for if zero to avoid divide by zero.. { frc /= newLength; speedwt = (newSpeed+leaderSpeed)/IDeleg->GetAverageSpeed(t); } else { speedwt = 0.0f; } } else //far enough away.. leave the ole frc value.. speedwt = (newSpeed+leaderSpeed)/IDeleg->GetAverageSpeed(t); } } else //we are at the goal { frc.x = frc.y = frc.z = 0.0f; //set the speedwt to be the leaderSpeed speedwt = leaderSpeed/IDeleg->GetAverageSpeed(t); } frc *= BhvrWeight *IDeleg->GetAverageSpeed(t); //scale by weight and average speed.. //set the speedWtAtGoal.. We want it to be the speed of the leader speedAtGoalwt = leaderSpeed/IDeleg->GetAverageSpeed(t); //Display Any Helpers. if (DisplayHelpers && IDeleg->OkToDisplayMyForces()) { if (DisplayTarget(t)) IDeleg->SphereDisplay(goal,pblock->GetFloat(target_scale),GetTargetColor(t)); if (DisplayForce(t)) IDeleg->LineDisplay(IDeleg->GetCurrentPosition(),IDeleg->GetCurrentPosition()+frc,GetForceColor(t),TRUE); } //set up the out structure.. out.frc = frc; out.goal = goal; out.speedwt = speedwt; out.speedAtGoalwt = speedAtGoalwt; return BHVR_SETS_FORCE | BHVR_SETS_GOAL | BHVR_SETS_SPEED; }
void CParty::SetSyncTarget(int8* MemberName, uint16 message) { CBattleEntity* PEntity = nullptr; if (MemberName) { PEntity = GetMemberByName(MemberName); } if (map_config.level_sync_enable) { if (PEntity && PEntity->objtype == TYPE_PC) { CCharEntity* PChar = (CCharEntity*)PEntity; //enable level sync if (PChar->GetMLevel() < 10) { ((CCharEntity*)GetLeader())->pushPacket(new CMessageBasicPacket((CCharEntity*)GetLeader(), (CCharEntity*)GetLeader(), 0, 10, 541)); return; } else if (PChar->getZone() != GetLeader()->getZone()) { ((CCharEntity*)GetLeader())->pushPacket(new CMessageBasicPacket((CCharEntity*)GetLeader(), (CCharEntity*)GetLeader(), 0, 0, 542)); return; } else { for (uint8 i = 0; i < members.size(); ++i) { if (members.at(i)->StatusEffectContainer->HasStatusEffect({EFFECT_LEVEL_RESTRICTION, EFFECT_LEVEL_SYNC})) { ((CCharEntity*)GetLeader())->pushPacket(new CMessageBasicPacket((CCharEntity*)GetLeader(), (CCharEntity*)GetLeader(), 0, 0, 543)); return; } } m_PSyncTarget = PChar; for (uint8 i = 0; i < members.size(); ++i) { if (members.at(i)->objtype != TYPE_PC) continue; CCharEntity* member = (CCharEntity*)members.at(i); if (member->status != STATUS_DISAPPEAR && member->getZone() == PChar->getZone()) { member->pushPacket(new CMessageStandardPacket(PChar->GetMLevel(), 0, 0, 0, message)); member->StatusEffectContainer->AddStatusEffect(new CStatusEffect( EFFECT_LEVEL_SYNC, EFFECT_LEVEL_SYNC, PChar->GetMLevel(), 0, 0), true); member->StatusEffectContainer->DelStatusEffectsByFlag(EFFECTFLAG_DISPELABLE | EFFECTFLAG_ON_ZONE); member->loc.zone->PushPacket(member, CHAR_INRANGE, new CCharSyncPacket(member)); } } Sql_Query(SqlHandle, "UPDATE accounts_parties SET partyflag = partyflag & ~%d WHERE partyid = %u AND partyflag & %d", PARTY_SYNC, m_PartyID, PARTY_SYNC); Sql_Query(SqlHandle, "UPDATE accounts_parties SET partyflag = partyflag | %d WHERE partyid = %u AND charid = '%u';", PARTY_SYNC, m_PartyID, PChar->id); } } else { if (m_PSyncTarget != nullptr) { //disable level sync for (uint8 i = 0; i < members.size(); ++i) { if (members.at(i)->objtype != TYPE_PC) continue; CCharEntity* member = (CCharEntity*)members.at(i); if (member->status != STATUS_DISAPPEAR) { CStatusEffect* sync = member->StatusEffectContainer->GetStatusEffect(EFFECT_LEVEL_SYNC); if (sync && sync->GetDuration() == 0) { member->pushPacket(new CMessageBasicPacket(member, member, 10, 30, message)); sync->SetStartTime(server_clock::now()); sync->SetDuration(30000); } } } } m_PSyncTarget = nullptr; Sql_Query(SqlHandle, "UPDATE accounts_parties SET partyflag = partyflag & ~%d WHERE partyid = %u AND partyflag & %d", PARTY_SYNC, m_PartyID, PARTY_SYNC); } } }
/** * Orient head and eyes towards m_lookAt. */ void C_CHostage::UpdateLookAt( CStudioHdr *pStudioHdr ) { if (!m_isInit) { m_isInit = true; Initialize( ); } // head yaw if (m_headYawPoseParam < 0 || m_bodyYawPoseParam < 0 || m_headPitchPoseParam < 0) return; if (GetLeader()) { m_lookAt = GetLeader()->EyePosition(); } // orient eyes m_viewtarget = m_lookAt; // blinking if (m_blinkTimer.IsElapsed()) { m_blinktoggle = !m_blinktoggle; m_blinkTimer.Start( RandomFloat( 1.5f, 4.0f ) ); } // Figure out where we want to look in world space. QAngle desiredAngles; Vector to = m_lookAt - EyePosition(); VectorAngles( to, desiredAngles ); // Figure out where our body is facing in world space. float poseParams[MAXSTUDIOPOSEPARAM]; GetPoseParameters( pStudioHdr, poseParams ); QAngle bodyAngles( 0, 0, 0 ); bodyAngles[YAW] = GetRenderAngles()[YAW] + RemapVal( poseParams[m_bodyYawPoseParam], 0, 1, m_bodyYawMin, m_bodyYawMax ); float flBodyYawDiff = bodyAngles[YAW] - m_flLastBodyYaw; m_flLastBodyYaw = bodyAngles[YAW]; // Set the head's yaw. float desired = AngleNormalize( desiredAngles[YAW] - bodyAngles[YAW] ); desired = clamp( desired, m_headYawMin, m_headYawMax ); m_flCurrentHeadYaw = ApproachAngle( desired, m_flCurrentHeadYaw, HOSTAGE_HEAD_TURN_RATE * gpGlobals->frametime ); // Counterrotate the head from the body rotation so it doesn't rotate past its target. m_flCurrentHeadYaw = AngleNormalize( m_flCurrentHeadYaw - flBodyYawDiff ); desired = clamp( desired, m_headYawMin, m_headYawMax ); SetPoseParameter( pStudioHdr, m_headYawPoseParam, m_flCurrentHeadYaw ); // Set the head's yaw. desired = AngleNormalize( desiredAngles[PITCH] ); desired = clamp( desired, m_headPitchMin, m_headPitchMax ); m_flCurrentHeadPitch = ApproachAngle( desired, m_flCurrentHeadPitch, HOSTAGE_HEAD_TURN_RATE * gpGlobals->frametime ); m_flCurrentHeadPitch = AngleNormalize( m_flCurrentHeadPitch ); SetPoseParameter( pStudioHdr, m_headPitchPoseParam, m_flCurrentHeadPitch ); SetPoseParameter( pStudioHdr, "head_roll", 0.0f ); }