void SearchForTarget() { if (activeTarget != null && activeTarget.agent.isDead) { activeTarget = null; } List <MobileAgent> agents = agent.session.agents.FindAll(x => x != agent && (agent.session.teamsize == 0 || x.team != agent.team) && !x.isDead && PhysikEngine.GetDistance(x.transform.position, transform.position) < vision && (agent.heroType == Callipso.HeroType.Player || (agent.heroType == Callipso.HeroType.Creature && x.heroType == Callipso.HeroType.Player))); if (agents.Count > 0) { if (activeTarget == null || activeTarget.agent.heroType == Callipso.HeroType.Creature) { activeTarget = agents[Random.Range(0, agents.Count)].physik; } return; } if (activeTarget == null && !agent.pointed && agent.heroType == Callipso.HeroType.Player) { List <MobileAgent> targetCreatures = agent.session.creatures.FindAll(x => x != null); if (targetCreatures.Count > 0) { activeTarget = targetCreatures[Random.Range(0, targetCreatures.Count)].physik; GetPath(activeTarget.transform.position); return; } } /* * NO TARGET FOUND, LET's PICK A RANDOM Target * */ if (agent._hero.heroType == Callipso.HeroType.Player && (targetPath == null || targetPath.Count == 0)) { agents = agent.session.agents.FindAll(x => (agent.session.teamsize == 0 || x.team != agent.team) && !x.isDead && (agent.heroType == Callipso.HeroType.Player || (agent.heroType == Callipso.HeroType.Creature && x.heroType == Callipso.HeroType.Player))); if (agents.Count > 0) { GetPath(agents[Random.Range(0, agents.Count)].transform.position); } } }
void Start() { Physik physik = gameObject.AddComponent <Physik>(); physik.radius = collision; physik.SearchForCollision = true; physik.agent = caster; physik.session = session; physik.hitContinous = hitContinous; physik.updateTime = (skillType == SkillType.Mover) ? 0.05f : 1; physik.nextControl = Time.time + activeAfter; Inform(); started = true; }
public void LoadHero(string _heroId, bool isHero = false) { /* * SET TEAM * */ FindTeam(isHero); /* * */ if (string.IsNullOrEmpty(_heroId)) { // AUTO HERO SELECTION if (session.teamsize == 0) { _heroId = ServerManager.playerHeroes[Random.Range(0, ServerManager.playerHeroes.Count)].clientPrefab; } else { List <MobileAgent> teamMates = session.agents.FindAll(x => x.team == team); List <Callipso.Hero> trg = ServerManager.playerHeroes.FindAll(x => teamMates.Find(e => e.heroId == x.clientPrefab) == null); if (trg.Count == 0) { _heroId = ServerManager.playerHeroes[Random.Range(0, ServerManager.playerHeroes.Count)].clientPrefab; } else { _heroId = trg[Random.Range(0, trg.Count)].clientPrefab; } } } maxHealth = 0; heroId = _heroId; if (isHero) { _hero = ServerManager.playerHeroes.Find(x => x.clientPrefab == _heroId); } else { _hero = ServerManager.creatureHeroes.Find(x => x.clientPrefab == _heroId); } moveSpeed = _hero.moveSpeed; skills = _hero.skills; cooldowns = new float[skills.Length]; heroType = _hero.heroType; agentLevel.level = new Leveling.Level(); agentLevel.level.level = 1; agentLevel.exp = 0; agentLevel.requiredExp = 10; /* * DEFAULT BUFFS * */ agentBuff.buff.buffs.Clear(); agentBuff.buff.buffs.AddRange(_hero.defaultBuffs); /* * */ if (heroType == Callipso.HeroType.Creature) { gameObject.name = _heroId; } if (physik == null) { physik = gameObject.AddComponent <Physik>(); physik.agent = this; } physik.session = session; physik.radius = _hero.collision; physik.team = team; if (user != null) { // SEND SKILL INFO MObjects.SkillInfo mObject = new MObjects.SkillInfo(); mObject.skills = skills; NetworkServer.SendToClient(user.connectionId, MTypes.SkillInfo, mObject); } }
void GetAction() { if (skills_attack.Length == 0) { return; } if (agent.skillStart != 0f) { return; // already in action } if (activeTarget != null) { distanceToActive = PhysikEngine.GetDistance(activeTarget.transform.position, transform.position); if (distanceToActive > vision) { activeTarget = null; return; } else if (!MapLoader.isBlocked(agent.session.map, transform.position, activeTarget.transform.position, false)) // TARGET IN SIGHT, SEARCH FOR SKILLS OR NOT MOVE TO TARGET { short tSpell = -1; /* * DECIDE WITH PROPORTION RANDOM * */ /* * */ ProportionValue <ushort>[] clist = new ProportionValue <ushort> [skills_attack.Length]; ushort rVal = (ushort)clist.Length; for (ushort r = 0; r < rVal; r++) { ushort idx = (ushort)agent.skills.ToList().FindIndex(x => x == skills_attack[r]); clist[r] = ProportionValue.Create((agent.cooldowns[idx] < Time.time) ? agent.skills[idx].botsDecideChance : 1, idx); } if (rVal > 1) { rVal = clist.ChooseByRandom(); } else { rVal = clist[0].Value; } if (agent.skills[rVal].skillType != SkillType.Self) { float distance = (agent.skills[rVal].skillType == SkillType.Area) ? 10 : (agent.skills[rVal].moveSpeed * agent.skills[rVal].life); if ((distance * 3) / 4 > distanceToActive) { tSpell = (short)rVal; } } else { tSpell = (short)rVal; } if (tSpell != -1) { /* * CAST SPELL * */ agent.session.LastAim(agent.customId, activeTarget.transform.position, transform.position); agent.session.SkillRequest(agent.customId, (ushort)tSpell); return; } } GetPath(activeTarget.transform.position); } }