public static HitDirection ReturnDirection(Transform Object, Transform ObjectHit) { HitDirection hitDirection = HitDirection.None; RaycastHit2D myRayHit; Vector2 direction = (Object.position - ObjectHit.position).normalized; Vector2 origin = new Vector2(Object.position.x, Object.position.y); myRayHit = Physics2D.Raycast(origin, direction); if (myRayHit.collider != null) { Vector3 myNormal = myRayHit.normal; myNormal = myRayHit.transform.TransformDirection(myNormal); if (Mathf.Sign(myNormal.x) == -1.0f) { hitDirection = HitDirection.Right; } else { hitDirection = HitDirection.Left; } } return(hitDirection); }
public void Insert(long amount, Type type, Entity target, Entity source, long skillId, bool hotdot, bool critic, long time, Entity petSource, HitDirection direction) { var sql = "INSERT INTO skills (amount, type, target, source, skill_id, hotdot, critic, time, pet_zone, pet_id, direction) VALUES( $amount , $type , $target , $source , $skill_id, $hotdot , $critic , $time, $pet_zone, $pet_id, $direction ) ;"; var command = new SQLiteCommand(sql, Connexion); command.Parameters.AddWithValue("$amount", amount); command.Parameters.AddWithValue("$type", (int)type); command.Parameters.AddWithValue("$target", target.Id.Id); command.Parameters.AddWithValue("$source", source.Id.Id); command.Parameters.AddWithValue("$skill_id", skillId); command.Parameters.AddWithValue("$critic", critic ? 1 : 0); command.Parameters.AddWithValue("$hotdot", hotdot ? 1 : 0); command.Parameters.AddWithValue("$time", time); command.Parameters.AddWithValue("$direction", direction); if (petSource != null) { var pet = (NpcEntity)petSource; command.Parameters.AddWithValue("$pet_zone", pet.Info.HuntingZoneId); command.Parameters.AddWithValue("$pet_id", pet.Info.TemplateId); } else { command.Parameters.AddWithValue("$pet_id", DBNull.Value); command.Parameters.AddWithValue("$pet_zone", DBNull.Value); } command.ExecuteNonQuery(); }
public override void Handle_Hit(HitDirection hitDirection) { DisableCollider(); StopMoving(); PlayAnimation(hitDirection); EnemyDown?.Invoke(); }
public Skill(long amount, Database.Type type, Entity target, Player targetPlayer, Entity source, Player sourcePlayer, int skillId, bool hotdot, bool critic, long time, NpcInfo pet, HitDirection direction) { Amount = amount; Type = type; EntityTarget = target; EntitySource = source; PlayerTarget = targetPlayer; PlayerSource = sourcePlayer; SkillId = skillId; Critic = critic; HotDot = hotdot; Time = time; Pet = pet; Direction = direction; Source = source; Target = target; if(PlayerSource != null) { Source = PlayerSource.User; } if(PlayerTarget != null) { Target = PlayerTarget.User; } }
/*public void OnTriggerEnter (Collider collider) * { * * //Rooms = GameObject.Find("ap.b3d").GetComponent<B3DScript>().Rooms; * //Debug.Log(Rooms[0].name); * if (collider.gameObject.GetComponent<LoadTrigger>()) * { * CameraControl camera = GameObject.Find("Main Camera").GetComponent<CameraControl>(); * string name = collider.gameObject.GetComponent<LoadTrigger>().roomName; * camera.ChangeCurrentRoom(name); * } * else if (collider.gameObject.GetComponent<LODCustom>()) * { * //Debug.Log("collider: "+collider,collider); * collider.gameObject.GetComponent<LODCustom>().SwitchState(0); * } * * }*/ //public void OnTriggerEnter(Collider col) void OnCollisionEnter(Collision collision) { Debug.LogWarning(collision.transform.name); //collider.transform.LookAt(transform.position,) //Debug.Log(1); //Collision collision = new Collision(); foreach (ContactPoint contact in collision.contacts) { //Debug.Log( ReturnDirection( contact.thisCollider.gameObject, this.gameObject ) ); Vector3 vec = new Vector3(); vec = -(contact.thisCollider.transform.position - contact.point); HitDirection hd = HitDirection.None; //if (>vec>) Debug.DrawLine(contact.thisCollider.transform.position, contact.point, Color.blue, 10f); Debug.Log(vec); Debug.Log(contact.thisCollider.gameObject, contact.thisCollider.gameObject); Debug.Log(contact.otherCollider.gameObject, contact.otherCollider.gameObject); Debug.Log(contact.point + " : " + contact.thisCollider.transform.position); Debug.DrawRay(contact.point, contact.normal, Color.white, 10f); } }
private void SetAnimation(HitDirection direction) { if (0 == m_Random.Next(0, 2)) { if (HitDirection.FRONT == direction) { m_AnimationDict.StiffStartAnim = m_FrontStiffStartAnim; m_AnimationDict.StiffEndAnim = m_FrontStiffEndAnim; m_AnimationDict.IdleAnim = m_IdleAnim; } else if (HitDirection.BACK == direction) { m_AnimationDict.StiffStartAnim = m_BackStiffStartAnim; m_AnimationDict.StiffEndAnim = m_BackStiffEndAnim; m_AnimationDict.IdleAnim = m_IdleAnim; } } else { if (HitDirection.FRONT == direction) { m_AnimationDict.StiffStartAnim = m_FrontStiffStartAnimExtra; m_AnimationDict.StiffEndAnim = m_FrontStiffEndAnimExtra; m_AnimationDict.IdleAnim = m_IdleAnim; } else if (HitDirection.BACK == direction) { m_AnimationDict.StiffStartAnim = m_BackStiffStartAnimExtra; m_AnimationDict.StiffEndAnim = m_BackStiffEndAnimExtra; m_AnimationDict.IdleAnim = m_IdleAnim; } } }
private HitDirection ReturnDirectionOnly(GameObject Object, GameObject ObjectHit) { RaycastHit MyRayHit; Vector3 direction = (Object.transform.position - ObjectHit.transform.position).normalized; Ray MyRay = new Ray(ObjectHit.transform.position, direction); if (Physics.Raycast(MyRay, out MyRayHit)) { if (MyRayHit.collider != null) { Vector3 MyNormal = MyRayHit.normal; MyNormal = MyRayHit.transform.TransformDirection(MyNormal); if (MyNormal == MyRayHit.transform.forward) { hitDirection = HitDirection.Right; } if (MyNormal == -MyRayHit.transform.forward) { hitDirection = HitDirection.Left; } if (MyNormal == MyRayHit.transform.right) { hitDirection = HitDirection.Forward; } if (MyNormal == -MyRayHit.transform.right) { hitDirection = HitDirection.Back; } } } return(hitDirection); }
private HitDirection ReturnDirection(Collision2D col) { HitDirection hitDirection = HitDirection.None; Vector3 contactPoint = col.contacts[0].point; Vector3 center = col.collider.bounds.center; float rectWidth = col.collider.bounds.size.x; float rectHieght = col.collider.bounds.size.y; if (contactPoint.y > center.y && (contactPoint.x < center.x + rectWidth / 2 && contactPoint.x > center.x - rectWidth / 2)) { hitDirection = HitDirection.Top; } else if (contactPoint.y < center.y && (contactPoint.x < center.x + rectWidth / 2 && contactPoint.x > center.x - rectWidth / 2)) { hitDirection = HitDirection.Bottom; } else if (contactPoint.x > center.x && (contactPoint.y < center.y + rectHieght / 2 && contactPoint.y > center.y - rectHieght / 2)) { hitDirection = HitDirection.Right; } else if (contactPoint.x < center.x && (contactPoint.y < center.y + rectHieght / 2 && contactPoint.y > center.y - rectHieght / 2)) { hitDirection = HitDirection.Left; } return(hitDirection); }
private TileBreakEffect CreateBreakEffectTile(HitDirection hitDirection, float curDamage, float maxDamage) { float percentDamage = curDamage / maxDamage; int spriteValue = (int)Mathf.Lerp(0, BreakEffectSprites.Length, percentDamage); return(ScriptableObject.CreateInstance <TileBreakEffect>().Initialise(BreakEffectSprites[spriteValue], _breakEffectSpriteRotation[hitDirection])); }
public override void OnUpdate() { if (!isKnockbackApplied) { if (Time.frameCount % knockbackInitiationTimeInFrames == 0) { isKnockbackApplied = true; var knockBackDir = (npc.transform.position - ServiceLocator.Current.Get <EntityManager>().players[0].transform.position).normalized; var flyNormalDirection = new Vector3(knockBackDir.y, -knockBackDir.x, 0); // normal vector of flying direction vector npc.rigidbody2D.AddForce(knockBackDir * (appliedPunchForce * flySpeed) + flyNormalDirection * flyHeight / 3, ForceMode2D.Impulse); if (knockBackDir != Vector3.zero) { _hitAngle = Mathf.Acos(Vector2.Dot(Vector2.right, knockBackDir) / knockBackDir.magnitude); if (knockBackDir.y < 0) { _hitAngle = 2 * Mathf.PI - _hitAngle; } _hitAngle %= 2 * Mathf.PI; _hitDirection = (HitDirection)(Mathf.RoundToInt(_hitAngle * Mathf.Rad2Deg / _angleDivider) % 4); } else { _hitDirection = HitDirection.Left; } switch (_hitDirection) { case HitDirection.Top: npc.spriteRenderer.sprite = npc.topHitSprites[npc.HitSpriteIndexTop]; break; case HitDirection.Bottom: npc.spriteRenderer.sprite = npc.bottomHitSprites[npc.HitSpriteIndexBottom]; break; case HitDirection.Left: npc.spriteRenderer.sprite = npc.leftHitSprites[npc.HitSpriteIndexLeft]; break; case HitDirection.Right: npc.spriteRenderer.sprite = npc.rightHitSprites[npc.HitSpriteIndexRight]; break; case HitDirection.None: npc.spriteRenderer.sprite = npc.idleSprite; break; } } } exitStateTimer += (1.0f * Time.deltaTime); if (exitStateTimer > exitStateTime) { npc.spriteRenderer.sprite = npc.idleSprite; npc.stunned = false; ServiceLocator.Current.Get <AIManager>().ChangeState(npc, typeof(PromotionGuy_ChaseKid)); } }
public Skill(long amount, Database.Type type, Entity target, Player targetPlayer, Entity source, Player sourcePlayer, int skillId, bool hotdot, bool critic, long time, NpcInfo pet, HitDirection direction) { Amount = amount; Type = type; EntityTarget = target; EntitySource = source; PlayerTarget = targetPlayer; PlayerSource = sourcePlayer; SkillId = skillId; Critic = critic; HotDot = hotdot; Time = time; Pet = pet; Direction = direction; Source = source; Target = target; if (PlayerSource != null) { Source = PlayerSource.User; } if (PlayerTarget != null) { Target = PlayerTarget.User; } }
static public HitDirection HitDirection2Test(Collision2D col) { Vector3 hit = col.contacts[0].normal; Debug.Log(hit); float angle = Vector3.Angle(hit, Vector3.up); HitDirection hitDirection = HitDirection.None; if (Mathf.Approximately(angle, 0)) { //Down hitDirection = HitDirection.Bottom; } if (Mathf.Approximately(angle, 180)) { //Up hitDirection = HitDirection.Top; } if (Mathf.Approximately(angle, 90)) { // Sides Vector3 cross = Vector3.Cross(Vector3.forward, hit); if (cross.y > 0) { // left side of the player hitDirection = HitDirection.Left; } else { // right side of the player hitDirection = HitDirection.Right; } } return(hitDirection); }
private void SetAnimation(HitDirection direction) { if (HitDirection.FRONT == direction) { m_AnimationDict.DropAnim = m_FrontDropAnim; m_AnimationDict.HitGroundAnim = m_FrontHitGroundAnim; m_AnimationDict.StandAnim = m_StandAnim; m_AnimationDict.RisingAnim = m_FrontRisingAnim; m_AnimationDict.StandUpAnim = m_FrontStandUpAnim; m_AnimationDict.OnLandHoldAnim = m_FrontOnGroundHoldAnim; m_AnimationDict.FlyHitAnim = m_FlyHitAnim; } else if (HitDirection.BACK == direction) { m_AnimationDict.DropAnim = m_BackDropAnim; m_AnimationDict.HitGroundAnim = m_BackHitGroundAnim; m_AnimationDict.StandAnim = m_StandAnim; m_AnimationDict.RisingAnim = m_BackRisingAnim; m_AnimationDict.OnLandHoldAnim = m_BackOnGroundHoldAnim; m_AnimationDict.StandUpAnim = m_BackStandUpAnim; m_AnimationDict.FlyHitAnim = m_FlyHitAnim; } m_AnimationPlayer.AddMixingTranform(m_AnimationDict.FlyHitAnim.name, m_TestTransform, true); m_AnimationPlayer.SetAnimationState(m_AnimationDict.FlyHitAnim.name, 1, 1.0f, 1.0f, AnimationBlendMode.Additive); }
public HitDirection ReturnDirection(GameObject Object, GameObject ObjectHit) { HitDirection hitDirection = HitDirection.None; RaycastHit2D MyRayHit; Vector2 direction = (Object.transform.position - ObjectHit.transform.position).normalized; if (MyRayHit = Physics2D.Raycast(new Vector2(ObjectHit.transform.position.x, ObjectHit.transform.position.y), direction)) { if (MyRayHit.collider != null) { Vector3 MyNormal = MyRayHit.normal; MyNormal = MyRayHit.transform.TransformDirection(MyNormal); if (MyNormal == MyRayHit.transform.up) { hitDirection = HitDirection.Top; } if (MyNormal == -MyRayHit.transform.up) { hitDirection = HitDirection.Bottom; } if (MyNormal == MyRayHit.transform.right) { hitDirection = HitDirection.Right; } if (MyNormal == -MyRayHit.transform.right) { hitDirection = HitDirection.Left; } } } return(hitDirection); }
void OnCollisionExit(Collision collision) { if (hitDirection == HitDirection.Corner) { ReturnDirectionOnly(collision.gameObject, this.gameObject); } else { hitDirection = HitDirection.None; } }
public override void OnComplete() { //How do combos/hitdirs work for aoe abilities or does that not matter for aoe? HitDirection hitDir = owner.GetHitDirection(target); bool hitTarget = false; spell.targetFind.FindWithinArea(target, spell.validTarget, spell.aoeTarget); isCompleted = true; var targets = spell.targetFind.GetTargets(); owner.DoBattleCommand(spell, "magic"); }
public Skill(long amount, Database.Type type, EntityId target, EntityId source, int skillId, bool hotdot, bool critic, long time, NpcInfo pet, HitDirection direction) { Amount = amount; Type = type; Target = target; Source = source; SkillId = skillId; Critic = critic; HotDot = hotdot; Time = time; Pet = pet; Direction = direction; }
private void HandleCollision(HitDirection hitDirection) { if (hitDirection.Equals(HitDirection.SITE)) { move.setSiteHit(true); StartCoroutine(ShakeCam(0.2f)); manager.setNearDeath(true); } else { manager.setPlayerEnum(PlayerStatEnum.DEAD); SceneManager.LoadScene("StartMenuScene"); } Vibration.Vibrate(50); }
public HitDirection ReturnDirection(GameObject Object, GameObject ObjectHit) { HitDirection hitDirection = HitDirection.None; if ((Object.transform.position.x - ObjectHit.GetComponent <Collider2D>().transform.position.x) < 0) { hitDirection = HitDirection.Left; } else if ((Object.transform.position.x - ObjectHit.GetComponent <Collider2D>().transform.position.x) > 0) { hitDirection = HitDirection.Right; } return(hitDirection); }
public void DamageTile(TileLayer layer, Vector3Int position, int amount, HitDirection hitDirection) { Tilemap tilemap = GetTilemap(layer); TileBasic tile = tilemap.GetTile <TileBasic>(position); if (tile != null) { if (!_terrainWorldTiles.ContainsKey(position)) { // Check if the tile is destroyed instantly if (amount > tile.Item.WorldTileDamage) { WorldItem worldItem = WorldItem.CreateWorldItem(new InstanceItem(tile.Item), tilemap.CellToWorld(position)); tilemap.SetTile(position, null); } // else make a worldtile and apply damage else { _terrainWorldTiles.Add(position, new WorldTile { Damage = amount }); // Create a break effect tile to represent damage EffectTilemap.SetTile(position, CreateBreakEffectTile(hitDirection, amount, tile.Item.WorldTileDamage)); } } else { // Get world tile from dictionary and apply damage _terrainWorldTiles[position].Damage += amount; // check for tile destruction if (_terrainWorldTiles[position].Damage >= tile.Item.WorldTileDamage) { _terrainWorldTiles.Remove(position); WorldItem worldItem = WorldItem.CreateWorldItem(new InstanceItem(tile.Item), tilemap.CellToWorld(position)); tilemap.SetTile(position, null); EffectTilemap.SetTile(position, null); } else { // Update the break effect tile EffectTilemap.SetTile(position, CreateBreakEffectTile(hitDirection, _terrainWorldTiles[position].Damage, tile.Item.WorldTileDamage)); } } } }
private HitDirection ReturnDirection(GameObject Object, GameObject ObjectHit) { HitDirection hitDirection = HitDirection.None; RaycastHit MyRayHit; Vector3 direction = (Object.transform.position - ObjectHit.transform.position).normalized; Ray MyRay = new Ray(ObjectHit.transform.position, direction); Debug.Log(MyRay); if (Physics.Raycast(MyRay, out MyRayHit)) { Debug.Log("raycast"); if (MyRayHit.collider != null) { Debug.Log("not null"); Vector3 MyNormal = MyRayHit.normal; MyNormal = MyRayHit.transform.TransformDirection(MyNormal); if (MyNormal == MyRayHit.transform.up) { hitDirection = HitDirection.Top; } if (MyNormal == -MyRayHit.transform.up) { hitDirection = HitDirection.Bottom; } if (MyNormal == MyRayHit.transform.forward) { hitDirection = HitDirection.Forward; } if (MyNormal == -MyRayHit.transform.forward) { hitDirection = HitDirection.Back; } if (MyNormal == MyRayHit.transform.right) { hitDirection = HitDirection.Right; } if (MyNormal == -MyRayHit.transform.right) { hitDirection = HitDirection.Left; } } } return(hitDirection); }
private void PlayAnimation(HitDirection hitDirection) { switch (hitDirection) { case HitDirection.Above: _animator.SetTrigger("DieToDown"); break; case HitDirection.Below: _animator.SetTrigger("DieToUp"); break; case HitDirection.RightSide: case HitDirection.LeftSide: _animator.SetTrigger("DieToSide"); break; } }
private void SetAnimation(HitDirection direction) { if (HitDirection.FRONT == direction) { m_AnimationDict.FallDownAnim = m_FrontFallDownAnim; m_AnimationDict.HitGroundAnim = m_FrontHitGroundAnim; m_AnimationDict.OnLandHoldAnim = m_FrontOnLandHoldAnim; m_AnimationDict.StandUpAnim = m_FrontStandUpAnim; m_AnimationDict.IdleAnim = m_IdleAnim; } else if (HitDirection.BACK == direction) { m_AnimationDict.FallDownAnim = m_BackFallDownAnim; m_AnimationDict.HitGroundAnim = m_BackHitGroundAnim; m_AnimationDict.OnLandHoldAnim = m_BackOnLandHoldAnim; m_AnimationDict.StandUpAnim = m_BackStandUpAnim; m_AnimationDict.IdleAnim = m_IdleAnim; } }
private void StartKnockback(HitDirection direction) { elapsed = 0; start = transform.position; switch (direction) { case HitDirection.BackCenter: dest = transform.position + (transform.forward * knockbackDistance); break; case HitDirection.BackLeft: dest = transform.position + ((transform.forward * knockbackDistance) + (transform.right * knockbackDistance)) / 2; break; case HitDirection.BackRight: dest = transform.position + ((transform.forward * knockbackDistance) - (transform.right * knockbackDistance)) / 2; break; case HitDirection.FrontRight: dest = transform.position - ((transform.forward * knockbackDistance) + (transform.right * knockbackDistance)) / 2; break; case HitDirection.FrontLeft: dest = transform.position - ((transform.forward * knockbackDistance) - (transform.right * knockbackDistance)) / 2; break; case HitDirection.FrontCenter: dest = transform.position - (transform.forward * knockbackDistance); break; case HitDirection.Left: dest = transform.position + (transform.right * knockbackDistance); break; case HitDirection.Right: dest = transform.position - (transform.right * knockbackDistance); break; } StartCoroutine("DoKnockback"); }
//Convert a HitDirection to a BattleCommandPositionBonus. Basically just combining left/right into flank public static BattleCommandPositionBonus ConvertHitDirToPosition(HitDirection hitDir) { BattleCommandPositionBonus position = BattleCommandPositionBonus.None; switch (hitDir) { case (HitDirection.Front): position = BattleCommandPositionBonus.Front; break; case (HitDirection.Right): case (HitDirection.Left): position = BattleCommandPositionBonus.Flank; break; case (HitDirection.Rear): position = BattleCommandPositionBonus.Rear; break; } return(position); }
//public HitDirection ReturnDirection(GameObject other, GameObject objectHit) //{ // HitDirection hitDirection = HitDirection.None; // RaycastHit MyRayHit; // Vector3 direction = (other.transform.position - objectHit.transform.position).normalized; // Ray MyRay = new Ray(objectHit.transform.position, direction); // if (Physics.Raycast(MyRay, out MyRayHit)) // { // if (MyRayHit.collider != null) // { // Vector3 MyNormal = MyRayHit.normal; // Debug.Log("WorldNormal: " + MyNormal); // MyNormal = MyRayHit.transform.TransformDirection(MyNormal); // Debug.Log("LocalNormal: " + MyNormal); // } // } // return hitDirection; //} public HitDirection ReturnDirection(GameObject other, GameObject objectHit, Color rayColor) { HitDirection hitDirection = HitDirection.None; Vector2 direction = (other.transform.position - objectHit.transform.position).normalized; //Ray MyRay = new Ray(objectHit.transform.position, direction); RaycastHit2D MyRayHit = Physics2D.Raycast(objectHit.transform.position, direction); if (MyRayHit.collider != null) { Vector2 MyNormal = MyRayHit.normal; Debug.Log("WorldNormal: " + MyNormal); //MyNormal = MyRayHit.transform.InverseTransformDirection(MyNormal); //MyNormal = MyRayHit.transform.TransformDirection(MyNormal); Debug.Log("LocalNormal: " + MyNormal); //Debug.DrawRay(objectHit.transform.position, direction * 100, rayColor, 100); Debug.DrawRay(other.transform.position, MyNormal * 100, rayColor, 1000); } return(hitDirection); }
protected void GeneralStartImpact(ImpactInfo impactInfo) { m_StartTime = Time.time; m_IsActive = true; m_ImpactInfo = impactInfo; m_ImpactInfo.ApplyOffset(m_ImpactInfo.m_Offset); m_IsHitHighLight = m_ImpactInfo.m_IsHitHighLight; m_HitHilghtLightTime = m_ImpactInfo.m_HitHighLightTime; ComputeDirectionAndSpeed(); m_CurVelocity = m_ImpactInfo.m_Velocity; if (!m_ImpactInfo.m_Velocity.Equals(Vector3.zero)) { if (Vector3.Dot(m_ImpactInfo.m_Velocity, this.transform.forward) > 0) { m_HitDirection = HitDirection.BACK; } else { m_HitDirection = HitDirection.FRONT; } } if (m_IsHitHighLight && null != m_HighLightMaterial) { m_Renderer.material = m_HighLightMaterial; } InterruptSkill(); SharedGameObjectInfo info = LogicSystem.GetSharedGameObjectInfo(gameObject); ImpactPlaySound(); if (null != info) { LogicSystem.PublishLogicEvent("ge_set_ai_enable", "ai", info.m_LogicObjectId, false); } LogicSystem.NotifyGfxAnimationStart(gameObject); LogicSystem.NotifyGfxMoveControlStart(gameObject); }
/// <summary> /// constructor /// </summary> /// <param name="hit2D">hit result in raycasthit2d</param> /// <param name="direction"></param> /// <param name="detailPos">which ray hits the object</param> public HitResult(RaycastHit2D hit2D, HitDirection direction, Vector2 detailPos) { Hit2D = hit2D; Direction = direction; DetailPos = detailPos; }
public override void OnStart() { var returnCode = lua.LuaEngine.CallLuaBattleCommandFunction(owner, skill, "weaponskill", "onSkillStart", owner, target, skill); if (returnCode != 0) { interrupt = true; errorResult = new CommandResult(owner.actorId, (ushort)(returnCode == -1 ? 32558 : returnCode), 0); } else { hitDirection = owner.GetHitDirection(target); //Do positionals and combo effects first because these can influence accuracy and amount of targets/numhits, which influence the rest of the steps //If there is no positon required or if the position bonus should be activated if ((skill.positionBonus & utils.BattleUtils.ConvertHitDirToPosition(hitDirection)) == skill.positionBonus) { //If there is a position bonus if (skill.positionBonus != BattleCommandPositionBonus.None) { //lua.LuaEngine.CallLuaBattleCommandFunction(owner, skill, "weaponskill", "onPositional", owner, target, skill); skill.CallLuaFunction(owner, "onPositional", owner, target, skill); } //Combo stuff if (owner is Player) { Player p = (Player)owner; //If skill is part of owner's class/job, it can be used in a combo if (skill.job == p.GetClass() || skill.job == p.GetCurrentClassOrJob()) { //If owner is a player and the skill being used is part of the current combo if (p.playerWork.comboNextCommandId[0] == skill.id || p.playerWork.comboNextCommandId[1] == skill.id) { lua.LuaEngine.CallLuaBattleCommandFunction(owner, skill, "weaponskill", "onCombo", owner, target, skill); skill.CallLuaFunction(owner, "onCombo", owner, target, skill); skill.isCombo = true; } //or if this just the start of a combo else if (skill.comboStep == 1) { skill.isCombo = true; } } } if (!skill.IsInstantCast()) { float castTime = skill.castTimeMs; // command casting duration if (owner is Player) { // todo: modify spellSpeed based on modifiers and stuff ((Player)owner).SendStartCastbar(skill.id, Utils.UnixTimeStampUTC(DateTime.Now.AddMilliseconds(castTime))); } owner.GetSubState().chantId = 0xf0; owner.SubstateModified(); //You ready [skill] (6F000002: BLM, 6F000003: WHM, 0x6F000008: BRD) owner.DoBattleAction(skill.id, (uint)0x6F000000 | skill.castType, new CommandResult(target.actorId, 30126, 1, 0, 1)); } } } }
public void Insert(long amount, Type type, Entity target, Entity source, long skillId, bool hotdot, bool critic, long time, Entity petSource, HitDirection direction) { var sql = "INSERT INTO skills (amount, type, target, source, skill_id, hotdot, critic, time, pet_zone, pet_id, direction, targetServerIdPlayerId, sourceServerIdPlayerId ) VALUES( $amount , $type , $target , $source , $skill_id, $hotdot , $critic , $time, $pet_zone, $pet_id, $direction, $targetServerIdPlayerId, $sourceServerIdPlayerId ) ;"; var command = new SQLiteCommand(sql, Connexion); command.Parameters.AddWithValue("$amount", amount); command.Parameters.AddWithValue("$type", (int) type); command.Parameters.AddWithValue("$target", target.Id.Id); command.Parameters.AddWithValue("$source", source.Id.Id); command.Parameters.AddWithValue("$skill_id", skillId); command.Parameters.AddWithValue("$critic", critic ? 1 : 0); command.Parameters.AddWithValue("$hotdot", hotdot ? 1 : 0); command.Parameters.AddWithValue("$time", time); command.Parameters.AddWithValue("$direction", direction); if (petSource != null) { var pet = (NpcEntity)petSource; command.Parameters.AddWithValue("$pet_zone", pet.Info.HuntingZoneId); command.Parameters.AddWithValue("$pet_id", pet.Info.TemplateId); } else { command.Parameters.AddWithValue("$pet_id", DBNull.Value); command.Parameters.AddWithValue("$pet_zone", DBNull.Value); } var playerSource = source as UserEntity; if(playerSource != null) { var spid = (ulong)playerSource.ServerId << 32 | playerSource.PlayerId; command.Parameters.AddWithValue("$sourceServerIdPlayerId", spid); } else { command.Parameters.AddWithValue("$sourceServerIdPlayerId", DBNull.Value); } var playerTarget = target as UserEntity; if (playerTarget != null) { var spid = (ulong)playerTarget.ServerId << 32 | playerTarget.PlayerId; command.Parameters.AddWithValue("$targetServerIdPlayerId", spid); } else { command.Parameters.AddWithValue("$targetServerIdPlayerId", DBNull.Value); } command.ExecuteNonQuery(); command.Dispose(); }
/// <summary> /// Take damage /// </summary> /// <param name="damageDealer"></param> /// <returns></returns> private void TakeDamage(DamageDealer damageDealer, GameObject damageSourceObject) { // check if damage dealer is self if (GetComponentsInChildren <DamageDealer>().ToList().Contains(damageDealer)) { return; } // Get hit direction HitDirection hitDirection = GetHitDirection(damageDealer.gameObject.transform.position); // Check for immunity if (directionImmunity != 0 && (directionImmunity | hitDirection) == hitDirection) { onImmuneToDamage?.Invoke(); return; } if (immuneRemaining > 0) { return; } // Add Effects #if STATS_COG if (damageDealer.effects != null) { foreach (StatEffect effect in damageDealer.effects) { if (effectList.availableEffects.Contains(effect)) { AddEffect(effect); } } } #endif float adjustedDamage = 0; float totalAdjustedDamage = 0; // Apply weakness foreach (Damage damage in damageDealer.damage) { #if STATS_COG if (damageDealer.StatsSource != null) { adjustedDamage = damageDealer.StatsSource.GetExpressionValue(damage.baseAmount); } else { adjustedDamage = float.Parse(damage.baseAmount); } #endif if (damage.damageType != null) { List <DamageModifier> modifiers = FindDamageModifiers(damage.damageType.name); foreach (DamageModifier dm in modifiers) { if (dm.modifierType == DamageModType.Resistance) { adjustedDamage -= adjustedDamage * dm.CurrentValue; if (dm.CurrentValue == 1) { onImmuneToDamage?.Invoke(); } } else { adjustedDamage *= dm.CurrentValue; } } } else { Debug.LogError("Damage is missing a DamageType"); } totalAdjustedDamage += adjustedDamage; } // Apply damage StatValue hp = FindStat(healthStat); if (hp != null) { adjustedDamage = Mathf.Clamp(GetExpressionValue(ReplaceInsensitive(damageValue, "[damage]", totalAdjustedDamage.ToString())), 0, float.MaxValue); hp.SetValue(hp.CurrentValue - adjustedDamage); lastDmgSource = damageDealer.StatsSource; onDamageTaken?.Invoke(adjustedDamage, damageDealer, damageSourceObject); onHitDamageDirection?.Invoke(hitDirection); immuneRemaining = immunityAfterHit; onHitDirection?.Invoke(hitDirection); if (hp.CurrentValue <= 0) { onDeath?.Invoke(); } } else { Debug.LogWarning("Could not find '" + healthStat + "' to apply damage"); } }
private HitDirection ReturnDirection(GameObject Object, GameObject ObjectHit) { RaycastHit MyRayHit; Vector3 direction = (Object.transform.position - ObjectHit.transform.position).normalized; Ray MyRay = new Ray(ObjectHit.transform.position, direction); if (Physics.Raycast(MyRay, out MyRayHit)) { if (MyRayHit.collider != null) { Vector3 MyNormal = MyRayHit.normal; MyNormal = MyRayHit.transform.TransformDirection(MyNormal); if (hitDirection == HitDirection.Back || hitDirection == HitDirection.Forward || hitDirection == HitDirection.Right || hitDirection == HitDirection.Left) { hitDirection = HitDirection.Corner; if (MyNormal == MyRayHit.transform.forward) { playerPositionOnEnter.z = this.gameObject.transform.position.z; } if (MyNormal == -MyRayHit.transform.forward) { playerPositionOnEnter.z = this.gameObject.transform.position.z; } if (MyNormal == MyRayHit.transform.right) { playerPositionOnEnter.x = this.gameObject.transform.position.x; } if (MyNormal == -MyRayHit.transform.right) { playerPositionOnEnter.x = this.gameObject.transform.position.x; } } else { if (MyNormal == MyRayHit.transform.forward) { hitDirection = HitDirection.Forward; playerPositionOnEnter.z = this.gameObject.transform.position.z; } if (MyNormal == -MyRayHit.transform.forward) { hitDirection = HitDirection.Back; playerPositionOnEnter.z = this.gameObject.transform.position.z; } if (MyNormal == MyRayHit.transform.right) { hitDirection = HitDirection.Right; playerPositionOnEnter.x = this.gameObject.transform.position.x; } if (MyNormal == -MyRayHit.transform.right) { hitDirection = HitDirection.Left; playerPositionOnEnter.x = this.gameObject.transform.position.x; } } } } return(hitDirection); }