private void LaunchToxin(Vector3 target) { if (microbe.Hitpoints > 0 && microbe.AgentVacuoleCount > 0 && (microbe.Translation - target).LengthSquared() <= SpeciesFocus * 10.0f) { if (CanShootToxin()) { microbe.LookAtPoint = target; microbe.QueueEmitToxin(oxytoxy); } } }
/// <summary> /// For chasing down and killing prey in various ways /// </summary> private void DealWithPrey(List <Microbe> allMicrobes, Random random) { // Tick the engulf tick ticksSinceLastToggle += 1; bool lostPrey = false; try { targetPosition = prey.Translation; } catch (ObjectDisposedException) { lostPrey = true; } if (lostPrey) { preyPegged = false; prey = null; return; } // Chase your prey if you dont like acting like a plant // Allows for emergence of Predatory Plants (Like a single celled version of a venus fly trap) // Creatures with lethargicness of 400 will not actually chase prey, just lie in wait microbe.LookAtPoint = targetPosition; hasTargetPosition = true; // Always set target Position, for use later in AI if (moveThisHunt) { microbe.MovementDirection = moveFocused ? new Vector3(0.0f, 0.0f, -Constants.AI_FOCUSED_MOVEMENT) : new Vector3(0.0f, 0.0f, -Constants.AI_BASE_MOVEMENT); } else { microbe.MovementDirection = new Vector3(0, 0, 0); } // Turn off engulf if prey is Dead // This is probably not working. This is almost certainly not working in the Godot version if (prey.Dead) { hasTargetPosition = false; prey = GetNearestPreyItem(allMicrobes); if (prey != null) { preyPegged = true; } microbe.EngulfMode = false; // You got a kill, good job if (!microbe.IsPlayerMicrobe && !microbe.Species.PlayerSpecies) { microbe.SuccessfulKill(); } if (RollCheck(SpeciesOpportunism, 400.0f, random)) { lifeState = LifeState.SCAVENGING_STATE; boredom = 0; } } else { // Turn on engulf mode if close if ((microbe.Translation - targetPosition).LengthSquared() <= 300 + microbe.EngulfSize * 3.0f && microbe.Compounds.GetCompoundAmount(atp) >= 1.0f && !microbe.EngulfMode && microbe.EngulfSize > Constants.ENGULF_SIZE_RATIO_REQ * prey.EngulfSize && !microbe.Membrane.Type.CellWall) { microbe.EngulfMode = true; ticksSinceLastToggle = 0; } else if ((microbe.Translation - targetPosition).LengthSquared() >= 500 + microbe.EngulfSize * 3.0f && microbe.EngulfMode && ticksSinceLastToggle >= Constants.AI_ENGULF_INTERVAL) { microbe.EngulfMode = false; ticksSinceLastToggle = 0; } } // Shoot toxins if able There should be AI that prefers shooting over engulfing, etc, not sure how to model that // without a million and one variables perhaps its a mix? Maybe a creature with a focus less then a certain // amount simply never attacks that way? Maybe a creature with a specific focus, only ever shoots and never // engulfs? Maybe their lethargicness impacts that? I just dont want each enemy to feel the same you know. For // now creatures with a focus under 100 will never shoot. if (SpeciesFocus >= 100.0f) { if (microbe.Hitpoints > 0 && microbe.AgentVacuoleCount > 0 && (microbe.Translation - targetPosition).LengthSquared() <= SpeciesFocus * 10.0f) { if (microbe.Compounds.GetCompoundAmount(oxytoxy) >= Constants.MINIMUM_AGENT_EMISSION_AMOUNT) { microbe.QueueEmitToxin(oxytoxy); } } } }