[MOD] Set New Char Spawn Point

Place for sharing your game modifications for Life is Feudal: Your Own

RudgerWolvram
 
Posts: 37
Joined: 01 Jan 2015, 22:27

[MOD] Set New Char Spawn Point

Post by RudgerWolvram » 08 Jan 2015, 05:08

OK, so this came about because we created a "spawn area" in the center of our map for any new players. If you get any errors adding this trigger, make sure you don't have another trigger that is on the same time and table. For example, if you have trigger that gives new characters croc sandals, your trigger would be BEFORE INSERT on `Character`. The contents of this trigger will need to be added to your croc sandals trigger.

OK, so this requires a bit of setup on your side first. Take your character to the spawn location you want new players to come into. Log out, then:

Code: Select all
SELECT * FROM `character`;


Find the character name you just logged out of and copy the GeoID and GeoAlt values from its row.

Add a few numbers to your GeoAlt. like, if it's value is 5000, make it like 5025. This will cause the new player to drop into that location and prevent any "stuck in the terrain" issues.

The below code will set all new characters to spawn in that same exact location, every time.
Code: Select all
delimiter $$
CREATE TRIGGER `t_set_first_spawn` before INSERT ON `character` FOR EACH ROW BEGIN
   set New.GeoID = 117052637;
   set New.GeoAlt = 5100;
END;
$$


But what if you want multiple locations around an area and want it to be random? Repeat the go to X spot, logout, get GeoID and GeoAlt for each possible spawn location you want, then, for each location, say we have 3 possible location, update the below code with the correct GeoID and GeoAlt values. Adding a bit to each GeoAlt.

Code: Select all
delimiter $$
CREATE TRIGGER `t_set_first_spawn_rand` before INSERT ON `character` FOR EACH ROW BEGIN
declare rd int default 0;
set rd =  (select truncate((RAND()*10 MOD 3),0));
   CASE rd
      when 0 then
            set New.GeoID = 117052637;
            set New.GeoAlt = 5100;
      when 1 then
            set New.GeoID = 1170123637;
            set New.GeoAlt = 6100;
      when 2 then
            set New.GeoID = 126052637;
            set New.GeoAlt = 4500;
      else
            set New.GeoID = 117052637;
            set New.GeoAlt = 5100;
   end CASE;
END;
$$


Explanation of RAND() selection:
Select RAND(); (which you can just run as a query) will return a 0.xxxxxxxx number.
To get an integer out of it, first we need it above 0, so in this case I multiplied by 10 since there are less than 10 possible spawn points in the case statement. You can just as easily multiple it by 1,000,000 if you really wanted.
The Modulus operator MOD will give the division remainder of the value to the right. e.g. 10 MOD 3 is 1 (3*3 = 9 + 1 = 10). 10 mod 5 = 0 (5 * 2 + 0 = 10 0 remainder). MOD is used to put the random number into a range of number from 0 to n-1. n being the amount of numbers you need.

So with that, if you needed say 6 spawn points you would use MOD 6 and the SELECT RAND would be changed to:
Code: Select all
set rd =  (select truncate((RAND()*10 MOD 6,0));


The CASE statements start at 0 and go to 2 (3 numbers including 0).
If you need more spawn points, copy the WHEN statement, add 1 to the value, and add 1 to the number on the MOD number for each spawn point you need.

The ELSE statement is there as a catch all, just in case MySQL/Maria's RAND() has an aneurysm and returns and elephant in a leisure suit. Just update the ELSE's geo data with the data from the 0 case and you'll be fine.


Sanctifiedevil
 
Posts: 12
Joined: 22 Dec 2014, 07:37

Re: [MOD] Set New Char Spawn Point

Post by Sanctifiedevil » 03 Feb 2015, 16:08

Quick question, would this also work for the spawns for praying? Someone on my server seems to have set up base camp right at a spawn point and people are starting to abuse the pray function to get over their walls.


RudgerWolvram
 
Posts: 37
Joined: 01 Jan 2015, 22:27

Re: [MOD] Set New Char Spawn Point

Post by RudgerWolvram » 05 Feb 2015, 05:46

In order to prevent that, you'd have to go into the database and find where the player was bound (i'm still looking for that info in the tables) and manually change that geoid value.

Though, if you really wanted to, you could disable the pray for home coming skill by changing the skill requirements on the serverside and upping the stam required to like 300. But that affects all players and may not be beneficial.


Sanctifiedevil
 
Posts: 12
Joined: 22 Dec 2014, 07:37

Re: [MOD] Set New Char Spawn Point

Post by Sanctifiedevil » 05 Feb 2015, 17:12

Yeah I'm not over sure how it calculates where non-bound players (players without a home set) will go when they pray. It seems to be specific GeoDataIDs that are tied to the regular spawnpoints but beyond that I don't see it in the database or the .xml files. It very well may be hard coded with the player spawns.

My idea for this script would be to trigger it on what ever function is being called when praying by non-bound characters and revert them to specified spawn points.


SKuDD3r
 
Posts: 15
Joined: 01 Feb 2015, 19:41

Re: [MOD] Set New Char Spawn Point

Post by SKuDD3r » 05 Feb 2015, 21:49

This gives me a good idea.... for making a new GM command for teleporting to players.

User avatar
Respectful
 
Posts: 8
Joined: 26 Jan 2015, 18:43

Re: [MOD] Set New Char Spawn Point

Post by Respectful » 17 Feb 2015, 11:00

Bit of a noob with this sort of thing, how exactly would I add the trigger? A new file, or no?


RudgerWolvram
 
Posts: 37
Joined: 01 Jan 2015, 22:27

Re: [MOD] Set New Char Spawn Point

Post by RudgerWolvram » 17 Feb 2015, 19:19

Copy the SQL code and run it as a query in Heidi or MySQL Workbench against the server. It will create the trigger in the database. Refresh the database tree and you'll see it towards the bottom.

User avatar
Respectful
 
Posts: 8
Joined: 26 Jan 2015, 18:43

Re: [MOD] Set New Char Spawn Point

Post by Respectful » 17 Feb 2015, 21:13

RudgerWolvram wrote:Copy the SQL code and run it as a query in Heidi or MySQL Workbench against the server. It will create the trigger in the database. Refresh the database tree and you'll see it towards the bottom.



Awesome, thank you!

User avatar
Respectful
 
Posts: 8
Joined: 26 Jan 2015, 18:43

Re: [MOD] Set New Char Spawn Point

Post by Respectful » 19 Feb 2015, 08:47

Probably a dumb question I can solve by watching an SQL query tutorial, but would I just copy and paste it as is, or would I have to write more?

EDIT: figured it out, nevermind. Thanks!


Aranax
 
Posts: 12
Joined: 25 Sep 2014, 05:40

Re: [MOD] Set New Char Spawn Point

Post by Aranax » 09 Apr 2015, 08:25

Where do you get the character location from?

edit: problem solved found the info in the character data in the SQL database.
Image

User avatar
HolyCrusader
Beta Tester
 
Posts: 251
Joined: 24 Nov 2014, 15:47

Re: [MOD] Set New Char Spawn Point

Post by HolyCrusader » 05 Nov 2015, 14:26

I think if you want the players to RESPAWN at the specific location when they die, until they bind a new bind point, you can place an item such as a fountain in a neutral city (ObjectID = 96), look it up in the unmovable_objects table and note its unique item ID (example, 12345), then you can add "Set New.BindedObjectID = 12345;" to your trigger:


Code: Select all
delimiter $$
CREATE TRIGGER `t_set_first_spawn` before INSERT ON `character` FOR EACH ROW BEGIN
   set New.GeoID = 117052637;
   set New.GeoAlt = 5100;
        set New.BindedObjectID = 12345;
END;
$$


MacDante
 
Posts: 95
Joined: 12 May 2015, 10:08

Re: [MOD] Set New Char Spawn Point

Post by MacDante » 27 Nov 2015, 19:31

I write some modification to trigger and this trigger set specific spawn point depending on the selected race.

Code: Select all
delimiter $$
CREATE DEFINER=`root`@`localhost` TRIGGER `t_set_first_spawn` BEFORE INSERT ON `character` FOR EACH ROW BEGIN
   CASE new.RaceID
      when 1 then
            set New.GeoID = 117517090;
            set New.GeoAlt = 5270;
      when 2 then
            set New.GeoID = 118017424;
            set New.GeoAlt = 6100;
      when 3 then
            set New.GeoID = 115944941;
            set New.GeoAlt = 5100;
      else
            set New.GeoID = 117052637;
            set New.GeoAlt = 5100;
   end CASE;
END;
$$


Joeyzombie
 
Posts: 1
Joined: 03 Dec 2015, 21:02

Re: [MOD] Set New Char Spawn Point

Post by Joeyzombie » 03 Dec 2015, 21:09

I apologize in advance but please bear with me, I am a complete noob to this game/SQL I tried th add trigger thing and the Query. This is the error I'm getting when I add it to my trigger http://prntscr.com/9a09gd and this is the error I get when I add it as a query http://prntscr.com/9a7ycd


Sneauxx
Devoted Believer
 
Posts: 5
Joined: 13 Feb 2016, 23:24

Re: [MOD] Set New Char Spawn Point

Post by Sneauxx » 16 Feb 2016, 02:47

I seem to be having a unrealistically hard time figuring this out,

Can I possibly get someone to walk me through this?

Would be glad to paypal over a few bucks for their time.

Add me on steam sn0w.nyc


Catherine
 
Posts: 31
Joined: 01 Mar 2016, 10:00

Re: [MOD] Set New Char Spawn Point

Post by Catherine » 06 May 2016, 16:54

its not working for me, i did exacly whats in the post


Thril
 
Posts: 6
Joined: 07 Jun 2017, 22:17

Re: [MOD] Set New Char Spawn Point

Post by Thril » 19 Jun 2017, 21:43

The trigger is working quite nice, but i noticed some weird behaviour:

If i set just one Spawn Location that way, it seems to work, but new Characters don't spawn at the exact location, but often in a few couple tiles around that spot. sometimes a couple more also... but always around the area.

Anyone has the same "issue" ?


Shrewdcrow
 
Posts: 12
Joined: 24 Nov 2015, 02:34

Re: [MOD] Set New Char Spawn Point

Post by Shrewdcrow » 20 Jun 2017, 12:13

Thril wrote:The trigger is working quite nice, but i noticed some weird behaviour:

If i set just one Spawn Location that way, it seems to work, but new Characters don't spawn at the exact location, but often in a few couple tiles around that spot. sometimes a couple more also... but always around the area.

Anyone has the same "issue" ?


Is the location in a claim? It will spawn at random just outside of claims if so.

User avatar
Galestaer
 
Posts: 11
Joined: 30 May 2016, 03:22
Location: Brazil

Re: [MOD] Set New Char Spawn Point

Post by Galestaer » 13 Sep 2017, 23:41

Shrewdcrow wrote:
Thril wrote:The trigger is working quite nice, but i noticed some weird behaviour:

If i set just one Spawn Location that way, it seems to work, but new Characters don't spawn at the exact location, but often in a few couple tiles around that spot. sometimes a couple more also... but always around the area.

Anyone has the same "issue" ?


Is the location in a claim? It will spawn at random just outside of claims if so.


Is there any way to set the new char spawn inside a claim?
Image

Return to Game mods

cron