froglok20
06-22-2003, 06:23 PM
Yes thats right iv finished off the non combat zones code, however it doesnt support /duel and /pvp yet. that im still working on when i get the time.
here it is, enjoy =)
zone.cpp
bool Database::LoadAllowCombat(int8 zoneid)
{
bool allowed = TRUE;
char errbuf[MYSQL_ERRMSG_SIZE];
char *query = 0;
MYSQL_RES *result;
MYSQL_ROW row;
if (database.RunQuery(query, MakeAnyLenString(&query, "SELECT can_attack from zone where zoneidnumber=%i", zoneid), errbuf, &result))
{
delete[] query;
int32 numrows = mysql_num_rows(result);
if(numrows != 1)
{
cerr << "Error in AllowAttackingInZone() More than 1 Zone Returned for zoneid" << endl;
mysql_free_result(result);
return true; // DEFAULT to allow attacking the the case there are more than 1 zone with the same ID
}
while ((row = mysql_fetch_row(result))) {
allowed = atoi(row[0]);
}
}
return allowed;
}
zone.cpp
in function Bootup()
approx line:318
zone->zone_combat = database.LoadAllowCombat(iZoneID);
if(zone->zone_combat = 0)
LogFile->write(EQEMuLog::Status, "Setting Zone to Non-Combat / Agression");
else
LogFile->write(EQEMuLog::Status, "Setting Zone to Normal Combat / Agression");
spells.cpp in function SpellOnTarget() line: 2986 approx
if(!zone->zone_combat)
{
if (this->IsClient() && !this->CastToClient()->GetGM())
{
if(IsDetrimental(spell_id))
{
Message(10, "This Zone does not support combat.");
return;
}
} else {
Message(10, "This Zone does not support combat, but we will let you!");
}
}
client_process.cpp in function HandlePacket()
under case PET_ATTACK: at approx line 10672
if(!zone->zone_combat)
{
if (this->IsClient() && !this->CastToClient()->GetGM())
{
Message(10,"%s tells you, 'Sorry Master, but i am unable to attack here.'", mypet->GetName());
break;
} else {
Message(10,"%s tells you, 'Attacking %s, Master. But Im not ment to!'", mypet->GetName(), this->target->GetName());
}
}
attack.cpp in function Attack()
at line approx 844
if(!zone->zone_combat)
{
if (this->IsClient() && !this->CastToClient()->GetGM())
{
Message(10, "This Zone does not support combat.");
return false;
} else {
Message(10, "This Zone does not support combat, but we will let you!");
}
}
database.h
inside class Database : public DBcore struct
approx line: 239
bool LoadAllowCombat(int8 zoneid);
This code will allow GM's to attack and cast detramental spells in the non combat zones, after all they are a GM...
Here is the SQL to update your database
ALTER TABLE zone ADD can_attack BOOL default "1";
UPDATE zone SET can_attack='0' where zoneidnumber='152';
UPDATE zone SET can_attack='0' where zoneidnumber='202';
UPDATE zone SET can_attack='0' where zoneidnumber='203';
this will update the nexus, pok and potranquil and set them to non combat zones
Enjoy :D
Froglok
here it is, enjoy =)
zone.cpp
bool Database::LoadAllowCombat(int8 zoneid)
{
bool allowed = TRUE;
char errbuf[MYSQL_ERRMSG_SIZE];
char *query = 0;
MYSQL_RES *result;
MYSQL_ROW row;
if (database.RunQuery(query, MakeAnyLenString(&query, "SELECT can_attack from zone where zoneidnumber=%i", zoneid), errbuf, &result))
{
delete[] query;
int32 numrows = mysql_num_rows(result);
if(numrows != 1)
{
cerr << "Error in AllowAttackingInZone() More than 1 Zone Returned for zoneid" << endl;
mysql_free_result(result);
return true; // DEFAULT to allow attacking the the case there are more than 1 zone with the same ID
}
while ((row = mysql_fetch_row(result))) {
allowed = atoi(row[0]);
}
}
return allowed;
}
zone.cpp
in function Bootup()
approx line:318
zone->zone_combat = database.LoadAllowCombat(iZoneID);
if(zone->zone_combat = 0)
LogFile->write(EQEMuLog::Status, "Setting Zone to Non-Combat / Agression");
else
LogFile->write(EQEMuLog::Status, "Setting Zone to Normal Combat / Agression");
spells.cpp in function SpellOnTarget() line: 2986 approx
if(!zone->zone_combat)
{
if (this->IsClient() && !this->CastToClient()->GetGM())
{
if(IsDetrimental(spell_id))
{
Message(10, "This Zone does not support combat.");
return;
}
} else {
Message(10, "This Zone does not support combat, but we will let you!");
}
}
client_process.cpp in function HandlePacket()
under case PET_ATTACK: at approx line 10672
if(!zone->zone_combat)
{
if (this->IsClient() && !this->CastToClient()->GetGM())
{
Message(10,"%s tells you, 'Sorry Master, but i am unable to attack here.'", mypet->GetName());
break;
} else {
Message(10,"%s tells you, 'Attacking %s, Master. But Im not ment to!'", mypet->GetName(), this->target->GetName());
}
}
attack.cpp in function Attack()
at line approx 844
if(!zone->zone_combat)
{
if (this->IsClient() && !this->CastToClient()->GetGM())
{
Message(10, "This Zone does not support combat.");
return false;
} else {
Message(10, "This Zone does not support combat, but we will let you!");
}
}
database.h
inside class Database : public DBcore struct
approx line: 239
bool LoadAllowCombat(int8 zoneid);
This code will allow GM's to attack and cast detramental spells in the non combat zones, after all they are a GM...
Here is the SQL to update your database
ALTER TABLE zone ADD can_attack BOOL default "1";
UPDATE zone SET can_attack='0' where zoneidnumber='152';
UPDATE zone SET can_attack='0' where zoneidnumber='202';
UPDATE zone SET can_attack='0' where zoneidnumber='203';
this will update the nexus, pok and potranquil and set them to non combat zones
Enjoy :D
Froglok