Jump to content

HELP ME! I can't get the peds to walk!


toddyclipsgg

Recommended Posts

I know this isn't a topic about GTA 5 mods, but the other RDR 2 topic is very quiet. So, let's get straight to the point. I've tried several commands to get the peds to walk, but I haven't had any success. I even tried to get them to walk on foot, following a route or road, but I couldn't do it at all. I'm new to programming and I don't know where I'm going wrong. Could you help me?

void odriscollGang() {

    int groupId = PED::CREATE_GROUP(0);

    Ped playerPed = PLAYER::PLAYER_PED_ID();
    Vector3 playerPos = ENTITY::GET_ENTITY_COORDS(playerPed, true, false);
    Vector3 destination = getRandomPedPositionInRange(playerPos, 100); // Random destination

    float position = destination.x;

    std::string randomHorse = GetRandomHorseHash();
    Hash horseHash = MISC::GET_HASH_KEY(randomHorse.c_str());

    // Get a random O'Driscoll model and hash it
    std::string randomOdriscoll = GetRandomOdriscollHash();
    Hash odriscollHash = MISC::GET_HASH_KEY(randomOdriscoll.c_str());

    // Creating peds
    Ped ped1 = createPed(odriscollHash, getRandomPedPositionInRange(playerPos, 60));
    Ped ped2 = createPed(odriscollHash, getRandomPedPositionInRange(playerPos, 60));
    Ped ped3 = createPed(odriscollHash, getRandomPedPositionInRange(playerPos, 60));
    Ped ped4 = createPed(odriscollHash, getRandomPedPositionInRange(playerPos, 60));

    /*
    // Creating horses
    Ped horse1 = createPed(horseHash, getRandomPedPositionInRange(playerPos, 60));
    Ped horse2 = createPed(horseHash, getRandomPedPositionInRange(playerPos, 60));
    Ped horse3 = createPed(horseHash, getRandomPedPositionInRange(playerPos, 60));
    Ped horse4 = createPed(horseHash, getRandomPedPositionInRange(playerPos, 60));

    // Creating peds and mounting the horses
    Ped ped1 = pedMount(horse1, groupId, true, playerPos, 60);
    Ped ped2 = pedMount(horse2, groupId, true, playerPos, 60);
    Ped ped3 = pedMount(horse3, groupId, true, playerPos, 60);
    Ped ped4 = pedMount(horse4, groupId, true, playerPos, 60);
    */

    // Set ped1 as the group leader
    PED::SET_PED_AS_GROUP_LEADER(ped1, groupId, false);

    // Add the other peds as group members
    PED::SET_PED_AS_GROUP_MEMBER(ped2, groupId);
    PED::SET_PED_AS_GROUP_MEMBER(ped3, groupId);
    PED::SET_PED_AS_GROUP_MEMBER(ped4, groupId);

    // Ensure the peds are controlling the horses
    // TASK::TASK_MOUNT_ANIMAL(ped1, horse1, -1, -1, 1.5f, 1, 0, 0);
    // TASK::TASK_MOUNT_ANIMAL(ped2, horse2, -1, -1, 1.5f, 1, 0, 0);
    // TASK::TASK_MOUNT_ANIMAL(ped3, horse3, -1, -1, 1.5f, 1, 0, 0);
    // TASK::TASK_MOUNT_ANIMAL(ped4, horse4, -1, -1, 1.5f, 1, 0, 0);

    // Assign movement tasks to the mounted peds
    TASK::TASK_GO_TO_ENTITY(groupId, ped1, -1, position, 1, 0, 0);
    // TASK::TASK_FOLLOW_NAV_MESH_TO_COORD(ped1, destination.x, destination.y, destination.z, 2.0f, -1, 0.25f, 0, 0);
    TASK::TASK_FOLLOW_TO_OFFSET_OF_ENTITY(ped2, ped1, 5.0f, -5.0f, 0.0f, 2.0f, -1, 0.5f, true, false, false, false, false, false);
    TASK::TASK_FOLLOW_TO_OFFSET_OF_ENTITY(ped3, ped1, -5.0f, -5.0f, 0.0f, 2.0f, -1, 0.5f, true, false, false, false, false, false);
    TASK::TASK_FOLLOW_TO_OFFSET_OF_ENTITY(ped4, ped1, 5.0f, 5.0f, 0.0f, 2.0f, -1, 0.5f, true, false, false, false, false, false);

    /*
    // Movement task for the horses (makes the horse follow too)
    TASK::TASK_VEHICLE_DRIVE_WANDER(ped1, horse1, 2.0f, 786603);
    TASK::TASK_VEHICLE_DRIVE_WANDER(ped2, horse2, 2.0f, 786603);
    TASK::TASK_VEHICLE_DRIVE_WANDER(ped3, horse3, 2.0f, 786603);
    TASK::TASK_VEHICLE_DRIVE_WANDER(ped4, horse4, 2.0f, 786603);

    // Force activation of the AI and physics of the horses
    ENTITY::FORCE_ENTITY_AI_AND_ANIMATION_UPDATE(ped1, true);
    ENTITY::FORCE_ENTITY_AI_AND_ANIMATION_UPDATE(ped2, true);
    ENTITY::FORCE_ENTITY_AI_AND_ANIMATION_UPDATE(ped3, true);
    ENTITY::FORCE_ENTITY_AI_AND_ANIMATION_UPDATE(ped4, true);

    // Apply a light force to the horses to unlock them
    ENTITY::APPLY_FORCE_TO_ENTITY(ped1, 1, 0.1f, 0.1f, 0.0f, 0.0f, 0.0f, 0.0f, 1, true, true, true, false, true);
    ENTITY::APPLY_FORCE_TO_ENTITY(ped2, 1, 0.1f, 0.1f, 0.0f, 0.0f, 0.0f, 0.0f, 1, true, true, true, false, true);
    ENTITY::APPLY_FORCE_TO_ENTITY(ped3, 1, 0.1f, 0.1f, 0.0f, 0.0f, 0.0f, 0.0f, 1, true, true, true, false, true);
    ENTITY::APPLY_FORCE_TO_ENTITY(ped4, 1, 0.1f, 0.1f, 0.0f, 0.0f, 0.0f, 0.0f, 1, true, true, true, false, true);
    */

    // Check the progress of the movement task
    if (TASK::GET_SCRIPT_TASK_STATUS(groupId, 0x4924437D, false)) {
        logMessage("Ped is not following the leader.");
    }

    logMessage("Mounted peds and movement tasks assigned.");
}

 

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...