Getting a spawn when the zone is vacant of players

Discussions on development of both the EQ2Emulator LUA Script Engine and Script specifications

Moderator: Team Members

Post Reply
User avatar
Gangrenous
Posts: 812
Joined: Sun Apr 24, 2016 6:54 am
Characters: Dinsmoor

Getting a spawn when the zone is vacant of players

Post by Gangrenous » Fri Oct 14, 2016 8:53 am

So I have a need to check if a spawn is there when no players are present. I know the spawn id, name, etc. I even have other spawns there. The zone is always running. The catch is I want to check a spawn in Kylong Plains from an NPC in Antonica.

How can you do this though?

Code: Select all

local spawn2 = GetSpawn(Spawn, 1234)
That requires the Spawn object. You cannot get the spawn, unless you have the spawn, and of course I cannot get the spawn without the spawn. I cannot simply do it by the spawn ID. Am I going to have to create a new function?
Resident Dirty Hippy

Jabantiz
Lead Developer
Posts: 2912
Joined: Wed Jul 25, 2007 2:52 pm
Location: California

Re: Getting a spawn when the zone is vacant of players

Post by Jabantiz » Fri Oct 14, 2016 3:25 pm

Not possible currently as you need either a spawn in the same zone or a pointer to the zone for the various GetSpawn functions. There is no way to get a zone pointer for a different zone through lua currently.

User avatar
Gangrenous
Posts: 812
Joined: Sun Apr 24, 2016 6:54 am
Characters: Dinsmoor

Re: Getting a spawn when the zone is vacant of players

Post by Gangrenous » Fri Oct 14, 2016 5:12 pm

Oh no doubt. Okay, no worry. I have other tricks up my sleeve.
Resident Dirty Hippy

User avatar
Gangrenous
Posts: 812
Joined: Sun Apr 24, 2016 6:54 am
Characters: Dinsmoor

Re: Getting a spawn when the zone is vacant of players

Post by Gangrenous » Fri Oct 14, 2016 9:43 pm

Figured a way around my problem. I had to do some manipulating. So second question. I want to move a player as he enters the zone, using the

Code: Select all

function ZonePlayer(Zone, Spawn)
I think you cannot, because you are not actually in the zone yet. I kind of tricked it by sending an existing NPC a function. That works but you zone twice, having to use the zone function. Is there a way to move a player without zoning them twice? I mean you are already in the zone.

New function?
Resident Dirty Hippy

Jabantiz
Lead Developer
Posts: 2912
Joined: Wed Jul 25, 2007 2:52 pm
Location: California

Re: Getting a spawn when the zone is vacant of players

Post by Jabantiz » Sat Oct 15, 2016 12:18 am

Why not just zone them to those coords instead of zoning then moving? Just provide the cords in the lua Zone() function.

User avatar
Gangrenous
Posts: 812
Joined: Sun Apr 24, 2016 6:54 am
Characters: Dinsmoor

Re: Getting a spawn when the zone is vacant of players

Post by Gangrenous » Sat Oct 15, 2016 6:08 am

Because I am working on boats. I cannot get the coordinates of the boat, because I cannot get them in the source zone. I have to get those coordinates in the destination zone. Does that make sense? Also if a player goes link dead, comes back into the zone later...I want to be able to put him on the boat if it is in the zone still. So I want to capture that when the player is coming into the zone, I want to put him on the boat. He is already zoning, so no sense in zoning him twice.
Resident Dirty Hippy

User avatar
Gangrenous
Posts: 812
Joined: Sun Apr 24, 2016 6:54 am
Characters: Dinsmoor

Re: Getting a spawn when the zone is vacant of players

Post by Gangrenous » Sat Oct 15, 2016 8:46 am

I figured it out. I used some of the code from the function to move a player to a spawn, created a new function called MovePlayer. May not be pretty, but it works for me.

Code: Select all

void Client::MovePlayer(float x, float y, float z, float heading){	
	GetPlayer()->SetX(x);
	GetPlayer()->SetY(y);
	GetPlayer()->SetZ(z);
	GetPlayer()->SetHeading(heading);

	EQ2Packet* app = GetPlayer()->Move(x, y, z, GetVersion());
	if(app)
		QueuePacket(app);
}
Resident Dirty Hippy

Jabantiz
Lead Developer
Posts: 2912
Joined: Wed Jul 25, 2007 2:52 pm
Location: California

Re: Getting a spawn when the zone is vacant of players

Post by Jabantiz » Sat Oct 15, 2016 3:22 pm

Boats that cross zones have special packets fyi.

User avatar
Gangrenous
Posts: 812
Joined: Sun Apr 24, 2016 6:54 am
Characters: Dinsmoor

Re: Getting a spawn when the zone is vacant of players

Post by Gangrenous » Sat Oct 15, 2016 5:25 pm

Jabantiz wrote:Boats that cross zones have special packets fyi.
I am doing it a ghetto way, but it will work and be unnoticeable to players.
Resident Dirty Hippy

User avatar
Gangrenous
Posts: 812
Joined: Sun Apr 24, 2016 6:54 am
Characters: Dinsmoor

Re: Getting a spawn when the zone is vacant of players

Post by Gangrenous » Sat Oct 15, 2016 7:35 pm

Now if you know of some way of doing this easier, definitely let me know. But before I started this process I was under the understanding that boats were not working and definitely not able to take players across zones.
Resident Dirty Hippy

Jabantiz
Lead Developer
Posts: 2912
Joined: Wed Jul 25, 2007 2:52 pm
Location: California

Re: Getting a spawn when the zone is vacant of players

Post by Jabantiz » Sat Oct 15, 2016 7:51 pm

They don't work currently, no one has looked into the packets or the process to get it working yet. I was just pointing out that there are special packets for it if you wanted to try and do it the correct way, no clue what would be involved with it though.

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests