예제 #1
0
        void DamageTaken(Unit* /*doneBy*/, uint32& damage, DamageEffectType, SpellSchoolMask)
        {
            if (damage >= me->GetHealth())
                if (Creature* krick = GetKrick())
                {
                    krick->InterruptNonMeleeSpells(true);
                    krick->RemoveAllAuras();
                    Position myPos(*me), exitPos;
                    float ang = me->GetOrientation()+3*M_PI/2;
                    float dist = 3.0f;
                    exitPos.Relocate(myPos.GetPositionX()+dist*cos(ang), myPos.GetPositionY()+dist*sin(ang), 515.0f, M_PI);
                    exitPos.m_positionZ = me->GetMap()->GetHeight(exitPos.GetPositionX(), exitPos.GetPositionY(), exitPos.GetPositionZ());

                    if (exitPos.GetPositionZ() < 505.0f || exitPos.GetPositionZ() > 512.0f || !me->IsWithinLOS(exitPos.GetPositionX(), exitPos.GetPositionY(), exitPos.GetPositionZ()))
                        exitPos.Relocate(myPos);

                    krick->_ExitVehicle(&exitPos);
                    krick->AI()->DoAction(1);
                }
        }
예제 #2
0
float DoorsDebugUI::GetDistance(PDOOR door)
{
	PCHARINFO charInfo = GetCharInfo();
	if (!charInfo)
		return 0;

	glm::vec3 myPos(charInfo->pSpawn->X, charInfo->pSpawn->Y, charInfo->pSpawn->Z);
	if (myPos != m_lastPos)
		m_distanceCache.clear();
	m_lastPos = myPos;

	auto it = m_distanceCache.find(door->ID);
	if (it != m_distanceCache.end())
		return it->second;

	glm::vec3 doorPos(door->DefaultX, door->DefaultY, door->DefaultZ);
	float distance = glm::distance(myPos, doorPos);

	m_distanceCache[door->ID] = distance;
	return distance;
}
예제 #3
0
파일: enemy.cpp 프로젝트: TAhub/WPRIN
creature *enemy::inRange(unsigned int distance)
{
	unsigned int numCreatures = global_map->getNumCreatures();
	sf::Vector2f myPos(getX() + getMaskWidth() / 2, getY() + getMaskHeight());
	std::vector<creature *> possibilities;
	for (unsigned int i = 0; i < numCreatures; i++)
	{
		creature *them = global_map->getCreature(i);
		sf::Vector2f theirPos(them->getX() + them->getMaskWidth() / 2, them->getY() + them->getMaskHeight());

		if (!them->dead() && them->getType() == TYPE_PLAYER && !them->invisible() &&
			abs(myPos.x - theirPos.x) < distance && myPos.y >= theirPos.y && myPos.y - MELEEDETECTV <= theirPos.y)
			possibilities.push_back(them);
	}
	if (possibilities.size() > 0)
	{
		unsigned int pick = rand() % possibilities.size();
		return possibilities[pick];
	}
	return NULL;
}
    void UpdateWaypointDriver()
    {
        double thrust = 0;
        double steering = 0;
        // Are we in an execute state (e.g. received execute command and are
        // in ready state for driving).  This part is not needed if you are
        // doing the Underwater Vehicle Competition, since you are not required to
        // drive to local waypoints.
        if(mpLocalWaypointListDriver->IsExecuting())
        {
            // If the current element in the list is 0, then we have reached the
            // end of the list.  The element ID in the list is set by the OCP using
            // the Execute message which the LocalWaypointListDriver service processes
            // for you.
            if(mpLocalWaypointListDriver->GetActiveListElementID() != 0)
            {
                // Get the current waypoint in the list.
                JAUS::SetLocalWaypoint wp = mpLocalWaypointListDriver->GetCurrentWaypoint();
                JAUS::LocalPose pose = mpLocalPoseSensor->GetLocalPose();
                // See if we reached the point.
                CxUtils::Point3D wpPos(wp.GetX(), wp.GetY(), wp.GetZ());
                CxUtils::Point3D myPos(pose.GetX(), pose.GetY(), pose.GetZ());
                double distanceToWaypoint = myPos.Distance(wpPos);
                double tolerance = 0.25;
                // See if the waypoint has a desired tolerance, if not use the
                // default value of 0.25 meter radius.
                if(wp.IsFieldPresent(JAUS::SetLocalWaypoint::PresenceVector::WaypointTolerance))
                {
                    tolerance = wp.GetWaypointTolerance();
                }
                if(distanceToWaypoint <= tolerance)
                {
                    // Reached point, advance list.
                    mpLocalWaypointListDriver->AdvanceListElement();
                }
                else
                {
                    // Drive to local waypoint by generating a desired
                    // thrust and steering.  For this demo/example program
                    // an open-loop control system is used.

                    // Get angle to waypoint.
                    double angle = atan2(wpPos.mY - myPos.mY, wpPos.mX - myPos.mX);
                    double angleDiff = CxUtils::Orientation::AngleDiff(pose.GetYaw(), angle);
                    // Steer to angle
                    if(fabs(angleDiff) > CxUtils::CxToRadians(5))
                    {
                        steering = 30;
                        if(angleDiff < 0)
                        {
                            steering *= -1;
                        }
                    }
                    else
                    {
                        // Within 5 degrees of desired heading
                        // set thrust to 30 to drive, and
                        // stop rotating.
                        thrust = 30;
                        steering = 0;
                    }
                }
            }

            // Check for control of Primitive Driver component
            if(mLocalWaypointDriverComponent.AccessControlService()->HaveControl(mBaselineComponent.GetComponentID()) == false)
            {
                mLocalWaypointDriverComponent.AccessControlService()->RequestComponentControl(mBaselineComponent.GetComponentID());
                // Put component in ready state.
                mLocalWaypointDriverComponent.ManagementService()->Resume(mBaselineComponent.GetComponentID());
            }
            if(mLocalWaypointDriverComponent.AccessControlService()->HaveControl(mBaselineComponent.GetComponentID()))
            {
                // Send drive command to make robot move!
                JAUS::SetWrenchEffort wrenchCommand(mBaselineComponent.GetComponentID(), mLocalWaypointDriverComponent.GetComponentID());
                wrenchCommand.SetPropulsiveLinearEffortX(thrust);
                wrenchCommand.SetPropulsiveRotationalEffortZ(steering);
                mLocalWaypointDriverComponent.Send(&wrenchCommand);
            }
        }
        else
        {
            // Make sure we release control if we don't need it.
            if(mLocalWaypointDriverComponent.AccessControlService()->HaveControl(mBaselineComponent.GetComponentID()))
            {
                mLocalWaypointDriverComponent.AccessControlService()->ReleaseComponentControl(mBaselineComponent.GetComponentID());
            }
        }
    }
예제 #5
0
파일: ofApp.cpp 프로젝트: husk00/phi
//--------------------------------------------------------------
void ofApp::setup(){
	//ofSetOrientation(OF_ORIENTATION_90_RIGHT);
		  ofBackground(0,0,0);
	    //ofSetBackgroundAuto(true);
	    ofSetOrientation(OF_ORIENTATION_90_LEFT);
		  ofSetFrameRate(60);
	    ofEnableSmoothing();
	    ofSetCircleResolution(48);
		center.set((ofGetWidth()/2),410);

	    //OSC
	    // open an outgoing connection to HOST:PORT
	    M8sender.setup(M8HOST, M8PORT);
	    liveSender.setup(LIVEHOST, LIVEPORT);

	    //timing
	    elapsedTime = ofGetElapsedTimeMillis();
	    last = ofGetElapsedTimeMillis();
	    activeStep = 33;

	    //paging
	    page = 1;
	    currentPage = 1;
	    font.loadFont("fonts/Inconsolata.otf", 15, true,false,false,0.3,90);
	    rightBover = false;
	    leftBover = false;
	    fadeUp = false;
	    fadeDown = false;
	    cc = 80;
	    pausa = false;

	    //stepping
	    counter = 5;
	    nextStep = false;
	    //step state inizialization
		  for(int i=0; i<8; i++){
	      stepOver[i] = false;
	    }

		  //load interface images
		  banner.loadImage("images/banner.jpg");
		  colsx.loadImage("images/colsx.jpg");
		  coldx.loadImage("images/coldx.jpg");
		  fondocentral.loadImage("images/fondocentral.jpg");
		  letra.loadImage("images/letra.jpg");

		  // crear las slices
		  for(int i=0; i<32; i++){
		    slice[i].lineTo(center);
		    slice[i].arc(center,315,310,(i*11.25),(i*11.25)+11.25, 100);
		  }
		  //color FX slice
		  for(int i=0; i<4; i++){
	      if(i == 0){
	      fxColor[i].r=255;
		    fxColor[i].g=0;
		    fxColor[i].b=103;
	      }
	      if(i == 1){
	      fxColor[i].r=0;
		    fxColor[i].g=177;
		    fxColor[i].b=177;
	      }
	      if(i == 2){
	      fxColor[i].r=176;
		    fxColor[i].g=241;
		    fxColor[i].b=0;
	      }
	      if(i == 3){
	      fxColor[i].r=243;
		    fxColor[i].g=46;
		    fxColor[i].b=35;
	      }
	    }

	    //FX state inizialization
		  for(int i=0; i<32; i++){
	        fxState[i] = false;
	    }

	    //inizialize steps
	    myStep = new ofStep*[8];
	        for(int j = 0; j < 8; j++){
	           myStep[j] = new ofStep(j, center);
	        }

	        //inizialize buttons
	        myButton = new ofButton*[3];
	        //reset
	        //ofPoint myPos(965, (ofGetHeight()-((ofGetHeight()/100)*35)));
	        ofPoint myPos(0, (ofGetHeight()-((ofGetHeight()/100)*23)));
	        myButton[0] = new ofButton(0,myPos, "RESET", false );
	        //random
	        myPos.y += myButton[0]->form.height+10;
	        myButton[1] = new ofButton(1,myPos, "RANDOM", false );
	        //masterplay
	        ofPoint myPos2(0, (ofGetHeight()-((ofGetHeight()/100)*35)));
	        myButton[2] = new ofButton(2,myPos2, "PLAY/STOP", false );

	    /*
	        myButton[1] = new ofButton(1,myPos, "RANDOM" );
	      */
	        //convertir steps en ofPath para que se puedan llenar
	        for(int j = 0; j < 32; j++){
	          for( int i = 0; i < slice[j].getVertices().size(); i++) {
	              if(i == 0) {
	                  path[j].newSubPath();
	                  path[j].moveTo(slice[j].getVertices()[i] );
	              } else {
	                  path[j].lineTo( slice[j].getVertices()[i] );
	              }
	          }
	            path[j].close();
	            path[j].simplify();
	          }

	        //inizialize patterns
	        pattern = new myPattern*[32];
	        for(int j = 0; j < 32; j++){
	           pattern[j] = new myPattern(j+1);
	        }


}
예제 #6
0
void MQ2NavigationPlugin::OnUpdateTab(TabPage tabId)
{
	if (tabId == TabPage::Navigation)
	{
		ImGui::TextColored(ImColor(255, 255, 0), "Type /nav ui to toggle this window");

		if (ImGui::Checkbox("Pause navigation", &m_isPaused)) {
			if (m_isPaused)
				MQ2Globals::ExecuteCmd(FindMappableCommand("FORWARD"), 0, 0);
		}

		if (ImGui::CollapsingHeader("Pathing Debug"))
		{
			bool settingsChanged = false;
			auto& settings = mq2nav::GetSettings();

			if (ImGui::Checkbox("Render pathing debug draw", &settings.debug_render_pathing))
				settingsChanged = true;
			if (ImGui::Checkbox("Use Pathing Corridor (experimental)", &settings.debug_use_pathing_corridor))
				settingsChanged = true;

			if (settingsChanged)
				mq2nav::SaveSettings();

			if (m_activePath) 
			{
				auto charInfo = GetCharInfo();
				glm::vec3 myPos(charInfo->pSpawn->X, charInfo->pSpawn->Z, charInfo->pSpawn->Y);
				auto dest = m_activePath->GetDestination();

				ImGui::LabelText("Position", "(%.2f, %.2f, %.2f)", myPos.x, myPos.y, myPos.z);

				ImGui::LabelText("Current Waypoint", "(%.2f, %.2f, %.2f,",
					m_currentWaypoint.x, m_currentWaypoint.y, m_currentWaypoint.z);
				ImGui::LabelText("Distance to Waypoint", "%.2f", glm::distance(m_currentWaypoint, myPos));

				ImGui::LabelText("Destination", "(%.2f, %.2f, %.2f)", dest.x, dest.y, dest.z);
				ImGui::LabelText("Distance", "%.2f", glm::distance(dest, myPos));

				ImGui::Text("Path Nodes");
				ImGui::Separator();

				ImGui::BeginChild("PathNodes");
				for (int i = 0; i < m_activePath->GetPathSize(); ++i)
				{
					ImColor color(255, 255, 255);

					if (i == 0)
						color = ImColor(255, 255, 0);
					if (i == m_activePath->GetPathIndex())
						color = ImColor(0, 255, 0);
					if (i == m_activePath->GetPathSize() - 1)
						color = ImColor(255, 0, 0);

					auto pos = m_activePath->GetRawPosition(i);
					ImGui::TextColored(color, "%04d: (%.2f, %.2f, %.2f)", i,
						pos[0], pos[1], pos[2]);
				}
				ImGui::EndChild();
			}
			else {
				ImGui::LabelText("Destination", "<none>");
				ImGui::LabelText("Distance", "");
			}

			ImGui::Separator();
			ImGui::LabelText("Ending Door", "%s", m_pEndingDoor ? m_pEndingDoor->Name : "<none>");
			ImGui::LabelText("Ending Item", "%s", m_pEndingItem ? m_pEndingItem->Name : "<none>");
			ImGui::LabelText("Is Active", "%s", m_isActive ? "true" : "false");
			ImGui::LabelText("Spam Click", "%s", m_bSpamClick ? "true" : "false");
			ImGui::LabelText("Current Waypoint", "(%.2f, %.2f, %.2f)", m_currentWaypoint.x, m_currentWaypoint.y, m_currentWaypoint.z);
			ImGui::LabelText("Stuck Data", "(%.2f, %.2f) %d", m_stuckX, m_stuckY, m_stuckTimer.time_since_epoch());
			ImGui::LabelText("Last Click", "%d", m_lastClick.time_since_epoch() / 1000000);
			ImGui::LabelText("Pathfind Timer", "%d", m_pathfindTimer.time_since_epoch() / 1000000);
		}

		ImGui::Separator();

		auto navmeshRenderer = Get<NavMeshRenderer>();
		navmeshRenderer->OnUpdateUI();

		if (m_activePath) m_activePath->OnUpdateUI();
	}
}