My player doesn't change the focus shot when I change to unfocus, but changes the unfocus shot when I change to focus (this may be a little hard to understand).
Here is the code:
task ShotU1{
while(true){
let las = -1;
let las1 = -1;
if(Shooting){
ascent(i in 0..1){
las = ObjShot_Create(OBJ_STRAIGHT_LASER);
ObjShot_Regist(las);
ObjShot_SetAutoDelete(las, false);
ObjShot_SetGraphic(las, 1016);
ObjShot_SetDamage(las, 5);
ObjShot_SetPenetration(las, 3);
ObjLaser_SetLength(las, 512);
ObjLaser_SetRenderWidth(las,20);
ObjLaser_SetIntersectionWidth(las,20);
ObjStLaser_SetAngle(las,270);
KeepAtObj(las,playerID);
deleteinloop(las);
ObjStLaser_SetSource(las,false);
Obj_SetRenderPriorityI(las,79);
}
while(Shooting&&!isFocus){
let angleT= 270-(360/72)*2;
ascent(i in 0..72/16){
let obj = CreatePlayerShotA1(ObjRender_GetX(ObjOption),ObjRender_GetY(ObjOption),5,angleT,10,1,879);
let obj1 = CreatePlayerShotA1(ObjRender_GetX(ObjOption1),ObjRender_GetY(ObjOption1),5,angleT,10,1,879);
angleT+=360/72;
ObjRender_SetColor(obj,0,0,0);
ObjRender_SetColor(obj1,0,0,0);
}
wait(5);
}
if(Shooting&&isFocus){
ascent(i in 0..1){
las = ObjShot_Create(OBJ_STRAIGHT_LASER);
ObjShot_Regist(las);
ObjShot_SetAutoDelete(las, false);
ObjShot_SetGraphic(las, 1016);
ObjShot_SetDamage(las, 5);
ObjShot_SetPenetration(las, 3);
ObjLaser_SetLength(las, 512+256);
ObjLaser_SetRenderWidth(las,20);
ObjLaser_SetIntersectionWidth(las,20);
KeepAtObj(las,ObjOption);
deleteinloop(las);
ObjStLaser_SetSource(las,false);
Obj_SetRenderPriorityI(las,79);
las1 = ObjShot_Create(OBJ_STRAIGHT_LASER);
ObjShot_Regist(las1);
ObjShot_SetAutoDelete(las1, false);
ObjShot_SetGraphic(las1, 1016);
ObjShot_SetDamage(las1, 5);
ObjShot_SetPenetration(las1, 3);
ObjLaser_SetLength(las1, 512+256);
ObjLaser_SetRenderWidth(las1,20);
ObjLaser_SetIntersectionWidth(las1,20);
KeepAtObj(las1,ObjOption1);
deleteinloop(las1);
ObjStLaser_SetSource(las1,false);
Obj_SetRenderPriorityI(las1,79);
while(!Obj_IsDeleted(las)&&!Obj_IsDeleted(las1)){
let enemy = GetAllEnemyID;
let dist = [];
let nearestID = 0;
let distA2 = [0];
ascent(i in 0..length(enemy)){
let distV = [GetDistance(ObjMove_GetX(enemy[i]),ObjMove_GetY(enemy[i]),GetPlayerX,GetPlayerY)];
dist = dist ~ distV;
}
ascent(i in 0..length(dist)){
let distnrst = min(dist[i],dist[max(i-1,0)]);
let distnrstA = [distnrst];
distA2 = distA2 ~ distnrstA;
if(distA2[i] == distnrst){nearestID++;}
}
ObjStLaser_SetAngle(las,GetAngleToObj(las,enemy[nearestID]));
ObjStLaser_SetAngle(las1,GetAngleToObj(las1,enemy[nearestID]));
yield;
}
}
}
while(Shooting){yield;}
}
yield;
}
}