Jump to content

Placing a ped at a location


SAC
 Share

Recommended Posts

 

I am trying to teleport a ped to a nearby location (within the local map, not remote)

 

I am trying to use 

 

SAC_appendLineToFile("sac_rdr2_log.txt", "Noose victim at x = " + to_string(nooseSpot->getAnchorPosition().x) + " y = " + to_string(nooseSpot->getAnchorPosition().y) + " z = " + to_string(nooseSpot->getAnchorPosition().z));

	// trace file logs: Noose victim at x = -315.040009 y = 732.947998 z = 122.899002, so x, y and z should be valid

ENTITY::SET_ENTITY_COORDS(victim, nooseSpot->getAnchorPosition().x, nooseSpot->getAnchorPosition().y, nooseSpot->getAnchorPosition().z + 1, 1, 1, 1, false);

 

and it doesn't do anything

 

How should I implement this?

 

 

 

My Fallout 4 and Skyrim mods: SAC - LoversLab

 

Link to comment
Share on other sites

I have no experience in placing peds somewhere, but is there a function GET_ENTITY_COORDS? If so, could you check the victims coords after you applied the function you mentioned above? (so you can see if the entity is anywhere near the coords you get in your log.

Link to comment
Share on other sites

I'm using this one to do that:

ENTITY::_SET_ENTITY_COORDS_AND_HEADING_NO_OFFSET(entity, coord.x, coord.y, coords.z, heading, true, true);

Can't remember why I started using this instead of SET_ENTITY_COORDS, but this one works for me.

  • Thanks 1
Link to comment
Share on other sites

4 hours ago, crossed99 said:

I'm using this one to do that:

ENTITY::_SET_ENTITY_COORDS_AND_HEADING_NO_OFFSET(entity, coord.x, coord.y, coords.z, heading, true, true);

Can't remember why I started using this instead of SET_ENTITY_COORDS, but this one works for me.

 

Thank you, seems to work fine.

 

Actually, SET_ENTITY_COORDS seems to work too, but only sometimes. Anyway, will use yours, thanks\

 

  • Like 1

 

My Fallout 4 and Skyrim mods: SAC - LoversLab

 

Link to comment
Share on other sites

  • 2 weeks later...
On 1/9/2022 at 12:53 PM, crossed99 said:

I'm using this one to do that:

ENTITY::_SET_ENTITY_COORDS_AND_HEADING_NO_OFFSET(entity, coord.x, coord.y, coords.z, heading, true, true);

Can't remember why I started using this instead of SET_ENTITY_COORDS, but this one works for me.

 

 

Because I needed precise positioning and I kept getting random glitches (NPCs being strung off-position), I've ended up using a loop to attempt multiple placements until the position is confirmed

 

        PED::SET_BLOCKING_OF_NON_TEMPORARY_EVENTS(victim, true);

        int position_i = 0;
        float trapdoor_distance = 10;
        Vector3 victim_pos;
        Vector3 trapdoor_pos;
        trapdoor_pos = nooseSpot->getTrapdoorPosition();

        while (position_i < 10 && trapdoor_distance > 1)
        {
            ENTITY::_SET_ENTITY_COORDS_AND_HEADING_NO_OFFSET(victim, nooseSpot->getAnchorPosition().x, nooseSpot->getAnchorPosition().y, nooseSpot->getAnchorPosition().z - 0.5, requested_gallow->noosedPedHeading, true, true);

            WAIT(500);

            victim_pos = ENTITY::GET_ENTITY_COORDS(victim, 1, 0);
            
            trapdoor_distance = GAMEPLAY::GET_DISTANCE_BETWEEN_COORDS(victim_pos.x, victim_pos.y, victim_pos.z, trapdoor_pos.x, trapdoor_pos.y, trapdoor_pos.z, 1);

            position_i = position_i + 1;
          
          	// WAIT(0); // must have a wait in while loops
        }

        SAC_appendLineToFile("sac_rdr2_log.txt", "autogallows - check 3, required " + to_string(position_i) + " positioning iterations, distance to trapdoor is " + to_string(trapdoor_distance));

 

 

Sometimes it works straight up, sometimes it takes a number of tries - these are the results for 4 different NPCs being placed sequentially, note that 3 out of 4 were placed at the first try, however the 4th required 3 cycles to position correctly (which are the glitches I've seen happening in-game as well)

 

autogallows - check 3, required 1 positioning iterations, distance to trapdoor is 0.830377
autogallows - check 3, required 1 positioning iterations, distance to trapdoor is 0.851509
autogallows - check 3, required 1 positioning iterations, distance to trapdoor is 0.579172
autogallows - check 3, required 3 positioning iterations, distance to trapdoor is 0.788400

<!-- later edit -->

autogallows - check 3, required 3 positioning iterations, distance to trapdoor is 0.831077
autogallows - check 3, required 4 positioning iterations, distance to trapdoor is 0.632743
autogallows - check 3, required 1 positioning iterations, distance to trapdoor is 0.829728
autogallows - check 3, required 1 positioning iterations, distance to trapdoor is 0.794881

 

LE: added more attempts demonstrating some of the NPCs take multiple iterations to position correctly

 

 

 

Edited by SAC

 

My Fallout 4 and Skyrim mods: SAC - LoversLab

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...