• New Horizons on Maelstrom
    Maelstrom New Horizons


    Visit our website www.piratehorizons.com to quickly find download links for the newest versions of our New Horizons mods Beyond New Horizons and Maelstrom New Horizons!

Need Help Self dialog camera

Myth

Freebooter
Good afternoon. I can not solve the problem:
It is necessary that after talking with himself the hero turned 180 degrees. Now when there is a quest conversation with himself, the camera shows the hero in front. But the problem is that the hero turns, not the camera. And after the dialogue the hero does not turn back. Very much interferes.

void StartActorSelfDialog(string _CurrentNode, bool CameraFace, bool BackToPlayer)
{
LAi_SetActorType(pchar);
if(pchar.location.group == "sit")
{
LAi_ActorSetSitMode(pchar);
}
if(CameraFace == true)
{
LAi_CharacterSaveAy(pchar);
locCameraSleep(true);
if (stf(pchar.chr_ai.type.ay) > 0)
{
CharacterTurnAy(pchar, -PI + abs(stf(pchar.chr_ai.type.ay))); // 180 == 1
}
else
{
CharacterTurnAy(pchar, PI - abs(stf(pchar.chr_ai.type.ay))); // 180 == 1
}
}
pchar.Dialog.CurrentNode = _CurrentNode;

if(BackToPlayer && CameraFace)
{
LAi_ActorSelfDialog(pchar, "Turn180Player");
}
if(BackToPlayer && !CameraFace)
{
LAi_ActorSelfDialog(pchar, "pchar_back_to_player");
}
else
{
LAi_ActorSelfDialog(pchar, "");
}
}

case "Turn180Player":
Lai_SetPlayerType(pchar);
//Here we need a reversal
break;
 
I've never done any of this myself, but I know some PotC modders in the past did.
This function by @Maximus might give you some clues:
Code:
// MAXIMUS: sometimes player can't see his interlocutor - now camera will be moved to the some side for full scene viewing <--
bool DialogCamera(ref pchar, float mag, bool docheck)
{
    int side = 1;
    float x, y, z, ay, tmpY;
    bool bSmallLoc = false;
    if (FindLoadedLocation() == -1) return false; //if not in loc mode, return
    GetCharacterPos(&pchar, &x, &y, &z); // get pos
    GetCharacterAy(&pchar, &ay); // get angle
    if (mag == 0.0) {
        z -= cos(ay);
        x -= sin(ay);
        ay += PI;
        x += sin(ay);
        z += cos(ay);
        y += stf(pchar.model.height);
        locCameraToPos(x, y, z, true);
        return true;
    }
    if (Rand(3) == Rand(3)) side = -1;
    mag *= makefloat(side); // KK
    if (CheckAttribute(loadedLocation,"models.back") || HasSubStr(loadedLocation.id,"House") || HasSubStr(loadedLocation.id,"Tutorial_Deck") || HasSubStr(loadedLocation.id,"Cabin") || HasSubStr(loadedLocation.id,"Seadog")) bSmallLoc = true;
    if (bSmallLoc)
        tmpY = y + 2.2;
    else
        tmpY = y + 3.0;

    //moves back a little for viewing interlocutor
    z -= cos(ay); // add Z component
    x -= sin(ay); // add X component

    ay += PId2; // rotate angle to perpendicular
    z += cos(ay) * mag; // add Z component
    x += sin(ay) * mag; // add X component
    if (docheck)
    {
        if(CheckLocationPosition(loadedLocation, x, tmpY, z)==0)
        {
            locCameraFollow();
            return false;
        }
    }
    locCameraToPos(x, tmpY, z, true);
    return true;
}
// MAXIMUS: sometimes player can't see his interlocutor - now camera will be moved to the some side for full scene viewing <--

I don't think we've ever used a "180 degree" option, but we did do 90 degrees either side:
Code:
// a simple virtual sailor -->
bool locCameraRight(ref Character)
{
    float a,b,c,locx,locy,locz,x,y,z,ay,d,e,f;
    ref pchar = GetMainCharacter();
    GetCharacterPos(pchar, &a, &b, &c);
    GetCharacterPos(Character, &x, &y, &z);
    locy = b / 2.0 + y / 2.0 + 1.5; 
    d = abs(a - x);
    e = abs(c - z);
    GetCharacterAy(pchar, &ay);
    f = ay + PId2;
    locx = a / 3.0 + 2.0 * x / 3.0 + sin(f) * (d + e) * 1.5;
    locz = c / 3.0 + 2.0 * z / 3.0 + cos(f) * (d + e) * 1.5;
    locCameraToPos(locx, locy, locz, true);
    return true;
}

bool locCameraLeft(ref Character)
{
    float a,b,c,locx,locy,locz,x,y,z,ay,d,e,f;
    ref pchar = GetMainCharacter();
    GetCharacterPos(pchar, &a, &b, &c);
    GetCharacterPos(Character, &x, &y, &z);
    locy = b / 2.0 + y / 2.0 + 1.5; 
    d = abs(a - x);
    e = abs(c - z);
    GetCharacterAy(pchar, &ay);
    f = ay - PId2;
    locx = a / 3.0 + 2.0 * x / 3.0 + sin(f) * (d + e) * 1.5;
    locz = c / 3.0 + 2.0 * z / 3.0 + cos(f) * (d + e) * 1.5;
    locCameraToPos(locx, locy, locz, true);
    return true;
}
// a simple virtual sailor <--
Hopefully you can figure out from that how to do what you want. :doff
 
void StartActorSelfDialog(string _CurrentNode, bool CameraFace, bool BackToPlayer)
{
LAi_SetActorType(pchar);
if(pchar.location.group == "sit")
{
LAi_ActorSetSitMode(pchar);
}
if(CameraFace == true)
{
GetCharacterPos(pchar, &locx, &locy, &locz);
SendMessage(&locCamera, "lfffl", MSG_CAMERA_TOPOS, sti(&locx)+2.8, sti(&locy)+1.8, sti(&locz), false);
}
pchar.Dialog.CurrentNode = _CurrentNode;

if(BackToPlayer && CameraFace)
{
LAi_ActorSelfDialog(pchar, "Turn180Player");
}
if(BackToPlayer && !CameraFace)
{
LAi_ActorSelfDialog(pchar, "pchar_back_to_player");
}
else
{
LAi_ActorSelfDialog(pchar, "");
}
}
case "Turn180Player":
Lai_SetPlayerType(pchar);
locCameraTarget(pchar);
SendMessage(&locCamera, "l", MSG_CAMERA_FOLLOW);
break;
 
Why is the code that goes below does not always work completely. A hero unfolds only if he is in a dialogue.

LAi_CharacterSaveAy(pchar);
locCameraSleep(false);
if (stf(pchar.chr_ai.type.ay) > 0)
{
CharacterTurnAy(pchar, -PI + abs(stf(pchar.chr_ai.type.ay))); // 180 == 1
}
else
{
CharacterTurnAy(pchar, PI - abs(stf(pchar.chr_ai.type.ay))); // 180 == 1
}
 
Solved!

case "Turn180Player":
LAi_CharacterRestoreAy(pchar);
locCameraSleep(false);
DoQuestCheckDelay("pchar_back_to_player", 1.0);
break;
 
I did everything right, the problem was that there should be a delay between the turn and the change of type. If it is not, then the hero will not unfold. Apparently the type change removes the reversal parameters.
 
Back
Top