// Note: // the following was tested on a IIDC camera over USB therefore might not work as // well on a camera over proper firewire transport void FirewireVideo::init_format7_camera( uint64_t guid, int dma_frames, dc1394speed_t iso_speed, dc1394video_mode_t video_mode, int framerate, uint32_t width, uint32_t height, uint32_t left, uint32_t top, bool reset_at_boot ) { if(video_mode< DC1394_VIDEO_MODE_FORMAT7_0) throw VideoException("roi can be specified only for format7 modes"); camera = dc1394_camera_new (d, guid); if (!camera) throw VideoException("Failed to initialize camera"); // Attempt to stop camera if it is already running dc1394switch_t is_iso_on = DC1394_OFF; dc1394_video_get_transmission(camera, &is_iso_on); if (is_iso_on==DC1394_ON) { dc1394_video_set_transmission(camera, DC1394_OFF); } cout << "Using camera with GUID " << camera->guid << endl; if(reset_at_boot){ dc1394_camera_reset(camera); } //----------------------------------------------------------------------- // setup mode and roi //----------------------------------------------------------------------- if(iso_speed >= DC1394_ISO_SPEED_800) { err=dc1394_video_set_operation_mode(camera, DC1394_OPERATION_MODE_1394B); if( err != DC1394_SUCCESS ) throw VideoException("Could not set DC1394_OPERATION_MODE_1394B"); } err=dc1394_video_set_iso_speed(camera, iso_speed); if( err != DC1394_SUCCESS ) throw VideoException("Could not set iso speed"); // check that the required mode is actually supported dc1394format7mode_t format7_info; err = dc1394_format7_get_mode_info(camera, video_mode, &format7_info); if( err != DC1394_SUCCESS ) throw VideoException("Could not get format7 mode info"); // safely set the video mode err=dc1394_video_set_mode(camera, video_mode); if( err != DC1394_SUCCESS ) throw VideoException("Could not set format7 video mode"); // set position to 0,0 so that setting any size within min and max is a valid command err = dc1394_format7_set_image_position(camera, video_mode,0,0); if( err != DC1394_SUCCESS ) throw VideoException("Could not set format7 image position"); // work out the desired image size width = nearest_value(width, format7_info.unit_pos_x, 0, format7_info.max_size_x - left); height = nearest_value(height, format7_info.unit_pos_y, 0, format7_info.max_size_y - top); // set size err = dc1394_format7_set_image_size(camera,video_mode,width,height); if( err != DC1394_SUCCESS ) throw VideoException("Could not set format7 size"); // get the info again since many parameters depend on image size err = dc1394_format7_get_mode_info(camera, video_mode, &format7_info); if( err != DC1394_SUCCESS ) throw VideoException("Could not get format7 mode info"); // work out position of roi left = nearest_value(left, format7_info.unit_size_x, format7_info.unit_size_x, format7_info.max_size_x - width); top = nearest_value(top, format7_info.unit_size_y, format7_info.unit_size_y, format7_info.max_size_y - height); // set roi position err = dc1394_format7_set_image_position(camera,video_mode,left,top); if( err != DC1394_SUCCESS ) throw VideoException("Could not set format7 size"); this->width = width; this->height = height; this->top = top; this->left = left; cout<<"roi: "<<left<<" "<<top<<" "<<width<<" "<<height<<" "; //----------------------------------------------------------------------- // setup frame rate //----------------------------------------------------------------------- if((framerate == MAX_FR)||(framerate == EXT_TRIG)){ err=dc1394_format7_set_packet_size(camera,video_mode, format7_info.max_packet_size); if( err != DC1394_SUCCESS ) throw VideoException("Could not set format7 packet size"); } else { // setting packet size to get the desired frame rate according to the libdc docs // does not do the trick, so for now we support only max frame rate throw VideoException("In format 7 only max frame rate is currently supported"); // uint32_t depth; // err = dc1394_format7_get_data_depth(camera, video_mode, &depth); // if( err != DC1394_SUCCESS ) // throw VideoException("Could not get format7 depth"); // // // the following is straight from the libdc docs // double bus_period = bus_period_from_iso_speed(iso_speed); // // // work out the max number of packets that the bus can deliver // int num_packets = (int) (1.0/(bus_period*framerate) + 0.5); // // if((num_packets > 4095)||(num_packets < 0)) // throw VideoException("number of format7 packets out of range"); // // // work out what the packet size should be for the requested size and framerate // uint32_t packet_size = (width*964*depth + (num_packets*8) - 1)/(num_packets*8); // packet_size = nearest_value(packet_size,format7_info.unit_packet_size,format7_info.unit_packet_size,format7_info.max_packet_size); // // if(packet_size > format7_info.max_packet_size){ // throw VideoException("format7 requested frame rate and size exceed bus bandwidth"); // } // // err=dc1394_format7_set_packet_size(camera,video_mode, packet_size); // if( err != DC1394_SUCCESS ){ // throw VideoException("Could not set format7 packet size"); // } } // ask the camera what is the resulting framerate (this assume that such a rate is actually // allowed by the shutter time) err = dc1394_feature_set_power(camera,DC1394_FEATURE_FRAME_RATE,DC1394_OFF); if( err != DC1394_SUCCESS ) throw VideoException("Could not turn off frame rate"); float value; err=dc1394_feature_get_absolute_value(camera,DC1394_FEATURE_FRAME_RATE,&value); if( err != DC1394_SUCCESS ) throw VideoException("Could not get framerate"); cout<<" framerate(shutter permitting):"<<value<<endl; //----------------------------------------------------------------------- // setup capture //----------------------------------------------------------------------- err=dc1394_capture_setup(camera,dma_frames, DC1394_CAPTURE_FLAGS_DEFAULT); if( err != DC1394_SUCCESS ) throw VideoException("Could not setup camera - check settings"); Start(); }
void UpdateAI(const uint32 diff) { if (IsEvent) { //Must update npc_escortAI npc_escortAI::UpdateAI(diff); if(!go) { go = true; if(pInstance) { AddWaypoint(0, 5492.91, -2404.61, 1462.63); AddWaypoint(1, 5531.76, -2460.87, 1469.55); AddWaypoint(2, 5554.58, -2514.66, 1476.12); AddWaypoint(3, 5554.16, -2567.23, 1479.90); AddWaypoint(4, 5540.67, -2625.99, 1480.89); AddWaypoint(5, 5508.16, -2659.2, 1480.15); AddWaypoint(6, 5489.62, -2704.05, 1482.18); AddWaypoint(7, 5457.04, -2726.26, 1485.10); Start(false, true); SetDespawnAtEnd(false); } } } //Return since we have no target if (!UpdateVictim() ) return; if(RainTimer < diff) { DoCast(SelectUnit(SELECT_TARGET_RANDOM,0,30,true), SPELL_RAIN_OF_FIRE); RainTimer = 20000+rand()%15000; }else RainTimer -= diff; if(DoomTimer < diff) { DoCast(SelectUnit(SELECT_TARGET_RANDOM,1,100,true), SPELL_DOOM);//never on tank DoomTimer = 45000+rand()%5000; }else DoomTimer -= diff; if(HowlTimer < diff) { DoCast(m_creature, SPELL_HOWL_OF_AZGALOR); HowlTimer = 30000; }else HowlTimer -= diff; if(CleaveTimer < diff) { DoCast(m_creature->getVictim(), SPELL_CLEAVE); CleaveTimer = 10000+rand()%5000; }else CleaveTimer -= diff; if(EnrageTimer < diff && !enraged) { m_creature->InterruptNonMeleeSpells(false); DoCast(m_creature, SPELL_BERSERK, true); enraged = true; EnrageTimer = 600000; }else EnrageTimer -= diff; DoMeleeAttackIfReady(); }
void MoleGraph::CheckInput() { if (0 == Serial.available()) return; unsigned char instruction = Serial.read(); switch (instruction) { case INS_GET_VERSION: Serial.write(VERSION); break; case INS_SET_FREQUENCY: { unsigned frequency; FillFromSerial(frequency); InitTimer(); //workaround there was a 1s lag after start when there had been set 1 Hz period and user set 200 Hz period OCR1A = 62500/frequency; // compare match register 16MHz/256/2Hz } break; case INS_SET_TIME: { FillFromSerial(g_requiredTime); InitTimer(); //workaround as in set frequenc case OCR1A = 62500; // compare match register 16MHz/256/2Hz } break; case INS_ENABLED_CHANNELS: FillFromSerial(g_enabledChannels); g_channelCount = 0; for (int i = 0; i < 8; i++) if (0 != (g_enabledChannels & (1 << i))) g_channelCount++; break; case INS_START: Start(); g_measurementStartedCallback(); break; case INS_STOP: Stop(); g_measurementStoppedCallback(); break; case INS_CONTINUE: Start(); g_measurementContinuedCallback(); break; case INS_PAUSE: Stop(); g_measurementPausedCallback(); break; case INS_SET_TYPE: unsigned char type; FillFromSerial(type); g_type = (Type)type; if (g_type == typeOnDemand) { g_sampleRequest = false; g_timeFromStart = 0; InitTimer(); OCR1A = 1; //1/62500 s } else g_currentTime = g_requiredTime - 1; //to be data send immediately break; case INS_GET_SAMLPE: g_sampleRequest = true; break; case INS_INITIALIZE: //when desktop application crash, this stay in sending data Stop(); break; } }
Enemy::Enemy(Game *attachedGame, float mass) : GameObject(attachedGame) { this->mass = mass; Start(); }
/* =============== idCameraAnim::Event_Start ================ */ void idCameraAnim::Event_Start( void ) { Start(); }
nsresult nsHtml5Parser::ParseHtml5Fragment(const nsAString& aSourceBuffer, nsIContent* aTargetNode, nsIAtom* aContextLocalName, PRInt32 aContextNamespace, bool aQuirks, bool aPreventScriptExecution) { NS_ENSURE_TRUE(aSourceBuffer.Length() <= PR_INT32_MAX, NS_ERROR_OUT_OF_MEMORY); nsIDocument* doc = aTargetNode->OwnerDoc(); nsIURI* uri = doc->GetDocumentURI(); NS_ENSURE_TRUE(uri, NS_ERROR_NOT_AVAILABLE); mExecutor->EnableFragmentMode(aPreventScriptExecution); Initialize(doc, uri, nsnull, nsnull); mExecutor->SetParser(this); mExecutor->SetNodeInfoManager(doc->NodeInfoManager()); nsIContent* target = aTargetNode; mTreeBuilder->setFragmentContext(aContextLocalName, aContextNamespace, &target, aQuirks); #ifdef DEBUG if (!aPreventScriptExecution) { NS_ASSERTION(!aTargetNode->IsInDoc(), "If script execution isn't prevented, " "the target node must not be in doc."); nsCOMPtr<nsIDOMDocumentFragment> domFrag = do_QueryInterface(aTargetNode); NS_ASSERTION(domFrag, "If script execution isn't prevented, must parse to DOM fragment."); } #endif NS_PRECONDITION(!mExecutor->HasStarted(), "Tried to start parse without initializing the parser."); mTreeBuilder->setScriptingEnabled(mExecutor->IsScriptEnabled()); mTokenizer->start(); mExecutor->Start(); // Don't call WillBuildModel in fragment case if (!aSourceBuffer.IsEmpty()) { bool lastWasCR = false; nsHtml5DependentUTF16Buffer buffer(aSourceBuffer); while (buffer.hasMore()) { buffer.adjust(lastWasCR); lastWasCR = false; if (buffer.hasMore()) { lastWasCR = mTokenizer->tokenizeBuffer(&buffer); if (mTreeBuilder->HasScript()) { // Flush on each script, because the execution prevention code // can handle at most one script per flush. mTreeBuilder->Flush(); // Move ops to the executor mExecutor->FlushDocumentWrite(); // run the ops } } } } mTokenizer->eof(); mTreeBuilder->StreamEnded(); mTreeBuilder->Flush(); mExecutor->FlushDocumentWrite(); mTokenizer->end(); mExecutor->DropParserAndPerfHint(); mExecutor->DropHeldElements(); mTreeBuilder->DropHandles(); mAtomTable.Clear(); return NS_OK; }
void FGTurbine::Calculate(void) { double thrust; RunPreFunctions(); ThrottlePos = in.ThrottlePos[EngineNumber]; if (ThrottlePos > 1.0) { AugmentCmd = ThrottlePos - 1.0; ThrottlePos -= AugmentCmd; } else { AugmentCmd = 0.0; } // When trimming is finished check if user wants engine OFF or RUNNING if ((phase == tpTrim) && (in.TotalDeltaT > 0)) { if (Running && !Starved) { phase = tpRun; N1_factor = MaxN1 - IdleN1; N2_factor = MaxN2 - IdleN2; N2 = IdleN2 + ThrottlePos * N2_factor; N1 = IdleN1 + ThrottlePos * N1_factor; OilTemp_degK = 366.0; Cutoff = false; } else { phase = tpOff; Cutoff = true; EGT_degC = in.TAT_c; } } if (!Running && Cutoff && Starter) { if (phase == tpOff) phase = tpSpinUp; } // start if ((Starter == true) || (in.qbar > 30.0)) { if (!Running && !Cutoff && (N2 > 15.0)) phase = tpStart; } if (Cutoff && (phase != tpSpinUp)) phase = tpOff; if (in.TotalDeltaT == 0) phase = tpTrim; if (Starved) phase = tpOff; if (Stalled) phase = tpStall; if (Seized) phase = tpSeize; switch (phase) { case tpOff: thrust = Off(); break; case tpRun: thrust = Run(); break; case tpSpinUp: thrust = SpinUp(); break; case tpStart: thrust = Start(); break; case tpStall: thrust = Stall(); break; case tpSeize: thrust = Seize(); break; case tpTrim: thrust = Trim(); break; default: thrust = Off(); } Thruster->Calculate(thrust); // allow thruster to modify thrust (i.e. reversing) RunPostFunctions(); }
EXPORT_C TInt CBusyTestUnit::Start(TTimeIntervalMicroSeconds aRunFor) { return Start(0, aRunFor); }
bool CLogicBoad::DoLogicBoardCmd( stBaseCmd* pcmd,int nLen ) { switch (pcmd->value) { case stTetrisRefresh::_value: { stTetrisRefresh* pDstCmd = (stTetrisRefresh*)pcmd; for (int i = 0; i < BoardWidth * BoardHeight; ++i) { board[i] = Tetrominoes(pDstCmd->board[i]); } curX = pDstCmd->nCurX; curY = pDstCmd->nCurY; memcpy(&curPiece,&pDstCmd->curPiece,sizeof(curPiece)); Refresh(); } break; case stTetrisDrawText::_value: { stTetrisDrawText* pDstCmd = (stTetrisDrawText*)pcmd; strcpy_s(szDrawText,sizeof(szDrawText),pDstCmd->szDrawText); Refresh(); } break; case stTetrisOperator::_value: { stTetrisOperator* pDstcmd = (stTetrisOperator*)pcmd; switch (pDstcmd->btOperator) { case emTR_OPERATOR_START: { Start(); } break; case emTR_OPERATOR_RIGHT: { TryMove(curPiece,curX+1,curY); } break; case emTR_OPERATOR_LEFT: { TryMove(curPiece,curX-1,curY); } break; case emTR_OPERATOR_DOWN: { TryMove(curPiece,curX,curY-1); } break; case emTR_OPERATOR_ROTATELEFT: { TryMove(curPiece.RotateLeft(),curX,curY); } break; case emTR_OPERATOR_PAUSE: { Pause(); } } } break; } return true; }
ResponseCode CResourceHTMLItem::Request ( HttpRequest * ipoHttpRequest, HttpResponse * ipoHttpResponse, CAccount * account ) { if ( !m_pVM ) Start (); if ( m_bIsBeingRequested ) { ipoHttpResponse->SetBody ( "Busy!", strlen("Busy!") ); return HTTPRESPONSECODE_500_INTERNALSERVERERROR; } m_bIsBeingRequested = true; m_responseCode = HTTPRESPONSECODE_200_OK; if ( !m_bIsRaw ) { ipoHttpResponse->oResponseHeaders [ "content-type" ] = m_strMime; CLuaArguments formData; for ( FormValueMap::iterator iter = ipoHttpRequest->oFormValueMap.begin(); iter != ipoHttpRequest->oFormValueMap.end(); iter++ ) { formData.PushString ( (*iter).first.c_str() ); formData.PushString ( ((FormValue)(*iter).second).sBody.c_str() ); } CLuaArguments cookies; for ( CookieMap::iterator iter = ipoHttpRequest->oCookieMap.begin(); iter != ipoHttpRequest->oCookieMap.end(); iter++ ) { cookies.PushString ( (*iter).first.c_str() ); cookies.PushString ( (*iter).second.c_str() ); } CLuaArguments headers; for ( StringMap::iterator iter = ipoHttpRequest->oRequestHeaders.begin(); iter != ipoHttpRequest->oRequestHeaders.end(); iter++ ) { headers.PushString ( (*iter).first.c_str() ); headers.PushString ( (*iter).second.c_str() ); } m_currentResponse = ipoHttpResponse; CLuaArguments querystring ( formData ); CLuaArguments args; args.PushTable ( &headers ); // requestHeaders args.PushTable ( &formData ); // form args.PushTable ( &cookies ); // cookies args.PushString ( ipoHttpRequest->GetAddress().c_str() ); // hostname args.PushString ( ipoHttpRequest->sOriginalUri.c_str() ); // url args.PushTable ( &querystring ); // querystring args.PushAccount ( account ); // g_pGame->Lock(); // get the mutex (blocking) args.CallGlobal ( m_pVM, "renderPage" ); // g_pGame->Unlock(); // release the mutex ipoHttpResponse->SetBody ( m_strPageBuffer.c_str (), m_strPageBuffer.size () ); m_strPageBuffer.clear (); } else { // its a raw page FILE * file = fopen ( m_strResourceFileName.c_str (), "rb" ); if ( file ) { fseek ( file, 0, SEEK_END ); long lBufferLength = ftell ( file ); char* pBuffer = new char [ lBufferLength ]; rewind ( file ); fread ( pBuffer, 1, lBufferLength, file ); fclose ( file ); ipoHttpResponse->oResponseHeaders [ "content-type" ] = m_strMime.c_str (); ipoHttpResponse->SetBody ( pBuffer, lBufferLength ); delete[] pBuffer; } else { ipoHttpResponse->SetBody ( "Can't read file!", strlen("Can't read file!") ); } } m_bIsBeingRequested = false; return m_responseCode; }
EXPORT_C TInt CBusyTestUnit::Start() { return Start(0); }
SC_TcpConnectionPort::SC_TcpConnectionPort(SC_TcpInPort *inParent, int inSocket) : SC_ComPort(0), mParent(inParent) { mSocket = inSocket; Start(); }
void OCThreadBase::Initialize() { Start(); }
int main(int argc, char* argv[]) { GtkWidget* window; GtkWidget* vbox; GtkWidget* hbox; GtkWidget* button; GtkWidget* frame; gtk_init(&argc, &argv); window = gtk_window_new(GTK_WINDOW_TOPLEVEL); g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(gtk_main_quit), NULL); g_signal_connect(G_OBJECT(window), "key_press_event", G_CALLBACK(KeyPress), NULL); //按键信号 gtk_window_set_title(GTK_WINDOW(window), "Snake Game"); gtk_window_set_resizable(GTK_WINDOW(window), FALSE); //禁止调整窗口大小 gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); gtk_container_set_border_width(GTK_CONTAINER(window), 5); //设置窗口边框厚度 //垂直排放 vbox = gtk_vbox_new(FALSE, 0); gtk_container_add(GTK_CONTAINER(window), vbox); //水平排放 hbox = gtk_hbox_new(FALSE, 0); gtk_container_add(GTK_CONTAINER(vbox), hbox); //“单词”标签 frame = gtk_frame_new("单词"); word_label = gtk_label_new(" Eureka "); gtk_container_add(GTK_CONTAINER(frame), word_label); gtk_box_pack_start(GTK_BOX(hbox), frame, TRUE, TRUE, 5); //“单词序列”标签 frame = gtk_frame_new("单词序列"); seq_label = gtk_label_new(" E u r e k a "); gtk_container_add(GTK_CONTAINER(frame), seq_label); gtk_box_pack_start(GTK_BOX(hbox), frame, TRUE, TRUE, 3); /* //游戏LOGO GtkWidget *logo; pix = gdk_pixbuf_new_from_file("logo.png", NULL); logo = gtk_image_new_from_pixbuf(pix); gtk_box_pack_start(GTK_BOX(hbox), logo, FALSE, FALSE, 0); */ //水平排放 hbox = gtk_hbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 5); //30*20表格容器 table = gtk_table_new(30, 20, FALSE); gtk_box_pack_start(GTK_BOX(hbox), table, TRUE, TRUE, 5); //垂直排放 vbox = gtk_vbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, 3); //“开始”按钮 button = gtk_button_new_with_label("开始"); g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(on_begin_clicked), NULL); //on_begin_clicked gtk_box_pack_start(GTK_BOX(vbox), button, TRUE, TRUE, 3); //“退出”按钮 button = gtk_button_new_with_label("退出"); g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(on_exit_clicked), NULL); //on_exit_clicked gtk_box_pack_start(GTK_BOX(vbox), button, TRUE, TRUE, 3); //“等级”标签 frame = gtk_frame_new("等级"); level_label = gtk_label_new("\n1-1\n\n"); gtk_container_add(GTK_CONTAINER(frame), level_label); gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 3); //“时间”标签 frame = gtk_frame_new("时间"); time_label = gtk_label_new("\n19:31:51\n"); gtk_container_add(GTK_CONTAINER(frame), time_label); gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 3); Start(); gtk_widget_show_all(window); gtk_main(); return FALSE; }
void SetGUID(uint64 guid, int32 /*id = 0*/) { InitWaypoint(); Start(false, false, guid); SetDespawnAtFar(false); }
void SetData(uint32 type, uint32 data) { if (type == 1) Start(false, true, 0, NULL); }
NS_IMETHODIMP nsHtml5Parser::Parse(const nsAString& aSourceBuffer, void* aKey, const nsACString& aContentType, bool aLastCall, nsDTDMode aMode) // ignored { NS_PRECONDITION(!mExecutor->IsFragmentMode(), "Document.write called in fragment mode!"); if (mExecutor->IsBroken()) { return NS_ERROR_OUT_OF_MEMORY; } if (aSourceBuffer.Length() > PR_INT32_MAX) { mExecutor->MarkAsBroken(); return NS_ERROR_OUT_OF_MEMORY; } // Maintain a reference to ourselves so we don't go away // till we're completely done. The old parser grips itself in this method. nsCOMPtr<nsIParser> kungFuDeathGrip(this); // Gripping the other objects just in case, since the other old grip // required grips to these, too. nsRefPtr<nsHtml5StreamParser> streamKungFuDeathGrip(mStreamParser); nsRefPtr<nsHtml5TreeOpExecutor> treeOpKungFuDeathGrip(mExecutor); if (!mExecutor->HasStarted()) { NS_ASSERTION(!mStreamParser, "Had stream parser but document.write started life cycle."); // This is the first document.write() on a document.open()ed document mExecutor->SetParser(this); mTreeBuilder->setScriptingEnabled(mExecutor->IsScriptEnabled()); mTokenizer->start(); mExecutor->Start(); if (!aContentType.EqualsLiteral("text/html")) { mTreeBuilder->StartPlainText(); mTokenizer->StartPlainText(); } /* * If you move the following line, be very careful not to cause * WillBuildModel to be called before the document has had its * script global object set. */ mExecutor->WillBuildModel(eDTDMode_unknown); } // Return early if the parser has processed EOF if (mExecutor->IsComplete()) { return NS_OK; } if (aLastCall && aSourceBuffer.IsEmpty() && aKey == GetRootContextKey()) { // document.close() NS_ASSERTION(!mStreamParser, "Had stream parser but got document.close()."); mDocumentClosed = true; if (!mBlocked && !mInDocumentWrite) { ParseUntilBlocked(); } return NS_OK; } // If we got this far, we are dealing with a document.write or // document.writeln call--not document.close(). NS_ASSERTION(IsInsertionPointDefined(), "Doc.write reached parser with undefined insertion point."); NS_ASSERTION(!(mStreamParser && !aKey), "Got a null key in a non-script-created parser"); // XXX is this optimization bogus? if (aSourceBuffer.IsEmpty()) { return NS_OK; } // This guard is here to prevent document.close from tokenizing synchronously // while a document.write (that wrote the script that called document.close!) // is still on the call stack. mozilla::AutoRestore<bool> guard(mInDocumentWrite); mInDocumentWrite = true; // The script is identified by aKey. If there's nothing in the buffer // chain for that key, we'll insert at the head of the queue. // When the script leaves something in the queue, a zero-length // key-holder "buffer" is inserted in the queue. If the same script // leaves something in the chain again, it will be inserted immediately // before the old key holder belonging to the same script. // // We don't do the actual data insertion yet in the hope that the data gets // tokenized and there no data or less data to copy to the heap after // tokenization. Also, this way, we avoid inserting one empty data buffer // per document.write, which matters for performance when the parser isn't // blocked and a badly-authored script calls document.write() once per // input character. (As seen in a benchmark!) // // The insertion into the input stream happens conceptually before anything // gets tokenized. To make sure multi-level document.write works right, // it's necessary to establish the location of our parser key up front // in case this is the first write with this key. // // In a document.open() case, the first write level has a null key, so that // case is handled separately, because normal buffers containing data // have null keys. // These don't need to be owning references, because they always point to // the buffer queue and buffers can't be removed from the buffer queue // before document.write() returns. The buffer queue clean-up happens the // next time ParseUntilBlocked() is called. // However, they are made owning just in case the reasoning above is flawed // and a flaw would lead to worse problems with plain pointers. If this // turns out to be a perf problem, it's worthwhile to consider making // prevSearchbuf a plain pointer again. nsRefPtr<nsHtml5OwningUTF16Buffer> prevSearchBuf; nsRefPtr<nsHtml5OwningUTF16Buffer> firstLevelMarker; if (aKey) { if (mFirstBuffer == mLastBuffer) { nsHtml5OwningUTF16Buffer* keyHolder = new nsHtml5OwningUTF16Buffer(aKey); keyHolder->next = mLastBuffer; mFirstBuffer = keyHolder; } else if (mFirstBuffer->key != aKey) { prevSearchBuf = mFirstBuffer; for (;;) { if (prevSearchBuf->next == mLastBuffer) { // key was not found nsHtml5OwningUTF16Buffer* keyHolder = new nsHtml5OwningUTF16Buffer(aKey); keyHolder->next = mFirstBuffer; mFirstBuffer = keyHolder; prevSearchBuf = nsnull; break; } if (prevSearchBuf->next->key == aKey) { // found a key holder break; } prevSearchBuf = prevSearchBuf->next; } } // else mFirstBuffer is the keyholder // prevSearchBuf is the previous buffer before the keyholder or null if // there isn't one. } else { // We have a first-level write in the document.open() case. We insert // before mLastBuffer. We need to put a marker there, because otherwise // additional document.writes from nested event loops would insert in the // wrong place. Sigh. firstLevelMarker = new nsHtml5OwningUTF16Buffer((void*)nsnull); if (mFirstBuffer == mLastBuffer) { firstLevelMarker->next = mLastBuffer; mFirstBuffer = firstLevelMarker; } else { prevSearchBuf = mFirstBuffer; while (prevSearchBuf->next != mLastBuffer) { prevSearchBuf = prevSearchBuf->next; } firstLevelMarker->next = mLastBuffer; prevSearchBuf->next = firstLevelMarker; } } nsHtml5DependentUTF16Buffer stackBuffer(aSourceBuffer); while (!mBlocked && stackBuffer.hasMore()) { stackBuffer.adjust(mLastWasCR); mLastWasCR = false; if (stackBuffer.hasMore()) { PRInt32 lineNumberSave; bool inRootContext = (!mStreamParser && (aKey == mRootContextKey)); if (inRootContext) { mTokenizer->setLineNumber(mRootContextLineNumber); } else { // we aren't the root context, so save the line number on the // *stack* so that we can restore it. lineNumberSave = mTokenizer->getLineNumber(); } mLastWasCR = mTokenizer->tokenizeBuffer(&stackBuffer); if (inRootContext) { mRootContextLineNumber = mTokenizer->getLineNumber(); } else { mTokenizer->setLineNumber(lineNumberSave); } if (mTreeBuilder->HasScript()) { mTreeBuilder->Flush(); // Move ops to the executor mExecutor->FlushDocumentWrite(); // run the ops // Flushing tree ops can cause all sorts of things. // Return early if the parser got terminated. if (mExecutor->IsComplete()) { return NS_OK; } } // Ignore suspension requests } } nsRefPtr<nsHtml5OwningUTF16Buffer> heapBuffer; if (stackBuffer.hasMore()) { // The buffer wasn't tokenized to completion. Create a copy of the tail // on the heap. heapBuffer = stackBuffer.FalliblyCopyAsOwningBuffer(); if (!heapBuffer) { // Allocation failed. The parser is now broken. mExecutor->MarkAsBroken(); return NS_ERROR_OUT_OF_MEMORY; } } if (heapBuffer) { // We have something to insert before the keyholder holding in the non-null // aKey case and we have something to swap into firstLevelMarker in the // null aKey case. if (aKey) { NS_ASSERTION(mFirstBuffer != mLastBuffer, "Where's the keyholder?"); // the key holder is still somewhere further down the list from // prevSearchBuf (which may be null) if (mFirstBuffer->key == aKey) { NS_ASSERTION(!prevSearchBuf, "Non-null prevSearchBuf when mFirstBuffer is the key holder?"); heapBuffer->next = mFirstBuffer; mFirstBuffer = heapBuffer; } else { if (!prevSearchBuf) { prevSearchBuf = mFirstBuffer; } // We created a key holder earlier, so we will find it without walking // past the end of the list. while (prevSearchBuf->next->key != aKey) { prevSearchBuf = prevSearchBuf->next; } heapBuffer->next = prevSearchBuf->next; prevSearchBuf->next = heapBuffer; } } else { NS_ASSERTION(firstLevelMarker, "How come we don't have a marker."); firstLevelMarker->Swap(heapBuffer); } } if (!mBlocked) { // buffer was tokenized to completion NS_ASSERTION(!stackBuffer.hasMore(), "Buffer wasn't tokenized to completion?"); // Scripting semantics require a forced tree builder flush here mTreeBuilder->Flush(); // Move ops to the executor mExecutor->FlushDocumentWrite(); // run the ops } else if (stackBuffer.hasMore()) { // The buffer wasn't tokenized to completion. Tokenize the untokenized // content in order to preload stuff. This content will be retokenized // later for normal parsing. if (!mDocWriteSpeculatorActive) { mDocWriteSpeculatorActive = true; if (!mDocWriteSpeculativeTreeBuilder) { // Lazily initialize if uninitialized mDocWriteSpeculativeTreeBuilder = new nsHtml5TreeBuilder(nsnull, mExecutor->GetStage()); mDocWriteSpeculativeTreeBuilder->setScriptingEnabled( mTreeBuilder->isScriptingEnabled()); mDocWriteSpeculativeTokenizer = new nsHtml5Tokenizer(mDocWriteSpeculativeTreeBuilder, false); mDocWriteSpeculativeTokenizer->setInterner(&mAtomTable); mDocWriteSpeculativeTokenizer->start(); } mDocWriteSpeculativeTokenizer->resetToDataState(); mDocWriteSpeculativeTreeBuilder->loadState(mTreeBuilder, &mAtomTable); mDocWriteSpeculativeLastWasCR = false; } // Note that with multilevel document.write if we didn't just activate the // speculator, it's possible that the speculator is now in the wrong state. // That's OK for the sake of simplicity. The worst that can happen is // that the speculative loads aren't exactly right. The content will be // reparsed anyway for non-preload purposes. // The buffer position for subsequent non-speculative parsing now lives // in heapBuffer, so it's ok to let the buffer position of stackBuffer // to be overwritten and not restored below. while (stackBuffer.hasMore()) { stackBuffer.adjust(mDocWriteSpeculativeLastWasCR); if (stackBuffer.hasMore()) { mDocWriteSpeculativeLastWasCR = mDocWriteSpeculativeTokenizer->tokenizeBuffer(&stackBuffer); } } mDocWriteSpeculativeTreeBuilder->Flush(); mDocWriteSpeculativeTreeBuilder->DropHandles(); mExecutor->FlushSpeculativeLoads(); } return NS_OK; }
Player::Player(Ogre::Entity* entity,Ogre::SceneNode* node,Ogre::SceneManager *sceneMgr,Ogre::Camera *camera,OIS::Keyboard *keyboard) :GameObject(entity,node,sceneMgr, camera, keyboard) { Start(); }
npc_morriduneAI(Creature* creature) : npc_escortAI(creature) { Talk(SAY_MORRIDUNE_1); me->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); Start(false); }
virtual void ProcessEvent( EFlowEvent event,SActivationInfo *pActInfo ) { switch (event) { case eFE_Activate: { // update destination only if dynamic update is enabled. otherwise destination is read on Start/Reset only if (m_bActive && IsPortActive(pActInfo, IN_DEST) && GetPortBool(pActInfo, IN_DYN_DEST) == true) { ReadDestinationPosFromInput( pActInfo ); if (m_valueType==VT_TIME) CalcSpeedFromTimeInput( pActInfo ); } if (m_bActive && IsPortActive(pActInfo, IN_VALUE)) { ReadSpeedFromInput( pActInfo ); } if (IsPortActive(pActInfo, IN_START)) { Start( pActInfo ); } if (IsPortActive(pActInfo, IN_STOP)) { pActInfo->pGraph->SetRegularlyUpdated( pActInfo->myID, false ); if (m_bActive) { ActivateOutput(pActInfo, OUT_DONE, true); m_bActive = false; } ActivateOutput(pActInfo, OUT_STOP, true); } // we dont support dynamic change of those inputs assert( !IsPortActive(pActInfo, IN_COORDSYS) ); assert( !IsPortActive(pActInfo, IN_VALUETYPE) ); break; } case eFE_Initialize: { m_bActive = false; m_position = ZERO; m_coorSys = (ECoordSys)GetPortInt( pActInfo, IN_COORDSYS ); m_valueType = (EValueType)GetPortInt(pActInfo, IN_VALUETYPE); IEntity *pEnt = pActInfo->pEntity; if(pEnt) m_position = pEnt->GetWorldPos(); ActivateOutput(pActInfo, OUT_CURRENT, m_position); // i dont see a sense for this, but lets keep it for now pActInfo->pGraph->SetRegularlyUpdated( pActInfo->myID, false ); break; } case eFE_Update: { IEntity *pEnt = pActInfo->pEntity; if (!pEnt) { pActInfo->pGraph->SetRegularlyUpdated( pActInfo->myID, false ); break; } // Use physics velocity updates, unless the entity is parented in another entity space and not rigid. IPhysicalEntity* pPhysEnt = pEnt->GetPhysics(); if( pPhysEnt && (pEnt->GetParent()!=NULL || pPhysEnt->GetType() == PE_STATIC) ) { pPhysEnt = NULL; } if (m_stopping) { m_stopping = false; pActInfo->pGraph->SetRegularlyUpdated( pActInfo->myID, false ); if( pPhysEnt == NULL ) { SetPos(pActInfo, m_destination); } m_bActive = false; break; } if (!m_bActive) break; float time = gEnv->pTimer->GetFrameStartTime().GetSeconds(); float timeDifference = time - m_lastFrameTime; m_lastFrameTime = time; // note - if there's no physics then this will be the same, but if the platform is moved through physics, then // we have to get back the actual movement - this maybe framerate dependent. m_position = pActInfo->pEntity->GetPos(); // let's compute the movement vector now Vec3 oldPosition = m_position; if(m_bForceFinishAsTooNear || m_position.IsEquivalent(m_destination, 0.01f)) { m_position = m_destination; oldPosition = m_destination; ActivateOutput(pActInfo, OUT_DONE, true); ActivateOutput(pActInfo, OUT_FINISH, true); SetPos(pActInfo, m_position); // for finishing we have to make a manual setpos even if there is physics involved, to make sure the entity will be where it should. if (pPhysEnt) { pe_action_set_velocity setVel; setVel.v = ZERO; pPhysEnt->Action( &setVel ); m_stopping = true; } else { pActInfo->pGraph->SetRegularlyUpdated( pActInfo->myID, false ); m_bActive = false; } } else { Vec3 direction = m_destination - m_position; float distance = direction.GetLength(); Vec3 directionAndSpeed = direction.normalized(); // ease-area calcs float distanceForEaseOutCalc = distance + m_easeOutDistance * EASE_MARGIN_FACTOR; if (distanceForEaseOutCalc < m_easeOutDistance) // takes care of m_easeOutDistance being 0 { directionAndSpeed *= distanceForEaseOutCalc / m_easeOutDistance; } else // init code makes sure both eases dont overlap, when the movement is time defined. when it is speed defined, only ease out is applied if they overlap. { if (m_easeInDistance>0.f) { Vec3 vectorFromStart = m_position - m_startPos; float distanceFromStart = vectorFromStart.GetLength(); float distanceForEaseInCalc = distanceFromStart + m_easeInDistance * EASE_MARGIN_FACTOR; if (distanceForEaseInCalc < m_easeInDistance) { directionAndSpeed *= distanceForEaseInCalc / m_easeInDistance; } } } directionAndSpeed *= (m_topSpeed * timeDifference); if(direction.GetLength() < directionAndSpeed.GetLength()) { m_position = m_destination; m_bForceFinishAsTooNear = true; } else m_position += directionAndSpeed; } ActivateOutput(pActInfo, OUT_CURRENT, m_position); if (pPhysEnt == NULL) { SetPos(pActInfo, m_position); } else { pe_action_set_velocity setVel; float rTimeStep = timeDifference>0.000001f ? 1.f / timeDifference : 0.0f; setVel.v = (m_position - oldPosition) * rTimeStep; pPhysEnt->Action( &setVel ); } break; } }; };
void ThreadedDriver::Resume() { Start(); }
void CPatchEngine::OnNotify( CORE::CNotifier* notifier , const CORE::CEvent& eventid , CORE::CICloneable* eventdata /* = NULL */ ) {GUCEF_TRACE; if ( !m_stopSignalGiven && m_isActive ) { // Call base-class version CORE::CForwardingNotifier::OnNotify( notifier , eventid , eventdata ); if ( notifier == m_patchListEngine ) { if ( eventid == PatchListProcessingCompletedEvent ) { // YIHA,.. We are finished m_stopSignalGiven = false; m_isActive = false; NotifyObservers( PatchProcessCompletedEvent ); } else if ( eventid == PatchListProcessingFailedEvent ) { // Cascade failure m_stopSignalGiven = false; m_isActive = false; NotifyObservers( PatchProcessFailedEvent ); } } else if ( notifier == &m_url ) { if ( eventid == CORE::CURL::URLDataRecievedEvent ) { GUCEF_DEBUG_LOG( CORE::LOGLEVEL_NORMAL, "CPatchEngine: Patch list data received" ); // Translate event data const CORE::CDynamicBuffer& buffer = ( static_cast< CORE::CURL::TURLDataRecievedEventData* >( eventdata ) )->GetData(); // Append the data to our buffer m_listDataBuffer.Append( buffer.GetConstBufferPtr() , buffer.GetDataSize() ); NotifyObservers( PatchListDataReceivedEvent ); } else if ( eventid == CORE::CURL::URLAllDataRecievedEvent ) { // The retrieval process of the patch list has been completed NotifyObservers( PatchListRetrievalCompletedEvent ); // Now we must process the received patch list if ( !ProcessRecievedPatchList() ) { NotifyObservers( PatchProcessFailedEvent ); } } else if ( eventid == CORE::CURL::URLDeactivateEvent ) { GUCEF_DEBUG_LOG( CORE::LOGLEVEL_NORMAL, "CPatchEngine: Aborting patch list retrieval" ); // Someone has called Stop() while we where busy with our data retrieval m_stopSignalGiven = false; m_isActive = false; NotifyObservers( PatchProcessAbortedEvent ); } else if ( eventid == CORE::CURL::URLDataRetrievalErrorEvent ) { GUCEF_DEBUG_LOG( CORE::LOGLEVEL_NORMAL, "CPatchEngine: Patch list data retrieval error" ); // We failed to obtain the patch list data using the URL m_stopSignalGiven = false; m_isActive = false; NotifyObservers( PatchListRetrievalFailedEvent ); NotifyObservers( PatchProcessFailedEvent ); } } } else { if ( m_stopSignalGiven && m_isActive ) { m_stopSignalGiven = false; m_isActive = false; NotifyObservers( PatchProcessAbortedEvent ); } else if ( ( eventid != CORE::CNotifier::DestructionEvent ) && ( eventid != CORE::CNotifier::UnsubscribeEvent ) && ( eventid != CORE::CNotifier::SubscribeEvent ) ) { if ( m_config.HasEngineStartTriggerEvent( eventid ) ) { Start(); } else if ( m_config.HasEngineStopTriggerEvent( eventid ) ) { Stop(); } } } }
void UpdateAI(const uint32 diff) { if (!pInstance) return; if (MobDeath_Timer) { if (MobDeath_Timer <= diff) { MobDeath_Timer = 2500; if (RingBossGUID) { Creature* boss = Unit::GetCreature(*me,RingBossGUID); if (boss && !boss->isAlive() && boss->isDead()) { RingBossGUID = 0; Event_Timer = 5000; MobDeath_Timer = 0; return; } return; } for (uint8 i = 0; i < MAX_MOB_AMOUNT; ++i) { Creature* mob = Unit::GetCreature(*me,RingMobGUID[i]); if (mob && !mob->isAlive() && mob->isDead()) { RingMobGUID[i] = 0; --MobCount; //seems all are gone, so set timer to continue and discontinue this if (!MobCount) { Event_Timer = 5000; MobDeath_Timer = 0; } } } } else MobDeath_Timer -= diff; } if (Event_Timer) { if (Event_Timer <= diff) { switch (EventPhase) { case 0: DoScriptText(SCRIPT_TEXT5, me);//1 HandleGameObject(DATA_ARENA4, false); Start(false, false); CanWalk = true; Event_Timer = 0; break; case 1: CanWalk = true; Event_Timer = 0; break; case 2: Event_Timer = 2000; break; case 3: HandleGameObject(DATA_ARENA1, true); Event_Timer = 3000; break; case 4: CanWalk = true; me->SetVisibility(VISIBILITY_OFF); SummonRingMob(); Event_Timer = 8000; break; case 5: SummonRingMob(); SummonRingMob(); Event_Timer = 8000; break; case 6: SummonRingMob(); Event_Timer = 0; break; case 7: me->SetVisibility(VISIBILITY_ON); HandleGameObject(DATA_ARENA1, false); DoScriptText(SCRIPT_TEXT6, me);//4 CanWalk = true; Event_Timer = 0; break; case 8: HandleGameObject(DATA_ARENA2, true); Event_Timer = 5000; break; case 9: me->SetVisibility(VISIBILITY_OFF); SummonRingBoss(); Event_Timer = 0; break; case 10: //if quest, complete HandleGameObject(DATA_ARENA2, false); HandleGameObject(DATA_ARENA3, true); HandleGameObject(DATA_ARENA4, true); CanWalk = true; Event_Timer = 0; break; } ++EventPhase; } else Event_Timer -= diff; } if (CanWalk) npc_escortAI::UpdateAI(diff); }
void InitFx_Repeater01() { // effect auto _ps = DiEffectManager::GetInstance().CreateParticleSystemTemplate("Fx_repeater1"); std::shared_ptr<DiTransformUnit> ps(_ps); _ps->Start(); { DiParticleElement* element = _ps->CreateElement(); element->SetRenderer("Billboard"); auto emitter = element->CreateEmitter("Box"); auto mat = DiMaterial::QuickCreate("basic_v", "basic_p", SHADER_FLAG_USE_COLOR | SHADER_FLAG_USE_MAP); mat->GetShaderParameter()->WriteTexture2D("map", "glow_01.dds"); mat->SetBlendMode(BLEND_ADD); mat->SetDepthWrite(false); element->SetMaterialName(mat->GetName()); ((DiBoxEmitter*)emitter)->SetWidth(50); ((DiBoxEmitter*)emitter)->SetHeight(70); ((DiBoxEmitter*)emitter)->SetDepth(50); emitter->position = DiVec3(0, 165, 5); auto rt = DI_NEW DiAttributeFixed(); rt->SetValue(30); emitter->SetDynEmissionRate(rt); auto spd = DI_NEW DiAttributeFixed(); spd->SetValue(20); emitter->SetDynVelocity(spd); auto ttl = DI_NEW DiAttributeRandom(); ttl->SetMinMax(1, 2); emitter->SetDynTotalTimeToLive(ttl); auto sz = DI_NEW DiAttributeRandom(); sz->SetMinMax(20, 40); emitter->SetDynParticleAllDimensions(sz); DiColorController* colorCtrl = (DiColorController*)element->CreateController("Color"); colorCtrl->AddColour(0, DiColor::Black); colorCtrl->AddColour(0.5f, DiColor(0.25f, 1, 0.5f)); colorCtrl->AddColour(1, DiColor::Black); } { DiParticleElement* element = _ps->CreateElement(); element->SetRenderer("Billboard"); auto emitter = element->CreateEmitter("Box"); auto mat = DiMaterial::QuickCreate("basic_v", "basic_p", SHADER_FLAG_USE_COLOR | SHADER_FLAG_USE_MAP); auto texture = mat->GetShaderParameter()->WriteTexture2D("map", "mysticenergy2.dds"); mat->SetBlendMode(BLEND_ADD); mat->SetDepthWrite(false); element->SetMaterialName(mat->GetName()); texture->SetAddressing(AM_CLAMP); ((DiBoxEmitter*)emitter)->SetWidth(50); ((DiBoxEmitter*)emitter)->SetHeight(70); ((DiBoxEmitter*)emitter)->SetDepth(50); emitter->position = DiVec3(0, 165, 5); auto rt = DI_NEW DiAttributeFixed(); rt->SetValue(6); emitter->SetDynEmissionRate(rt); auto spd = DI_NEW DiAttributeFixed(); spd->SetValue(20); emitter->SetDynVelocity(spd); auto ttl = DI_NEW DiAttributeRandom(); ttl->SetMinMax(1, 2); emitter->SetDynTotalTimeToLive(ttl); auto sz = DI_NEW DiAttributeRandom(); sz->SetMinMax(20, 40); emitter->SetDynParticleAllDimensions(sz); DiColorController* colorCtrl = (DiColorController*)element->CreateController("Color"); colorCtrl->AddColour(0, DiColor::Black); colorCtrl->AddColour(0.5f, DiColor(0.25f, 1, 0.5f)); colorCtrl->AddColour(1, DiColor::Black); DiTextureRotatorController* texrotCtrl = (DiTextureRotatorController*)element->CreateController("TextureRotator"); texrotCtrl->SetUseOwnRotationSpeed(true); auto rotspeed = DI_NEW DiAttributeRandom(); rotspeed->SetMinMax(-100, 100); texrotCtrl->SetRotationSpeed(rotspeed); auto rot = DI_NEW DiAttributeRandom(); rot->SetMinMax(0, 300); texrotCtrl->SetRotation(rot); } // create the editor object from the particle system DiEditorManager::Get()->LoadParticleSystem(_ps); }
//----------------------------------------------------------------------------- // Purpose: Input handler that starts the target moving. //----------------------------------------------------------------------------- void CGunTarget::InputStart( inputdata_t &inputdata ) { Start(); }
void UpdateAI(const uint32 diff) { if (IsEvent) { //Must update npc_escortAI npc_escortAI::UpdateAI(diff); if (!pGo) { pGo = true; if (pInstance) { AddWaypoint(0, 5492.91f, -2404.61f, 1462.63f); AddWaypoint(1, 5531.76f, -2460.87f, 1469.55f); AddWaypoint(2, 5554.58f, -2514.66f, 1476.12f); AddWaypoint(3, 5554.16f, -2567.23f, 1479.90f); AddWaypoint(4, 5540.67f, -2625.99f, 1480.89f); AddWaypoint(5, 5508.16f, -2659.2f, 1480.15f); AddWaypoint(6, 5489.62f, -2704.05f, 1482.18f); AddWaypoint(7, 5457.04f, -2726.26f, 1485.10f); Start(false, true); SetDespawnAtEnd(false); } } } //Return since we have no target if (!UpdateVictim()) return; if (CleaveTimer <= diff) { DoCast(me, SPELL_CLEAVE); CleaveTimer = 6000+rand()%15000; } else CleaveTimer -= diff; if (WarStompTimer <= diff) { DoCast(me, SPELL_WARSTOMP); WarStompTimer = 60000; } else WarStompTimer -= diff; if (me->HasAura(SPELL_MARK)) me->RemoveAurasDueToSpell(SPELL_MARK); if (MarkTimer <= diff) { //cast dummy, useful for bos addons me->CastCustomSpell(me, SPELL_MARK, NULL, NULL, NULL, false, NULL, NULL, me->GetGUID()); std::list<HostileReference *> t_list = me->getThreatManager().getThreatList(); for (std::list<HostileReference *>::const_iterator itr = t_list.begin(); itr!= t_list.end(); ++itr) { Unit *pTarget = Unit::GetUnit(*me, (*itr)->getUnitGuid()); if (pTarget && pTarget->GetTypeId() == TYPEID_PLAYER && pTarget->getPowerType() == POWER_MANA) { pTarget->CastSpell(pTarget, SPELL_MARK,true);//only cast on mana users } } MarkTimerBase -= 5000; if (MarkTimerBase < 5500) MarkTimerBase = 5500; MarkTimer = MarkTimerBase; switch (urand(0,2)) { case 0: DoPlaySoundToSet(me, SOUND_MARK1); me->MonsterYell(SAY_MARK1, LANG_UNIVERSAL, NULL); break; case 1: DoPlaySoundToSet(me, SOUND_MARK2); me->MonsterYell(SAY_MARK2, LANG_UNIVERSAL, NULL); break; } } else MarkTimer -= diff; DoMeleeAttackIfReady(); }
void UpdateAI(const uint32 diff) { npc_escortAI::UpdateAI(diff); if (PlayerGUID) { Player* AuraPlayer = Unit::GetPlayer(*me,PlayerGUID); if (!AuraPlayer) { me->DisappearAndDie(); return; } else { if (AuraPlayer->isDead()) { AuraPlayer->FailQuest(QUEST_A_FALL_FROM_GRACE); me->DisappearAndDie(); return; } if (EndSequence) { if (EndSequenceTimer <= diff) { EndSequenceTimer = 12000; if (EndSayCount == 6) { me->GetMotionMaster()->MoveJump(HighAbbotLandgrenJumpPos[0][0][0], HighAbbotLandgrenJumpPos[0][0][1], HighAbbotLandgrenJumpPos[0][0][2], 0.5f, 8.0f); EndSequenceTimer = 2000; } if (EndSayCount == 7) { me->MonsterSay(HighAbbotText[6], LANG_UNIVERSAL, 0); EndSequenceTimer = 2000; } if (EndSayCount == 8) { AuraPlayer->KilledMonsterCredit(27444, 0); if (AuraPlayer->HasAura(SPELL_SCARLET_RAVEN_PRIEST_IMAGE_FEMALE)) AuraPlayer->RemoveAura(SPELL_SCARLET_RAVEN_PRIEST_IMAGE_FEMALE); if (AuraPlayer->HasAura(SPELL_SCARLET_RAVEN_PRIEST_IMAGE_MALE)) AuraPlayer->RemoveAura(SPELL_SCARLET_RAVEN_PRIEST_IMAGE_MALE); EndSequence = false; } if (EndSayCount < 6) me->MonsterSay(HighAbbotText[EndSayCount], LANG_UNIVERSAL, PlayerGUID); EndSayCount++; } else EndSequenceTimer -= diff; } if (!EventStarted && me->GetEntry() == NPC_HIGH_ABBOT_LANDGREN_ESCORTEE_ENTRY) { Start(false, false, PlayerGUID, 0, false); EventStarted = true; } if (CheckPlayerDist) if (AuraPlayer->GetDistance(2827.796f, -420.191f, 118.196f) < 4) StartMove(); if (AuraCheckTimer <= diff) { if (AuraPlayer && AuraPlayer->GetQuestStatus(QUEST_A_FALL_FROM_GRACE) == QUEST_STATUS_INCOMPLETE && AuraPlayer->getQuestStatusMap()[QUEST_A_FALL_FROM_GRACE].m_creatureOrGOcount[0] == 1 && !AuraPlayer->HasAura(SPELL_SCARLET_RAVEN_PRIEST_IMAGE_MALE) && !AuraPlayer->HasAura(SPELL_SCARLET_RAVEN_PRIEST_IMAGE_FEMALE)) { switch(AuraPlayer->getGender()) { case GENDER_FEMALE: AuraPlayer->CastSpell(AuraPlayer, SPELL_SCARLET_RAVEN_PRIEST_IMAGE_FEMALE, false); break; case GENDER_MALE: AuraPlayer->CastSpell(AuraPlayer, SPELL_SCARLET_RAVEN_PRIEST_IMAGE_MALE, false); break; } } AuraCheckTimer = 300; } else AuraCheckTimer -= diff; if (me->GetEntry() != NPC_HIGH_ABBOT_LANDGREN_ESCORTEE_ENTRY) { if (BodyGuardStart && AuraPlayer->GetQuestStatus(QUEST_A_FALL_FROM_GRACE) == QUEST_STATUS_INCOMPLETE && AuraPlayer->getQuestStatusMap()[QUEST_A_FALL_FROM_GRACE].m_creatureOrGOcount[0] == 1) { if (Creature* tmp = me->FindNearestCreature(NPC_DEVOUT_BODYGUARD, Range, true)) { if (BodyGuardMoveTimer <= diff) { CAST_AI(npc_devout_bodyguard::npc_devout_bodyguardAI, tmp->AI())->StartMove(); BodyGuardMoveTimer = 6000; Range = 4.0f; if (GuardCount == 1) BodyGuardStart = false; GuardCount++; } else BodyGuardMoveTimer -= diff; } } } } } }
void UpdateEscortAI(const uint32 diff) { if (!instance) return; if (instance->GetData(DATA_LICHKING_EVENT) == NOT_STARTED || instance->GetData(DATA_LICHKING_EVENT) == FAIL) { if (!UpdateVictim()) return; DoMeleeAttackIfReady(); } if (me->isInCombat() && instance->GetData(DATA_LICHKING_EVENT) == IN_PROGRESS) { npc_escortAI::EnterEvadeMode(); } // Start chase for leader if (instance->GetData(DATA_LICHKING_EVENT) == IN_PROGRESS && StartEscort != true) { StartEscort = true; me->RemoveAurasDueToSpell(SPELL_ICE_PRISON); me->RemoveAurasDueToSpell(SPELL_DARK_ARROW); me->setActive(true); NonFight = true; me->AttackStop(); Start(false, false); Step = 0; StepTimer = 100; } // Leader caught, wipe if (Creature * leader = ObjectAccessor::GetCreature(*me, instance->GetData64(DATA_ESCAPE_LEADER))) { if (leader->IsWithinDistInMap(me, 2.0f) && instance->GetData(DATA_LICHKING_EVENT) == IN_PROGRESS) { me->setActive(false); SetEscortPaused(false); me->StopMoving(); DoScriptText(SAY_LICH_KING_WIN, me); me->CastSpell(me, SPELL_FURY_OF_FROSTMOURNE, false); me->DealDamage(leader, leader->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); } } if (wall == 1) { if (StepTimer < diff) Wall01(); else StepTimer -= diff; } if (wall == 2) { if (StepTimer < diff) Wall02(); else StepTimer -= diff; } if (wall == 3) { if (StepTimer < diff) Wall03(); else StepTimer -= diff; } if (wall == 4) { if (StepTimer < diff) Wall04(); else StepTimer -= diff; } return; }
void UpdateAI(const uint32 diff) { if (IsEvent) { //Must update npc_escortAI npc_escortAI::UpdateAI(diff); if (!go) { go = true; if (instance) { AddWaypoint(0, 4896.08f, -1576.35f, 1333.65f); AddWaypoint(1, 4898.68f, -1615.02f, 1329.48f); AddWaypoint(2, 4907.12f, -1667.08f, 1321.00f); AddWaypoint(3, 4963.18f, -1699.35f, 1340.51f); AddWaypoint(4, 4989.16f, -1716.67f, 1335.74f); AddWaypoint(5, 5026.27f, -1736.89f, 1323.02f); AddWaypoint(6, 5037.77f, -1770.56f, 1324.36f); AddWaypoint(7, 5067.23f, -1789.95f, 1321.17f); Start(false, true); SetDespawnAtEnd(false); } } } //Return since we have no target if (!UpdateVictim()) return; if (FrostArmorTimer <= diff) { DoCast(me, SPELL_FROST_ARMOR); FrostArmorTimer = 40000+rand()%20000; } else FrostArmorTimer -= diff; if (DecayTimer <= diff) { DoCast(me->getVictim(), SPELL_DEATH_AND_DECAY); DecayTimer = 60000+rand()%20000; switch (urand(0, 1)) { case 0: DoPlaySoundToSet(me, SOUND_DECAY1); me->MonsterYell(SAY_DECAY1, LANG_UNIVERSAL, 0); break; case 1: DoPlaySoundToSet(me, SOUND_DECAY2); me->MonsterYell(SAY_DECAY2, LANG_UNIVERSAL, 0); break; } } else DecayTimer -= diff; if (NovaTimer <= diff) { DoCast(me->getVictim(), SPELL_FROST_NOVA); NovaTimer = 30000+rand()%15000; switch (urand(0, 1)) { case 0: DoPlaySoundToSet(me, SOUND_NOVA1); me->MonsterYell(SAY_NOVA1, LANG_UNIVERSAL, 0); break; case 1: DoPlaySoundToSet(me, SOUND_NOVA2); me->MonsterYell(SAY_NOVA2, LANG_UNIVERSAL, 0); break; } } else NovaTimer -= diff; if (IceboltTimer <= diff) { DoCast(SelectTarget(SELECT_TARGET_RANDOM, 0, 40, true), SPELL_ICEBOLT); IceboltTimer = 11000+rand()%20000; } else IceboltTimer -= diff; DoMeleeAttackIfReady(); }
void cVNSIStatus::Init(CVNSITimers *timers) { m_vnsiTimers = timers; Start(); }