Skip to content

Commit

Permalink
Oxytoxy is now removed from the compound bag when it is ejected diuri…
Browse files Browse the repository at this point in the history
…ng death so it doesn't get in the chunks,.

ai and engulfable chunks now use the cached hex size when determining, whether to prey on things/whether things should be engulfed
  • Loading branch information
Untrustedlife authored and hhyyrylainen committed Mar 15, 2019
1 parent 197f24f commit 2cf679e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
18 changes: 9 additions & 9 deletions scripts/microbe_stage/microbe_ai.as
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ class MicrobeAISystem : ScriptSystem{
Float3 testPosition = world.GetComponent_Position(predator)._Position;
MicrobeComponent@ secondMicrobeComponent = cast<MicrobeComponent>(
world.GetScriptComponentHolder("MicrobeComponent").Find(predator));
if ((position._Position - testPosition).LengthSquared() <= (2000+(secondMicrobeComponent.organelles.length()*8.0f)*2)){
if ((position._Position - testPosition).LengthSquared() <= (2000+(secondMicrobeComponent.totalHexCountCache*8.0f)*2)){
if (aiComponent.lifeState != FLEEING_STATE)
{
// Reset target position for faster fleeing
Expand Down Expand Up @@ -287,8 +287,8 @@ class MicrobeAISystem : ScriptSystem{
// At max aggression add them all
if (allMicrobes[i] != microbeEntity && (secondMicrobeComponent.speciesName != microbeComponent.speciesName) && !secondMicrobeComponent.dead){
if ((aiComponent.speciesAggression==MAX_SPECIES_AGRESSION) or
((((numberOfAgentVacuoles+microbeComponent.organelles.length())*1.0f)*(aiComponent.speciesAggression/AGRESSION_DIVISOR)) >
(secondMicrobeComponent.organelles.length()*1.0f))){
((((numberOfAgentVacuoles+microbeComponent.totalHexCountCache)*1.0f)*(aiComponent.speciesAggression/AGRESSION_DIVISOR)) >
(secondMicrobeComponent.organelles.totalHexCountCache*1.0f))){
//You are non-threatening to me
aiComponent.preyMicrobes.insertLast(allMicrobes[i]);
}
Expand Down Expand Up @@ -342,8 +342,8 @@ class MicrobeAISystem : ScriptSystem{
// At max fear add them all
if (allMicrobes[i] != microbeEntity && (secondMicrobeComponent.speciesName != microbeComponent.speciesName) && !secondMicrobeComponent.dead){
if ((aiComponent.speciesFear==MAX_SPECIES_FEAR) or
((((numberOfAgentVacuoles+secondMicrobeComponent.organelles.length())*1.0f)*(aiComponent.speciesFear/FEAR_DIVISOR)) >
(microbeComponent.organelles.length()*1.0f))){
((((numberOfAgentVacuoles+secondMicrobeComponent.totalHexCountCache)*1.0f)*(aiComponent.speciesFear/FEAR_DIVISOR)) >
(microbeComponent.totalHexCountCache*1.0f))){
//You are bigger then me and i am afraid of that
aiComponent.predatoryMicrobes.insertLast(allMicrobes[i]);
//LOG_INFO("Added predator " + allMicrobes[i] );
Expand Down Expand Up @@ -435,15 +435,15 @@ class MicrobeAISystem : ScriptSystem{
else
{
// Turn on engulfmode if close
if (((position._Position - aiComponent.targetPosition).LengthSquared() <= 300+(microbeComponent.organelles.length()*3.0f))
if (((position._Position - aiComponent.targetPosition).LengthSquared() <= 300+(microbeComponent.totalHexCountCache*3.0f))
&& (MicrobeOperations::getCompoundAmount(world,microbeEntity,atpID) >= 1.0f)
&& !microbeComponent.engulfMode &&
(float(microbeComponent.organelles.length()) > (
ENGULF_HP_RATIO_REQ*secondMicrobeComponent.organelles.length()))){
(float(microbeComponent.totalHexCountCache) > (
ENGULF_HP_RATIO_REQ*secondMicrobeComponent.totalHexCountCache))){
MicrobeOperations::toggleEngulfMode(world, microbeEntity);
aiComponent.ticksSinceLastToggle=0;
}
else if (((position._Position - aiComponent.targetPosition).LengthSquared() >= 500+(microbeComponent.organelles.length()*3.0f))
else if (((position._Position - aiComponent.targetPosition).LengthSquared() >= 500+(microbeComponent.totalHexCountCache*3.0f))
&& (microbeComponent.engulfMode && aiComponent.ticksSinceLastToggle >= AI_ENGULF_INTERVAL)){
MicrobeOperations::toggleEngulfMode(world, microbeEntity);
aiComponent.ticksSinceLastToggle=0;
Expand Down
2 changes: 2 additions & 0 deletions scripts/microbe_stage/microbe_operations.as
Original file line number Diff line number Diff line change
Expand Up @@ -1137,6 +1137,8 @@ void kill(CellStageWorld@ world, ObjectID microbeEntity)

createAgentCloud(world, compoundId, position._Position, direction, ejectedAmount,
2000, microbeComponent.speciesName, NULL_OBJECT);
//take oxytoxy
takeCompound(world,microbeEntity,compoundId,ejectedAmount);
++createdAgents;

if(createdAgents >= maxAgentsToShoot)
Expand Down
2 changes: 1 addition & 1 deletion scripts/microbe_stage/setup.as
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ void cellHitIron(GameWorld@ world, ObjectID firstEntity, ObjectID secondEntity)
if (microbeComponent !is null && engulfableComponent !is null
&& compoundBagComponent !is null && floatBag !is null)
{
if (microbeComponent.engulfMode && microbeComponent.organelles.length() >=
if (microbeComponent.engulfMode && microbeComponent.totalHexCountCache >=
engulfableComponent.getSize()*ENGULF_HP_RATIO_REQ)
{
uint64 compoundCount = SimulationParameters::compoundRegistry().getSize();
Expand Down

0 comments on commit 2cf679e

Please sign in to comment.