public virtual void Reset() { ResetSkills(); m_AnimationDelta = UnityEngine.Vector3Int.zero; m_AnimationDirection = Directions.North; m_AnimationEnd = 0; m_AnimationSpeed = UnityEngine.Vector3Int.zero; m_Brightness = 0; m_Direction = Directions.North; m_ID = 0; m_Trapper = false; m_Unpassable = false; m_KnownSince = -1; m_LightColor = UnityEngine.Color.black; m_MovementEnd = 0; m_MovementRunning = false; Name = null; m_PartyFlag = PartyFlags.None; m_PKFlag = PKFlags.Revenge; m_Type = CreatureTypes.Monster; m_Visible = false; m_GuildFlag = GuildFlags.None; m_Marks.Clear(); m_MountOutfit = null; m_Outfit = null; m_Position = UnityEngine.Vector3Int.zero; }
private void ParseGraphicalEffects(Internal.CommunicationStream message) { var initialPosition = message.ReadPosition(); int modifier = message.ReadUnsignedByte(); Appearances.AppearanceInstance effect = null; byte effectId = 0; var fromPosition = initialPosition; ushort unclampedOffset = 0; while (modifier != 0) { if (modifier == 1) { unclampedOffset = message.ReadUnsignedShort(); int offset = unclampedOffset % 256; fromPosition.x += offset % Constants.MapSizeX; fromPosition.y += offset / Constants.MapSizeX; } // the effect is far away from the initial position while (fromPosition.x - initialPosition.x >= Constants.MapSizeX) { fromPosition.x -= Constants.MapSizeX; fromPosition.y++; } if ((unclampedOffset >= 1024 && modifier == 1) || (modifier & 3) == 0) { effectId = message.ReadUnsignedByte(); int deltaX = message.ReadSignedByte(); int deltaY = message.ReadSignedByte(); var toPosition = new Vector3Int(fromPosition.x + deltaX, fromPosition.y + deltaY, fromPosition.z); effect = AppearanceStorage.CreateMissileInstance(effectId, fromPosition, toPosition); } else if (unclampedOffset >= 768 || modifier == 3) { effectId = message.ReadUnsignedByte(); effect = AppearanceStorage.CreateEffectInstance(effectId); } else { throw new System.NotImplementedException(); } if (!effect) { throw new System.Exception("ProtocolGame.ParseGraphicalEffects: Unknown effect: " + effectId); } WorldMapStorage.AppendEffect(fromPosition, effect); modifier = message.ReadUnsignedByte(); } }
private AppearanceInstance ReadCreatureOutfit(Internal.ByteArray message, AppearanceInstance instance = null) { int outfitID; if (OpenTibiaUnity.GameManager.GetFeature(GameFeature.GameOutfitIDU16)) { outfitID = message.ReadUnsignedShort(); } else { outfitID = message.ReadUnsignedByte(); } if (outfitID != 0) { int headColor = message.ReadUnsignedByte(); int torsoColor = message.ReadUnsignedByte(); int legsColor = message.ReadUnsignedByte(); int detailColor = message.ReadUnsignedByte(); int addonsFlags = 0; if (OpenTibiaUnity.GameManager.GetFeature(GameFeature.GamePlayerAddons)) { addonsFlags = message.ReadUnsignedByte(); } OutfitInstance outfitInstance = instance as OutfitInstance; if (!!outfitInstance) { outfitInstance.UpdateProperties(headColor, torsoColor, legsColor, detailColor, addonsFlags); return(instance); } return(AppearanceStorage.CreateOutfitInstance((uint)outfitID, headColor, torsoColor, legsColor, detailColor, addonsFlags)); } uint objectID = message.ReadUnsignedShort(); ObjectInstance objectInstance = instance as ObjectInstance; if (!!objectInstance && objectInstance.ID == objectID) { return(objectInstance); } if (objectID == 0) { return(AppearanceStorage.CreateOutfitInstance(OutfitInstance.InvisibleOutfitID, 0, 0, 0, 0, 0)); } return(AppearanceStorage.CreateObjectInstance(objectID, 0)); }
private AppearanceInstance ReadMountOutfit(Internal.ByteArray message, AppearanceInstance instance = null) { uint outfitID = message.ReadUnsignedShort(); OutfitInstance outfitInstance = instance as OutfitInstance; if (!!outfitInstance && outfitInstance.ID == outfitID) { return(outfitInstance); } if (outfitID != 0) { return(AppearanceStorage.CreateOutfitInstance(outfitID, 0, 0, 0, 0, 0)); } return(null); }
private AppearanceInstance ReadMountOutfit(InputMessage message, AppearanceInstance instance = null) { uint lookType = message.GetU16(); OutfitInstance outfitInstance = instance as OutfitInstance; if (!!outfitInstance && outfitInstance.ID == lookType) { return(outfitInstance); } if (lookType != 0) { return(m_AppearanceStorage.CreateOutfitInstance(lookType, 0, 0, 0, 0, 0)); } return(null); }
public void AppendEffect(UnityEngine.Vector3Int position, Appearances.AppearanceInstance effect) { UnityEngine.Vector3Int?mapPosition = ToMapInternal(position); int index = -1; Field field = null; if (mapPosition != null) { index = ToIndexInternal(mapPosition.Value); field = m_Fields[index]; } if (!!field && effect is Appearances.TextualEffectInstance) { Appearances.TextualEffectInstance textualEffect = (Appearances.TextualEffectInstance)effect; for (int i = field.EffectsCount - 1; i > 0; i--) { var otherEffect = field.Effects[i]; if (otherEffect is Appearances.TextualEffectInstance && textualEffect.Merge(otherEffect)) { return; } } } if (m_EffectsCount < Constants.NumEffects) { effect.MapField = index; if (!!field) { field.AppendEffect(effect); } else { effect.MapData = 0; } m_Effects[m_EffectsCount] = effect; m_EffectsCount++; } }
private AppearanceInstance ReadCreatureOutfit(InputMessage message, AppearanceInstance instance = null) { int lookType = message.GetU16(); if (lookType != 0) { int head = message.GetU8(); int body = message.GetU8(); int legs = message.GetU8(); int feet = message.GetU8(); int addons = message.GetU8(); OutfitInstance outfitInstance = instance as OutfitInstance; if (!!outfitInstance) { outfitInstance.UpdateProperties(head, body, legs, feet, addons); return(instance); } return(m_AppearanceStorage.CreateOutfitInstance((uint)lookType, head, body, legs, feet, addons)); } int lookTypeEx = message.GetU16(); ObjectInstance objectInstance = instance as ObjectInstance; if (!!objectInstance && objectInstance.ID == (uint)lookTypeEx) { return(objectInstance); } if (lookTypeEx == 0) { return(m_AppearanceStorage.CreateOutfitInstance(OutfitInstance.InvisibleOutfitID, 0, 0, 0, 0, 0)); } return(m_AppearanceStorage.CreateObjectInstance((uint)lookTypeEx, 0)); }
public void AppendEffect(UnityEngine.Vector3Int absolutePosition, Appearances.AppearanceInstance effect) { UnityEngine.Vector3Int?mapPosition = ToMappublic(absolutePosition); int index = -1; Field field = null; if (mapPosition != null) { index = ToIndexpublic(mapPosition.Value); field = _fields[index]; } if (!!field && effect is Appearances.TextualEffectInstance textualEffect) { for (int i = field.EffectsCount - 1; i > 0; i--) { var otherEffect = field.Effects[i]; if (otherEffect is Appearances.TextualEffectInstance && textualEffect.Merge(otherEffect)) { return; } } } if (_effectsCount < Constants.NumEffects) { effect.MapField = index; effect.MapData = 0; if (!!field) { field.AppendEffect(effect); } _effects[_effectsCount] = effect; _effectsCount++; } }
public void AppendEffect(Appearances.AppearanceInstance effect) { if (!effect || (!(effect is Appearances.TextualEffectInstance) && !effect.Type)) { throw new System.ArgumentException("Field.AppendEffect: Invalid effect."); } if (!!effect.Type && effect.Type.IsTopEffect) { Effects.Insert(0, effect); for (int i = 0; i < Effects.Count; i++) { Effects[i].MapData = i; } } else { Effects.Add(effect); effect.MapData = EffectsCount; } EffectsCount++; }
private void ParseOutfitDialog(Internal.CommunicationStream message) { var outfit = ProtocolGameExtentions.ReadCreatureOutfit(message); Appearances.AppearanceInstance mountOutfit = null; if (OpenTibiaUnity.GameManager.GetFeature(GameFeature.GamePlayerMounts)) { mountOutfit = ProtocolGameExtentions.ReadMountOutfit(message); } var outfitList = new List <ProtocolOutfit>(); if (OpenTibiaUnity.GameManager.GetFeature(GameFeature.GameNewOutfitProtocol)) { int count; if (OpenTibiaUnity.GameManager.ClientVersion >= 1185) { count = message.ReadUnsignedShort(); } else { count = message.ReadUnsignedByte(); } for (int i = 0; i < count; i++) { outfitList.Add(ReadNewProtocolOutfit(message)); } } else { ushort outfitStart, outfitEnd; if (OpenTibiaUnity.GameManager.GetFeature(GameFeature.GameOutfitIdU16)) { outfitStart = message.ReadUnsignedShort(); outfitEnd = message.ReadUnsignedShort(); } else { outfitStart = message.ReadUnsignedByte(); outfitEnd = message.ReadUnsignedByte(); } for (ushort i = outfitStart; i <= outfitEnd; i++) { outfitList.Add(new ProtocolOutfit() { _id = i }); } } List <ProtocolMount> mountList = null; if (OpenTibiaUnity.GameManager.GetFeature(GameFeature.GamePlayerMounts)) { mountList = new List <ProtocolMount>(); int count; if (OpenTibiaUnity.GameManager.ClientVersion >= 1185) { count = message.ReadUnsignedShort(); } else { count = message.ReadUnsignedByte(); } for (int i = 0; i < count; i++) { mountList.Add(ReadProtocolMount(message)); } } OutfitDialogType type = 0; if (OpenTibiaUnity.GameManager.ClientVersion >= 1185) { type = message.ReadEnum <OutfitDialogType>(); bool mounted = message.ReadBoolean(); } OpenTibiaUnity.GameManager.onRequestOutfitDialog.Invoke(outfit, mountOutfit, outfitList, mountList); }
private void ParseOutfitDialog(Internal.ByteArray message) { var outfit = ReadCreatureOutfit(message); Appearances.AppearanceInstance mountOutfit = null; if (OpenTibiaUnity.GameManager.GetFeature(GameFeature.GamePlayerMounts)) { mountOutfit = ReadMountOutfit(message); } var outfitList = new List <ProtocolOutfit>(); if (OpenTibiaUnity.GameManager.GetFeature(GameFeature.GameNewOutfitProtocol)) { int count; if (OpenTibiaUnity.GameManager.ClientVersion >= 1185) { count = message.ReadUnsignedShort(); } else { count = message.ReadUnsignedByte(); } for (int i = 0; i < count; i++) { ushort outfitId = message.ReadUnsignedShort(); var outfitName = message.ReadString(); int addOns = message.ReadUnsignedByte(); bool locked = true; uint offerId = 0; if (OpenTibiaUnity.GameManager.ClientVersion >= 1185) { locked = message.ReadBoolean(); if (locked) { offerId = message.ReadUnsignedInt(); } } outfitList.Add(new ProtocolOutfit() { _id = outfitId, Name = outfitName, AddOns = addOns, Locked = locked, StoreOfferId = offerId, }); } } else { ushort outfitStart, outfitEnd; if (OpenTibiaUnity.GameManager.GetFeature(GameFeature.GameOutfitIdU16)) { outfitStart = message.ReadUnsignedShort(); outfitEnd = message.ReadUnsignedShort(); } else { outfitStart = message.ReadUnsignedByte(); outfitEnd = message.ReadUnsignedByte(); } for (ushort i = outfitStart; i <= outfitEnd; i++) { outfitList.Add(new ProtocolOutfit() { _id = i }); } } List <ProtocolMount> mountList = null; if (OpenTibiaUnity.GameManager.GetFeature(GameFeature.GamePlayerMounts)) { mountList = new List <ProtocolMount>(); int count; if (OpenTibiaUnity.GameManager.ClientVersion >= 1185) { count = message.ReadUnsignedShort(); } else { count = message.ReadUnsignedByte(); } for (int i = 0; i < count; i++) { ushort mountId = message.ReadUnsignedShort(); var mountName = message.ReadString(); bool locked = true; uint offerId = 0; if (OpenTibiaUnity.GameManager.ClientVersion >= 1185) { locked = message.ReadBoolean(); if (locked) { offerId = message.ReadUnsignedInt(); } } mountList.Add(new ProtocolMount() { _id = mountId, Name = mountName, Locked = locked, StoreOfferId = offerId, }); } } if (OpenTibiaUnity.GameManager.ClientVersion >= 1185) { bool tryOutfit = message.ReadBoolean(); bool mounted = message.ReadBoolean(); } OpenTibiaUnity.GameManager.onRequestOutfitDialog.Invoke(outfit, mountOutfit, outfitList, mountList); }
private AppearanceInstance ReadMountOutfit(Internal.CommunicationStream message, AppearanceInstance instance = null) { uint outfitId = message.ReadUnsignedShort(); OutfitInstance outfitInstance = instance as OutfitInstance; if (!!outfitInstance && outfitInstance.Id == outfitId) { return(outfitInstance); } if (outfitId != 0) { return(AppearanceStorage.CreateOutfitInstance(outfitId, 0, 0, 0, 0, 0)); } return(null); }
public void CopyMaskFromAppearance(Appearances.AppearanceInstance appearance, UnityEngine.Vector3Int position) { }