Go Back   EQEmulator Home > EQEmulator Forums > Development > Development::Server Code Submissions

Reply
 
Thread Tools Display Modes
  #1  
Old 07-07-2008, 07:12 AM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default Disable CotH on a Per-Zone Basis

After seeing a request by Kingmort to have a CotH version of the canlevitate and castoutdoor code for the Zone table, I thought that I could maybe handle writing this code. I work pretty well by example, so I looked at the code written by Magoth78 and by Qadar and it looked pretty straight forward.

I just changed what they had already done to add in a coth version. The only part that took any thinking on my end was figuring out how to get it to use a spell ID instead of the things they had it check for levitate and outdoor spells. The rest was pretty simple.

So, here is the code to allow you to restrict Call of the Hero from being used in any zone you desire:

In /zone/spells.cpp After:
Code:
	if(IsEffectInSpell(spell_id, SE_Levitate) && !zone->CanLevitate()){
			if(IsClient()){
				if(!CastToClient()->GetGM()){
					Message(13, "You can't levitate in this zone.");
					return false;
				}
			}
		}
Add the following:
Code:
	if(spell_id == 1771 && !zone->CanCotH()){
		if(IsClient()){
				if(!CastToClient()->GetGM()){
					Message(13, "You can't summon players in this zone.");
					return false;
				}
			}
		}
/zone/zone.h (note that you do NOT add the + sign, that just signifies the line to add)
Code:
After - bool    CanCastOutdoor() const {return(can_castoutdoor);} //qadar
+bool    CanCotH() const {return(can_coth); } //trevius

After - bool    can_levitate;
+bool    can_coth;
/zone/zone.cpp
Code:
-	if(!database.GetZoneCFG(database.GetZoneID(filename), &newzone_data, can_bind, can_combat, can_levitate, can_castoutdoor, is_city)) {
+	if(!database.GetZoneCFG(database.GetZoneID(filename), &newzone_data, can_bind, can_combat, can_levitate, can_castoutdoor, is_city, can_coth)) {

/zone/zonedb.h
Code:
-bool	GetZoneCFG(int32 zoneid, NewZone_Struct *data, bool &can_bind, bool &can_combat, bool &can_levitate, bool &can_castoutdoor, bool &is_city);
+bool	GetZoneCFG(int32 zoneid, NewZone_Struct *data, bool &can_bind, bool &can_combat, bool &can_levitate, bool &can_castoutdoor, bool &is_city, bool &can_coth);

In /zone/zonedb.cpp Remove:
Code:
bool ZoneDatabase::GetZoneCFG(int32 zoneid, NewZone_Struct *zone_data, bool &can_bind, bool &can_combat, bool &can_levitate, bool &can_castoutdoor, bool &is_city) {
	char errbuf[MYSQL_ERRMSG_SIZE];
	char *query = 0;
	MYSQL_RES *result;
	MYSQL_ROW row;
	int i=0;
	int b=0;
	bool good = false;
	if (RunQuery(query, MakeAnyLenString(&query, "SELECT ztype,"
		"fog_red,fog_green,fog_blue,fog_minclip,fog_maxclip,"
		"fog_red2,fog_green2,fog_blue2,fog_minclip2,fog_maxclip2,"
		"fog_red3,fog_green3,fog_blue3,fog_minclip3,fog_maxclip3,"
		"fog_red4,fog_green4,fog_blue4,fog_minclip4,fog_maxclip4,"
		"sky,zone_exp_multiplier,safe_x,safe_y,safe_z,underworld,"
		"minclip,maxclip,time_type,canbind,cancombat,canlevitate,castoutdoor"
		" from zone where zoneidnumber=%i",zoneid), errbuf, &result)) {
		safe_delete_array(query);
		while((row = mysql_fetch_row(result))) {
			int r = 0;
			memset(zone_data,0,sizeof(NewZone_Struct));
			zone_data->ztype=atoi(row[r++]);
			
			for(i=0;i<4;i++){
				zone_data->fog_red[i]=atoi(row[r++]);
				zone_data->fog_green[i]=atoi(row[r++]);
				zone_data->fog_blue[i]=atoi(row[r++]);
				zone_data->fog_minclip[i]=atof(row[r++]);
				zone_data->fog_maxclip[i]=atof(row[r++]);
			}
			
			zone_data->sky=atoi(row[r++]);
			zone_data->zone_exp_multiplier=atof(row[r++]);
			zone_data->safe_x=atof(row[r++]);
			zone_data->safe_y=atof(row[r++]);
			zone_data->safe_z=atof(row[r++]);
			zone_data->underworld=atof(row[r++]);
			zone_data->minclip=atof(row[r++]);
			zone_data->maxclip=atof(row[r++]);
			
			zone_data->time_type=atoi(row[r++]);
//not in the DB yet:
			zone_data->gravity = 0.4;
			
			b = atoi(row[r++]);
			can_bind = b==0?false:true;
			is_city = b==2?true:false;
			can_combat = atoi(row[r++])==0?false:true;
            		can_levitate = atoi(row[r++])==0?false:true;
			can_castoutdoor = atoi(row[r++])==0?false:true;
			
			good = true;
		}
		mysql_free_result(result);
	}
	else
		LogFile->write(EQEMuLog::Error, "Error in GetZoneCFG query %s: %s", query, errbuf);
	safe_delete_array(query);
	
	zone_data->zone_id = zoneid;
	
	return(good);
}
And in /zone/zonedb.cpp, replace what was just removed with:
Code:
bool ZoneDatabase::GetZoneCFG(int32 zoneid, NewZone_Struct *zone_data, bool &can_bind, bool &can_combat, bool &can_levitate, bool &can_castoutdoor, bool &is_city, bool &can_coth) {
	char errbuf[MYSQL_ERRMSG_SIZE];
	char *query = 0;
	MYSQL_RES *result;
	MYSQL_ROW row;
	int i=0;
	int b=0;
	bool good = false;
	if (RunQuery(query, MakeAnyLenString(&query, "SELECT ztype,"
		"fog_red,fog_green,fog_blue,fog_minclip,fog_maxclip,"
		"fog_red2,fog_green2,fog_blue2,fog_minclip2,fog_maxclip2,"
		"fog_red3,fog_green3,fog_blue3,fog_minclip3,fog_maxclip3,"
		"fog_red4,fog_green4,fog_blue4,fog_minclip4,fog_maxclip4,"
		"sky,zone_exp_multiplier,safe_x,safe_y,safe_z,underworld,"
		"minclip,maxclip,time_type,canbind,cancombat,canlevitate,castoutdoor,cancoth"
		" from zone where zoneidnumber=%i",zoneid), errbuf, &result)) {
		safe_delete_array(query);
		while((row = mysql_fetch_row(result))) {
			int r = 0;
			memset(zone_data,0,sizeof(NewZone_Struct));
			zone_data->ztype=atoi(row[r++]);
			
			for(i=0;i<4;i++){
				zone_data->fog_red[i]=atoi(row[r++]);
				zone_data->fog_green[i]=atoi(row[r++]);
				zone_data->fog_blue[i]=atoi(row[r++]);
				zone_data->fog_minclip[i]=atof(row[r++]);
				zone_data->fog_maxclip[i]=atof(row[r++]);
			}
			
			zone_data->sky=atoi(row[r++]);
			zone_data->zone_exp_multiplier=atof(row[r++]);
			zone_data->safe_x=atof(row[r++]);
			zone_data->safe_y=atof(row[r++]);
			zone_data->safe_z=atof(row[r++]);
			zone_data->underworld=atof(row[r++]);
			zone_data->minclip=atof(row[r++]);
			zone_data->maxclip=atof(row[r++]);
			
			zone_data->time_type=atoi(row[r++]);
//not in the DB yet:
			zone_data->gravity = 0.4;
			
			b = atoi(row[r++]);
			can_bind = b==0?false:true;
			is_city = b==2?true:false;
			can_combat = atoi(row[r++])==0?false:true;
            		can_levitate = atoi(row[r++])==0?false:true;
			can_castoutdoor = atoi(row[r++])==0?false:true;
			can_coth = atoi(row[r++])==0?false:true;
			
			good = true;
		}
		mysql_free_result(result);
	}
	else
		LogFile->write(EQEMuLog::Error, "Error in GetZoneCFG query %s: %s", query, errbuf);
	safe_delete_array(query);
	
	zone_data->zone_id = zoneid;
	
	return(good);
}


Required SQL:
Code:
alter table `zone` add column `cancoth` tinyint (4) DEFAULT '1' NOT NULL  after `castoutdoor`;
The default will be set to enabled for all zones. To disable a zone, you will simply open the zones table and change the "cancoth" field from 1 to 0.

I have tested this quickly just now after adding it and it seems to work as intended. I will keep an eye out for any further issues with this code. If anyone else wishes to try it, feel free, and post your results.
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!
Reply With Quote
  #2  
Old 07-07-2008, 04:56 PM
KLS
Administrator
 
Join Date: Sep 2006
Posts: 1,348
Default

I think we need a solution that works for areas of zones instead of just entire zones.
Reply With Quote
  #3  
Old 07-07-2008, 05:21 PM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

Ya, that would be nice. That would go well beyond my coding skill level lol. IMO, disabling per zone should work well in most cases. I can't really think of many cases where I would like to have CotH available in a zone, but not in 1 section of it. In most cases, I think disabling for the entire zone would be just fine. Just my opinion though.

I am not really sure how you would disable it for a certain area. It seems like it would be very complex to add in a defined area to limit CotH.

IMO, the best way to remove CotH from a certain area would probably be to use quests instead of code. Then, just use a quest with a proximity that encompasses the entire area you want to remove coth from and use some kind of check for players casting spell 1771 within that proximity and have it duck the player or cancel the spell in another way.
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!
Reply With Quote
  #4  
Old 07-07-2008, 06:22 PM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

I was thinking a bit more about it and maybe the cancoth field could be set to allow more input. If it could be set so that 0 disables coth for the entire zone, and 1 enables it for the entire zone, and then have another option of setting which could be option 2,x,y,z,xr,yr,zr. If this option 2 could then have more information included with it, maybe you could set this up as a proximity to define areas.

It could pull the values from a comma separated input something like:

Code:
cancoth
2,0,0,0,50,50,25
Where, the first 2 is what tells the code that it is going to use the additional input that follows. Then, the 3 0s are the location of the center of the proximity you are setting. Then, the first 50 is for setting the X axis range of the proximity check. The next 50 is for setting the Y axis range, and the 25 sets the Z axis range.

I think the code I have posted here would do part of what is needed to get this set, but you would have to change the input type in the field to accept the additional input. There would also have to be some code added that will allow you to define the proximity. Maybe looking into the code for setting quest proximities would help to figure out what needs to be added to get it working to do this.
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!
Reply With Quote
  #5  
Old 07-07-2008, 06:53 PM
AndMetal
Developer
 
Join Date: Mar 2007
Location: Ohio
Posts: 648
Default

Quote:
Originally Posted by trevius View Post
It could pull the values from a comma separated input something like:

Code:
cancoth
2,0,0,0,50,50,25
I personally think adding a table to the database for this would be better than using a text file. The only somewhat difficult part may be for areas that you want to block off that you don't really want rectangular for whatever reason. In reality though, it just means more entries in the database.

Then again, I think this could be taken a step further: why just CotH, Lev, & SoW manually blocked in the code? Why not make it apply to any spell you want?

Just thinking out loud, you could define a table, maybe blocked_spells, with the spell id, type of block (using 1 & 2 like you suggested), zone id, and coordinates/sizes. Here would be an example:

Code:
| id | spellid | type | zoneid |  x   |  y   |  z   |  l   |  w   |  h   |
|----+---------+------+--------+------+------+------+------+------+------|
| 1  |  1771   |  1   |   71   | NULL | NULL | NULL | NULL | NULL | NULL |
| 2  |  1771   |  2   |  202   | 978  |  0   | 425  |  50  |  50  |  35  |
This would block CotH from being used in airplane at all & poknowledge in the library tower.

In the code, you could then just run a check when the spell is cast to see if the spell is restricted in the table, and then if you are standing in the coordinates if they are defined. If you are, return false (causing the spell not to be cast) w/ an client that you can use that spell there. Hell, you could just define a message to the client in the same table.

Thoughts?
__________________
GM-Impossible of 'A work in progress'
A non-legit PEQ DB server
How to create your own non-legit server

My Contributions to the Wiki
Reply With Quote
  #6  
Old 07-07-2008, 08:15 PM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

Ya, another table would probably be best. I was just trying to avoid having to add another table to do this. Though, it would be nice to have the option to block any spell in any area.

From what I can tell, it looks like this is where set_proximity is defined for quests:

questmgr.cpp
Code:
void QuestManager::set_proximity(float minx, float maxx, float miny, float maxy, float minz, float maxz) {
	if(!owner->IsNPC())
		return;

	entity_list.AddProximity(owner->CastToNPC());

	owner->CastToNPC()->proximity->min_x = minx;
	owner->CastToNPC()->proximity->max_x = maxx;
	owner->CastToNPC()->proximity->min_y = miny;
	owner->CastToNPC()->proximity->max_y = maxy;
	owner->CastToNPC()->proximity->min_z = minz;
	owner->CastToNPC()->proximity->max_z = maxz;
}
Maybe that could be adjusted to be used without requiring an NPC and then make it a static proximity in the zone.

This is definitely getting beyond my level of code understanding though, lol. I can normally find where the code is or examples to work from, but as far as figuring out exactly what needs to be changed to get something working, I am not very good at that.
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!
Reply With Quote
  #7  
Old 07-26-2008, 05:02 PM
Angelox
AX Classic Developer
 
Join Date: May 2006
Location: filler
Posts: 2,049
Default

trevius;
Are you still using the original version of this fix, or have you changed it any?
Also, would an SQL of zones that use this be possible?

Thanks
Reply With Quote
  #8  
Old 07-26-2008, 09:23 PM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

Ya, I am still using the original code change that I posted. I think it works just fine and I am pretty sure it was done on a per zone basis for EQLive. I wouldn't mind having a way to define proximities that stop certain spells from being casted. But, I think that the per zone limits meets any needs I would have for disabling CotH. I don't really need to be too specific about limiting it.

I don't have a list of which zones didn't allow it. The only one I can think of off the top of my head that I am pretty sure didn't allow CotH is Ssra Temple, but then again, that might have only been for the emperor area lol... Been too long.
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!
Reply With Quote
  #9  
Old 08-05-2008, 12:05 AM
Flare83
Sarnak
 
Join Date: Aug 2008
Location: usa
Posts: 43
Default

Quote:
Originally Posted by trevius View Post
Ya, I am still using the original code change that I posted. I think it works just fine and I am pretty sure it was done on a per zone basis for EQLive.
I think it was until PoP came out. i remember only being able to coth / necro summon people in the graveyard's in PoP zones.
Reply With Quote
  #10  
Old 08-05-2008, 04:53 AM
Garath
Fire Beetle
 
Join Date: Jun 2005
Posts: 5
Default

Just a quick note in case you want to use the same text as on live when CoH isn't working instead of a generic can't use message. It said:
A voice whispers in your mind: "There are no heroes here..."
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 12:27 AM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3