//Begin page main // for scholar spaceman float otherAttitude[3]; float zero[3]; float mystate[12]; float otherState[12]; float otherAngle[12]; float score; int step; int seconds; int rendezvoustime; bool hooked; float a0, b0, c0, a1, b1, c1; void init(){ step = 0; seconds = 0; rendezvoustime = 0; } void loop(){ seconds++; for(int i = 0; i < 3; i++){ otherAttitude[i] = otherState[i+6]; } for(int i = 0; i < 3; i++){ zero[i] = 0; } api.getMyZRState(mystate); api.getOtherZRState(otherState); game.getOtherEulerState(otherAngle); score = game.getScore(); hooked = game.getHooked(); targetPos(); hook(); Tug(); } float angles[3]; float pos[3]; float vectorBetween[3]; void targetPos(){ if(step == 0){ rendezvoustime ++; // x^2+y^2+z^2 = 1 pos[0] = otherAttitude[0]*2*0.17095f + otherState[0]; pos[1] = otherAttitude[1]*2*0.17095f + otherState[1]; if(otherState[0] > 0){ pos[2] = otherAttitude[2]*2*0.17095f + otherState[2] + 0.002; } else{ pos[2] = otherAttitude[2]*2*0.17095f + otherState[2] - 0.002; } if(sqrtf((otherState[0])*(otherState[0])+(otherState[2])*(otherState[2])) < 0.03f) pos[2] = -0.05f; if(seconds <= 10){ mathVecSubtract(vectorBetween,otherState,mystate,3); api.setVelocityTarget(vectorBetween); } else{ api.setPositionTarget(pos); } //api.setPositionTarget(pos); angles[0] = -otherAngle[6] + PI; angles[1] = otherAngle[7] + PI; angles[2] = otherAngle[8]; game.setEulerTarget(angles); if(fabs(otherState[1] - mystate[1]) <= 0.335 || game.getGamePhase() == 4){ a0 = angles[0]; b0 = angles[1]; c0 = angles[2]; a1 = otherAngle[6]; b1 = otherAngle[7]; c1 = otherAngle[8]; step++; } } } void hook(){ if(step == 1){ for(int i = 0;i < 3; i++){ pos[i] = otherAttitude[i]*2*0.17095f + otherState[i]; } api.setPositionTarget(pos); if(seconds <= 60) { angles[0] = -otherAngle[6] + PI; angles[1] = otherAngle[7] + PI; angles[2] = otherAngle[8]; game.setEulerTarget(angles); } DEBUG(("%f %f %f", otherAngle[6], otherAngle[7], otherAngle[8])); if(score > 4 || (seconds > 70&&sqrtf((otherState[0])*(otherState[0])+(otherState[2])*(otherState[2])) < 0.03f)){ a0 = angles[0]; b0 = angles[1]; c0 = angles[2]; step++; } } } void Tug(){ if(step == 2){ game.getOtherEulerState(otherAngle); angles[0] = a0; angles[1] = b0; angles[2] = c0; game.setEulerTarget(angles); if(otherState[2] > 0 && otherState[1] < 0){ pos[0] = otherState[0]; pos[1] = 0.9; pos[2] = otherState[2];// - 1; } else { pos[0] = otherState[0]; pos[1] = 0.9; pos[2] = otherState[2];// + 1; } api.setPositionTarget(pos); if(mystate[1] > 0){ pos[0] = otherState[0] - 1; pos[1] = 0.7; if(otherState[2] > 0){ pos[2] = mystate[2] - 1; } else if(otherState[2] < 0){ pos[2] = mystate[2] + 1; } api.setForces(pos); } } } //End page main