public void RemoveItemFromActorPC(ActorPC pc, int itemID, byte amount, ITEM_UPDATE_REASON reason) { ActorEventHandlers.PC_EventHandler eh = (SagaMap.ActorEventHandlers.PC_EventHandler)pc.e; DeleteItemResult res; byte namount, index; Item item = pc.inv.GetItem(CONTAINER_TYPE.INVENTORY, itemID); res = pc.inv.DeleteItem(CONTAINER_TYPE.INVENTORY, itemID, amount, out index, out namount); if (res == DeleteItemResult.ERROR || res == DeleteItemResult.WRONG_ITEMID) { return; } switch (res) { case DeleteItemResult.NOT_ALL_DELETED: Packets.Server.UpdateItem p2 = new SagaMap.Packets.Server.UpdateItem(); p2.SetContainer(CONTAINER_TYPE.INVENTORY); p2.SetItemIndex(index); p2.SetAmount(namount); p2.SetUpdateType(SagaMap.Packets.Server.ITEM_UPDATE_TYPE.AMOUNT); p2.SetUpdateReason(reason); eh.C.netIO.SendPacket(p2, eh.C.SessionID); MapServer.charDB.UpdateItem(pc, item); break; case DeleteItemResult.ALL_DELETED: Packets.Server.DeleteItem delI = new SagaMap.Packets.Server.DeleteItem(); delI.SetContainer(CONTAINER_TYPE.INVENTORY); delI.SetAmount(1); delI.SetIndex(index); eh.C.netIO.SendPacket(delI, eh.C.SessionID); MapServer.charDB.DeleteItem(pc, item); break; } }
public void SendActorToMap(Actor mActor, Map newMap, float x, float y, float z) { // todo: add support for multiple map servers // obtain the new map byte mapid = (byte)newMap.id; if (mapid == mActor.mapID) { TeleportActor(mActor, x, y, z); return; } // delete the actor from this map this.DeleteActor(mActor); // update the actor mActor.mapID = mapid; mActor.x = x; mActor.y = y; mActor.z = z; ActorEventHandlers.PC_EventHandler eh = (SagaMap.ActorEventHandlers.PC_EventHandler)mActor.e; eh.C.map = newMap; // register the actor in the new map if (mActor.type != ActorType.PC) { newMap.RegisterActor(mActor); } else { newMap.RegisterActor(mActor, mActor.id); } }
public void SetAnimation(ActorPC pc, uint ani) { ActorEventHandlers.PC_EventHandler eh = (SagaMap.ActorEventHandlers.PC_EventHandler)pc.e; Packets.Server.ActorAnimation p = new SagaMap.Packets.Server.ActorAnimation(); p.SetActor(this.ActorI.id); p.SetAnimation(ani); eh.C.netIO.SendPacket(p, eh.C.SessionID); }
public override void OnClicked(ActorPC pc) { base.OnClicked(pc); ActorEventHandlers.PC_EventHandler eh = (ActorEventHandlers.PC_EventHandler)pc.e; Packets.Server.MailList p1 = new SagaMap.Packets.Server.MailList(); p1.SetMails(MapServer.charDB.GetMail(SearchType.Receiver, pc.name)); p1.SetActorID(pc.CurTarget.id); eh.C.netIO.SendPacket(p1, eh.C.SessionID); }
public static void Warp(ActorPC pc, byte mapid) { ActorEventHandlers.PC_EventHandler eh = (SagaMap.ActorEventHandlers.PC_EventHandler)pc.e; Map map; if (!MapManager.Instance.GetMap(mapid, out map)) { return; } float[] coord = map.GetRandomPos(); eh.C.map.SendActorToMap(pc, mapid, coord[0], coord[1], coord[2]); }
public void SendLootList(ActorPC pc) { ActorEventHandlers.PC_EventHandler eh = (SagaMap.ActorEventHandlers.PC_EventHandler)pc.e; if (this.NPCItem == null) { this.NPCItem = new List <Item>(); } pc.CurNPCinv = this.NPCItem; Packets.Server.SendNpcInventory sendPacket = new Packets.Server.SendNpcInventory(); sendPacket.SetActorID(pc.id); sendPacket.SetItems(this.NPCItem); eh.C.netIO.SendPacket(sendPacket, eh.C.SessionID); }
public void SendActorToMap(Actor mActor, byte mapid, float x, float y, float z) { // todo: add support for multiple map servers // obtain the new map Map newMap; if (mapid == mActor.mapID) { TeleportActor(mActor, x, y, z); return; } if (!MapManager.Instance.GetMap(mapid, out newMap)) { return; } // delete the actor from this map this.DeleteActor(mActor); if (x == 0f && y == 0f && z == 0f) { float[] pos = newMap.GetRandomPos(); x = pos[0]; y = pos[1]; z = pos[2]; } // update the actor mActor.mapID = mapid; mActor.x = x; mActor.y = y; mActor.z = z; ActorEventHandlers.PC_EventHandler eh = (SagaMap.ActorEventHandlers.PC_EventHandler)mActor.e; eh.C.map = newMap; // register the actor in the new map if (mActor.type != ActorType.PC) { newMap.RegisterActor(mActor); } else { newMap.RegisterActor(mActor, mActor.id); } }
public void SendEventToAllActorsWhoCanSeeActor(EVENT_TYPE etype, MapEventArgs args, Actor sActor, bool sendToSourceActor) { try { for (short deltaY = -1; deltaY <= 1; deltaY++) { for (short deltaX = -1; deltaX <= 1; deltaX++) { uint region = (uint)(sActor.region + (deltaX * 1000000) + deltaY); if (!this.actorsByRegion.ContainsKey(region)) { continue; } foreach (Actor actor in this.actorsByRegion[region]) { try { if (!sendToSourceActor && (actor.id == sActor.id)) { continue; } if (this.ACanSeeB(actor, sActor)) { switch (etype) { case EVENT_TYPE.APPEAR: actor.e.OnActorAppears(sActor); actor.e.OnActorChangesState(sActor, null); break; case EVENT_TYPE.DISAPPEAR: actor.e.OnActorDisappears(sActor); break; case EVENT_TYPE.CHANGE_STATE: actor.e.OnActorChangesState(sActor, args); break; case EVENT_TYPE.CHAT: actor.e.OnActorChat(sActor, args); break; case EVENT_TYPE.SKILL: actor.e.OnActorSkillUse(sActor, args); break; case EVENT_TYPE.CHANGE_EQUIP: actor.e.OnActorChangeEquip(sActor, args); break; case EVENT_TYPE.CHANGE_STATUS: actor.e.OnChangeStatus(sActor, args); break; case EVENT_TYPE.ACTOR_SELECTION: Map.ActorSelArgs arg = (Map.ActorSelArgs)args; Actor target = this.GetActor(arg.target); if (target != null) { if (actor == sActor) //broadcast disabled temporaryly, which crashes the client { if (this.ACanSeeB(actor, target)) { actor.e.OnActorSelection((ActorPC)sActor, args); } } } break; case EVENT_TYPE.YAW_UPDATE: if (actor.type == ActorType.PC) { ActorPC pc = (ActorPC)actor; ActorEventHandlers.PC_EventHandler eh = (SagaMap.ActorEventHandlers.PC_EventHandler)pc.e; Packets.Server.UpdateActorYaw p1 = new SagaMap.Packets.Server.UpdateActorYaw(); p1.SetActor(sActor.id); p1.SetYaw(sActor.yaw); eh.C.netIO.SendPacket(p1, eh.C.SessionID); } break; default: break; } } } catch (Exception ex) { Logger.ShowError(ex); } } } } } catch (Exception ex) { Logger.ShowError(ex); } }
public static void Warp(ActorPC pc, byte mapid, float x, float y, float z) { ActorEventHandlers.PC_EventHandler eh = (SagaMap.ActorEventHandlers.PC_EventHandler)pc.e; eh.C.map.SendActorToMap(pc, mapid, x, y, z); }