Example #1
0
bool ChatHandler::HandleCastSpellCommand(const char* args, WorldSession *m_session)
{
    Unit* caster = m_session->GetPlayer();
    Unit* target = getSelectedUnit(m_session, false);
    if(!target)
        target = caster;

    uint32 spellid = atol(args);
    if(spellid == 0)
        spellid = GetSpellIDFromLink( args );

    SpellEntry *spellentry = dbcSpell.LookupEntryForced(spellid);
    if(spellentry == NULL)
    {
        RedSystemMessage(m_session, "Invalid spell id!");
        return false;
    }

    Spell* sp = new Spell(caster, spellentry, false, NULLAURA);
    if(!sp)
    {
        RedSystemMessage(m_session, "Spell failed creation!");
        return false;
    }
    BlueSystemMessage(m_session, "Casting spell %d on target.", spellid);
    SpellCastTargets targets;
    targets.m_unitTarget = target->GetGUID();
    sp->prepare(&targets);
    sWorld.LogGM(m_session, "Used castspell command on %s" , target->GetName());
    return true;
}
Example #2
0
bool ChatHandler::HandleDebugSendOpcodeCommand(const char* /*args*/)
{
    Unit *unit = getSelectedUnit();
    Player *player = NULL;
    if (!unit || (unit->GetTypeId() != TYPEID_PLAYER))
        player = m_session->GetPlayer();
    else
        player = (Player*)unit;
    if (!unit) unit = player;

    std::ifstream ifs("opcode.txt");
    if (ifs.bad())
        return false;

    uint32 opcode;
    ifs >> opcode;

    WorldPacket data(opcode, 0);

    while (!ifs.eof())
    {
        std::string type;
        ifs >> type;

        if (type == "")
            break;

        if (type == "uint8")
        {
            uint16 val1;
            ifs >> val1;
            data << uint8(val1);
        }
        else if (type == "uint16")
Example #3
0
bool ChatHandler::HandleDebugSendPoiCommand(const char* args)
{
    if (!*args)
        return false;

    Player *pPlayer = m_session->GetPlayer();
    Unit* target = getSelectedUnit();
    if (!target)
    {
        SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE);
        return true;
    }

    char* icon_text = strtok((char*)args, " ");
    char* flags_text = strtok(NULL, " ");
    if (!icon_text || !flags_text)
        return false;

    uint32 icon = atol(icon_text);
    uint32 flags = atol(flags_text);

    sLog.outDetail("Command : POI, NPC = %u, icon = %u flags = %u", target->GetGUIDLow(), icon,flags);
    pPlayer->PlayerTalkClass->SendPointOfInterest(target->GetPositionX(), target->GetPositionY(), Poi_Icon(icon), flags, 30, "Test POI");
    return true;
}
Example #4
0
bool ChatHandler::HandleKillCommand(const char *args, WorldSession *m_session)
{
    Unit* unit = getSelectedUnit(m_session);
    if(!unit)
        return true;

    sWorld.LogGM(m_session, "used kill command on %s %s", unit->IsPlayer() ? "Player" : "Creature", unit->GetName());

    if(unit->IsPlayer())
    {
        // If we're killing a player, send a message indicating a gm killed them.
        BlueSystemMessageToPlr(TO_PLAYER(unit), "%s killed you with a GM command.", m_session->GetPlayer()->GetName());
        TO_PLAYER(unit)->SetUInt32Value(UNIT_FIELD_HEALTH, 0); // Die, insect
        TO_PLAYER(unit)->KillPlayer();
        GreenSystemMessage(m_session, "Killed player %s.", unit->GetName());
    }
    else if(isTargetDummy(unit->GetEntry()))
        RedSystemMessage(m_session, "Target cannot be killed.");
    else
    {
        m_session->GetPlayer()->DealDamage(unit, 0xFFFFFFFF, 0, 0, 0);
        GreenSystemMessage(m_session, "Killed unit %s.", unit->GetName());
    }
    return true;
}
Example #5
0
bool ChatHandler::HandleSendOpcodeCommand(const char* args)
{
    Unit *unit = getSelectedUnit();
    if (!unit || (unit->GetTypeId() != TYPEID_PLAYER))
        unit = m_session->GetPlayer();

    std::ifstream ifs("opcode.txt");
    if(ifs.bad())
        return false;

    uint32 opcode;
    ifs >> opcode;

    WorldPacket data(opcode, 0);

    while(!ifs.eof())
    {
        std::string type;
        ifs >> type;

        if(type == "uint8")
        {
            uint8 val1;
            ifs >> val1;
            data << val1;
        }
        else if(type == "uint16")
Example #6
0
bool ChatHandler::HandleDeMorphCommand(const char* args, WorldSession *m_session)
{
    Unit *unit = getSelectedUnit(m_session);
    if(!unit)
        return false;
    unit->DeMorph();
    return true;
}
Example #7
0
bool ChatHandler::HandleBindSightCommand(const char * /*args*/)
{
    Unit* unit = getSelectedUnit();
    if (!unit)
        return false;

    m_session->GetPlayer()->CastSpell(unit, 6277, true);
    return true;
}
Example #8
0
bool ChatHandler::HandleUnPossessCommand(const char * /*args*/)
{
    Unit* unit = getSelectedUnit();
    if (!unit)
        unit = m_session->GetPlayer();

    unit->RemoveCharmAuras();

    return true;
}
Example #9
0
bool ChatHandler::HandleSendHomeCommand(char* args)
{
    Player *self = m_session->GetPlayer();
    Unit *target = getSelectedUnit();
    if(target && target->GetTypeId() == TYPEID_PLAYER)
    {
        Player *ptarget = (Player*)target;
        ptarget->TeleportToHomebind();
    }
    return true;
}
Example #10
0
bool ChatHandler::HandleDebugInArcCommand(const char* /*args*/)
{
    Object* obj = getSelectedUnit();

    if (!obj)
    {
        SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE);
        return true;
    }

    SendSysMessage(LANG_NOT_IMPLEMENTED);

    return true;
}
Example #11
0
//demorph player or unit
bool ChatHandler::HandleDeMorphCommand(const char* /*args*/)
{
    Unit* target = getSelectedUnit();
    if (!target)
        target = m_session->GetPlayer();

    // check online security
    else if (target->GetTypeId() == TYPEID_PLAYER && HasLowerSecurity((Player*)target, 0))
        return false;

    target->DeMorph();

    return true;
}
Example #12
0
bool ChatHandler::HandleMonsterYellCommand(const char* args, WorldSession *m_session)
{
    Unit* crt = getSelectedUnit(m_session, false);
    if(!crt)
        return true;

    if(crt->IsPlayer())
    {
        WorldPacket * data = FillMessageData(CHAT_MSG_YELL, LANG_UNIVERSAL, args, crt->GetGUID(), 0);
        crt->SendMessageToSet(data, true);
        delete data;
    }
    else
        crt->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, args);
    sWorld.LogGM(m_session, "Used npc yell command on %s %s", crt->IsPlayer() ? "Player" : "Creature", crt->GetName());
    return true;
}
Example #13
0
bool ChatHandler::HandleDebugAddFormationToFileCommand(const char* args)
{
    if (!args)
        return false;

    std::fstream file;
    file.open("formations.txt", std::ios_base::app);
    if (file.fail())
        return false;

    uint32 leader = atoi((char*)args);
    uint32 member = 0;
    if (Unit *sel = getSelectedUnit())
        member = ((Creature *)sel)->GetDBTableGUIDLow();

    file << "INSERT INTO `creature_formations` VALUES ('" << leader << "', '" << member << "', '0', '0', '2');" << std::endl;
    file.close();
    return true;
}
Example #14
0
bool ChatHandler::HandleCastSpellNECommand(const char* args, WorldSession *m_session)
{
    Unit* caster = m_session->GetPlayer();
    Unit* target = getSelectedUnit(m_session, false);
    if(!target)
        target = caster;

    uint32 spellId = atol(args);
    SpellEntry *spellentry = dbcSpell.LookupEntryForced(spellId);
    if(spellentry == NULL)
    {
        RedSystemMessage(m_session, "Invalid spell id!");
        return false;
    }
    BlueSystemMessage(m_session, "Casting spell %d on target.", spellId);

    WorldPacket data;

    data.Initialize( SMSG_SPELL_START );
    data << caster->GetNewGUID();
    data << caster->GetNewGUID();
    data << spellId;
    data << uint8(0);
    data << uint16(0);
    data << uint32(0);
    data << uint16(2);
    data << target->GetGUID();
    m_session->SendPacket( &data );
    data.clear();

    data.Initialize( SMSG_SPELL_GO );
    data << caster->GetNewGUID();
    data << caster->GetNewGUID();
    data << spellId;
    data << uint8(0) << uint8(1) << uint8(1);
    data << target->GetGUID();
    data << uint8(0);
    data << uint16(2);
    data << target->GetGUID();
    m_session->SendPacket( &data );
    return true;
}
Example #15
0
bool ChatHandler::HandleDebugHostilRefList(const char * /*args*/)
{
    Unit* target = getSelectedUnit();
    if(!target)
        target = m_session->GetPlayer();
    HostilReference* ref = target->getHostilRefManager().getFirst();
    uint32 cnt = 0;
    PSendSysMessage("Hostil reference list of %s (guid %u)",target->GetName(), target->GetGUIDLow());
    while(ref)
    {
        if(Unit * unit = ref->getSource()->getOwner())
        {
            ++cnt;
            PSendSysMessage("   %u.   %s   (guid %u)  - threat %f",cnt,unit->GetName(), unit->GetGUIDLow(), ref->getThreat());
        }
        ref = ref->next();
    }
    SendSysMessage("End of hostil reference list.");
    return true;
}
Example #16
0
//demorph player or unit
bool ChatHandler::HandleDeMorphCommand(const char* /*args*/)
{
    Unit *target = getSelectedUnit();
    if (!target)
        target = m_session->GetPlayer();

    // check online security
    if (target->GetTypeId() == TYPEID_PLAYER && HasLowerSecurity((Player*)target, 0))
        return false;
    
    if (target->GetTypeId() == TYPEID_PLAYER)
        if (target->ToPlayer()->NoModify() && m_session->GetPlayer() != target && !m_session->GetPlayer()->IsAdmin())
        {
            PSendSysMessage("This player has disabled gm commands being used on them.");
            return true;
        }

    target->DeMorph();

    return true;
}
Example #17
0
bool ChatHandler::HandleDebugSendPoiCommand(char* args)
{
    Player *pPlayer = m_session->GetPlayer();
    Unit* target = getSelectedUnit();
    if (!target)
    {
        SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE);
        return true;
    }

    uint32 icon;
    if (!ExtractUInt32(&args, icon))
        return false;

    uint32 flags;
    if (!ExtractUInt32(&args, flags))
        return false;

    DETAIL_LOG("Command : POI, NPC = %u, icon = %u flags = %u", target->GetGUIDLow(), icon,flags);
    pPlayer->PlayerTalkClass->SendPointOfInterest(target->GetPositionX(), target->GetPositionY(), Poi_Icon(icon), flags, 30, "Test POI");
    return true;
}
Example #18
0
bool ChatHandler::HandleGPSCommand(const char* args)
{
    Object *obj = getSelectedUnit();

    if(!obj)
    {
        SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE);
        return true;
    }

    CellPair cell_val = MaNGOS::ComputeCellPair(obj->GetPositionX(), obj->GetPositionY());
    Cell cell = RedZone::GetZone(cell_val);

    PSendSysMultilineMessage(LANG_MAP_POSITION,
        obj->GetMapId(), obj->GetZoneId(), obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ(),
        obj->GetOrientation(),cell.GridX(), cell.GridY(), cell.CellX(), cell.CellY());

    sLog.outDebug("Player %s GPS call unit " I64FMT " " LANG_MAP_POSITION, m_session->GetPlayer()->GetName(), obj->GetGUID(),
        obj->GetMapId(), obj->GetZoneId(), obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ(),
        obj->GetOrientation(), cell.GridX(), cell.GridY(), cell.CellX(), cell.CellY());

    return true;
}
Example #19
0
bool ChatHandler::HandleGPSCommand(const char* args)
{
    WorldObject *obj = getSelectedUnit();

    if(!obj)
    {
        SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE);
        return true;
    }

    CellPair cell_val = MaNGOS::ComputeCellPair(obj->GetPositionX(), obj->GetPositionY());
    Cell cell = RedZone::GetZone(cell_val);

    PSendSysMultilineMessage(LANG_MAP_POSITION,
        obj->GetMapId(), obj->GetZoneId(), obj->GetAreaId(), obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ(),
        obj->GetOrientation(),cell.GridX(), cell.GridY(), cell.CellX(), cell.CellY(),obj->GetInstanceId());

    sLog.outDebug("Player %s GPS call %s %u " LANG_MAP_POSITION, m_session->GetPlayer()->GetName(),
        (obj->GetTypeId() == TYPEID_PLAYER ? "player" : "creature"), obj->GetGUIDLow(),
        obj->GetMapId(), obj->GetZoneId(), obj->GetAreaId(), obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ(),
        obj->GetOrientation(), cell.GridX(), cell.GridY(), cell.CellX(), cell.CellY(),obj->GetInstanceId());

    return true;
}
Example #20
0
bool ChatHandler::HandleSendOpcodeCommand(const char* args)
{
    Unit *unit = getSelectedUnit();
    if (!unit || (unit->GetTypeId() != TYPEID_PLAYER))
        unit = m_session->GetPlayer();

    FILE *file = fopen("opcode.txt", "r");
    if(!file)
        return false;

    uint32 type;

    uint32 val1;
    uint64 val2;
    float val3;
    char val4[101];

    uint32 opcode = 0;
    fscanf(file, "%u", &opcode);
    if(!opcode)
    {
        fclose(file);
        return false;
    }

    WorldPacket data(opcode, 0);

    while(fscanf(file, "%u", &type) != EOF)
    {
        switch(type)
        {
            case 0:                                         // uint8
                fscanf(file, "%u", &val1);
                data << uint8(val1);
                break;
            case 1:                                         // uint16
                fscanf(file, "%u", &val1);
                data << uint16(val1);
                break;
            case 2:                                         // uint32
                fscanf(file, "%u", &val1);
                data << uint32(val1);
                break;
            case 3:                                         // uint64
                fscanf(file, I64FMTD, &val2);
                data << uint64(val2);
                break;
            case 4:                                         // float
                fscanf(file, "%f", &val3);
                data << float(val3);
                break;
            case 5:                                         // string
                fscanf(file, "%s", val4, 101);
                data << val4;
                break;
            case 6:                                         // packed guid
                data.append(unit->GetPackGUID());
                break;
            default:
                fclose(file);
                return false;
        }
    }
    fclose(file);
    sLog.outDebug("Sending opcode %u", data.GetOpcode());
    data.hexlike();
    ((Player*)unit)->GetSession()->SendPacket(&data);
    PSendSysMessage(LANG_COMMAND_OPCODESENT, data.GetOpcode(), unit->GetName());
    return true;
}
Example #21
0
bool ChatHandler::HandleGPSCommand(const char* args)
{
    WorldObject *obj = NULL;
    if (*args)
    {
        uint64 guid = extractGuidFromLink((char*)args);
        if (guid)
            obj = (WorldObject*)ObjectAccessor::GetObjectByTypeMask(*m_session->GetPlayer(), guid, TYPEMASK_UNIT|TYPEMASK_GAMEOBJECT);

        if (!obj)
        {
            SendSysMessage(LANG_PLAYER_NOT_FOUND);
            SetSentErrorMessage(true);
            return false;
        }
    }
    else
    {
        obj = getSelectedUnit();

        if (!obj)
        {
            SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE);
            SetSentErrorMessage(true);
            return false;
        }
    }
    CellPair cell_val = Trinity::ComputeCellPair(obj->GetPositionX(), obj->GetPositionY());
    Cell cell(cell_val);

    uint32 zone_id, area_id;
    obj->GetZoneAndAreaId(zone_id, area_id);

    MapEntry const* mapEntry = sMapStore.LookupEntry(obj->GetMapId());
    AreaTableEntry const* zoneEntry = GetAreaEntryByAreaID(zone_id);
    AreaTableEntry const* areaEntry = GetAreaEntryByAreaID(area_id);

    float zone_x = obj->GetPositionX();
    float zone_y = obj->GetPositionY();

    Map2ZoneCoordinates(zone_x, zone_y, zone_id);

    Map const *map = obj->GetMap();
    float ground_z = map->GetHeight(obj->GetPositionX(), obj->GetPositionY(), MAX_HEIGHT);
    float floor_z = map->GetHeight(obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ());

    GridPair p = Trinity::ComputeGridPair(obj->GetPositionX(), obj->GetPositionY());

    // 63? WHY?
    int gx = 63 - p.x_coord;
    int gy = 63 - p.y_coord;

    uint32 have_map = Map::ExistMap(obj->GetMapId(), gx, gy) ? 1 : 0;
    uint32 have_vmap = Map::ExistVMap(obj->GetMapId(), gx, gy) ? 1 : 0;

    if (have_vmap)
    {
        if (map->IsOutdoors(obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ()))
            PSendSysMessage("You are outdoors");
        else
            PSendSysMessage("You are indoors");
    }
    else PSendSysMessage("no VMAP available for area info");

    PSendSysMessage(LANG_MAP_POSITION,
                    obj->GetMapId(), (mapEntry ? mapEntry->name[GetSessionDbcLocale()] : "<unknown>"),
                    zone_id, (zoneEntry ? zoneEntry->area_name[GetSessionDbcLocale()] : "<unknown>"),
                    area_id, (areaEntry ? areaEntry->area_name[GetSessionDbcLocale()] : "<unknown>"),
                    obj->GetPhaseMask(),
                    obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ(), obj->GetOrientation(),
                    cell.GridX(), cell.GridY(), cell.CellX(), cell.CellY(), obj->GetInstanceId(),
                    zone_x, zone_y, ground_z, floor_z, have_map, have_vmap);

    LiquidData liquid_status;
    ZLiquidStatus res = map->getLiquidStatus(obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ(), MAP_ALL_LIQUIDS, &liquid_status);
    if (res)
    {
        PSendSysMessage(LANG_LIQUID_STATUS, liquid_status.level, liquid_status.depth_level, liquid_status.type, res);
    }
    return true;
}