LCKB
Relocate NPC's - Printable Version

+- LCKB (https://lckb.dev/forum)
+-- Forum: ** OLD LCKB DATABASE ** (https://lckb.dev/forum/forumdisplay.php?fid=109)
+--- Forum: Guides & Help Section (https://lckb.dev/forum/forumdisplay.php?fid=193)
+---- Forum: Tutorials & Guides (https://lckb.dev/forum/forumdisplay.php?fid=124)
+----- Forum: Ep4 Guides (https://lckb.dev/forum/forumdisplay.php?fid=125)
+----- Thread: Relocate NPC's (/showthread.php?tid=5023)



- RGT - 02-26-2023


A complete guide for relocating NPC’s have been requested, and that happens to be one of the very few things I know how to do. Hopefully this will explain everything clearly, but if not, don’t hesitate to ask questions and I’ll try to answer to the best of my ability.

First off you need to find the ID of the NPC you want moved. For this you will need a NPC tool, and in this case I’m using the LCMT ( Last Chaos Multi Tool ). I will be relocating Weapon Lending Dealer, which has ID = 272

 



After you’ve found the ID, you need to decide where you want the NPC to stand. You do this by going in game and positioning your character at the exact spot you want the NPC to be at. In this case, I want Weapon Lending Dealer to stand at “1123, 898”. This is the x and z coordinates, which you will find in the top right corner above your minimap.

 



 

Now that you know the ID and the coordinates, we can go ahead and open the database and find our guy. Every NPC you need will be listed in two separate tables under live_data -> t_npc_regen and t_shop.

 



 

All the shop NPC’s will be in t_shop, and other “people” NPC will be in t_npc_regen. It’s safe to assume that Weapon Lending Dealer will be in the t_shop table, and we can make a query to find him there. To open a new Query in Navicat, go to Query -> new query and the second window will open as shown in the picture below.

To find NPC’s in t_shop you will need this query:

Select * from  t_shop where a_keeper_idx = Id (the id you found earlier)

To find NPC’s in t_npc_regen you will need this query:

Select * from  t_npc_regen where a_npc_idx = Id (the id you found earlier)

 



 

When you press the “run” button after typing the query, you should find the NPC you are looking for. If not, you might be in the wrong table, or have the wrong ID.

But now you can go ahead and change his coordinates to match the ones at the location you want the NPC. The first number 1123 = x and the second 898 = y. After the information changed to your liking, press apply to confirm it.

 



 

You can leave h as it is, and lastly there is the r position. You might find the NPC facing the wrong way, and to fix this you have to change the r value. In my case I can leave it as is, but lets say you want it to face south, you would put 180 as the value here. A nice trick is to just think of what direction relative to the north gate in Randol you are facing

 



 

After you are happy with your edits, you can go ahead and pull out the NPC tool, then save the new “mobAll.lod” file and replace the old one in your client. If you are using LCMT, you simply press file -> save as -> find your mobAll.lod in the data folder of the client and replace the file.

Close everything down and reboot the servers, then voila! Go nuts ?

If I'm wrong in anything here, please  let me know and we'll set it right!

 

 




- Judgement - 11-16-2023


Additional Thing for exact coordinates:

- Stay ingame + watch in way npc should watch

- Logout

- Go t_characters -> search for your character and take a_was_x a_was_z and a_was_r




- Judgement - 11-17-2023


Simple PHP script. Call it in browser with param 


cid


(= a_index of your t_characters row) to see values on refresh.



 


<?php



$host = "localhost";



$db = 'db';



$user = 'USER';



$pass = 'password';



$charset = 'utf8mb4';

 


try {



    $pdo = new PDO("mysql:host=$host;dbname=$db", $user, $pass);



} catch (\PDOException $e) {



    throw new \PDOException($e->getMessage(), (int)$e->getCode());



}

 


// Check for 'cid' in the URL



$cid = isset($_GET['cid']) ? $_GET['cid'] : null;



$data = null;

 


if ($cid) {



    // Prepare and execute the query



    $stmt = $pdo->prepare("SELECT a_nick, a_was_x, a_was_z, a_was_r, a_was_h FROM t_characters WHERE a_datestamp >= NOW() - INTERVAL 48 HOUR AND a_index = ?");



    $stmt->execute([$cid]);



    $data = $stmt->fetch(PDO::FETCH_ASSOC);



}



?>

 


<!doctype html>



<html lang="en">



<head>



    <!-- Bootstrap CSS -->



    <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">



    <title>Character Form</title>



</head>



<body>



<div class="container">



    <?php if (!$cid? ?>



        <!-- Form to submit 'cid' -->



        <form action="" method="get">



            <div class="mb-3">



                <label for="cid" class="form-label">Character ID</label>



                <input type="text" class="form-control" id="cid" name="cid" required>



            </div>



            <button type="submit" class="btn btn-primary">Submit</button>



        </form>



    <?php else: ?>



        <!-- New form populated with data if available -->



        <form>



            <input type="hidden" name="cid" value="<?= htmlspecialchars($cid) ?>">



            <div class="mb-3">



                <label for="a_pos_x" class="form-label">Nick</label>



                <input type="text" class="form-control" id="a_nick" name="a_nick" value="<?= htmlspecialchars($data['a_nick'] ?? '') ?>">



                <label for="a_pos_x" class="form-label">Position X</label>



                <input type="text" class="form-control" id="a_pos_x" name="a_pos_x" value="<?= htmlspecialchars($data['a_was_x'] ?? '') ?>">



                <label for="a_pos_x" class="form-label">Position Z</label>



                <input type="text" class="form-control" id="a_pos_z" name="a_pos_z" value="<?= htmlspecialchars($data['a_was_z'] ?? '') ?>">



                <label for="a_pos_x" class="form-label">Position H</label>



                <input type="text" class="form-control" id="a_pos_h" name="a_pos_h" value="<?= htmlspecialchars($data['a_was_h'] ?? '') ?>">



                <label for="a_pos_x" class="form-label">Position R</label>



                <input type="text" class="form-control" id="a_pos_r" name="a_pos_r" value="<?= htmlspecialchars($data['a_was_r'] ?? '') ?>">



            </div>



        </form>



    <?php endif; ?>



</div>



</body>



</html>





- RGT - 11-18-2023


Oooh thats a neat script, never thought of that! Nice ?




- Scura - 11-29-2023

SET @npc_id = 144; -- Id of the npc you want to update
SET @char_id = 1; -- Id of the char which logged out

UPDATE lc_data.t_npc_regen
SET 
    a_pos_h = (SELECT a_was_x FROM lc_db.t_characters WHERE a_index = @char_id),
    a_pos_r = (SELECT a_was_z FROM lc_db.t_characters WHERE a_index = @char_id),
    a_pos_x = (SELECT a_was_r FROM lc_db.t_characters WHERE a_index = @char_id),
    a_pos_z = (SELECT a_was_h FROM lc_db.t_characters WHERE a_index = @char_id)
        
        
WHERE t_npc_regen.a_npc_idx = @npc_id 
  AND t_npc_regen.a_zone_num = 6 -- 6 is just for example purpose 

You can archive the same result directly via query! (of course adapt to t_shop in case) 

    




- Judgement - 11-29-2023


Also a good job here. It's a good idea, I would also write the zone into a variable. However, I think that the PHP script is a bit better for some who then want to adjust individual values more often, without having to manually click around in the tables. With the PHP script, you still have the old values in the boxes and can manually correct them.




- Scura - 01-12-2024



On 11/29/2023 at 12:27 PM, Judgement said:




Also a good job here. It's a good idea, I would also write the zone into a variable. However, I think that the PHP script is a bit better for some who then want to adjust individual values more often, without having to manually click around in the tables. With the PHP script, you still have the old values in the boxes and can manually correct them.




Yep, agree! Just shared my personal solution since the topic was that ?




- Judgement - 01-12-2024


happy about every person who share stuff to help others. ?