[Release] Edit of Monster spawn time/rate edit to make it easy.

05/31/2024 17:52 Mdarude#1
Hello all this is my first release and it's a remake of a other query in this one allows you only open the 3 tables and find more information of the monster.

and the second one you could edit things like this :
-- desired total count of mobs
-- desired minimum spawn delay
-- desired maximum spawn delay

I did not find one like this and wanted to make it easy for myself.
Since some monsters have 2 Id's this will find that also.

Code:
USE SRO_VT_SHARD;

DECLARE @MOB VARCHAR(64);
DECLARE @NESTID INT;
DECLARE @HiveID INT;

SET @MOB = 'MOB_RM_WINGTRIBE_CLON'; -- mob name

-- Temporary table to hold Tactics IDs
CREATE TABLE #TacticsIDs (dwTacticsID INT);

-- Fetch all Tactics IDs based on MOB
INSERT INTO #TacticsIDs (dwTacticsID)
SELECT dwTacticsID 
FROM Tab_RefTactics 
WHERE dwObjID = (SELECT ID FROM _RefObjCommon WHERE Codename128 = @MOB);

-- Fetch and display information for each Tactics ID
DECLARE @CurrentTacticsID INT;

DECLARE TacticsCursor CURSOR FOR 
SELECT dwTacticsID FROM #TacticsIDs;

OPEN TacticsCursor;

FETCH NEXT FROM TacticsCursor INTO @CurrentTacticsID;

WHILE @@FETCH_STATUS = 0
BEGIN
    -- Fetch Nest ID based on Tactics ID
    SET @NESTID = (SELECT TOP 1 dwNestID FROM Tab_RefNest WHERE dwTacticsID = @CurrentTacticsID);

    -- Fetch Hive ID based on Tactics ID
    SET @HiveID = (SELECT TOP 1 dwHiveID FROM Tab_RefNest WHERE dwTacticsID = @CurrentTacticsID);

    -- Select detailed information from relevant tables
    SELECT * FROM Tab_RefHive WHERE dwHiveID = @HiveID;
    SELECT * FROM Tab_RefTactics WHERE dwTacticsID = @CurrentTacticsID;
    SELECT * FROM Tab_RefNest WHERE dwTacticsID = @CurrentTacticsID;

    FETCH NEXT FROM TacticsCursor INTO @CurrentTacticsID;
END;

CLOSE TacticsCursor;
DEALLOCATE TacticsCursor;

-- Drop temporary table
DROP TABLE #TacticsIDs;
the second one.

Code:
USE SRO_VT_SHARD;

DECLARE @MOB VARCHAR(64);
DECLARE @NESTID INT;
DECLARE @HiveID INT;
DECLARE @MaxTotalCount INT;
DECLARE @DelayTimeMin INT;
DECLARE @DelayTimeMax INT;

SET @MOB = 'MOB_TK_BONELORD'; -- replace with your specific monster code name
SET @MaxTotalCount = 20; -- desired total count of mobs
SET @DelayTimeMin = 5;   -- desired minimum spawn delay
SET @DelayTimeMax = 10;  -- desired maximum spawn delay

-- Temporary table to hold Tactics IDs
CREATE TABLE #TacticsIDs (dwTacticsID INT);

-- Fetch all Tactics IDs based on MOB
INSERT INTO #TacticsIDs (dwTacticsID)
SELECT dwTacticsID 
FROM Tab_RefTactics 
WHERE dwObjID = (SELECT ID FROM _RefObjCommon WHERE Codename128 = @MOB);

-- Fetch and display information for each Tactics ID
DECLARE @CurrentTacticsID INT;

DECLARE TacticsCursor CURSOR FOR 
SELECT dwTacticsID FROM #TacticsIDs;

OPEN TacticsCursor;

FETCH NEXT FROM TacticsCursor INTO @CurrentTacticsID;

WHILE @@FETCH_STATUS = 0
BEGIN
    -- Fetch Nest ID based on Tactics ID
    SET @NESTID = (SELECT TOP 1 dwNestID FROM Tab_RefNest WHERE dwTacticsID = @CurrentTacticsID);

    -- Fetch Hive ID based on Tactics ID
    SET @HiveID = (SELECT TOP 1 dwHiveID FROM Tab_RefNest WHERE dwTacticsID = @CurrentTacticsID);

    -- Select detailed information from relevant tables
    SELECT * FROM Tab_RefHive WHERE dwHiveID = @HiveID;
    SELECT * FROM Tab_RefTactics WHERE dwTacticsID = @CurrentTacticsID;
    SELECT * FROM Tab_RefNest WHERE dwTacticsID = @CurrentTacticsID;

    -- Update the dwMaxTotalCount, dwDelayTimeMin, and dwDelayTimeMax fields
    UPDATE Tab_RefNest
    SET dwMaxTotalCount = @MaxTotalCount, -- Set the new number of mobs
        dwDelayTimeMin = @DelayTimeMin,    -- Set the new minimum spawn delay
        dwDelayTimeMax = @DelayTimeMax     -- Set the new maximum spawn delay
    WHERE dwTacticsID = @CurrentTacticsID;

    FETCH NEXT FROM TacticsCursor INTO @CurrentTacticsID;
END;

CLOSE TacticsCursor;
DEALLOCATE TacticsCursor;

-- Drop temporary table
DROP TABLE #TacticsIDs;
I hope you like it

Have a good Day.
06/01/2024 04:03 johnnydung#2
thanks
06/03/2024 02:05 Worshiper#3
thanks
06/08/2024 05:36 #HB#4
Why would you use a cursor for such a simple transaction, when you can just join the tables?

You have to think carefully before using cursors, because they're much slower, they use much more resources, unnecessary in your case.
06/11/2024 16:34 Mdarude#5
Quote:
Originally Posted by #HB View Post
Why would you use a cursor for such a simple transaction, when you can just join the tables?

You have to think carefully before using cursors, because they're much slower, they use much more resources, unnecessary in your case.
in my opinion this is faster and less time consuming.
I do not have all day to work on my server in good day's i only have 1 hour making this saves me alot of time and i can adjusts per monster faster.
06/13/2024 10:57 JellyBitz#6
Quote:
Originally Posted by Mdarude View Post
Quote:
Originally Posted by #HB View Post
Why would you use a cursor for such a simple transaction, when you can just join the tables?
in my opinion this is faster and less time consuming.
I do not have all day to work on my server in good day's i only have 1 hour making this saves me alot of time and i can adjusts per monster faster.
I think what he mean to say, it's making use of JOIN statements on queries, and it's simpler than you think.
Taking your query as example (you don't even need to check Tab_RefHive by the way):
PHP Code:
USE SRO_VT_SHARD

-- Setup
DECLARE @CodeName128 VARCHAR(129) = 'MOB_TK_BONELORD'
DECLARE @MaxTotalCount INTEGER 20
DECLARE @DelayTimeMin INTEGER 5
DECLARE @DelayTimeMax INTEGER 10

-- Query
UPDATE Tab_RefNest
SET dwMaxTotalCount 
= @MaxTotalCount
    
dwDelayTimeMin = @DelayTimeMin
    
dwDelayTimeMax = @DelayTimeMax
FROM Tab_RefNest
INNER JOIN Tab_RefTactics ON Tab_RefTactics
.dwTacticsID Tab_RefNest.dwTacticsID
INNER JOIN _RefObjCommon ON _RefObjCommon
.ID Tab_RefTactics.dwObjID
WHERE _RefObjCommon
.CodeName128 LIKE @CodeName128 
This is something I was talking recently with my friends, in a ONLINE GAME like this MMORPG you should care a lot about performance otherwise you'll add unnecesary delay to the game, every increasing on PING counts!
06/19/2024 21:15 Mdarude#7
Thank you for the feedback i am still new at this and if i find someting or do it i just want to share it since this will give me some feedback on how to improve myself