Example #1
0
    private void HandleMoonGateUse(WorldClient client, MabiPacket packet)
    {
        var character = client.GetCreatureOrNull(packet.Id) as MabiPC;
        if(character == null)
            goto L_Fail;

        var source = packet.GetString();
        var target = packet.GetString();

        // Check gates
        MoonGate sGate, tGate;
        _gates.TryGetValue(source, out sGate);
        _gates.TryGetValue(target, out tGate);
        if (sGate == null || tGate == null || sGate.Prop.State == "closed")
            goto L_Fail;

        // Check range to source
        if (character.Region != sGate.Region || !WorldManager.InRange(character, sGate.X, sGate.Y, 1000))
            goto L_Fail;

        // Check if char has target
        if (!character.Keywords.Contains(tGate.KeywordId) && !_freeRoaming && !character.Keywords.Contains(10142))
            goto L_Fail;

        client.Warp(tGate.Region, tGate.X, tGate.Y);

        client.Send(new MabiPacket(Op.MoonGateUseR, client.Character.Id).PutByte(true));
        return;

        L_Fail:
        client.Send(new MabiPacket(Op.MoonGateUseR, client.Character.Id).PutByte(false));
    }