Warp To NM Script - With Search Suggestions

Post Reply
Avatarati
Posts: 53
Joined: Mon Jun 30, 2014 2:51 pm

Warp To NM Script - With Search Suggestions

Post by Avatarati » Sun Mar 12, 2017 3:38 pm

I wrote this script today; figured I'd share it in case anyone else is looking for the same thing. Place in darkstar/scripts/commands.

A few things of note:

1. Use the command in the following syntax: @tomob 'mobnamehere' (ex. @tomob kirin)
2. It uses nicknames (ex. @tomob JoL == @tomob Jailer of Love). Modify the nicknames to your liking.
3. If you misspell a name, or forget the name entirely, the script will attempt to compare the first two letters and produce search suggestions.
4. You may use uppercase or all lowercase letters, it doesn't matter.
5. If the mob is spawned, you'll warp directly to it.
6. If the mob is not spawned, you'll go to its spawn position as indicated in mob_spawn_points.sql.
7. Command is set for Level 5 GM's. To make available to all players, set 'permission = 5' to 'permission = 1'.

This can also be modified for NPC's, zones, places of interest, etc.

Scipt will probably look like garbage using the code tags. My IDE is set for Arial font with 4 spaces per tab, so looks good in the editor.


Code: Select all

---------------------------------------------------------------------------------------------------
--  Function: @tomob
--  Description: Warps GM to particular mob by short name or nickname
--  Author: Avatarati
---------------------------------------------------------------------------------------------------

cmdprops =
{
	permission = 5,
	parameters = "s"
};

function onTrigger( player, mobName )

	if ( string.len( mobName ) < 2 ) then --At least two letters are needed for mobName

		player:PrintToPlayer("Mob name must be at least two characters in length.", 0xD)

	else
	
		mobName = string.lower( mobName ) --CaN InPuT WhAtEvEr CaSe, will lowercase anyway

		local list = {
			--These are my perferred nicknames, can change to your liking (no spaces)
			[     1 ]		=	{	"tiamat",16806227,-515.011,-12.732,-78.101,50,7							},
			[     2 ]		=	{	"xolotl",16806215,-565.482,-4.459,203.424,241,7							},
			[     3 ]		=	{	"punisher",17395800,-223,1,119,127,151											},
			[     4 ]		=	{	"gallant",17395870,58,1,-120,127,151												},
			[     5 ]		=	{	"highpriest",17396127,-106,-72,96,127,151										},
			[     6 ]		=	{	"manifest",17396137,-99,-72,93,127,151											},
			[     7 ]		=	{	"serket",17596720,-155,19,244,28,200												},
			[     8 ]		=	{	"headhunter",17142249,299.625,-48.281,103.555,7,147				},
			[     9 ]		=	{	"gascon",-202,-2,110,69,147																},
			[   10 ]		=	{	"adamantking",17379551,281,43,96,127,148									},
			[   11 ]		=	{	"simmy",17228242,-681,-31,-447,127,110										},
			[   12 ]		=	{	"charby",17498522,-152,48,-328,127,176											},
			[   13 ]		=	{	"sandcomber",17498199,16,-0.5,120,127,176									},
			[   14 ]		=	{	"shoreleaper",17498516,-243,41,-298,127,176								},
			[   15 ]		=	{	"vilma",17281358,42,9,245,127,123													},
			[   16 ]		=	{	"rosegarden",17281357,50,10,245,127,123										},
			[   17 ]		=	{	"hakutaku",17433005,24,25,-306,121,160											},
			[   18 ]		=	{	"tracker",17433001,-167.336,15.851,-120.259,100,160					},
			[   19 ]		=	{	"bombqueen",17617158,14.682,20.058,-104.121,0,205					},
			[   20 ]		=	{	"oramix",17617062,-111.470,3.764,141.784,0,205							},
			[   21 ]		=	{	"sozu",17428554,94.330,0,-14.457,127,159										},
			[   22 ]		=	{	"nue",17231971,-313.911,-100.308,147.196,127,111						},
			[   23 ]		=	{	"gargantua",17232079,348,-0.5,17,127,111										},
			[   24 ]		=	{	"cassie",17613130,-77.43,0.462,164.529,145,204							},
			[   25 ]		=	{	"goliath",17613046,-165.4,-0.098,189.481,187,204							},
			[   26 ]		=	{	"northshadow",17613103,-162.0,-15.0,154.0,213,204						},
			[   27 ]		=	{	"eastshadow",17613110,-92.12,-16.52,160.277,37,204					},
			[   28 ]		=	{	"westshadow",17613096,-206.6,-16.19,111.260,202,204				},
			[   29 ]		=	{	"southshadow",17613121,-164.6,-16.01,77.191,169,204				},
			[   30 ]		=	{	"culberry",16814432,-271.214,31.838,260.258,127,9						},
			[   31 ]		=	{	"geyser",17559558,-363,3,-69,127,191												},
			[   32 ]		=	{	"morion",17486190,255.652,-6.039,20.878,0,173							},
			[   33 ]		=	{	"sophie",17211537,234.104,-40.332,462.288,127,106					},
			[   34 ]		=	{	"crimsonarmor",17363305,20.433,-31.675,-97.176,127,143			},
			[   35 ]		=	{	"lizzy",17215868,-283.760,21.444,-412.182,127,107						},
			[   36 ]		=	{	"carnero",17215613,160.748,-40.01,-423.153,83,107						},
			[   37 ]		=	{	"helldiver",17260907,475,-0.5,-240,127,118										},
			[   38 ]		=	{	"onzozo",17649731,-44,14,-58,73,213												},
			[   39 ]		=	{	"mysticmaker",17649693,124.811,-0.363,-100.604,115,213			},
			[   40 ]		=	{	"ose",17649822,17,4,152,113,213														},
			[   41 ]		=	{	"argus",17588674,233,20,-71,127,198												},
			[   42 ]		=	{	"rapido",17244539,-43.733,0.029,-205.890,66,114							},
			[   43 ]		=	{	"dunewidow",17244396,-124.890,-8.576,32.533,64,114					},
			[   44 ]		=	{	"vinegar",17289575,-239,-0.226,-650,11,125									},
			[   45 ]		=	{	"aquarius",17404000,165.93,9.344,-56.348,51,153							},
			[   46 ]		=	{	"vivian",17404331,-208.7,5.276,203.289,56,153								},
			[   47 ]		=	{	"fafnir",17408018,78,6,39,127,154														},
			[   48 ]		=	{	"shikigami",17277127,-40,-4,-36,127,	122											},
			[   49 ]		=	{	"halidom",17272978,312,-0.5,159,127,121										},
			[   50 ]		=	{	"av",16912876,461.266,-1.643,-580.192,4,33									},
			[   51 ]		=	{	"joh",16912838,-683.592,-0.5,-61.571,233,33									},
			[   52 ]		=	{	"joj",16912839,-279.194,-0.5,-465.362,246,33									},
			[   53 ]		=	{	"jop",16912846,706.114,-1.021,24.110,85,33									},
			[   54 ]		=	{	"jol",16912848,437.760,-1.643,-598.571,4,33									},
			[   55 ]		=	{	"jofaith",16921021,-272.831,-0.5,-703.309,66,35								},
			[   56 ]		=	{	"jofort",16921015,-434.1,-0.5,697.849,190,35									},
			[   57 ]		=	{	"ixdrk",16921018,-590.082,-0.592,110.876,235,35							},
			[   58 ]		=	{	"ixdrg",16921022,-347.931,-0.5,-377.922,147,35								},
			[   59 ]		=	{	"ixmnk",16916815,112.783,-0.5,453.875,193,34								},
			[   60 ]		=	{	"jot",16916814,-426.739,-0.5,687.728,140,34									},
			[   61 ]		=	{	"lumberjack",17207308,-670,-23,352,127,105									},
			[   62 ]		=	{	"dirtyhand",17387945,56.259,-12.073,-152.955,127,149					},
			[   63 ]		=	{	"poisonhand",17125843,0,0,0,244,149												},
			[   64 ]		=	{	"cwn",17576054,-395.612,-0.102,378.777,231,195							},
			[   65 ]		=	{	"skullenvy",17575943,0,0,0,0,195														}, --MobID not found, placeholder element
			[   66 ]		=	{	"skullgluttony",17575938,0,0,0,0,195													}, --MobID not found, placeholder element
			[   67 ]		=	{	"skullgreed",17575939,0,0,0,0,195														}, --MobID not found, placeholder element
			[   68 ]		=	{	"skulllust",17575941,0,0,0,0,195															}, --MobID not found, placeholder element
			[   69 ]		=	{	"skullpride",17575942,0,0,0,0,195														}, --MobID not found, placeholder element
			[   70 ]		=	{	"skullsloth",17575940,0,0,0,0,195														}, --MobID not found, placeholder element
			[   71 ]		=	{	"skullwrath",17575944,0,0,0,0,	195														}, --MobID not found, placeholder element
			[   72 ]		=	{	"kingarthro",17203216,-144,5,474,93,104											},
			[   73 ]		=	{	"overlord",17391803,220,-2,-108,67,150											},
			[   74 ]		=	{	"kb",17297441,-267.469,-19.831,73.674,127,127							},
			[   75 ]		=	{	"alky",17424480,-300,-175,22,64,158												},
			[   76 ]		=	{	"mimas",17424419,-293.419,-144.07,53.648,127,158						},
			[   77 ]		=	{	"pallas",17424444,-300,-159,21,127,158											},
			[   78 ]		=	{	"ixtab",17424475,0,0,0,0,158																}, --MobID not found, placeholder element
			[   79 ]		=	{	"sewersyrup",17461307,-20,1,-179,127,167										},
			[   80 ]		=	{	"bigmouth",17191196,476,-30,-32,127,101										},
			[   81 ]		=	{	"swamfisk",17191291,461,-6,-356,127,101										},
			[   82 ]		=	{	"vrtra",17555890,228,7.134,-311,17,190											},
			[   83 ]		=	{	"cherry",17555863,33,0.5,-287,127,190											},
			[   84 ]		=	{	"jej",17187111,-281,-19,-220,127,100												},
			[   85 ]		=	{	"ashmaker",17358932,11.669,-0.903,-22.245,127,142					},
			[   86 ]		=	{	"spiny",17252657,270.957,-12.815,118.668,114,	116						},
			[   87 ]		=	{	"ropipi",17252489,332,-13,-325,0,116												},
			[   88 ]		=	{	"torrent",17371515,-50,1,-75,127,145												},
			[   89 ]		=	{	"oni",17469587,-378.2,21.997,-15.414,16,169									},
			[   90 ]		=	{	"brazenbones",17469747,169.27,8.0279,-110.58,223,169				},
			[   91 ]		=	{	"bombking",17572094,0,0,0,127,194													},
			[   92 ]		=	{	"legalox",17571873,0,0,0,0,194															},
			[   93 ]		=	{	"tittat",17248468,139.943,-35.719,299.835,127,115						},
			[   94 ]		=	{	"nun",17248517,-25,-15,385,127,115													},
			[   95 ]		=	{	"leshy",16875762,-238,-16,244,0,24													},
			[   96 ]		=	{	"megalo",16875741,-175.852,-7.811,22.823,60,24							},
			[   97 ]		=	{	"padfoot",16875748,-141.523,-15.529,91.709,171,24						},
			[   98 ]		=	{	"odqan",16879737,240.502,-23.726,303.277,44,25							},
			[   99 ]		=	{	"minotaur",16887889,60,0.5,304,64,27												},
			[ 100 ]		=	{	"dobsonfly",16900230,-191.213,47.667,-833.249,1,30					},
			[ 101 ]		=	{	"shieldtrap",16900320,0,0,0,0,30														}, --MobID not found, placeholder element
			[ 102 ]		=	{	"unstable",16896155,307.5,-1.5,-706.5,186,29									},
			[ 103 ]		=	{	"imdugud",16896107,655.263,20.664,651.320,0,29						},
			[ 104 ]		=	{	"boroka",16896131,-360.140,-31.428,484.944,205,29					},
			[ 105 ]		=	{	"keremet",16892049,261,0.001,0.001,124,28									},
			[ 106 ]		=	{	"professor",16891970,106,-2.437,130.026,55,28								},
			[ 107 ]		=	{	"byakko",17309982,-410.488,-70.520,394.720,214,130					},
			[ 108 ]		=	{	"despot",17309954,-0.1,-42,-291,114,130											},
			[ 109 ]		=	{	"genbu",17309980,257,-70,517,118,130											},
			[ 110 ]		=	{	"suzy",17309983,-514.533,-70.520,-264.736,72,130						},
			[ 111 ]		=	{	"seiryu",17309981,569,-70,-80,76,130												},
			[ 112 ]		=	{	"faust",17506370,740,-0.463,-99,127,178											},
			[ 113 ]		=	{	"kirin",17506670,-76,32,-4,166,178													},
			[ 114 ]		=	{	"mg",17506396,855.947,-99.924,-578.291,127,178						},
			[ 115 ]		=	{	"olla",17506669,851,-1,92,113,178													},
			[ 116 ]		=	{	"ulli",17506418,739,-99,-581,195,178												},
			[ 117 ]		=	{	"bb",17502568,-1,-1,-283,63,177														},
			[ 118 ]		=	{	"sc",17502569,317,-1,361,65,177														},
			[ 119 ]		=	{	"zip",17502570,-195,-0.5,396,1,177													},
			[ 120 ]		=	{	"bifrons",17440969,-199,-52,-99,127,162											},
			[ 121 ]		=	{	"urvan",16798078,563.638,-35.719,110.362,0,5								},
			[ 122 ]		=	{	"jorm",16896160,-704.433,0.464,798.733,150,5								},
			[ 123 ]		=	{	"coney",16798079,404.04,-0.588,-445.810,72,5								},
			[ 124 ]		=	{	"kreutzet",17240413,207,8,1,79,113													},
			[ 125 ]		=	{	"frostmane",17240376,-281,-0.5,471,127,113									},
			[ 126 ]		=	{	"bune",17645578,72,-10,-170,119,212												},
			[ 127 ]		=	{	"ungur",17645755,-316,-9,3,5,212														},
			[ 128 ]		=	{	"amemet",17490016,102,-0.191,3,127,174										},
			[ 129 ]		=	{	"guivre",17490234,119,-0.01,38,127,174											},
			[ 130 ]		=	{	"phantom",17490233,76.943,29.916,118.854,0,174						},
			[ 131 ]		=	{	"yowie",17490204,25.841,20.252,71.875,83	,174							},
			[ 132 ]		=	{	"aspid",17301538,19,0.089,14,117,128												},
			[ 133 ]		=	{	"aroma",17580341,0,0,0,0,196															},
			[ 134 ]		=	{	"straymary",17219795,-257.465,-15.805,-117.638,87,108				},
			[ 135 ]		=	{	"rampaging",17219886,160,24,121,0,108											},
			[ 136 ]		=	{	"lumbering",17195317,-216,-8,-107,3,102											},
			[ 137 ]		=	{	"morbolger",17568127,-99.08,-27.95,-219.33,184,193					},
			[ 138 ]		=	{	"goldenbat",17199564,-810.440,-8.270,33.978,127,103					},
			[ 139 ]		=	{	"ve",17199438,-211,-0.01,-34,39,103												},
			[ 140 ]		=	{	"medusa",16998862,-460,-20.5,460,32,54										},
			[ 141 ]		=	{	"experimentallamia",17101205,-773.369,-11.824,322.298,15,54	},
			[ 142 ]		=	{	"khimaira",17101201,842,-1,365,127,79											},
			[ 143 ]		=	{	"tyger",17101203,-766,-12,632,239,79												},
			[ 144 ]		=	{	"verdelet",17101202,417.02,-19.295,-69.990,63,79							},
			[ 145 ]		=	{	"paintorn",17101204,695.369,-7.147,527.646,42,79						},
			[ 146 ]		=	{	"achamoth",17031600,-13.17,9.699,339.540,229,62						},
			[ 147 ]		=	{	"bigbomb",17031401,-233.8,13.612,286.713,173,62						},
			[ 148 ]		=	{	"dextrose",17031598,-144,11,464,48,62											},
			[ 149 ]		=	{	"menacing",17031592,-59,-23,3,195,62												},
			[ 150 ]		=	{	"eruca",17027466,176.743,-14.210,-180.926,0,61							},
			[ 151 ]		=	{	"rabid",17027468,102.073,-14.899,-8.096,122,61							},
			[ 152 ]		=	{	"cerberus",17027458,316,-23,-84,127,61											},
			[ 153 ]		=	{	"claret",17027472,497,-9,52,248,61													},
			[ 154 ]		=	{	"anantaboga",17027473,-368.341,-13.742,366.448,58,61				},
			[ 155 ]		=	{	"brassborer",17027471,399.386,-27.022,120.479,245,61				},
			[ 156 ]		=	{	"sarameya",17027485,322.548,-14.706,-581.653,233,61				},
			[ 157 ]		=	{	"chigre",17056186,-217.5,34.866,13.689,122,68								},
			[ 158 ]		=	{	"nosferatu",17056157,-198.6,8.387,-60.832,207,68							},
			[ 159 ]		=	{	"pw",17056167,208.16,33.750,-138.61,90,68									},
			[ 160 ]		=	{	"chamrosh",17043887,206,14,-285,249	,65										},
			[ 161 ]		=	{	"gulool",16973900,-91,2,57,1,65															},
			[ 162 ]		=	{	"iriri",17043888,-118,7,-80,193,65														},
			[ 163 ]		=	{	"redolent",16986430,-337,-31,676,162,51											},
			[ 164 ]		=	{	"hydra",16986355,-282,-24,-1,127,51													},
			[ 165 ]		=	{	"jody",16986378,-486,-7,-438,127,51													},	
			[ 166 ]		=	{	"irizima",16986429,253,-23,116,245,51												},
			[ 167 ]		=	{	"tinnin",16986431,278,0.1,-703,176,51												},
			[ 168 ]		=	{	"vulpangue",16986428,-697,-7,-123,20,51											},
			[ 169 ]		=	{	"zoraal",16986197,208,-17,-93,127,51												},
			[ 170 ]		=	{	"armedgears",17072178,-19.957,-4.000,-182.656,188,72				},
			[ 171 ]		=	{	"cheesehoarder",17072172,-184.112,-8.105,24.555,26,72				},
			[ 172 ]		=	{	"ob",17072171,552.914,-0.112,-135.001,50,72								},
			[ 173 ]		=	{	"oupire",17072170,90,0.1,-100,0,72													},
			[ 174 ]		=	{	"dea",16990474,-34,-32,481,221,52													},
			[ 175 ]		=	{	"emergentelm",16990376,71,-33,627,127,52									},
			[ 176 ]		=	{	"lividroot",16990473,334,-10,184,129,52											},
			[ 177 ]		=	{	"sandworm",17109357,713,-59,402,247,88										},
			[ 178 ]		=	{	"ixion",17109367,236,-20,-323,114,81												}

		}

		local mob = nil

		for key, value in ipairs( list ) do --Search for the mob name

			if ( list[key][1] == mobName ) then --A match is found

				mob = GetMobByID( list[key][2] ) --Is ID valid?

				if ( mob:isSpawned(list[key][2] ) ) then --Is it already spawned?
					player:setPos( mob:getXPos(), mob:getYPos(), mob:getZPos(), 0, mob:getZoneID() ); --Go to mob
					return
				else
					player:setPos( list[key][3], list[key][4], list[key][5], list[key][6], list[key][7] ) --Go to mob default position
					return
				end

			end

		end

		--Cannot find mob name, so let's offer suggestions
		
		local possibilities = { } --Holds all possible matches
		local x, z = 1, 1

		--If first two characters of mobName match something in the table, let's make it a suggestion
		--Could expand this to provide even better matches, but it's a small list
		for key, value in ipairs(list) do

			local tempName = list[key][1]
			if ( tempName:sub( 1 , 1 ) == mobName:sub( 1, 1 ) ) then
				if ( tempName:sub( 2 , 2 ) == mobName:sub( 2, 2 ) ) then
					possibilities[x] = list[key][1] 
					x = x + 1
				end
			end

		end

		if ( possibilities[1] == nil ) then

			player:PrintToPlayer("No mobs were found for your search term.", 0xD)

		else

			local grammar = "match exists"

			if ( #possibilities > 1 ) then
				grammar = "matches exist" --Grammatik macht frei
			end

			player:PrintToPlayer(string.format("That mob name was not found. However, %d possible %s:", ( #possibilities ), ( grammar ) ), 0xD)

			repeat --Show all possibilities
				player:PrintToPlayer(string.format("  %d : %s", ( z ), ( possibilities[z]:gsub("^%l", string.upper) ) ), 0xD) --Uppercase possibilities
				z = z + 1
			until ( z > #possibilities )

		end

	end

end;

Avatarati
Posts: 53
Joined: Mon Jun 30, 2014 2:51 pm

Re: Warp To NM Script - With Search Suggestions

Post by Avatarati » Sun Mar 12, 2017 3:45 pm

P.S. The PrintToPlayer functions use Tagban's tweak: viewtopic.php?f=19&t=2402

If your luabaseentity files aren't modded, take out the hex color codes.

sunzhiheng888
Posts: 14
Joined: Thu Jun 23, 2016 1:50 am

Re: Warp To NM Script - With Search Suggestions

Post by sunzhiheng888 » Wed Aug 09, 2017 3:50 am

---------------------------------------------------------------------------------------------------
-- func: @go <mobId>
-- desc: im from China.
---------------------------------------------------------------------------------------------------

cmdprops =
{
permission = 1,
parameters = "ii"
};

function onTrigger(player, mobId, noDepop)
if (mobId == nil) then
player:PrintToPlayer("You must enter a valid MobID.");
return;
end

local mob = GetMobByID(mobId);
if (mob == nil) then
player:PrintToPlayer( string.format( "Mob with ID '%i' not found!", mobId ) );
return;
end

SpawnMob( mobId );
if (player:getGil() < 10000) then
player:PrintToPlayer("You not have enough Gil.");
return;
end
player:delGil(10000);
player:setPos( mob:getXPos(), mob:getYPos(), mob:getZPos(), mob:getRotPos(), mob:getZoneID() );
end;

-------------Enter MOBID or to spawn and transfer

---------------------------------------------------------------------------------------------------
-- func: @gotonpc <npcId>
-- desc: i form china
---------------------------------------------------------------------------------------------------

cmdprops =
{
permission = 1,
parameters = "ii"
};

function onTrigger(player, npcId)
require("scripts/globals/status");

if (npcId == nil) then
player:PrintToPlayer("You must enter a valid npcId.");
return;
end

local npc = GetNPCByID(npcId);
if (npc == nil) then
player:PrintToPlayer( string.format( "NPC with ID '%i' not found!", npcId ) );
return;
end

if (player:getGil() < 10) then
player:PrintToPlayer("You not have enough Gil.");
return;
end
player:delGil(10);
player:setPos( npc:getXPos(), npc:getYPos(), npc:getZPos(), npc:getRotPos(), npc:getZoneID() );
end;

-------------Enter NPCID or to spawn and transfer

User avatar
TeoTwawki
Developer
Posts: 527
Joined: Mon Jul 15, 2013 9:50 pm

Re: Warp To NM Script - With Search Suggestions

Post by TeoTwawki » Sun Aug 13, 2017 4:18 pm

Just an FYI, they are not color codes, they are message types which defaultly have diff colors in the client. For example "green" is just 2nd linkshell and if the player changes the color of that in client it won't be green anymore.






Another FYI, everytime someone doesn't use code tags and proper indents, the Joker gets away from Batman.
Hi, I run The Demiurge server.


Image
Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live. - Martin Golding
PLS USE [ code ] CODE TAGS [ /code ] WHEN POSTING CODE
DO NOT PRIVATE MESSAGE ME ABOUT BUGS

Post Reply