Skip to content

[REQUEST] new function onSpawnEntity(_entity) function for entities/items/skills #301

@Darxo

Description

@Darxo

Is your feature request related to a problem? Please describe.
Currently no skill, item or entity can actively react to an entity spawning mid fight.
This ability would be useful for

  • items and skills which emit an aura which can only be realised by having every other entity gain an aura-receiving-effect. Examples are the battle_standard_effect and captain_effect: these effects are currently added to every entity regardless of whether an emitter is present
  • new effects similar to night debuff that are depending on some conditions. Examples: reaction to world climate (heat, cold, wet), vampire-debuff for fighting during daylight

Describe the solution you'd like
There is the function spawnEntity in the BB root table that is used to spawn any entity via its scriptPath mid-fight.
That function should be hooked so that it calls the following new onSpawnEntity function on the spawned entity before returning it

Add this new function to the entity.nut:

function onSpawnEntity()
{
	if (!this.World.getTime().IsDaytime && player.getBaseProperties().IsAffectedByNight)
	{
		this.getSkills().add(::new("scripts/skills/special/night_effect"));
	}

	foreach (i, faction in this.getAllInstances())
	{
		foreach (actor in faction)
		{
			actor.getSkills().onSpawnEntity(this);
			actor.getItems().onSpawnEntity(this);
			actor.getSkills().update();
		}
	}
}

Similar functions would be added to skill_container.nut, skill.nut aswell as item_container.nut and item.nut. But here they wouldn't contain any inherent effects.

So as a nice side-effect the night effect is now automatically added to every entitiy that is spawned mid-fight. No longer do we need to do this manually for unleashable animals for example.

Metadata

Metadata

Assignees

Labels

feature requestA feature requested by the community

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions