Assist Radius

EQ2Emulator Development forum.

Moderator: Team Members

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

Assist Radius

Post by Gangrenous » Tue May 17, 2016 7:20 pm

I am not seeing anything in the source for an assist radius. I could be wrong but from my limited playing I did remember EQ2 to have an assist radius. I guess that does not so much as matter, I need one :D

So I am guessing this is the routine that checks for player proximity?

Code: Select all

void ZoneServer::CheckSpawnRange(Client* client, Spawn* spawn, bool initial_login){
	if(client && spawn && (initial_login || client->IsConnected())) {
		if(spawn != client->GetPlayer()) {
			if(spawn_range_map.count(client) == 0)
				spawn_range_map.Put(client, new MutexMap<int32, float >());
			spawn_range_map.Get(client)->Put(spawn->GetID(), spawn->GetDistance(client->GetPlayer()));
			if(!initial_login && client && spawn->IsNPC() && spawn_range_map.Get(client)->Get(spawn->GetID()) <= ((NPC*)spawn)->GetAggroRadius() && !client->GetPlayer()->GetInvulnerable())
				CheckNPCAttacks((NPC*)spawn, client->GetPlayer(), client);
		} 

		if(!initial_login && player_proximities.size() > 0 && player_proximities.count(spawn->GetID()) > 0)
			CheckPlayerProximity(spawn, client);
	}
}
It does not look overly hard to add some code for an NPC to NPC assist radius check, after I add it to the database that is. I am pretty sure this routine has either a parent or child function that checks faction, but I have not looked yet.
Resident Dirty Hippy

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

Re: Assist Radius

Post by Jabantiz » Wed May 18, 2016 2:16 am

No, that function is used to populate the lists of spawns that need to be sent to the client provided.

EQ2 has linked spawns called encounters, I am not sure off hand of anything outside the encounter coming to the aid of that encounter. Regardless as you need it their is a function that will return a list of NPC's within a radius of the provided spawn.

Code: Select all

vector<Spawn*> ZoneServer::GetAttackableSpawnsByDistance(Spawn* caster, float distance) {
	vector<Spawn*> ret;
	Spawn* spawn = 0;
	map<int32, Spawn*>::iterator itr;
	MSpawnList.readlock(__FUNCTION__, __LINE__);
	for (itr = spawn_list.begin(); itr != spawn_list.end(); itr++) {
		spawn = itr->second;
		if (spawn && spawn->IsNPC() && spawn->appearance.attackable > 0 && spawn != caster && spawn->Alive() && spawn->GetDistance(caster, true) <= distance) 
			ret.push_back(spawn);
	}
	MSpawnList.releasereadlock(__FUNCTION__, __LINE__);
	return ret;
}

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

Re: Assist Radius

Post by Gangrenous » Wed May 18, 2016 4:38 am

I hated linked encounters, they made no sense to me as a player. It was one of the things EQ2 did that I hated, I am stripping them out entirely. Assist radius is pretty low on my radar right now, but I will have to get it working within a few months.
Resident Dirty Hippy

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

Re: Assist Radius

Post by Gangrenous » Tue Jul 05, 2016 12:50 pm

I am finally getting back into looking at this. I am wondering the most efficient place to check this.

In SpawnProcess(), zoneserver.cpp I am already iterating the spawnlist for the zone around line 146 which checks the range to all clients in the zone, but I am not really checking the distance to the client. I am actually wanting the NPC to check any NPC's that are around it, in combat and have the same faction. If they have the same faction then they need to attack the player, or I guess adding hate would work. The CheckSpawnRange function is really only checking the distance to the NPC. I am thinking of a new function right before CheckSpawnRange in SpawnProcess that checks for NPC's range to each other if they are in combat and have like faction. Thoughts Miyagi?
Resident Dirty Hippy

tyrbo
Team Member
Posts: 271
Joined: Thu Feb 18, 2016 12:33 pm

Re: Assist Radius

Post by tyrbo » Wed Jul 06, 2016 9:56 am

provocating wrote:I am finally getting back into looking at this. I am wondering the most efficient place to check this.

In SpawnProcess(), zoneserver.cpp I am already iterating the spawnlist for the zone around line 146 which checks the range to all clients in the zone, but I am not really checking the distance to the client. I am actually wanting the NPC to check any NPC's that are around it, in combat and have the same faction. If they have the same faction then they need to attack the player, or I guess adding hate would work. The CheckSpawnRange function is really only checking the distance to the NPC. I am thinking of a new function right before CheckSpawnRange in SpawnProcess that checks for NPC's range to each other if they are in combat and have like faction. Thoughts Miyagi?
I don't recall mobs ever assisting each other like with the same target. There was radius assisting if you were to attack an NPC near another NPC that was friendly with it, but the hate lists of the two targets were maintained separately. Keep in mind it also only happened on an action, so if you were to body pull a monster, you wouldn't run the risk of pulling additional out-of-encounter NPCs.

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

Re: Assist Radius

Post by Gangrenous » Wed Jul 06, 2016 11:07 am

That is what I am talking about. Lets say you attack mob A and it is standing next to mob B, mob B is 15 units away from mob A. Mob A and B are on the same faction and have an assist radius of 15. If you attack mob A then mob B should also aggro you. On the same token if you are being chased by a mob and it passes by a mob within 15 units on the same faction you should get a nice little train.

Now this thinking may not be how EQ2 worked, that it is what I need. I am pretty close, working out some DB stuff but when I run my mob through a crowd of them, they all come running. Just adding the assist radius in the DB and working through a few issues.
Resident Dirty Hippy

User avatar
Zcoretri
Team Member
Posts: 1642
Joined: Fri Jul 27, 2007 12:55 pm
Location: SoCal

Re: Assist Radius

Post by Zcoretri » Wed Jul 06, 2016 12:27 pm

As far as I know it should still be that way...I remember as a tank carefully trying to pull just one mob from a closely grouped set of mobs that were not linked in a group. :mrgreen:

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

Re: Assist Radius

Post by Gangrenous » Wed Jul 06, 2016 12:48 pm

Well we need it then. Since I am doing a custom, I have all my Antonica Gnolls on one faction, Qeynos Guards on opposing. Before my changes I could hit one gnoll in the middle of four and one came. They all come now, they will chain each other to make me a nice train to the guards. I am at one hang up, cannot figure it out. I setup my assist_radius just the same as any other field, I have my Get and Set in C++ like any other. No compile errors but the float always remains zero, default in the DB for that field is 10. It still reports back as being 0.

For testing purposes I can set the float for 10 and it works beautifully, but there again I want each NPC to have a different assist radius.
Resident Dirty Hippy

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

Re: Assist Radius

Post by Gangrenous » Wed Jul 06, 2016 1:34 pm

Okay I figured it out. Well I redid my code and it works now, not sure what I had off, maybe an int instead of a float. Either way it works. What was funny is setting the assist radius on the gnoll spawns to 200 for a minute, then attack one. That was quite a scene.
Resident Dirty Hippy

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

Re: Assist Radius

Post by Gangrenous » Wed Jul 06, 2016 4:43 pm

Okay what I have working is working excellent. Testing it more I see it needs some work. During the initial aggro I am getting everything within assist radius. Any NPC within assist radius to the damaged npc gets aggro. What is not happening is while the mob is incoming, any npc in it's path is not getting aggro like I thought they were. So back to the drawing board.

By the way, what is spawn_range_map.Get(client), I have yet to figure that out. Mainly what is spawn_range_map?
Resident Dirty Hippy

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

Re: Assist Radius

Post by Gangrenous » Wed Jul 06, 2016 6:00 pm

Okay, that is figured out :)
Resident Dirty Hippy

tyrbo
Team Member
Posts: 271
Joined: Thu Feb 18, 2016 12:33 pm

Re: Assist Radius

Post by tyrbo » Thu Jul 07, 2016 9:35 am

So, given that this assist code is pretty important, how does one go about getting Gangrenous's particular set of changes merged in to the main repo?
I'm used to Github, where he'd just open a PR. What's the process for that here?

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

Re: Assist Radius

Post by Gangrenous » Thu Jul 07, 2016 9:39 am

Hell I will hand it out. I doubt it is "right" though, I am not the same level of coder as these guys are.
Resident Dirty Hippy

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests