EQEmulator Forums

EQEmulator Forums (https://www.eqemulator.org/forums/index.php)
-   Archive::Development (https://www.eqemulator.org/forums/forumdisplay.php?f=621)
-   -   Non Combat Zones Souce Code (https://www.eqemulator.org/forums/showthread.php?t=8260)

froglok20 06-22-2003 06:23 PM

Non Combat Zones Souce Code
 
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
Code:

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
Code:

        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
Code:

        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

Code:

                                                        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
Code:

        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
Code:

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

Code:


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

Edgar1898 06-23-2003 02:49 AM

You could have just added those to IsAttackAllowed in mob.cpp :P Everything except spells calls that function when you try to attack.

froglok20 06-23-2003 05:56 PM

oh.. hehe never thought of that :D :wink:


All times are GMT -4. The time now is 01:09 PM.

Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.