void JustDidDialogueStep(int32 iEntry) override { if (!m_pInstance) { return; } switch (iEntry) { case PHASE_DARKNESS: case PHASE_ARMAGEDDON: case PHASE_SACRIFICE: if (DoCastSpellIfCan(m_creature, SPELL_SINISTER_REFLECTION, CAST_INTERRUPT_PREVIOUS) == CAST_OK) { DoScriptText(irand(0, 1) ? SAY_REFLECTION_1 : SAY_REFLECTION_2, m_creature); // In the 2nd and 3rd transition kill all drakes if (iEntry == PHASE_ARMAGEDDON || iEntry == PHASE_SACRIFICE) { DoCastSpellIfCan(m_creature, SPELL_DESTROY_DRAKES, CAST_TRIGGERED); } m_uiPhase = PHASE_TRANSITION; // Darkness of Souls needs the timer reseted m_uiDarknessOfSoulsTimer = iEntry == PHASE_SACRIFICE ? 30000 : 45000; } break; case EVENT_SWITCH_PHASE_2: case EVENT_SWITCH_PHASE_3: case EVENT_SWITCH_PHASE_4: DoCastSpellIfCan(m_creature, SPELL_SHADOW_SPIKE); break; case EVENT_DRAGON_ORB: // Activate blue orbs if (Creature* pKalec = m_pInstance->GetSingleCreatureFromStorage(NPC_KALECGOS)) { DoScriptText(irand(0, 1) ? SAY_KALECGOS_ORB_2 : SAY_KALECGOS_ORB_3, pKalec); } DoActivateDragonOrb(GO_ORB_BLUE_FLIGHT_2); break; case SAY_KALECGOS_ORB_1: DoActivateDragonOrb(GO_ORB_BLUE_FLIGHT_1); break; case SAY_KALECGOS_ORB_4: DoActivateDragonOrb(GO_ORB_BLUE_FLIGHT_3); DoActivateDragonOrb(GO_ORB_BLUE_FLIGHT_4); break; case SAY_PHASE_3: // Set next phase and increase the max shield orbs m_uiPhase = PHASE_DARKNESS; ++m_uiMaxShieldOrbs; break; case SAY_PHASE_4: // Set next phase and increase the max shield orbs m_uiPhase = PHASE_ARMAGEDDON; ++m_uiMaxShieldOrbs; break; case SAY_PHASE_5: // Set next phase and sacrifice Anveena if (Creature* pAnveena = m_pInstance->GetSingleCreatureFromStorage(NPC_ANVEENA)) { pAnveena->RemoveAurasDueToSpell(SPELL_ANVEENA_PRISON); pAnveena->CastSpell(pAnveena, SPELL_SACRIFICE_ANVEENA, true); pAnveena->ForcedDespawn(3000); } m_uiPhase = PHASE_SACRIFICE; break; } }
void HandleScript(SpellEffIndex effIndex) { PreventHitDefaultEffect(effIndex); // Possible spells to handle this not found. for (uint32 i = 0; i < 4; ++i) GetCaster()->SummonCreature(NPC_BONE_MINION, GetCaster()->GetPositionX() + float(irand(-7, 7)), GetCaster()->GetPositionY() + float(irand(-7, 7)), GetCaster()->GetPositionZ(), 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 120000); }
void SummonMages(Unit* victim) { if (Creature* SummonedMage = DoSpawnCreature(16120, float(irand(-9, 9)), float(irand(-9, 9)), 0, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 120000)) SummonedMage->AI()->AttackStart(victim); }
int getRandInt(int max){ return irand(random_seed,max); }
int LocalMove(struct s_polymer *p, struct s_polymer *oldp,struct s_polymer *fragment,struct s_potential *pot,int nmul,struct s_mc_parms *parms, double t) { int ok=0,nang=0; int iw,ip,iapdbtocheck,i,m; double deltaE; double detL1,detL2,detA1,detA2,W1,W2,psisquared,e; ip=irand(parms->npol); iw=(nmul-1)+irand( (p+ip)->nback-nmul+1 ); //iw=20; for(i=0; i<nmul; i++) { nang+=((((p+ip)->back)+iw-nmul+i)+1)->move; } deltaE = -GetEnergyMonomerRange(p,iw-nmul+1,iw+1,ip); if(iw==((p+ip)->nback-1)) //pivot forward OK { for(i=0; i<nang; i++) (fragment+ip)->d_ang[i]=parms->dw_mpivot*(0.05-frand()); if (!parms->nodihpot) for(i=0; i<nmul+3; i++) { deltaE-=(((p+ip)->back)+iw-nmul+i+1)->e_dih; } m=0; for(i=0; i<nmul; i++) { if( (((p+ip)->back)+iw+i-nmul+2)->move==1) { ok*=PivotForward((p+ip),iw-nmul+i+1,(fragment+ip)->d_ang[m],nmul-i-2,parms); m++; if(m==nang) break; } } if(!parms->nosidechains) { ok*=AddSidechain(p,iw-nmul+1,iw+1,ip); } deltaE += EnergyMonomerRange(p,pot,iw-nmul+1,iw+1,ip,parms->npol,parms->shell,1,parms->nosidechains,parms->disentangle,parms->hb); if (!parms->nodihpot) for(i=0; i<nmul+3; i++) { deltaE+=EnergyDihedrals(p,pot,iw-nmul+i+1,ip,1); } ok*=Metropolis(deltaE,t,p->tables); if(ok==0) { UpdateMonomerRange(oldp,p,iw-nmul+1,iw+1,ip,parms->shell); } else { //move accepted UpdateMonomerRange(p,oldp,iw-nmul+1,iw+1,ip,parms->shell); p->etot+=deltaE; parms->acc++; } } //end of forward else if(iw==nmul-1) //pivot backward OK { for(i=0; i<nang; i++) (fragment+ip)->d_ang[i]=parms->dw_mpivot*(0.05-frand()); if (!parms->nodihpot) for(i=0; i<nmul+3; i++) { deltaE-=(((p+ip)->back)+i)->e_dih; } m=0; for(i=0; i<nmul; i++) { if( (((p+ip)->back)+iw-i)->move==1) { ok*=PivotBackward((p+ip),iw-i,(fragment+ip)->d_ang[m],nmul-i-2,parms); m++; if(m==nang) break; } } if(!parms->nosidechains) ok*=AddSidechain(p,0,iw+1,ip); deltaE += EnergyMonomerRange(p,pot,0,iw+1,ip,parms->npol,parms->shell,1,parms->nosidechains,parms->disentangle,parms->hb); if (!parms->nodihpot) for(i=0; i<nmul+3; i++) { deltaE+=EnergyDihedrals(p,pot,i,ip,1); } ok*=Metropolis(deltaE,t,p->tables); if(ok==0) { UpdateMonomerRange(oldp,p,0,iw+1,ip,parms->shell); } else { UpdateMonomerRange(p,oldp,0,iw+1,ip,parms->shell); p->etot+=deltaE; parms->acc++; } } //end of backward else if(iw!=((p+ip)->nback-2))//pivot local { if((((p+ip)->back)+iw+1)->iapdb==0) iapdbtocheck=1; if((((p+ip)->back)+iw+1)->iapdb==1) iapdbtocheck=2; if((((p+ip)->back)+iw+1)->iapdb==2) iapdbtocheck=0; int out; Gaussian_Angles((fragment+ip)->g_ang,nang); Compute_G(fragment,p,ip,iw-nmul+1,nmul,nang,parms); MatA((fragment+ip)->A,(fragment+ip)->G,nang,parms->bgs_a,parms->bgs_b); Cholesky_2((fragment+ip)->L,(fragment+ip)->A,nang); psisquared=Squared_n_Norma((fragment+ip)->g_ang,nang); e=exp(-psisquared); detL1=DetTriang((fragment+ip)->L,nang); detA1=detL1*detL1; W1=e * sqrt(detA1); InvertTriang((fragment+ip)->Y,(fragment+ip)->L,nang); TransposedMatOnVect((fragment+ip)->Y,(fragment+ip)->g_ang,(fragment+ip)->d_ang,nang); if(!parms->nodihpot) for(i=0; i<nmul+3; i++) { deltaE -= (((p+ip)->back)+iw-nmul+i+1)->e_dih; } if(!parms->noangpot) { deltaE-=(((p+ip)->back)+iw)->e_ang; deltaE-=(((p+ip)->back)+iw+1)->e_ang; } m=0; for(i=0; i<nmul; i++) { if( (((p+ip)->back)+iw+i-nmul+2)->move==1) { ok*=PivotForward((p+ip),iw-nmul+i+1,(fragment+ip)->d_ang[m],nmul-i-2,parms); m++; if(m==nang) break; } } double rc2=parms->r_cloose*parms->r_cloose; double dihedral=Dihedral( (((p+ip)->back)+iw-iapdbtocheck)->pos, (((p+ip)->back)+iw+1-iapdbtocheck)->pos, (((p+ip)->back)+iw+2-iapdbtocheck)->pos, (((p+ip)->back)+iw+3-iapdbtocheck)->pos, p->tables, &out ); // fprintf(stderr,"Checking Dihedral: backbone atoms %d,%d,%d,%d\n",+iw-iapdbtocheck,+iw+1-iapdbtocheck,+iw+2-iapdbtocheck,+iw+3-iapdbtocheck); if( DAbs (Dist2( (((p+ip)->back)+iw)->pos,(((p+ip)->back)+iw+1)->pos ) -(((p+ip)->back)+iw)->d2_next < rc2 ) && DAbs( Angle( (((p+ip)->back)+iw-1)->pos, (((p+ip)->back)+iw)->pos, (((p+ip)->back)+iw+1)->pos, (p+ip)->tables, &out) - (((p+ip)->back)+iw-1)->a_next) < 0.05 && DAbs(180-DAbs(dihedral)) < DELTAOMEGA) { if(!parms->nosidechains) { ok *= AddSidechain(p,iw-nmul+1,iw+1,ip); } deltaE += EnergyMonomerRange(p,pot,iw-nmul+1,iw+1,ip,parms->npol,parms->shell,1,parms->nosidechains,parms->disentangle,parms->hb); if (!parms->nodihpot) for(i=0; i<nmul+3; i++) { deltaE+=EnergyDihedrals(p,pot,iw-nmul+i+1,ip,1); } if(!parms->noangpot) { // fprintf(stderr,"\nCOMPUTING ANGLE ENERGY deltaE=%lf\t",deltaE); deltaE+=EnergyAngles(p,pot,iw,ip,1); deltaE+=EnergyAngles(p,pot,iw+1,ip,1); // fprintf(stderr,"-> %lf\n",deltaE); } Compute_G(fragment,p,ip,iw-nmul+1,nmul,nang,parms); MatA((fragment+ip)->A,(fragment+ip)->G,nang,parms->bgs_a,parms->bgs_b); Cholesky_2((fragment+ip)->L,(fragment+ip)->A,nang); detL2=DetTriang((fragment+ip)->L,nang); detA2=detL2*detL2; TransposedMatOnVect((fragment+ip)->L,(fragment+ip)->d_ang,(fragment+ip)->g_ang,nang); psisquared=Squared_n_Norma((fragment+ip)->g_ang,nang); e=exp(-psisquared); W2=e*sqrt(detA2); ok*=B_Metropolis(deltaE,t,W2,W1,p->tables); if(ok==0) //move rejected { UpdateMonomerRange(oldp,p,iw-nmul+1,iw+1,ip,parms->shell); } else //move accepted { UpdateMonomerRange(p,oldp,iw-nmul+1,iw+1,ip,parms->shell); p->etot+=deltaE; parms->acc++; } }//end of loose condition else //if not loose pivot { ok=0; UpdateMonomerRange(oldp,p,iw-nmul+1,iw+1,ip,parms->shell); } }//end of local pivot parms->mov++; return ok; }
/* ================================ brand ================================ */ bool brand() { return irand( 2 ); }
void CalcPeriodic(AuraEffect const* /*aurEff*/, bool& isPeriodic, int32& amplitude) { isPeriodic = true; amplitude = (irand(0, 60) + 30) * IN_MILLISECONDS; }
int erase_links(deque<set<int> > & E, const deque<deque<int> > & member_list, const bool excess, const bool defect, const double mixing_parameter) { int num_nodes= member_list.size(); int eras_add_times=0; if (excess) { for (int i=0; i<num_nodes; i++) { while ( (E[i].size()>1) && double(internal_kin(E, member_list, i))/E[i].size() < 1 - mixing_parameter) { //--------------------------------------------------------------------------------- cout<<"degree sequence changed to respect the option -sup ... "<<++eras_add_times<<endl; deque<int> deqar; for (set<int>::iterator it_est=E[i].begin(); it_est!=E[i].end(); it_est++) if (!they_are_mate(i, *it_est, member_list)) deqar.push_back(*it_est); if(deqar.size()==E[i].size()) { // this shouldn't happen... cerr<<"sorry, something went wrong: there is a node which does not respect the constraints. (option -sup)"<<endl; return -1; } int random_mate=deqar[irand(deqar.size()-1)]; E[i].erase(random_mate); E[random_mate].erase(i); } } } if (defect) { for (int i=0; i<num_nodes; i++) while ( (E[i].size()<E.size()) && double(internal_kin(E, member_list, i))/E[i].size() > 1 - mixing_parameter) { //--------------------------------------------------------------------------------- cout<<"degree sequence changed to respect the option -inf ... "<<++eras_add_times<<endl; int stopper_here=num_nodes; int stopper_=0; int random_mate=irand(num_nodes-1); while ( ( (they_are_mate(i, random_mate, member_list)) || E[i].find(random_mate)!=E[i].end()) && (stopper_<stopper_here) ) { random_mate=irand(num_nodes-1); stopper_++; } if(stopper_==stopper_here) { // this shouldn't happen... cerr<<"sorry, something went wrong: there is a node which does not respect the constraints. (option -inf)"<<endl; return -1; } E[i].insert(random_mate); E[random_mate].insert(i); } } //------------------------------------ Erasing links ------------------------------------------------------ return 0; }
int build_bipartite_network(deque<deque<int> > & member_matrix, const deque<int> & member_numbers, const deque<int> &num_seq) { // this function builds a bipartite network with num_seq and member_numbers which are the degree sequences. in member matrix links of the communities are stored // this means member_matrix has num_seq.size() rows and each row has num_seq[i] elements deque<set<int> > en_in; // this is the Ein of the subgraph deque<set<int> > en_out; // this is the Eout of the subgraph { set<int> first; for(int i=0; i<member_numbers.size(); i++) { en_in.push_back(first); } } { set<int> first; for(int i=0; i<num_seq.size(); i++) { en_out.push_back(first); } } multimap <int, int> degree_node_out; deque<pair<int, int> > degree_node_in; for(int i=0; i<num_seq.size(); i++) degree_node_out.insert(make_pair(num_seq[i], i)); for(int i=0; i<member_numbers.size(); i++) degree_node_in.push_back(make_pair(member_numbers[i], i)); sort(degree_node_in.begin(), degree_node_in.end()); deque<pair<int, int> >::iterator itlast = degree_node_in.end(); /* for (int i=0; i<degree_node_in.size(); i++) cout<<degree_node_in[i].first<<" "<<degree_node_in[i].second<<endl; */ while (itlast != degree_node_in.begin()) { itlast--; multimap <int, int>::iterator itit= degree_node_out.end(); deque <multimap<int, int>::iterator> erasenda; for (int i=0; i<itlast->first; i++) { if(itit!=degree_node_out.begin()) { itit--; en_in[itlast->second].insert(itit->second); en_out[itit->second].insert(itlast->second); erasenda.push_back(itit); } else return -1; } //cout<<"degree node out before"<<endl; //prints(degree_node_out); for (int i=0; i<erasenda.size(); i++) { if(erasenda[i]->first>1) degree_node_out.insert(make_pair(erasenda[i]->first - 1, erasenda[i]->second)); degree_node_out.erase(erasenda[i]); } //cout<<"degree node out after"<<endl; //prints(degree_node_out); } // this is to randomize the subgraph ------------------------------------------------------------------- for(int node_a=0; node_a<num_seq.size(); node_a++) for(int krm=0; krm<en_out[node_a].size(); krm++) { int random_mate=irand(member_numbers.size()-1); if (en_out[node_a].find(random_mate)==en_out[node_a].end()) { deque <int> external_nodes; for (set<int>::iterator it_est=en_out[node_a].begin(); it_est!=en_out[node_a].end(); it_est++) external_nodes.push_back(*it_est); int old_node=external_nodes[irand(external_nodes.size()-1)]; deque <int> not_common; for (set<int>::iterator it_est=en_in[random_mate].begin(); it_est!=en_in[random_mate].end(); it_est++) if (en_in[old_node].find(*it_est)==en_in[old_node].end()) not_common.push_back(*it_est); if (not_common.empty()) break; int node_h=not_common[irand(not_common.size()-1)]; en_out[node_a].insert(random_mate); en_out[node_a].erase(old_node); en_in[old_node].insert(node_h); en_in[old_node].erase(node_a); en_in[random_mate].insert(node_a); en_in[random_mate].erase(node_h); en_out[node_h].erase(random_mate); en_out[node_h].insert(old_node); } } member_matrix.clear(); deque <int> first; for (int i=0; i<en_out.size(); i++) { member_matrix.push_back(first); for (set<int>::iterator its=en_out[i].begin(); its!=en_out[i].end(); its++) member_matrix[i].push_back(*its); } return 0; }
void SummonMedic(Unit* victim) { if (Creature* SummonedMedic = DoSpawnCreature(8894, float(irand(-9, 9)), float(irand(-9, 9)), 0, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 120000)) SummonedMedic->AI()->AttackStart(victim); }
int connect_all_the_parts(deque<set<int> > & E, const deque<deque<int> > & member_list, const deque<deque<int> > & link_list) { deque<int> degrees; for(int i=0; i<link_list.size(); i++) degrees.push_back(link_list[i][link_list[i].size()-1]); deque<set<int> > en; // this is the en of the subgraph { set<int> first; for(int i=0; i<member_list.size(); i++) en.push_back(first); } multimap <int, int> degree_node; for(int i=0; i<degrees.size(); i++) degree_node.insert(degree_node.end(), make_pair(degrees[i], i)); int var=0; while (degree_node.size() > 0) { multimap<int, int>::iterator itlast= degree_node.end(); itlast--; multimap <int, int>::iterator itit= itlast; deque <multimap<int, int>::iterator> erasenda; int inserted=0; for (int i=0; i<itlast->first; i++) { if(itit!=degree_node.begin()) { itit--; en[itlast->second].insert(itit->second); en[itit->second].insert(itlast->second); inserted++; erasenda.push_back(itit); } else break; } for (int i=0; i<erasenda.size(); i++) { if(erasenda[i]->first>1) degree_node.insert(make_pair(erasenda[i]->first - 1, erasenda[i]->second)); degree_node.erase(erasenda[i]); } var+= itlast->first - inserted; degree_node.erase(itlast); } // this is to randomize the subgraph ------------------------------------------------------------------- for(int node_a=0; node_a<degrees.size(); node_a++) for(int krm=0; krm<en[node_a].size(); krm++) { int random_mate=irand(degrees.size()-1); while (random_mate==node_a) random_mate=irand(degrees.size()-1); if (en[node_a].insert(random_mate).second) { deque <int> out_nodes; for (set<int>::iterator it_est=en[node_a].begin(); it_est!=en[node_a].end(); it_est++) if ((*it_est)!=random_mate) out_nodes.push_back(*it_est); int old_node=out_nodes[irand(out_nodes.size()-1)]; en[node_a].erase(old_node); en[random_mate].insert(node_a); en[old_node].erase(node_a); deque <int> not_common; for (set<int>::iterator it_est=en[random_mate].begin(); it_est!=en[random_mate].end(); it_est++) if ((old_node!=(*it_est)) && (en[old_node].find(*it_est)==en[old_node].end())) not_common.push_back(*it_est); int node_h=not_common[irand(not_common.size()-1)]; en[random_mate].erase(node_h); en[node_h].erase(random_mate); en[node_h].insert(old_node); en[old_node].insert(node_h); } } // now there is a rewiring process to avoid "mate nodes" (nodes with al least one membership in common) to link each other int var_mate=0; for(int i=0; i<degrees.size(); i++) for(set<int>::iterator itss= en[i].begin(); itss!=en[i].end(); itss++) if(they_are_mate(i, *itss, member_list)) { var_mate++; } //cout<<"var mate = "<<var_mate<<endl; int stopper_mate=0; int mate_trooper=10; while(var_mate>0) { //cout<<"var mate = "<<var_mate<<endl; int best_var_mate=var_mate; // ************************************************ rewiring for(int a=0; a<degrees.size(); a++) for(set<int>::iterator its= en[a].begin(); its!=en[a].end(); its++) if(they_are_mate(a, *its, member_list)) { int b=*its; int stopper_m=0; while (true) { stopper_m++; int random_mate=irand(degrees.size()-1); while (random_mate==a || random_mate==b) random_mate=irand(degrees.size()-1); if(!(they_are_mate(a, random_mate, member_list)) && (en[a].find(random_mate)==en[a].end())) { deque <int> not_common; for (set<int>::iterator it_est=en[random_mate].begin(); it_est!=en[random_mate].end(); it_est++) if ((b!=(*it_est)) && (en[b].find(*it_est)==en[b].end())) not_common.push_back(*it_est); if(not_common.size()>0) { int node_h=not_common[irand(not_common.size()-1)]; en[random_mate].erase(node_h); en[random_mate].insert(a); en[node_h].erase(random_mate); en[node_h].insert(b); en[b].erase(a); en[b].insert(node_h); en[a].insert(random_mate); en[a].erase(b); if(!they_are_mate(b, node_h, member_list)) var_mate-=2; if(they_are_mate(random_mate, node_h, member_list)) var_mate-=2; break; } } if(stopper_m==en[a].size()) break; } break; // this break is done because if you erased some link you have to stop this loop (en[i] changed) } // ************************************************ rewiring if(var_mate==best_var_mate) { stopper_mate++; if(stopper_mate==mate_trooper) break; } else stopper_mate=0; //cout<<"var mate = "<<var_mate<<endl; } //cout<<"var mate = "<<var_mate<<endl; for (int i=0; i<en.size(); i++) { for(set<int>::iterator its=en[i].begin(); its!=en[i].end(); its++) if(i<*its) { E[i].insert(*its); E[*its].insert(i); } } return 0; }
void arriveEvent::processEvent () { if (theSimulation.canSeat (size)) theSimulation.scheduleEvent (new orderEvent (time + 1 + irand (4), size)); }
void UpdateAI(const uint32 diff) { if (!m_creature->SelectHostileTarget() || !m_creature->getVictim()) return; if (AppearDelay) { m_creature->StopMoving(); m_creature->AttackStop(); if (AppearDelay_Timer < diff) { AppearDelay = false; if (Phase == 2) { m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); m_creature->SetVisibility(VISIBILITY_OFF); } AppearDelay_Timer = 2000; }else AppearDelay_Timer -= diff; } if (Phase == 1) { //ArcaneMissiles_Timer if (ArcaneMissiles_Timer < diff) { //Solarian casts Arcane Missiles on on random targets in the raid. if (Unit* target = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0)) { if (target && !m_creature->HasInArc(2.5f, target)) target = m_creature->getVictim(); if (target) DoCastSpellIfCan(target, SPELL_ARCANE_MISSILES); } ArcaneMissiles_Timer = 3000; }else ArcaneMissiles_Timer -= diff; //Wrath of the Astromancer targets a random player which will explode after 6 secondes if (m_uiWrathOfTheAstromancer_Timer < diff) { m_creature->InterruptNonMeleeSpells(false); //Target the tank ? if (Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 1)) { if (pTarget->GetTypeId() == TYPEID_PLAYER) { DoCastSpellIfCan(pTarget, SPELL_WRATH_OF_THE_ASTROMANCER); m_uiWrathOfTheAstromancer_Timer = 25000; } else m_uiWrathOfTheAstromancer_Timer = 1000; } }else m_uiWrathOfTheAstromancer_Timer -= diff; //BlindingLight_Timer if (BlindingLight_Timer < diff) { //She casts this spell every 45 seconds. It is a kind of Moonfire spell, which she strikes down on the whole raid simultaneously. It hits everyone in the raid for 2280 to 2520 arcane damage. DoCastSpellIfCan(m_creature->getVictim(), SPELL_BLINDING_LIGHT); BlindingLight_Timer = 45000; }else BlindingLight_Timer -= diff; //Phase1_Timer if (Phase1_Timer < diff) { Phase = 2; Phase1_Timer = 50000; //After these 50 seconds she portals to the middle of the room and disappears, leaving 3 light portals behind. m_creature->GetMotionMaster()->Clear(); m_creature->GetMap()->CreatureRelocation(m_creature, CENTER_X, CENTER_Y, CENTER_Z, CENTER_O); for(int i = 0; i <= 2; ++i) { if (!i) { Portals[i][0] = Portal_X(SMALL_PORTAL_RADIUS); Portals[i][1] = Portal_Y(Portals[i][0], SMALL_PORTAL_RADIUS); Portals[i][2] = CENTER_Z; } else { Portals[i][0] = Portal_X(LARGE_PORTAL_RADIUS); Portals[i][1] = Portal_Y(Portals[i][0], LARGE_PORTAL_RADIUS); Portals[i][2] = PORTAL_Z; } } if ((abs(int(Portals[2][0]) - int(Portals[1][0])) < 7) && (abs(int(Portals[2][1]) - int(Portals[1][1])) < 7)) { int i = 1; if (abs(int(CENTER_X) + int(26.0f) - int(Portals[2][0])) < 7) i = -1; Portals[2][0] = Portals[2][0]+7*i; Portals[2][1] = Portal_Y(Portals[2][0], LARGE_PORTAL_RADIUS); } for (int i = 0; i <= 2; ++i) { if (Creature* Summoned = m_creature->SummonCreature(NPC_ASTROMANCER_SOLARIAN_SPOTLIGHT, Portals[i][0], Portals[i][1], Portals[i][2], CENTER_O, TEMPSUMMON_TIMED_DESPAWN, Phase2_Timer+Phase3_Timer+AppearDelay_Timer+1700)) { Summoned->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); Summoned->CastSpell(Summoned, SPELL_SPOTLIGHT, false); } } AppearDelay = true; }else Phase1_Timer -= diff; } else if (Phase == 2) { m_creature->AttackStop(); m_creature->StopMoving(); //Check Phase2_Timer if (Phase2_Timer < diff) { //10 seconds after Solarian disappears, 12 mobs spawn out of the three portals. Phase = 3; for (int i = 0; i <= 2; ++i) { for (int j = 1; j <= 4; ++j) SummonMinion(NPC_SOLARIUM_AGENT, Portals[i][0], Portals[i][1], Portals[i][2]); } DoScriptText(SAY_SUMMON1, m_creature); Phase2_Timer = 10000; } else Phase2_Timer -= diff; } else if (Phase == 3) { m_creature->AttackStop(); m_creature->StopMoving(); //Check Phase3_Timer if (Phase3_Timer < diff) { Phase = 1; //15 seconds later Solarian reappears out of one of the 3 portals. Simultaneously, 2 healers appear in the two other portals. int i = irand(0, 2); m_creature->GetMotionMaster()->Clear(); m_creature->GetMap()->CreatureRelocation(m_creature, Portals[i][0], Portals[i][1], Portals[i][2], CENTER_O); for (int j = 0; j <= 2; ++j) if (j != i) SummonMinion(NPC_SOLARIUM_PRIEST, Portals[j][0], Portals[j][1], Portals[j][2]); m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); m_creature->SetVisibility(VISIBILITY_ON); DoScriptText(SAY_SUMMON2, m_creature); AppearDelay = true; Phase3_Timer = 15000; }else Phase3_Timer -= diff; } else if (Phase == 4) { //Fear_Timer if (Fear_Timer < diff) { DoCastSpellIfCan(m_creature, SPELL_FEAR); Fear_Timer = 20000; }else Fear_Timer -= diff; //VoidBolt_Timer if (VoidBolt_Timer < diff) { DoCastSpellIfCan(m_creature->getVictim(), SPELL_VOID_BOLT); VoidBolt_Timer = 10000; }else VoidBolt_Timer -= diff; } //When Solarian reaches 20% she will transform into a huge void walker. if (Phase != 4 && m_creature->GetHealthPercent() < 20.0f) { Phase = 4; //To make sure she wont be invisible or not selecatble m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); m_creature->SetVisibility(VISIBILITY_ON); DoScriptText(SAY_VOIDA, m_creature); DoScriptText(SAY_VOIDB, m_creature); m_creature->SetArmor(WV_ARMOR); m_creature->SetDisplayId(MODEL_VOIDWALKER); m_creature->SetFloatValue(OBJECT_FIELD_SCALE_X, defaultsize*2.5f); } DoMeleeAttackIfReady(); }
int main() { PFC pfc(AES_SECURITY); // initialise pairing-friendly curve time_t seed; G1 Alice,Bob,sA,sB; G2 B6,Server,sS; GT res,sp,ap,bp; Big ss,s,a,b; time(&seed); irand((long)seed); pfc.random(ss); // TA's super-secret cout << "Mapping Server ID to point" << endl; pfc.hash_and_map(Server,(char *)"Server"); cout << "Mapping Alice & Bob ID's to points" << endl; pfc.hash_and_map(Alice,(char *)"Alice"); pfc.hash_and_map(Bob,(char *)"Robert"); cout << "Alice, Bob and the Server visit Trusted Authority" << endl; sS=pfc.mult(Server,ss); sA=pfc.mult(Alice,ss); sB=pfc.mult(Bob,ss); cout << "Alice and Server Key Exchange" << endl; pfc.random(a); // Alice's random number pfc.random(s); // Server's random number res=pfc.pairing(Server,sA); if (!pfc.member(res)) { cout << "Wrong group order - aborting" << endl; exit(0); } ap=pfc.power(res,a); res=pfc.pairing(sS,Alice); if (!pfc.member(res)) { cout << "Wrong group order - aborting" << endl; exit(0); } sp=pfc.power(res,s); cout << "Alice Key= " << pfc.hash_to_aes_key(pfc.power(sp,a)) << endl; cout << "Server Key= " << pfc.hash_to_aes_key(pfc.power(ap,s)) << endl; cout << "Bob and Server Key Exchange" << endl; pfc.random(b); // Bob's random number pfc.random(s); // Server's random number res=pfc.pairing(Server,sB); if (!pfc.member(res)) { cout << "Wrong group order - aborting" << endl; exit(0); } bp=pfc.power(res,b); res=pfc.pairing(sS,Bob); if (!pfc.member(res)) { cout << "Wrong group order - aborting" << endl; exit(0); } sp=pfc.power(res,s); cout << "Bob's Key= " << pfc.hash_to_aes_key(pfc.power(sp,b)) << endl; cout << "Server Key= " << pfc.hash_to_aes_key(pfc.power(bp,s)) << endl; return 0; }
void GameObject::Use(Unit* user) { // by default spell caster is user Unit* spellCaster = user; uint32 spellId = 0; switch(GetGoType()) { case GAMEOBJECT_TYPE_DOOR: //0 case GAMEOBJECT_TYPE_BUTTON: //1 //doors/buttons never really despawn, only reset to default state/flags if(user->GetTypeId()==TYPEID_PLAYER) { ((Player*)user)->setFaction(((Player*)user)->getFactionForRace(((Player*)user)->getRace())); //return; } UseDoorOrButton(); // activate script sWorld.ScriptsStart(sGameObjectScripts, GetDBTableGUIDLow(), spellCaster, this); return; case GAMEOBJECT_TYPE_QUESTGIVER: //2 { if(user->GetTypeId()!=TYPEID_PLAYER) return; Player* player = (Player*)user; player->PrepareQuestMenu( GetGUID() ); player->SendPreparedQuest( GetGUID() ); return; } //Sitting: Wooden bench, chairs enzz case GAMEOBJECT_TYPE_CHAIR: //7 { GameObjectInfo const* info = GetGOInfo(); if(!info) return; if(user->GetTypeId()!=TYPEID_PLAYER) return; Player* player = (Player*)user; // a chair may have n slots. we have to calculate their positions and teleport the player to the nearest one // check if the db is sane if(info->chair.slots > 0) { float lowestDist = DEFAULT_VISIBILITY_DISTANCE; float x_lowest = GetPositionX(); float y_lowest = GetPositionY(); // the object orientation + 1/2 pi // every slot will be on that straight line float orthogonalOrientation = GetOrientation()+M_PI*0.5f; // find nearest slot for(uint32 i=0; i<info->chair.slots; ++i) { // the distance between this slot and the center of the go - imagine a 1D space float relativeDistance = (info->size*i)-(info->size*(info->chair.slots-1)/2.0f); float x_i = GetPositionX() + relativeDistance * cos(orthogonalOrientation); float y_i = GetPositionY() + relativeDistance * sin(orthogonalOrientation); // calculate the distance between the player and this slot float thisDistance = player->GetDistance2d(x_i, y_i); /* debug code. It will spawn a npc on each slot to visualize them. Creature* helper = player->SummonCreature(14496, x_i, y_i, GetPositionZ(), GetOrientation(), TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 10000); std::ostringstream output; output << i << ": thisDist: " << thisDistance; helper->MonsterSay(output.str().c_str(), LANG_UNIVERSAL, 0); */ if(thisDistance <= lowestDist) { lowestDist = thisDistance; x_lowest = x_i; y_lowest = y_i; } } player->TeleportTo(GetMapId(), x_lowest, y_lowest, GetPositionZ(), GetOrientation(),TELE_TO_NOT_LEAVE_TRANSPORT | TELE_TO_NOT_LEAVE_COMBAT | TELE_TO_NOT_UNSUMMON_PET); } else { // fallback, will always work player->TeleportTo(GetMapId(), GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation(),TELE_TO_NOT_LEAVE_TRANSPORT | TELE_TO_NOT_LEAVE_COMBAT | TELE_TO_NOT_UNSUMMON_PET); } player->SetStandState(UNIT_STAND_STATE_SIT_LOW_CHAIR+info->chair.height); return; } //big gun, its a spell/aura case GAMEOBJECT_TYPE_GOOBER: //10 { GameObjectInfo const* info = GetGOInfo(); if(user->GetTypeId()==TYPEID_PLAYER) { Player* player = (Player*)user; // show page if(info->goober.pageId) { WorldPacket data(SMSG_GAMEOBJECT_PAGETEXT, 8); data << GetGUID(); player->GetSession()->SendPacket(&data); } // possible quest objective for active quests player->CastedCreatureOrGO(info->id, GetGUID(), 0); if (info->goober.eventId) sWorld.ScriptsStart(sEventScripts, info->goober.eventId, player, this); } // cast this spell later if provided spellId = info->goober.spellId; break; } case GAMEOBJECT_TYPE_CAMERA: //13 { GameObjectInfo const* info = GetGOInfo(); if(!info) return; if(user->GetTypeId()!=TYPEID_PLAYER) return; Player* player = (Player*)user; if (info->camera.cinematicId) player->SendCinematicStart(info->camera.cinematicId); if (info->camera.eventID) sWorld.ScriptsStart(sEventScripts, info->camera.eventID, player, this); return; } //fishing bobber case GAMEOBJECT_TYPE_FISHINGNODE: //17 { if(user->GetTypeId()!=TYPEID_PLAYER) return; Player* player = (Player*)user; if(player->GetGUID() != GetOwnerGUID()) return; switch(getLootState()) { case GO_READY: // ready for loot { // 1) skill must be >= base_zone_skill // 2) if skill == base_zone_skill => 5% chance // 3) chance is linear dependence from (base_zone_skill-skill) uint32 zone, subzone; GetZoneAndAreaId(zone,subzone); int32 zone_skill = sObjectMgr.GetFishingBaseSkillLevel( subzone ); if(!zone_skill) zone_skill = sObjectMgr.GetFishingBaseSkillLevel( zone ); //provide error, no fishable zone or area should be 0 if(!zone_skill) sLog.outErrorDb("Fishable areaId %u are not properly defined in `skill_fishing_base_level`.",subzone); int32 skill = player->GetSkillValue(SKILL_FISHING); int32 chance = skill - zone_skill + 5; int32 roll = irand(1,100); DEBUG_LOG("Fishing check (skill: %i zone min skill: %i chance %i roll: %i",skill,zone_skill,chance,roll); if(skill >= zone_skill && chance >= roll) { // prevent removing GO at spell cancel player->RemoveGameObject(this,false); SetOwnerGUID(player->GetGUID()); //fish catched player->UpdateFishingSkill(); //TODO: find reasonable value for fishing hole search GameObject* ok = LookupFishingHoleAround(20.0f + CONTACT_DISTANCE); if (ok) { player->SendLoot(ok->GetGUID(),LOOT_FISHINGHOLE); SetLootState(GO_JUST_DEACTIVATED); } else player->SendLoot(GetGUID(),LOOT_FISHING); } else { // fish escaped, can be deleted now SetLootState(GO_JUST_DEACTIVATED); WorldPacket data(SMSG_FISH_ESCAPED, 0); player->GetSession()->SendPacket(&data); } break; } case GO_JUST_DEACTIVATED: // nothing to do, will be deleted at next update break; default: { SetLootState(GO_JUST_DEACTIVATED); WorldPacket data(SMSG_FISH_NOT_HOOKED, 0); player->GetSession()->SendPacket(&data); break; } } player->FinishSpell(CURRENT_CHANNELED_SPELL); return; } case GAMEOBJECT_TYPE_SUMMONING_RITUAL: //18 { if(user->GetTypeId()!=TYPEID_PLAYER) return; Player* player = (Player*)user; Unit* caster = GetOwner(); GameObjectInfo const* info = GetGOInfo(); if( !caster || caster->GetTypeId()!=TYPEID_PLAYER ) return; // accept only use by player from same group for caster except caster itself if(((Player*)caster)==player || !((Player*)caster)->IsInSameRaidWith(player)) return; AddUniqueUse(player); // full amount unique participants including original summoner if(GetUniqueUseCount() < info->summoningRitual.reqParticipants) return; // in case summoning ritual caster is GO creator spellCaster = caster; if(!caster->GetCurrentSpell(CURRENT_CHANNELED_SPELL)) return; spellId = info->summoningRitual.spellId; // finish spell player->FinishSpell(CURRENT_CHANNELED_SPELL); // can be deleted now SetLootState(GO_JUST_DEACTIVATED); // go to end function to spell casting break; } case GAMEOBJECT_TYPE_SPELLCASTER: //22 { SetUInt32Value(GAMEOBJECT_FLAGS,2); GameObjectInfo const* info = GetGOInfo(); if(!info) return; if(info->spellcaster.partyOnly) { Unit* caster = GetOwner(); if( !caster || caster->GetTypeId()!=TYPEID_PLAYER ) return; if(user->GetTypeId()!=TYPEID_PLAYER || !((Player*)user)->IsInSameRaidWith((Player*)caster)) return; } spellId = info->spellcaster.spellId; AddUse(); break; } case GAMEOBJECT_TYPE_MEETINGSTONE: //23 { GameObjectInfo const* info = GetGOInfo(); if(user->GetTypeId()!=TYPEID_PLAYER) return; Player* player = (Player*)user; Player* targetPlayer = ObjectAccessor::FindPlayer(player->GetSelection()); // accept only use by player from same group for caster except caster itself if(!targetPlayer || targetPlayer == player || !targetPlayer->IsInSameGroupWith(player)) return; //required lvl checks! uint8 level = player->getLevel(); if (level < info->meetingstone.minLevel || level > info->meetingstone.maxLevel) return; level = targetPlayer->getLevel(); if (level < info->meetingstone.minLevel || level > info->meetingstone.maxLevel) return; spellId = 23598; break; } case GAMEOBJECT_TYPE_FLAGSTAND: // 24 { if(user->GetTypeId()!=TYPEID_PLAYER) return; Player* player = (Player*)user; if( player->CanUseBattleGroundObject() ) { // in battleground check BattleGround *bg = player->GetBattleGround(); if(!bg) return; // BG flag click // AB: // 15001 // 15002 // 15003 // 15004 // 15005 bg->EventPlayerClickedOnFlag(player, this); return; //we don;t need to delete flag ... it is despawned! } break; } case GAMEOBJECT_TYPE_FLAGDROP: // 26 { if(user->GetTypeId()!=TYPEID_PLAYER) return; Player* player = (Player*)user; if( player->CanUseBattleGroundObject() ) { // in battleground check BattleGround *bg = player->GetBattleGround(); if(!bg) return; // BG flag dropped // WS: // 179785 - Silverwing Flag // 179786 - Warsong Flag // EotS: // 184142 - Netherstorm Flag GameObjectInfo const* info = GetGOInfo(); if(info) { switch(info->id) { case 179785: // Silverwing Flag // check if it's correct bg if(bg->GetTypeID() == BATTLEGROUND_WS) bg->EventPlayerClickedOnFlag(player, this); break; case 179786: // Warsong Flag if(bg->GetTypeID() == BATTLEGROUND_WS) bg->EventPlayerClickedOnFlag(player, this); break; case 184142: // Netherstorm Flag if(bg->GetTypeID() == BATTLEGROUND_EY) bg->EventPlayerClickedOnFlag(player, this); break; } } //this cause to call return, all flags must be deleted here!! spellId = 0; Delete(); } break; } default: sLog.outDebug("Unknown Object Type %u", GetGoType()); break; } if(!spellId) return; SpellEntry const *spellInfo = sSpellStore.LookupEntry( spellId ); if(!spellInfo) { if(user->GetTypeId()!=TYPEID_PLAYER || !sOutdoorPvPMgr.HandleCustomSpell((Player*)user,spellId,this)) sLog.outError("WORLD: unknown spell id %u at use action for gameobject (Entry: %u GoType: %u )", spellId,GetEntry(),GetGoType()); else sLog.outDebug("WORLD: %u non-dbc spell was handled by OutdoorPvP", spellId); return; } Spell *spell = new Spell(spellCaster, spellInfo, false, GetGUID()); // spell target is user of GO SpellCastTargets targets; targets.setUnitTarget( user ); spell->prepare(&targets); }
int internal_degree_and_membership (double mixing_parameter, int overlapping_nodes, int max_mem_num, int num_nodes, deque<deque<int> > & member_matrix, bool excess, bool defect, deque<int> & degree_seq, deque<int> &num_seq, deque<int> &internal_degree_seq, bool fixed_range, int nmin, int nmax, double tau2) { if(num_nodes< overlapping_nodes) { cerr<<"\n***********************\nERROR: there are more overlapping nodes than nodes in the whole network! Please, decrease the former ones or increase the latter ones"<<endl; return -1; } // member_matrix.clear(); internal_degree_seq.clear(); deque<double> cumulative; // it assigns the internal degree to each node ------------------------------------------------------------------------- int max_degree_actual=0; // maximum internal degree for (int i=0; i<degree_seq.size(); i++) { double interno=(1-mixing_parameter)*degree_seq[i]; int int_interno=int(interno); if (ran4()<(interno-int_interno)) int_interno++; if (excess) { while ( ( double(int_interno)/degree_seq[i] < (1-mixing_parameter) ) && (int_interno<degree_seq[i]) ) int_interno++; } if (defect) { while ( ( double(int_interno)/degree_seq[i] > (1-mixing_parameter) ) && (int_interno>0) ) int_interno--; } internal_degree_seq.push_back(int_interno); if (int_interno>max_degree_actual) max_degree_actual=int_interno; } // it assigns the community size sequence ----------------------------------------------------------------------------- powerlaw(nmax, nmin, tau2, cumulative); if (num_seq.empty()) { int _num_=0; if (!fixed_range && (max_degree_actual+1)>nmin) { _num_=max_degree_actual+1; // this helps the assignment of the memberships (it assures that at least one module is big enough to host each node) num_seq.push_back(max_degree_actual+1); } while (true) { int nn=lower_bound(cumulative.begin(), cumulative.end(), ran4())-cumulative.begin()+nmin; if (nn+_num_<=num_nodes + overlapping_nodes * (max_mem_num-1) ) { num_seq.push_back(nn); _num_+=nn; } else break; } num_seq[min_element(num_seq.begin(), num_seq.end()) - num_seq.begin()]+=num_nodes + overlapping_nodes * (max_mem_num-1) - _num_; } //cout<<"num_seq"<<endl; //prints(num_seq); int ncom=num_seq.size(); //cout<<"\n----------------------------------------------------------"<<endl; /* cout<<"community sizes"<<endl; for (int i=0; i<num_seq.size(); i++) cout<<num_seq[i]<<" "; cout<<endl<<endl; //*/ /* deque <int> first; for (int i=0; i<ncom; i++) member_matrix.push_back(first); // it puts the overlapping_nodes inside cout<<ncom<<endl; for (int i=degree_seq.size() - overlapping_nodes; i<degree_seq.size(); i++) { cout<<i<<endl; set<int> members; int hh=0; while(members.size()<max_mem_num) { int random_module=irand(ncom-1); if(member_matrix[random_module].size()!=num_seq[random_module]) members.insert(random_module); hh++; if(hh>3*num_nodes) { cerr<<"it seems that the overlapping nodes need more communities that those I provided. Please increase the number of communities or decrease the number of overlapping nodes"<<endl; return -1; } } for (set<int>::iterator its=members.begin(); its!=members.end(); its++) member_matrix[*its].push_back(i); } // it decides the memberships for the not overlapping nodes int moment_module=0; for (int i=0; i<num_nodes - overlapping_nodes; i++) { while(member_matrix[moment_module].size()==num_seq[moment_module]) moment_module++; member_matrix[moment_module].push_back(i); } */ // I have to assign the degree to the nodes deque<int> member_numbers; for(int i=0; i<overlapping_nodes; i++) member_numbers.push_back(max_mem_num); for(int i=overlapping_nodes; i<degree_seq.size(); i++) member_numbers.push_back(1); //prints(member_numbers); //prints(num_seq); if(build_bipartite_network(member_matrix, member_numbers, num_seq)==-1) { cerr<<"it seems that the overlapping nodes need more communities that those I provided. Please increase the number of communities or decrease the number of overlapping nodes"<<endl; return -1; } //printm(member_matrix); //cout<<"degree_seq"<<endl; //prints(degree_seq); //cout<<"internal_degree_seq"<<endl; //prints(internal_degree_seq); deque<int> available; for (int i=0; i<num_nodes; i++) available.push_back(0); for (int i=0; i<member_matrix.size(); i++) { for (int j=0; j<member_matrix[i].size(); j++) available[member_matrix[i][j]]+=member_matrix[i].size()-1; } //cout<<"available"<<endl; //prints(available); deque<int> available_nodes; for (int i=0; i<num_nodes; i++) available_nodes.push_back(i); deque<int> map_nodes; // in the position i there is the new name of the node i for (int i=0; i<num_nodes; i++) map_nodes.push_back(0); for (int i=degree_seq.size()-1; i>=0; i--) { int & degree_here=internal_degree_seq[i]; int try_this = irand(available_nodes.size()-1); int kr=0; while (internal_degree_seq[i] > available[available_nodes[try_this]]) { kr++; try_this = irand(available_nodes.size()-1); if(kr==3*num_nodes) { if(change_community_size(num_seq)==-1) { cerr<<"\n***********************\nERROR: this program needs more than one community to work fine"<<endl; return -1; } cout<<"it took too long to decide the memberships; I will try to change the community sizes"<<endl; cout<<"new community sizes"<<endl; for (int i=0; i<num_seq.size(); i++) cout<<num_seq[i]<<" "; cout<<endl<<endl; return (internal_degree_and_membership(mixing_parameter, overlapping_nodes, max_mem_num, num_nodes, member_matrix, excess, defect, degree_seq, num_seq, internal_degree_seq, fixed_range, nmin, nmax, tau2)); } } map_nodes[available_nodes[try_this]]=i; available_nodes[try_this]=available_nodes[available_nodes.size()-1]; available_nodes.pop_back(); } for (int i=0; i<member_matrix.size(); i++) { for (int j=0; j<member_matrix[i].size(); j++) member_matrix[i][j]=map_nodes[member_matrix[i][j]]; } for (int i=0; i<member_matrix.size(); i++) sort(member_matrix[i].begin(), member_matrix[i].end()); return 0; }
void UpdateAI(uint32 const diff) { if (!UpdateVictim()) return; events.Update(diff); if (me->HasUnitState(UNIT_STAT_CASTING)) return; while (uint32 eventId = events.ExecuteEvent()) { switch(eventId) { case EVENT_BERSERK: DoScriptText(SAY_BRUNDIR_BERSERK, me); DoCast(SPELL_BERSERK); events.CancelEvent(EVENT_BERSERK); break; case EVENT_CHAIN_LIGHTNING: if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0)) DoCast(target, SPELL_CHAIN_LIGHTNING); events.ScheduleEvent(EVENT_CHAIN_LIGHTNING, urand(7000, 10000)); break; case EVENT_OVERLOAD: me->MonsterTextEmote(EMOTE_OVERLOAD, 0, true); DoScriptText(SAY_BRUNDIR_SPECIAL, me); DoCast(SPELL_OVERLOAD); events.ScheduleEvent(EVENT_OVERLOAD, urand(60000, 120000)); break; case EVENT_LIGHTNING_WHIRL: DoCast(SPELL_LIGHTNING_WHIRL); events.ScheduleEvent(EVENT_LIGHTNING_WHIRL, urand(15000, 20000)); break; case EVENT_LIGHTNING_TENDRILS: DoScriptText(SAY_BRUNDIR_FLIGHT, me); DoCast(SPELL_LIGHTNING_TENDRILS); me->AttackStop(); me->AddUnitMovementFlag(MOVEMENTFLAG_LEVITATING); DoCast(SPELL_LIGHTNING_TENDRILS_SELF_VISUAL); me->GetMotionMaster()->Initialize(); me->GetMotionMaster()->MovePoint(0, me->GetPositionX(), me->GetPositionY(), FINAL_FLIGHT_Z); events.DelayEvents(35000); events.ScheduleEvent(EVENT_FLIGHT, 2500); events.ScheduleEvent(EVENT_ENDFLIGHT, 32500); events.ScheduleEvent(EVENT_LIGHTNING_TENDRILS, 90000); break; case EVENT_FLIGHT: if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0)) me->GetMotionMaster()->MovePoint(0, target->GetPositionX(), target->GetPositionY(), FINAL_FLIGHT_Z); events.ScheduleEvent(EVENT_FLIGHT, 6000); break; case EVENT_ENDFLIGHT: me->GetMotionMaster()->Initialize(); me->GetMotionMaster()->MovePoint(0, 1586.920166f, 119.848984f, FINAL_FLIGHT_Z); events.CancelEvent(EVENT_FLIGHT); events.CancelEvent(EVENT_ENDFLIGHT); events.ScheduleEvent(EVENT_LAND, 4000); break; case EVENT_LAND: me->GetMotionMaster()->Initialize(); me->GetMotionMaster()->MovePoint(0, me->GetPositionX(), me->GetPositionY(), FLOOR_Z); events.CancelEvent(EVENT_LAND); events.ScheduleEvent(EVENT_GROUND, 2500); break; case EVENT_GROUND: me->RemoveUnitMovementFlag(MOVEMENTFLAG_LEVITATING); me->RemoveAurasDueToSpell(SPELL_LIGHTNING_TENDRILS); me->RemoveAurasDueToSpell(SPELL_LIGHTNING_TENDRILS_SELF_VISUAL); DoStartMovement(me->getVictim()); events.CancelEvent(EVENT_GROUND); break; case EVENT_MOVE_POSITION: if (me->IsWithinMeleeRange(me->getVictim())) { float x = float(irand(-25, 25)); float y = float(irand(-25, 25)); me->GetMotionMaster()->MovePoint(0, me->GetPositionX() + x, me->GetPositionY() + y, FLOOR_Z); // Prevention to go outside the room or into the walls if (Creature* trigger = me->FindNearestCreature(NPC_WORLD_TRIGGER, 100.0f, true)) if (me->GetDistance(trigger) >= 50.0f) me->GetMotionMaster()->MovePoint(0, trigger->GetPositionX(), trigger->GetPositionY(), FLOOR_Z); } events.ScheduleEvent(EVENT_MOVE_POSITION, urand(7500, 10000)); break; default: break; } } DoMeleeAttackIfReady(); }
int build_subgraph(deque<set<int> > & E, const deque<int> & nodes, const deque<int> & degrees) { /* cout<<"nodes"<<endl; prints(nodes); cout<<"degrees"<<endl; prints(degrees); */ if(degrees.size()<3) { cerr<<"it seems that some communities should have only 2 nodes! This does not make much sense (in my opinion) Please change some parameters!"<<endl; return -1; } // this function is to build a network with the labels stored in nodes and the degree seq in degrees (correspondence is based on the vectorial index) // the only complication is that you don't want the nodes to have neighbors they already have // labels will be placed in the end deque<set<int> > en; // this is the E of the subgraph { set<int> first; for(int i=0; i<nodes.size(); i++) en.push_back(first); } multimap <int, int> degree_node; for(int i=0; i<degrees.size(); i++) degree_node.insert(degree_node.end(), make_pair(degrees[i], i)); int var=0; while (degree_node.size() > 0) { multimap<int, int>::iterator itlast= degree_node.end(); itlast--; multimap <int, int>::iterator itit= itlast; deque <multimap<int, int>::iterator> erasenda; int inserted=0; for (int i=0; i<itlast->first; i++) { if(itit!=degree_node.begin()) { itit--; en[itlast->second].insert(itit->second); en[itit->second].insert(itlast->second); inserted++; erasenda.push_back(itit); } else break; } for (int i=0; i<erasenda.size(); i++) { if(erasenda[i]->first>1) degree_node.insert(make_pair(erasenda[i]->first - 1, erasenda[i]->second)); degree_node.erase(erasenda[i]); } var+= itlast->first - inserted; degree_node.erase(itlast); } // this is to randomize the subgraph ------------------------------------------------------------------- for(int node_a=0; node_a<degrees.size(); node_a++) for(int krm=0; krm<en[node_a].size(); krm++) { int random_mate=irand(degrees.size()-1); while (random_mate==node_a) random_mate=irand(degrees.size()-1); if (en[node_a].insert(random_mate).second) { deque <int> out_nodes; for (set<int>::iterator it_est=en[node_a].begin(); it_est!=en[node_a].end(); it_est++) if ((*it_est)!=random_mate) out_nodes.push_back(*it_est); int old_node=out_nodes[irand(out_nodes.size()-1)]; en[node_a].erase(old_node); en[random_mate].insert(node_a); en[old_node].erase(node_a); deque <int> not_common; for (set<int>::iterator it_est=en[random_mate].begin(); it_est!=en[random_mate].end(); it_est++) if ((old_node!=(*it_est)) && (en[old_node].find(*it_est)==en[old_node].end())) not_common.push_back(*it_est); int node_h=not_common[irand(not_common.size()-1)]; en[random_mate].erase(node_h); en[node_h].erase(random_mate); en[node_h].insert(old_node); en[old_node].insert(node_h); } } // now I try to insert the new links into the already done network. If some multiple links come out, I try to rewire them deque < pair<int, int> > multiple_edge; for (int i=0; i<en.size(); i++) { for(set<int>::iterator its=en[i].begin(); its!=en[i].end(); its++) if(i<*its ) { bool already = !(E[nodes[i]].insert(nodes[*its]).second); // true is the insertion didn't take place if (already) multiple_edge.push_back(make_pair(nodes[i], nodes[*its])); else E[nodes[*its]].insert(nodes[i]); } } //cout<<"multiples "<<multiple_edge.size()<<endl; for (int i=0; i<multiple_edge.size(); i++) { int &a = multiple_edge[i].first; int &b = multiple_edge[i].second; // now, I'll try to rewire this multiple link among the nodes stored in nodes. int stopper_ml=0; while (true) { stopper_ml++; int random_mate=nodes[irand(degrees.size()-1)]; while (random_mate==a || random_mate==b) random_mate=nodes[irand(degrees.size()-1)]; if(E[a].find(random_mate)==E[a].end()) { deque <int> not_common; for (set<int>::iterator it_est=E[random_mate].begin(); it_est!=E[random_mate].end(); it_est++) if ((b!=(*it_est)) && (E[b].find(*it_est)==E[b].end()) && (binary_search(nodes.begin(), nodes.end(), *it_est))) not_common.push_back(*it_est); if(not_common.size()>0) { int node_h=not_common[irand(not_common.size()-1)]; E[random_mate].insert(a); E[random_mate].erase(node_h); E[node_h].erase(random_mate); E[node_h].insert(b); E[b].insert(node_h); E[a].insert(random_mate); break; } } if(stopper_ml==2*E.size()) { cout<<"sorry, I need to change the degree distribution a little bit (one less link)"<<endl; break; } } } return 0; }
void WorldSession::DoLootRelease( uint64 lguid ) { Player *player = GetPlayer(); Loot *loot; player->SetLootGUID(0); player->SendLootRelease(lguid); player->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_LOOTING); if(!player->IsInWorld()) return; if (IS_GAMEOBJECT_GUID(lguid)) { GameObject *go = GetPlayer()->GetMap()->GetGameObject(lguid); // not check distance for GO in case owned GO (fishing bobber case, for example) or Fishing hole GO if (!go || ((go->GetOwnerGUID() != _player->GetGUID() && go->GetGoType() != GAMEOBJECT_TYPE_FISHINGHOLE) && !go->IsWithinDistInMap(_player,INTERACTION_DISTANCE))) return; loot = &go->loot; if (go->GetGoType() == GAMEOBJECT_TYPE_DOOR) { // locked doors are opened with spelleffect openlock, prevent remove its as looted go->UseDoorOrButton(); } else if (loot->isLooted() || go->GetGoType() == GAMEOBJECT_TYPE_FISHINGNODE) { // GO is mineral vein? so it is not removed after its looted if(go->GetGoType() == GAMEOBJECT_TYPE_CHEST) { uint32 go_min = go->GetGOInfo()->chest.minSuccessOpens; uint32 go_max = go->GetGOInfo()->chest.maxSuccessOpens; // only vein pass this check if(go_min != 0 && go_max > go_min) { float amount_rate = sWorld.getRate(RATE_MINING_AMOUNT); float min_amount = go_min*amount_rate; float max_amount = go_max*amount_rate; go->AddUse(); float uses = float(go->GetUseCount()); if(uses < max_amount) { if(uses >= min_amount) { float chance_rate = sWorld.getRate(RATE_MINING_NEXT); int32 ReqValue = 175; LockEntry const *lockInfo = sLockStore.LookupEntry(go->GetGOInfo()->chest.lockId); if(lockInfo) ReqValue = lockInfo->Skill[0]; float skill = float(player->GetSkillValue(SKILL_MINING))/(ReqValue+25); double chance = pow(0.8*chance_rate,4*(1/double(max_amount))*double(uses)); if(roll_chance_f(100*chance+skill)) { go->SetLootState(GO_READY); } else // not have more uses go->SetLootState(GO_JUST_DEACTIVATED); } else // 100% chance until min uses go->SetLootState(GO_READY); } else // max uses already go->SetLootState(GO_JUST_DEACTIVATED); } else // not vein go->SetLootState(GO_JUST_DEACTIVATED); } else if (go->GetGoType() == GAMEOBJECT_TYPE_FISHINGHOLE) { // The fishing hole used once more go->AddUse(); // if the max usage is reached, will be despawned in next tick if (go->GetUseCount()>=irand(go->GetGOInfo()->fishinghole.minSuccessOpens,go->GetGOInfo()->fishinghole.maxSuccessOpens)) { go->SetLootState(GO_JUST_DEACTIVATED); } else go->SetLootState(GO_READY); } else // not chest (or vein/herb/etc) go->SetLootState(GO_JUST_DEACTIVATED); loot->clear(); } else // not fully looted object go->SetLootState(GO_ACTIVATED); } else if (IS_CORPSE_GUID(lguid)) // ONLY remove insignia at BG { Corpse *corpse = ObjectAccessor::GetCorpse(*player, lguid); if (!corpse || !corpse->IsWithinDistInMap(_player,INTERACTION_DISTANCE) ) return; loot = &corpse->loot; if (loot->isLooted()) { loot->clear(); corpse->RemoveFlag(CORPSE_FIELD_DYNAMIC_FLAGS, CORPSE_DYNFLAG_LOOTABLE); } } else if (IS_ITEM_GUID(lguid)) { Item *pItem = player->GetItemByGuid(lguid ); if(!pItem) return; ItemPrototype const* proto = pItem->GetProto(); // destroy only 5 items from stack in case prospecting and milling if( (proto->BagFamily & (BAG_FAMILY_MASK_MINING_SUPP|BAG_FAMILY_MASK_HERBS)) && proto->Class == ITEM_CLASS_TRADE_GOODS) { pItem->m_lootGenerated = false; pItem->loot.clear(); uint32 count = pItem->GetCount(); // >=5 checked in spell code, but will work for cheating cases also with removing from another stacks. if(count > 5) count = 5; player->DestroyItemCount(pItem, count, true); } else // FIXME: item don't must be deleted in case not fully looted state. But this pre-request implement loot saving in DB at item save. Or checting possible. player->DestroyItem( pItem->GetBagSlot(),pItem->GetSlot(), true); return; // item can be looted only single player } else { Creature* pCreature = GetPlayer()->GetMap()->GetCreature(lguid); bool ok_loot = pCreature && pCreature->isAlive() == (player->getClass()==CLASS_ROGUE && pCreature->lootForPickPocketed); if ( !ok_loot || !pCreature->IsWithinDistInMap(_player,INTERACTION_DISTANCE) ) return; loot = &pCreature->loot; // update next looter if(Player *recipient = pCreature->GetLootRecipient()) if(Group* group = recipient->GetGroup()) if (group->GetLooterGuid() == player->GetGUID()) group->UpdateLooterGuid(pCreature); if (loot->isLooted()) { // skip pickpocketing loot for speed, skinning timer redunction is no-op in fact if(!pCreature->isAlive()) pCreature->AllLootRemovedFromCorpse(); pCreature->RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE); loot->clear(); } } //Player is not looking at loot list, he doesn't need to see updates on the loot list loot->RemoveLooter(player->GetGUID()); }
int build_subgraphs(deque<set<int> > & E, const deque<deque<int> > & member_matrix, deque<deque<int> > & member_list, deque<deque<int> > & link_list, const deque<int> & internal_degree_seq, const deque<int> & degree_seq, const bool excess, const bool defect) { E.clear(); member_list.clear(); link_list.clear(); int num_nodes=degree_seq.size(); //printm(member_matrix); { deque<int> first; for (int i=0; i<num_nodes; i++) member_list.push_back(first); } for (int i=0; i<member_matrix.size(); i++) for (int j=0; j<member_matrix[i].size(); j++) member_list[member_matrix[i][j]].push_back(i); //printm(member_list); for (int i=0; i<member_list.size(); i++) { deque<int> liin; for (int j=0; j<member_list[i].size(); j++) { compute_internal_degree_per_node(internal_degree_seq[i], member_list[i].size(), liin); liin.push_back(degree_seq[i] - internal_degree_seq[i]); } link_list.push_back(liin); } // now there is the check for the even node (it means that the internal degree of each group has to be even and we want to assure that, otherwise the degree_seq has to change) ---------------------------- // ------------------------ this is done to check if the sum of the internal degree is an even number. if not, the program will change it in such a way to assure that. for (int i=0; i<member_matrix.size(); i++) { int internal_cluster=0; for (int j=0; j<member_matrix[i].size(); j++) { int right_index= lower_bound(member_list[member_matrix[i][j]].begin(), member_list[member_matrix[i][j]].end(), i) - member_list[member_matrix[i][j]].begin(); internal_cluster+=link_list[member_matrix[i][j]][right_index]; } if(internal_cluster % 2 != 0) { bool default_flag=false; if(excess) default_flag=true; else if(defect) default_flag=false; else if (ran4()>0.5) default_flag=true; if(default_flag) { // if this does not work in a reasonable time the degree sequence will be changed for (int j=0; j<member_matrix[i].size(); j++) { int random_mate=member_matrix[i][irand(member_matrix[i].size()-1)]; int right_index= lower_bound(member_list[random_mate].begin(), member_list[random_mate].end(), i) - member_list[random_mate].begin(); if ((link_list[random_mate][right_index]<member_matrix[i].size()-1) && (link_list[random_mate][link_list[random_mate].size()-1] > 0 )) { link_list[random_mate][right_index]++; link_list[random_mate][link_list[random_mate].size()-1]--; break; } } } else { for (int j=0; j<member_matrix[i].size(); j++) { int random_mate=member_matrix[i][irand(member_matrix[i].size()-1)]; int right_index= lower_bound(member_list[random_mate].begin(), member_list[random_mate].end(), i) - member_list[random_mate].begin(); if (link_list[random_mate][right_index] > 0 ) { link_list[random_mate][right_index]--; link_list[random_mate][link_list[random_mate].size()-1]++; break; } } } } } // ------------------------ this is done to check if the sum of the internal degree is an even number. if not, the program will change it in such a way to assure that. { set<int> first; for(int i=0; i<num_nodes; i++) E.push_back(first); } for (int i=0; i<member_matrix.size(); i++) { deque<int> internal_degree_i; for (int j=0; j<member_matrix[i].size(); j++) { int right_index= lower_bound(member_list[member_matrix[i][j]].begin(), member_list[member_matrix[i][j]].end(), i) - member_list[member_matrix[i][j]].begin(); internal_degree_i.push_back(link_list[member_matrix[i][j]][right_index]); } if(build_subgraph(E, member_matrix[i], internal_degree_i)==-1) return -1; } return 0; }
void SetData(uint32 uiType, uint32 uiData) { if (uiType == DATA_GONG_WAVES) { uiGongWaves = uiData; switch (uiGongWaves) { case 9: case 14: if (GameObject* go = instance->GetGameObject(uiGongGUID)) go->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); break; case 1: case 10: case 16: { GameObject* go = instance->GetGameObject(uiGongGUID); if (!go) return; go->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE); uint32 uiCreature = 0; uint8 uiSummonTimes = 0; switch (uiGongWaves) { case 1: uiCreature = CREATURE_TOMB_FIEND; uiSummonTimes = 7; break; case 10: uiCreature = CREATURE_TOMB_REAVER; uiSummonTimes = 3; break; case 16: uiCreature = CREATURE_TUTEN_KASH; break; default: break; } if (Creature* creature = go->SummonCreature(uiCreature, 2502.635f, 844.140f, 46.896f, 0.633f)) { if (uiGongWaves == 10 || uiGongWaves == 1) { for (uint8 i = 0; i < uiSummonTimes; ++i) { if (Creature* summon = go->SummonCreature(uiCreature, 2502.635f + float(irand(-5, 5)), 844.140f + float(irand(-5, 5)), 46.896f, 0.633f)) summon->GetMotionMaster()->MovePoint(0, 2533.479f + float(irand(-5, 5)), 870.020f + float(irand(-5, 5)), 47.678f); } } creature->GetMotionMaster()->MovePoint(0, 2533.479f + float(irand(-5, 5)), 870.020f + float(irand(-5, 5)), 47.678f); } break; } default: break; } } if (uiType == BOSS_TUTEN_KASH) { m_auiEncounter[0] = uiData; if (uiData == DONE) SaveToDB(); } }
void UpdateEscortAI(const uint32 uiDiff) override { if (HasEscortState(STATE_ESCORT_PAUSED)) { if (m_uiRitualTimer < uiDiff) { switch (m_uiRitualPhase) { case 0: DoCastSpellIfCan(m_creature, SPELL_IDOL_SHUTDOWN); m_uiRitualTimer = 1000; break; case 1: DoSummonSpawner(irand(1, 3)); m_uiRitualTimer = 39000; break; case 2: DoSummonSpawner(irand(1, 3)); m_uiRitualTimer = 20000; break; case 3: DoScriptText(SAY_BELNISTRASZ_3_MIN, m_creature, m_creature); m_uiRitualTimer = 20000; break; case 4: DoSummonSpawner(irand(1, 3)); m_uiRitualTimer = 40000; break; case 5: DoSummonSpawner(irand(1, 3)); DoScriptText(SAY_BELNISTRASZ_2_MIN, m_creature, m_creature); m_uiRitualTimer = 40000; break; case 6: DoSummonSpawner(irand(1, 3)); m_uiRitualTimer = 20000; break; case 7: DoScriptText(SAY_BELNISTRASZ_1_MIN, m_creature, m_creature); m_uiRitualTimer = 40000; break; case 8: DoSummonSpawner(irand(1, 3)); m_uiRitualTimer = 20000; break; case 9: DoScriptText(SAY_BELNISTRASZ_FINISH, m_creature, m_creature); m_uiRitualTimer = 3000; break; case 10: { if (Player* pPlayer = GetPlayerForEscort()) { pPlayer->GroupEventHappens(QUEST_EXTINGUISHING_THE_IDOL, m_creature); if (GameObject* pGo = GetClosestGameObjectWithEntry(m_creature, GO_BELNISTRASZ_BRAZIER, 10.0f)) { if (!pGo->isSpawned()) { pGo->SetRespawnTime(HOUR * IN_MILLISECONDS); pGo->Refresh(); } } } m_creature->RemoveAurasDueToSpell(SPELL_IDOL_SHUTDOWN); SetEscortPaused(false); break; } } ++m_uiRitualPhase; } else m_uiRitualTimer -= uiDiff; return; } if (!m_creature->SelectHostileTarget() || !m_creature->getVictim()) return; if (m_uiFireballTimer < uiDiff) { DoCastSpellIfCan(m_creature->getVictim(), SPELL_FIREBALL); m_uiFireballTimer = urand(2000, 3000); } else m_uiFireballTimer -= uiDiff; if (m_uiFrostNovaTimer < uiDiff) { DoCastSpellIfCan(m_creature->getVictim(), SPELL_FROST_NOVA); m_uiFrostNovaTimer = urand(10000, 15000); } else m_uiFrostNovaTimer -= uiDiff; DoMeleeAttackIfReady(); }
void SummonHounds(Unit* pVictim) { if (Creature* Hound = DoSpawnCreature(19207, irand(-9,9), irand(-9,9), 0, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 300000)) Hound->AI()->AttackStart(pVictim); }
void SummonIllusions(Unit* victim) { if (Creature* Illusion = DoSpawnCreature(11439, irand(-9, 9), irand(-9, 9), 0, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 60000)) Illusion->AI()->AttackStart(victim); }
void SummonAdds(Unit* victim) { if (Creature *SummonedAdd = DoSpawnCreature(8901, float(irand(-14,14)), float(irand(-14,14)), 0, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 120000)) SummonedAdd->AI()->AttackStart(victim); }
main() { time_t seed1,seed2; char ctt[300]; PFC pfc(AES_SECURITY); // initialise pairing-friendly curve miracl* mip=get_mip(); Big order=pfc.order(); // print the number of points on the curve mip->IOBASE=16; ctt<<order; printf("Order: %s\n",ctt); mip->IOBASE=256; time(&seed1); irand((long)seed1); /* G1 aaa1,bb1; G2 aaa2, bb2; pfc.random(aaa1); pfc.hash_and_map(aaa1,(char *) "pippo"); pfc.random(bb1); pfc.hash_and_map(bb1,(char *) "pippo"); if (aaa1==bb1) printf("Equal\n"); else printf("Different\n"); pfc.random(aaa2); pfc.hash_and_map(aaa2,(char *) "xypippo"); pfc.random(bb2); pfc.hash_and_map(bb2,(char *) "xypippo"); if (aaa2==bb2) printf("Equal\n"); else printf("Different\n"); pfc.random(aaa1); pfc.random(aaa2); GT aaaT=pfc.pairing(aaa2,aaa1); char iv[16]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; char buff[32]={ 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07, 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17, 0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27, 0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,}; aes context,context1; Big KeyB=pfc.hash_to_aes_key(aaaT); char *KeyC; KeyC=(char *)(&KeyB); aes_init(&context,MR_CBC,16,KeyC,iv); aes_encrypt(&context,buff); KeyB=pfc.hash_to_aes_key(aaaT); KeyC=(char *)(&KeyB); aes_init(&context1,MR_CBC,16,KeyC,iv); aes_decrypt(&context1,buff); for(int i=0;i<32;i++){ if (i%8==0) printf("\n"); printf("%02x",buff[i]); } printf("\n"); */ int n=3; cout << "n=" << n << " (" << SizeOfTable << ")"<< endl; Ipdb a1; a1.GenPar3(&pfc,mip); time(&seed2); /* printf("m=%d ell=%d\n",a1.m,a1.ell); cout << "Gen Param: " << seed2-seed1 << endl; time(&seed1); EncryptedRow *EncryptedTable[SizeOfTable]; char **ROW=new char*[n]; for(int i=0;i<n;i++) ROW[i]=new char[16]; memcpy(ROW[0],"123456789abcdef",16); memcpy(ROW[1],"23456789abcdef1",16); memcpy(ROW[2],"3456789abcdef12",16); memcpy(ROW[3],"456789abcdef123",16); for(int k=0;k<SizeOfTable;k++){ EncryptedTable[k]=a1.EncRow(ROW); } time(&seed2); cout << "Enc Row : " << seed2-seed1 << endl; time(&seed1); int Cell=0; char *CQuery[n]; for(int i=0;i<n;i++){ CQuery[i]=new char[16]; memcpy(CQuery[i],ROW[i],16); } CQuery[Cell]=(char *)NULL; QueryKey *QQ=a1.QueryKeyGen(CQuery,Cell); time(&seed2); cout << "Query Gen: " << seed2-seed1 << endl; */ //printf("Checking the subencryption of length 3\n"); //IpdbCT *SubCT=EncryptedTable[0]->ek[1]; //IpdbKey *SubKey=QQ->Key[1]; //GT tmpT=a1.Dec(*SubCT,*SubKey); //if (a1.partial1==tmpT) printf("Equal\n"); else printf("Different\n"); G1 tmpG1; a1.pfc->random(tmpG1); GT M=a1.pfc->pairing(a1.g2,tmpG1); Big X[3]; X[0]=0; X[1]=0; X[2]=0; Big s1,s2,s3,s4; a1.pfc->random(s1); a1.pfc->random(s2); a1.pfc->random(s3); a1.pfc->random(s4); IpdbCT *CT3=a1.Enc(M,X,3,0,s1,s2,s3,s4); Big Y[3]; Y[0]=0; Y[1]=0; Y[2]=0; Big lambda1,lambda2; a1.pfc->random(lambda1); a1.pfc->random(lambda2); IpdbKey *Key3=a1.KeyGen(Y,3,0,lambda1,lambda2); GT Res=a1.pfc->pairing(Key3->KA,CT3->A); Res=Res*a1.pfc->pairing(Key3->KB,CT3->B); for(int i=0;i<3;i++){ Res=Res*a1.pfc->pairing(Key3->K1[i],CT3->C1[i]); Res=Res*a1.pfc->pairing(Key3->K2[i],CT3->C2[i]); Res=Res*a1.pfc->pairing(Key3->K3[i],CT3->C3[i]); Res=Res*a1.pfc->pairing(Key3->K4[i],CT3->C4[i]); } GT M88=CT3->C/Res; if (M==M88) printf("Equal\n"); else printf("Different\n"); /* time(&seed1); for(int k=0;k<SizeOfTable;k++){ char *MM=a1.DecRow(*(EncryptedTable[k]),*QQ,Cell); //printf("Decrypted message: %s\n",MM); } time(&seed2); //cout << "Dec : " << seed2-seed1 << endl; */ }
void SummonMinions(Unit* victim) { if (Creature* SummonedMinion = DoSpawnCreature(16119, float(irand(-7, 7)), float(irand(-7, 7)), 0, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 120000)) SummonedMinion->AI()->AttackStart(victim); }
int main() { int promptr; epoint *PB; big A,B,p,a,b,pa,pb,key; ebrick binst; miracl instance; /* create miracl workspace on the stack */ /* Specify base 16 here so that HEX can be read in directly without a base-change */ miracl *mip=mirsys(&instance,WORDS*HEXDIGS,16); /* size of bigs is fixed */ char mem_big[MR_BIG_RESERVE(8)]; /* we need 8 bigs... */ char mem_ecp[MR_ECP_RESERVE(1)]; /* ..and 1 elliptic curve points */ memset(mem_big, 0, MR_BIG_RESERVE(8)); /* clear the memory */ memset(mem_ecp, 0, MR_ECP_RESERVE(1)); A=mirvar_mem(mip, mem_big, 0); /* Initialise big numbers */ B=mirvar_mem(mip, mem_big, 1); pa=mirvar_mem(mip, mem_big, 2); pb=mirvar_mem(mip, mem_big, 3); key=mirvar_mem(mip, mem_big, 4); a=mirvar_mem(mip, mem_big, 5); b=mirvar_mem(mip, mem_big, 6); p=mirvar_mem(mip, mem_big, 7); PB=epoint_init_mem(mip, mem_ecp, 0); /* initialise Elliptic Curve points */ irand(mip, 3L); /* change parameter for different random numbers */ promptr=0; init_big_from_rom(p,WORDS,rom,WORDS*5,&promptr); /* Read in prime modulus p from ROM */ init_big_from_rom(B,WORDS,rom,WORDS*5,&promptr); /* Read in curve parameter B from ROM */ /* don't need q or G(x,y) (we have precomputed table from it) */ convert(mip,-3,A); /* set A=-3 */ /* Create precomputation instance from precomputed table in ROM */ ebrick_init(&binst,prom,A,B,p,WINDOW,CURVE_BITS); /* offline calculations */ bigbits(mip,CURVE_BITS,a); /* A's random number */ mul_brick(mip,&binst,a,pa,pa); /* a*G =(pa,ya) */ bigbits(mip,CURVE_BITS,b); /* B's random number */ mul_brick(mip,&binst,b,pb,pb); /* b*G =(pb,yb) */ /* swap X values of point */ /* online calculations */ ecurve_init(mip,A,B,p,MR_PROJECTIVE); epoint_set(mip,pb,pb,0,PB); /* decompress PB */ ecurve_mult(mip,a,PB,PB); epoint_get(mip,PB,key,key); /* since internal base is HEX, can use otnum instead of cotnum - avoiding a base change */ #ifndef MR_NO_STANDARD_IO printf("Alice's Key= "); otnum(mip,key,stdout); #endif epoint_set(mip,pa,pa,0,PB); /* decompress PA */ ecurve_mult(mip,b,PB,PB); epoint_get(mip,PB,key,key); #ifndef MR_NO_STANDARD_IO printf("Bob's Key= "); otnum(mip,key,stdout); #endif /* clear the memory */ memset(mem_big, 0, MR_BIG_RESERVE(8)); memset(mem_ecp, 0, MR_ECP_RESERVE(1)); return 0; }
void UpdateAI(const uint32 diff) { if (!UpdateVictim()) return; if (StormCount) { Unit *pTarget = Unit::GetUnit(*me, CloudGUID); if (!pTarget || !pTarget->isAlive()) { EnterEvadeMode(); return; } else if (Unit* Cyclone = Unit::GetUnit(*me, CycloneGUID)) Cyclone->CastSpell(pTarget, 25160, true); // keep casting or... if (StormSequenceTimer <= diff) HandleStormSequence(pTarget); else StormSequenceTimer -= diff; return; } if (Enrage_Timer <= diff) { me->MonsterYell(SAY_ONENRAGE, LANG_UNIVERSAL, NULL); DoPlaySoundToSet(me, SOUND_ONENRAGE); DoCast(me, SPELL_BERSERK, true); Enrage_Timer = 600000; } else Enrage_Timer -= diff; if (StaticDisruption_Timer <= diff) { Unit *pTarget = SelectUnit(SELECT_TARGET_RANDOM, 1); if (!pTarget) pTarget = me->getVictim(); TargetGUID = pTarget->GetGUID(); DoCast(pTarget, SPELL_STATIC_DISRUPTION, false); me->SetInFront(me->getVictim()); StaticDisruption_Timer = (10+rand()%8)*1000; // < 20s /*if (float dist = me->IsWithinDist3d(pTarget->GetPositionX(), pTarget->GetPositionY(), pTarget->GetPositionZ(), 5.0f) dist = 5.0f; SDisruptAOEVisual_Timer = 1000 + floor(dist / 30 * 1000.0f);*/ } else StaticDisruption_Timer -= diff; if (GustOfWind_Timer <= diff) { Unit *pTarget = SelectUnit(SELECT_TARGET_RANDOM, 1); if (!pTarget) pTarget = me->getVictim(); DoCast(pTarget, SPELL_GUST_OF_WIND); GustOfWind_Timer = (20+rand()%10)*1000; //20 to 30 seconds(bosskillers) } else GustOfWind_Timer -= diff; if (CallLighting_Timer <= diff) { DoCast(me->getVictim(), SPELL_CALL_LIGHTNING); CallLighting_Timer = (12 + rand()%5)*1000; //totaly random timer. can't find any info on this } else CallLighting_Timer -= diff; if (!isRaining && ElectricalStorm_Timer < uint32(8000 + rand() % 5000)) { SetWeather(WEATHER_STATE_HEAVY_RAIN, 0.9999f); isRaining = true; } if (ElectricalStorm_Timer <= diff) { Unit *pTarget = SelectTarget(SELECT_TARGET_RANDOM, 0, 50, true); if (!pTarget) { EnterEvadeMode(); return; } pTarget->CastSpell(pTarget, 44007, true);//cloud visual DoCast(pTarget, SPELL_ELECTRICAL_STORM, false);//storm cyclon + visual float x,y,z; pTarget->GetPosition(x,y,z); if (pTarget) { pTarget->SetUnitMovementFlags(MOVEMENTFLAG_LEVITATING); pTarget->SendMonsterMove(x,y,me->GetPositionZ()+15,0); } Unit *Cloud = me->SummonTrigger(x, y, me->GetPositionZ()+16, 0, 15000); if (Cloud) { CloudGUID = Cloud->GetGUID(); Cloud->SetUnitMovementFlags(MOVEMENTFLAG_LEVITATING); Cloud->StopMoving(); Cloud->SetFloatValue(OBJECT_FIELD_SCALE_X, 1.0f); Cloud->setFaction(35); Cloud->SetMaxHealth(9999999); Cloud->SetHealth(9999999); Cloud->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); } ElectricalStorm_Timer = 60000; //60 seconds(bosskillers) StormCount = 1; StormSequenceTimer = 0; } else ElectricalStorm_Timer -= diff; if (SummonEagles_Timer <= diff) { me->MonsterYell(SAY_ONSUMMON, LANG_UNIVERSAL, NULL); DoPlaySoundToSet(me, SOUND_ONSUMMON); float x, y, z; me->GetPosition(x, y, z); for (uint8 i = 0; i < 8; ++i) { Unit* bird = Unit::GetUnit(*me,BirdGUIDs[i]); if (!bird) //they despawned on die { if (Unit *pTarget = SelectUnit(SELECT_TARGET_RANDOM, 0)) { x = pTarget->GetPositionX() + irand(-10,10); y = pTarget->GetPositionY() + irand(-10,10); z = pTarget->GetPositionZ() + urand(16,20); if (z > 95) z = 95.0f - urand(0,5); } Creature *pCreature = me->SummonCreature(MOB_SOARING_EAGLE, x, y, z, 0, TEMPSUMMON_CORPSE_DESPAWN, 0); if (pCreature) { pCreature->AddThreat(me->getVictim(), 1.0f); pCreature->AI()->AttackStart(me->getVictim()); BirdGUIDs[i] = pCreature->GetGUID(); } } } SummonEagles_Timer = 999999; } else SummonEagles_Timer -= diff; DoMeleeAttackIfReady(); }
// // Neighbor* anyNbr() // Last modified: 30Nov2009 // // Returns a random neighbor in this neighborhood. // // Returns: random neighbor in this neighborhood // Parameters: <none> // Neighbor* Neighborhood::anyNbr() { srand(time(NULL)); if (!empty()) return &at(irand(0, size())); return NULL; } // anyNbr()