void SpecificWorker::compute() { switch(modovalue) { case -1: uphexapod(); break; case 0: LEGS->setVisible(false); break; case 1://Alternating tripod ocultarAngles(); if(caminar3x3()) { lini=QVec::vec3(-X,0,-Z); lfin=QVec::vec3(X,0,Z); } break; case 2://Cuadrupedo ocultarAngles(); if(Quadruped()) { lini=QVec::vec3(-X,0,-Z); lfin=QVec::vec3(X,0,Z); } break; case 3://Crawl ocultarAngles(); if(Crawl()) { lini=QVec::vec3(-X,0,-Z); lfin=QVec::vec3(X,0,Z); } break; case 4://rotate ocultarAngles(); if(rotar()) lrot=QVec::vec3(0,0,Y); break; case 5://FK legs ocultarPoint(); if(angles_pre.q1!=angles.q1||angles_pre.q2!=angles.q2||angles_pre.q3!=angles.q3) { fkLegs(); angles_pre.q1=angles.q1; angles_pre.q2=angles.q2; angles_pre.q3=angles.q3; } break; case 6://IK Legs ocultarAngles(); if(X_pre!=X || Y_pre!=Y || Z_pre!=Z) { ikLegs(); X_pre=X; Y_pre=Y; Z_pre=Z; } break; case 7://IK Body mostrarPointandAngles(); if(X_pre!=X || Y_pre!=Y || Z_pre!=Z||angles_pre.q1!=angles.q1||angles_pre.q2!=angles.q2||angles_pre.q3!=angles.q3) { ikBody(); X_pre=X; Y_pre=Y; Z_pre=Z; angles_pre.q1=angles.q1; angles_pre.q2=angles.q2; angles_pre.q3=angles.q3; } break; case 8://IKonlyoneleg ocultarAngles(); if(X_pre!=X || Y_pre!=Y || Z_pre!=Z) { ikonlyoneleg(); X_pre=X; Y_pre=Y; Z_pre=Z; } break; case 9://FKonlyoneleg ocultarPoint(); if(angles_pre.q1!=angles.q1||angles_pre.q2!=angles.q2||angles_pre.q3!=angles.q3) { fkonlyoneleg(); angles_pre.q1=angles.q1; angles_pre.q2=angles.q2; angles_pre.q3=angles.q3; } break; } }
void CControllerHeadBall :: HuntThink( void ) { pev->nextthink = gpGlobals->time + 0.1; pev->renderamt -= 5; MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); WRITE_BYTE( TE_ELIGHT ); WRITE_SHORT( entindex( ) ); // entity, attachment WRITE_COORD( pev->origin.x ); // origin WRITE_COORD( pev->origin.y ); WRITE_COORD( pev->origin.z ); WRITE_COORD( pev->renderamt / 16 ); // radius WRITE_BYTE( 255 ); // R WRITE_BYTE( 255 ); // G WRITE_BYTE( 255 ); // B WRITE_BYTE( 2 ); // life * 10 WRITE_COORD( 0 ); // decay MESSAGE_END(); // check world boundaries if (gpGlobals->time - pev->dmgtime > 5 || pev->renderamt < 64 || m_hEnemy == NULL || m_hOwner == NULL || pev->origin.x < -4096 || pev->origin.x > 4096 || pev->origin.y < -4096 || pev->origin.y > 4096 || pev->origin.z < -4096 || pev->origin.z > 4096) { SetTouch( NULL ); UTIL_Remove( this ); return; } MovetoTarget( m_hEnemy->Center( ) ); if ((m_hEnemy->Center() - pev->origin).Length() < 64) { TraceResult tr; UTIL_TraceLine( pev->origin, m_hEnemy->Center(), dont_ignore_monsters, ENT(pev), &tr ); CBaseEntity *pEntity = CBaseEntity::Instance(tr.pHit); if (pEntity != NULL && pEntity->pev->takedamage) { ClearMultiDamage( ); pEntity->TraceAttack( m_hOwner->pev, gSkillData.controllerDmgZap, pev->velocity, &tr, DMG_SHOCK ); ApplyMultiDamage( pev, m_hOwner->pev ); } MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); WRITE_BYTE( TE_BEAMENTPOINT ); WRITE_SHORT( entindex() ); WRITE_COORD( tr.vecEndPos.x ); WRITE_COORD( tr.vecEndPos.y ); WRITE_COORD( tr.vecEndPos.z ); WRITE_SHORT( g_sModelIndexLaser ); WRITE_BYTE( 0 ); // frame start WRITE_BYTE( 10 ); // framerate WRITE_BYTE( 3 ); // life WRITE_BYTE( 20 ); // width WRITE_BYTE( 0 ); // noise WRITE_BYTE( 255 ); // r, g, b WRITE_BYTE( 255 ); // r, g, b WRITE_BYTE( 255 ); // r, g, b WRITE_BYTE( 255 ); // brightness WRITE_BYTE( 10 ); // speed MESSAGE_END(); UTIL_EmitAmbientSound( ENT(pev), tr.vecEndPos, "weapons/electro4.wav", 0.5, ATTN_NORM, 0, RANDOM_LONG( 140, 160 ) ); m_flNextAttack = gpGlobals->time + 3.0; SetThink( DieThink ); pev->nextthink = gpGlobals->time + 0.3; } Crawl( ); }
bool CPathFinderRay::Execute() { CPathFinderRay *pRay; int iX,iY,iLastX,iLastY; switch (Status) { // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - case PF_Ray_Launch: // Path free if (PathFree(X2,Y2,TargetX,TargetY)) { // Back shorten for (pRay=this; pRay->From; pRay=pRay->From) while (pRay->CheckBackRayShorten()) {} // Set all waypoints for (pRay=this; pRay->From; pRay=pRay->From) pPathFinder->SetWaypoint(pRay->From->X2,pRay->From->Y2,pPathFinder->WaypointParameter); // Success pPathFinder->Success=true; Status=PF_Ray_Still; return true; } // Path intersected else { // Start crawling Status=PF_Ray_Crawl; CrawlStartX=X2; CrawlStartY=Y2; CrawlAttach=FindCrawlAttach(X2,Y2); CrawlLength=0; if (!CrawlAttach) CrawlAttach=FindCrawlAttachDiagonal(X2,Y2,Direction); CrawlStartAttach=CrawlAttach; // Intersected but no attach found: unexpected failure if (!CrawlAttach) Status=PF_Ray_Failure; return true; } break; // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - case PF_Ray_Crawl: // Crawl iLastX=X2; iLastY=Y2; if (!Crawl()) { Status=PF_Ray_Failure; break; } // Back at crawl starting position: done and still if ((X2==CrawlStartX) && (Y2==CrawlStartY) && (CrawlAttach==CrawlStartAttach)) { Status=PF_Ray_Still; break; } // Crawl length CrawlLength++; if (CrawlLength>=pPathFinder->MaxCrawl) { Status=PF_Ray_Still; break; } // Check back path intersection iX=X; iY=Y; if (!PathFree(iX,iY,X2,Y2)) // Insert split ray if (!pPathFinder->SplitRay(this,iLastX,iLastY)) { Status=PF_Ray_Failure; break; } // Try new ray at target iX=X2; iY=Y2; // If has been crawling for a while if (CrawlLength>pPathFinder->Threshold) // If all free... if ( PathFree(iX,iY,TargetX,TargetY) // ...or at least beyond threshold and not backwards toward crawl start || ((Distance(iX,iY,X2,Y2)>pPathFinder->Threshold) && (Distance(iX,iY,CrawlStartX,CrawlStartY)>Distance(X2,Y2,CrawlStartX,CrawlStartY))) ) { // Still Status=PF_Ray_Still; // Launch new rays if (!pPathFinder->AddRay(X2,Y2,TargetX,TargetY,Depth+1,PF_Direction_Left,this) || !pPathFinder->AddRay(X2,Y2,TargetX,TargetY,Depth+1,PF_Direction_Right,this)) Status=PF_Ray_Failure; } break; // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - case PF_Ray_Still: case PF_Ray_Failure: case PF_Ray_Deleted: return false; // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - } return true; }