Some findings of ParticleSystem

Users who are viewing this thread

I've succesfully emitted particles on most GameEntities
ParticleSystem particle = ParticleSystem.CreateParticleSystemAttachedToEntity("psys_game_burning_agent", missile.Entity, ref localFrame);

With this line of code I can create ParticleSystem on missiles, and so to make fire arrows.
I am aware fire arrows can be achieved by editing xml, but I want control over these particles so that I can make even the enemies who got hit burn, and deal damages to them.

The strange thing is, any GameEntity that belong to a living agent won't emit particles.

ParticleSystem particle = ParticleSystem.CreateParticleSystemAttachedToEntity("psys_game_burning_agent", weaponEntity, ref localFrame);

weaponEntity is the GameEntity of current whielded sword, and it doesn't work, the fire won't show when it's wielded.
But once I drop the sword on the ground it burns, and particles show up.

In the end I found a way to succesfully attach ParticleSystem to a living agent, which is by the following code:
Agent.Main.AgentVisuals.CreateParticleSystemAttachedToBone("psys_game_burning_agent",
Game.Current.HumanMonster.MainHandItemBoneIndex, ref localFrame);
IT WORKS! The fires show on the sword I am wielding, it looks great, now I have a fire sword, everything is cool, right?
No. This API returns no reference of the ParticleSystem created, so I have no control over it, I can't turn it off, the fire stays on the agent's hand even if I switch weapon or empty handed.

I've been toying with particles and got some funny looking effects, I hope someone can continue the search and find a way to attach ParticleSystem to an agent with the reference of the ParticleSystem.

X3Tz15L.png

X4H7BEB.png

ZAR6Wv6.png

93J5B3N.png

o3B2ior.png

aMLCvDU.png


My goal is to make a working fire arrows and fire swords mod that can lit the hit target on fire and deal burning damages.
The damage part is easy, checked.
The fire arrows is done, checked.
The fire sword is done as well but with some issues, half checked.
I CAN lit enemy on fire, also checked.

So the problem remains to be, once the ParticleSystem is generated on an agent, I can never remove it.

I've tried the following code:
ParticleSystem particle = ParticleSystem.CreateParticleSystemAttachedToBone("psys_game_burning_agent",
Agent.Main.AgentVisuals.GetSkeleton(), Game.Current.HumanMonster.MainHandItemBoneIndex, ref localFrame);

It's something similar to Agent.Main.AgentVisuals.CreateParticleSystemAttachedToBone(), but it returns the reference.
Still it doesn't work. Nothing other than AgentVisuals.CreateParticleSystemAttachedToBone() works on a living agent.
 
Last edited:
Nice researches, however I do believe this has already been done here: https://www.nexusmods.com/mountandblade2bannerlord/mods/472

Like I said, I am aware that fire arrows can be achieved by editing xml.
This mod only added trail_particle_name to all the arrow items.
It's uncontrollable, like you can't make the enemy burns, the arrow will disapear when it hits a target due to the burning="true" flag, but without it the arrow stays with the particles on and consumes tons of GPU memory, the behaviours are all designed by native game and you have no controll over the logics.

But by implementing it myself, I can get a lot of things done. Like the point lights on the arrows are white lights if you are using the xml way, but I added the point lights myself so I can make it orange which looks more like lights from a fire.

And by implementing it myself, I can make the arrow stay where it hits instead of disapearing, and only remove the fire particles and point light so that GPU memory usage won't be too high.

The main problem is still the exposed API doesn't return the reference of the ParticleSystem generated on an agent.
I can make the hit target burns when he gets shot, but I can't make the fire go away after a few seconds, it will always be on the agent.
 
Last edited:
Like I said, I am aware that fire arrows can be achieved by editing xml.
This mod only added trail_particle_name to all the arrow items.
It's uncontrollable, like you can't make the enemy burns, the arrow will disapear when it hits a target due to the burning="true" flag, but without it the arrow stays with the particles on and consumes tons of GPU memery, the behaviours are all designed by native game and you have no controll over the logics.

But by implementing it myself, I can get a lot of things done. Like the point lights on the arrows are white lights if you are using the xml way, but I added the point lights myself so I can make it orange which looks more like lights from a fire.

And by implementing it myself, I can make the arrow stay where it hits instead of disapearing, and only remove the fire particles and point light so that GPU memery usage won't be too high.

The main problem is still the exposed API doesn't return the reference of the ParticleSystem generated on an agent.
I can make the hit target burns when he gets shot, but I can't mke the fire go away after a few seconds, it will always be on the agent.

Ah yes indeed I missed that point. This is pretty good ! Keep it up.
 
It's uncontrollable, like you can't make the enemy burns, the arrow will disapear when it hits a target due to the burning="true" flag,
Actually you can achieve that only with XML. Adding this to WeaponFlags does the trick
AmmoSticksWhenShot="true" Burning="true"
I know it because I used that in Advanced Custom Battle mod months ago.

But apart from that, you are right. What you are researching is way more valuable than simple XML editing.
I can already see the Game of Thrones mods that will arise from this :smile:
 
It's uncontrollable, like you can't make the enemy burns, the arrow will disapear when it hits a target due to the burning="true" flag,
Actually you can achieve that only with XML. Adding this to WeaponFlags does the trick
AmmoSticksWhenShot="true" Burning="true"
I know it because I used that in Advanced Custom Battle mod months ago.

But apart from that, you are right. What you are researching is way more valuable than simple XML editing.
I can already see the Game of Thrones mods that will arise from this :smile:
I've found a workaround for the particle issue.
A working fire arrow and fire sword mod is on its way.

Lit target on fire and deliver burning damages.
Fire arrows sticked to object or ground will gradually burn out instead of disapering or remain burning forever.
Lit your sword/axe/polearm with hot key and burn your enemies.
Fires produce orange lights instead of white lights.

All values are customizable by editing .ini file or in-game menu with help of ModLib.

091HiO6.jpg

tvYwgTH.jpg

r3v2uGx.jpg

AqqmY1s.jpg

KAxFqaP.jpg
 
Last edited:
I haven't look at the Particle System or damage/burn decals yet, but is there any chance to slowly burn static objects without changing the effected object such as haystacks etc?
 
I haven't look at the Particle System or damage/burn decals yet, but is there any chance to slowly burn static objects without changing the effected object such as haystacks etc?
To achieve that, first we need haystacks models of different phases, little burnt, half burnt, totally burnt etc.
Without those all we can do is generate some fire particles on them and that doesn't look very convincing.
 
To achieve that, first we need haystacks models of different phases, little burnt, half burnt, totally burnt etc
If we are not aiming to destroy object physically correct, just for burn effect, replacing model on runtime wouldn't be performance-wise good imo.
Easiest way would be altering material, making it getting darker and darker over time and perhaps shifting down to make it look like it's burning away.

Have you checked anything about materials or decals? As far as I remember, when you burn someone, they weren't getting any darker or so. Which is a bit buzzkill. With material change, you can achieve scene-based burned objects a bit more realistically and with decals you can create area based burn effect, like burning small patch of grass on battlefields
 
If we are not aiming to destroy object physically correct, just for burn effect, replacing model on runtime wouldn't be performance-wise good imo.
Easiest way would be altering material, making it getting darker and darker over time and perhaps shifting down to make it look like it's burning away.

Have you checked anything about materials or decals? As far as I remember, when you burn someone, they weren't getting any darker or so. Which is a bit buzzkill. With material change, you can achieve scene-based burned objects a bit more realistically and with decals you can create area based burn effect, like burning small patch of grass on battlefields
I think that might only be possible when the engine tools come out.
I haven't even found a way to get the material instance of an agent's body not to mention changing it.
There are not enough APIs, a lot of work are still being done in c++ level. Can't touch any of that part.
I still can't figure out why they wouldn't return the reference of generated ParticleSystem, and why the API of AgentVisuals works while the other one of ParticleSystem doesn't.

EDIT:
Wait, I just found a Decal : GameEntityComponent which looks promising.
I am gonna look into it to see if I can add some burnt visuals.
 
Last edited:
There are not enough APIs, a lot of work are still being done in c++ level.
That's true. Every core graphic related stuff goes to RGL at the end, which is old variant of Warband RGL. Even some core AI decisions are still handled by RGL and C++ side components.

What you can do might be this; you can find a scene where you think you can use that material, you can setup a small Mission controller just for that scene and with Debug you can get that object. It should have a method called GetMaterial, once you get it's internal name, you can then call Material.GetFromResource to get it and set it again.
But of course, it's a bit too much hassle for sure.
 
The main problem is still the exposed API doesn't return the reference of the ParticleSystem generated on an agent.
I can make the hit target burns when he gets shot, but I can't make the fire go away after a few seconds, it will always be on the agent.
I'm not positive on this, but it appears that when the attribute "emit_at_once"
XML:
    <effect name="psys_game_burning_agent" guid="{42E394C5-21D5-409B-872C-DB082E417FE6}" sound_code="event:/mission/ambient/detail/fire/fire_small">
        <emitters>
            <emitter name="Emitter" _index_="0">
                <flags>
                    <flag name="emit_while_moving" value="false"/>
                    <flag name="dont_emit_while_moving" value="true"/>
                    <flag name="emit_at_once" value="false"/>
is set to false, the particle emitter will constantly emit the particles (ie. the particle system exists until the end of the mission). This seems to be the case for all the 'fire' type particle systems in 'particle_systems2.xml' including "psys_game_burning_agent" which you are using. When that attribute is set to true, and you call the system using the Mission method:
C#:
public void AddParticleSystemBurstByName(string particleSystem, MatrixFrame frame, bool synchThroughNetwork);
Then it will only emit once.

So, it seems like two things need to happen:
  1. Create a new fire particle system that has the 'emit_at_once' attribute set to true. (I couldn't seem to make new particle systems or override exiting ones, but I may have been making a mistake.)
  2. Use a mission behavior or some other method to periodically call AddParticleSystemBurstByName on your new fire particle system when your agent's sword is drawn.
If you already figured this out, sorry for the long comment. Also, please share if you know how to add/alter particle systems.
 
I'm not positive on this, but it appears that when the attribute "emit_at_once"
XML:
    <effect name="psys_game_burning_agent" guid="{42E394C5-21D5-409B-872C-DB082E417FE6}" sound_code="event:/mission/ambient/detail/fire/fire_small">
        <emitters>
            <emitter name="Emitter" _index_="0">
                <flags>
                    <flag name="emit_while_moving" value="false"/>
                    <flag name="dont_emit_while_moving" value="true"/>
                    <flag name="emit_at_once" value="false"/>
is set to false, the particle emitter will constantly emit the particles (ie. the particle system exists until the end of the mission). This seems to be the case for all the 'fire' type particle systems in 'particle_systems2.xml' including "psys_game_burning_agent" which you are using. When that attribute is set to true, and you call the system using the Mission method:
C#:
public void AddParticleSystemBurstByName(string particleSystem, MatrixFrame frame, bool synchThroughNetwork);
Then it will only emit once.

So, it seems like two things need to happen:
  1. Create a new fire particle system that has the 'emit_at_once' attribute set to true. (I couldn't seem to make new particle systems or override exiting ones, but I may have been making a mistake.)
  2. Use a mission behavior or some other method to periodically call AddParticleSystemBurstByName on your new fire particle system when your agent's sword is drawn.
If you already figured this out, sorry for the long comment. Also, please share if you know how to add/alter particle systems.
I've come up with a workaround and released my mod.
check this out:

And it's open source so you can check out my solution.
 
Nice, I'll check it out.

Edit:
Thanks for posting that code! I'm still new to C# and found reading the code enjoyable. I also learned how to properly run code in missions.
 
Last edited:
Back
Top Bottom