25.11.2011, 20:31
Yo.
I have a small drama:
I'm scripting currently a "guided missile" which starts in the sky and travels down to the ground.
It's launched > Heads @ a set location > Detonates on arrival.
This was all good, no bugs or anything.
The next step was to make the missile CONTROLLABLE, which has been quite a task lmao.
For camera movement, I'm using nCamera by Norn.
I'll post all the coding i've done so far to try and make this work
OnPlayerCommandText()
ControlMissle() ~Rob
MoveMissle() ~Rob
OnPlayerCameraFinish() ~Norn
What I want to achieve with this code is the ability to move left/right/forward/back with the missile RELATIVE to it's angle (while still maintaining it's downward momentum), and I don't want that angle to change.
My code at the moment moves the camera around in a "dome" sort of shape, which is REALLY hard to actually control, and with the constantly changing camera angles it's bloody disorienting.
Lmao im sure the answer is simple, but im sitting here @ like 3 AM and I have no idea how to proceed
Cheers in advance
I have a small drama:
I'm scripting currently a "guided missile" which starts in the sky and travels down to the ground.
It's launched > Heads @ a set location > Detonates on arrival.
This was all good, no bugs or anything.
The next step was to make the missile CONTROLLABLE, which has been quite a task lmao.
For camera movement, I'm using nCamera by Norn.
I'll post all the coding i've done so far to try and make this work
OnPlayerCommandText()
pawn Код:
if(strcmp(cmd, "/atgm", true) == 0)
{
if(PlayerInfo[playerid][pAdmin] == 9999)
{
SendClientMessage(playerid, COLOR_LIGHTBLUE, "You are now controlling an atgm");
ControllingMissile[playerid] = 1;
HasMissileMoved[playerid] = 0;
GetPlayerPos(playerid, MissileTarget[playerid][0], MissileTarget[playerid][1], MissileTarget[playerid][2]);
ControlMissile(playerid);
}
}
pawn Код:
public ControlMissile(playerid)
{
TogglePlayerControllable(playerid, 0);
HasMissileMoved[playerid] = 0;
GetPlayerPos(playerid, MissileTarget[playerid][0], MissileTarget[playerid][1], MissileTarget[playerid][2]);
ControllingMissile[playerid] = 1;
new Float:X, Float:Y, Float:Z;
GetPlayerPos(playerid, X, Y, Z);
SetCameraPosForPlayer(playerid, X, Y, Z + 500, MissileTarget[playerid][0], MissileTarget[playerid][1], MissileTarget[playerid][2], 100, false, false);
}
pawn Код:
public MoveMissile(playerid)
{
new Keys,ud,lr;
GetPlayerKeys(playerid,Keys,ud,lr);
SetPlayerCheckpoint(playerid, MissileTarget[playerid][0], MissileTarget[playerid][1], MissileTarget[playerid][2], 50);
if(ud > 0)//down
{
new Float:LocX, Float:LocY, Float:LocZ;
new Float:EndX, Float:EndY, Float:EndZ;
new Float:VX, Float:VY, Float:VZ;
GetPlayerCameraFrontVector(playerid, VX, VY, VZ);
if(HasMissileMoved[playerid] = 0)
{
GetPlayerPos(playerid, EndX, EndY, EndZ);
GetPlayerCameraPos(playerid, LocX, LocY, LocZ);
HasMissileMoved[playerid] = 1;
}
else if(HasMissileMoved[playerid] = 1)
{
GetPlayerCameraPos(playerid, LocX, LocY, LocZ);
EndX = MissileTarget[playerid][0];
EndY = MissileTarget[playerid][1];
EndZ = MissileTarget[playerid][2];
}
//LocX = LocX;
//LocY = LocY - ATGM_MOVE_DISTANCE;
//LocZ = LocZ;
EndX = EndX;
EndY = EndY - ATGM_MOVE_DISTANCE;
EndZ = EndZ;
LocX = LocX;
LocY = LocY - ATGM_MOVE_DISTANCE;
LocZ = LocZ;
DestroyCameraForPlayer(playerid);
SetCameraPosForPlayer(playerid, LocX, LocY, LocZ - ATGM_Z_FIX, EndX, EndY, EndZ, 100, false, false);
MissileTarget[playerid][0] = EndX;
MissileTarget[playerid][1] = EndY;
MissileTarget[playerid][2] = EndZ;
return 1;
}
else if(ud < 0)//up
{
new Float:LocX, Float:LocY, Float:LocZ;
new Float:EndX, Float:EndY, Float:EndZ;
if(HasMissileMoved[playerid] = 0)
{
GetPlayerPos(playerid, EndX, EndY, EndZ);
GetPlayerCameraPos(playerid, LocX, LocY, LocZ);
HasMissileMoved[playerid] = 1;
}
else if(HasMissileMoved[playerid] = 1)
{
GetPlayerCameraPos(playerid, LocX, LocY, LocZ);
EndX = MissileTarget[playerid][0];
EndY = MissileTarget[playerid][1];
EndZ = MissileTarget[playerid][2];
}
LocX = LocX;
LocY = LocY + ATGM_MOVE_DISTANCE;
LocZ = LocZ;
EndX = EndX;
EndY = EndY + ATGM_MOVE_DISTANCE;
EndZ = EndZ;
DestroyCameraForPlayer(playerid);
SetCameraPosForPlayer(playerid, LocX, LocY, LocZ - ATGM_Z_FIX, EndX, EndY, EndZ, 100, false, false);
MissileTarget[playerid][0] = EndX;
MissileTarget[playerid][1] = EndY;
MissileTarget[playerid][2] = EndZ;
return 1;
}
if(lr > 0)//right
{
new Float:LocX, Float:LocY, Float:LocZ;
new Float:EndX, Float:EndY, Float:EndZ;
if(HasMissileMoved[playerid] = 0)
{
GetPlayerPos(playerid, EndX, EndY, EndZ);
GetPlayerCameraPos(playerid, LocX, LocY, LocZ);
HasMissileMoved[playerid] = 1;
}
else if(HasMissileMoved[playerid] = 1)
{
GetPlayerCameraPos(playerid, LocX, LocY, LocZ);
EndX = MissileTarget[playerid][0];
EndY = MissileTarget[playerid][1];
EndZ = MissileTarget[playerid][2];
}
LocX = LocX + ATGM_MOVE_DISTANCE ;
LocY = LocY ;
LocZ = LocZ;
EndX = EndX + ATGM_MOVE_DISTANCE;
EndY = EndY;
EndZ = EndZ;
DestroyCameraForPlayer(playerid);
SetCameraPosForPlayer(playerid, LocX, LocY, LocZ - ATGM_Z_FIX, EndX, EndY, EndZ, 100, false, false);
MissileTarget[playerid][0] = EndX;
MissileTarget[playerid][1] = EndY;
MissileTarget[playerid][2] = EndZ;
return 1;
}
else if(lr < 0)//left
{
new Float:LocX, Float:LocY, Float:LocZ;
new Float:EndX, Float:EndY, Float:EndZ;
if(HasMissileMoved[playerid] = 0)
{
GetPlayerPos(playerid, EndX, EndY, EndZ);
GetPlayerCameraPos(playerid, LocX, LocY, LocZ);
HasMissileMoved[playerid] = 1;
}
else if(HasMissileMoved[playerid] = 1)
{
GetPlayerCameraPos(playerid, LocX, LocY, LocZ);
EndX = MissileTarget[playerid][0];
EndY = MissileTarget[playerid][1];
EndZ = MissileTarget[playerid][2];
}
LocX = LocX - ATGM_MOVE_DISTANCE;
LocY = LocY ;
LocZ = LocZ;
EndX = EndX - ATGM_MOVE_DISTANCE;
EndY = EndY ;
EndZ = EndZ;
DestroyCameraForPlayer(playerid);
SetCameraPosForPlayer(playerid, LocX, LocY, LocZ - ATGM_Z_FIX, EndX, EndY, EndZ, 100, false, false);
MissileTarget[playerid][0] = EndX;
MissileTarget[playerid][1] = EndY;
MissileTarget[playerid][2] = EndZ;
return 1;
}
}
pawn Код:
public OnPlayerCameraFinish(playerid)
{
if(ControllingMissile[playerid] == 1)
{
HasMissileMoved[playerid] = 0;
ControllingMissile[playerid] = 0;
DestroyCameraForPlayer(playerid);
CreateExplosion(MissileTarget[playerid][0], MissileTarget[playerid][1], MissileTarget[playerid][2], 7, 500);
TogglePlayerControllable(playerid, 1);
SetCameraBehindPlayer(playerid);
MissileTarget[playerid][0] = 0.0;
MissileTarget[playerid][1] = 0.0;
MissileTarget[playerid][2] = 0.0;
}
}
My code at the moment moves the camera around in a "dome" sort of shape, which is REALLY hard to actually control, and with the constantly changing camera angles it's bloody disorienting.
Lmao im sure the answer is simple, but im sitting here @ like 3 AM and I have no idea how to proceed
Cheers in advance