Jump to content

Need Help on Particles


Allan
 Share

Recommended Posts

Posted (edited)

I have a great result with these ! If you want to try 

Particle file : 

<?xml version="1.0" encoding="utf-8"?>
<particles>

    <texture>art/textures/particles/red_lightning.png</texture>
    <blend mode="over"/>

    <constant name="emissionrate" value="250.0"/>
    <uniform name="lifetime" min="0.1" max="1.0"/>


    <uniform name="angle" min="-3.14" max="3.14"/>

    <uniform name="velocity.x" min="-5.0" max="5.0"/>
    <uniform name="velocity.y" min="-5.0" max="5.0"/>
    <uniform name="velocity.z" min="-5.0" max="5.0"/>

    <uniform name="size" min="1.0" max="8.0"/>
	<constant name="size.growthRate" value="25.0"/>

    <expr name="color.r"  from="colorr" mul="1.0" max="1.0"/>
    <expr name="color.g" from="colorg"  mul="1.0" max="1.0"/>
    <expr name="color.b"  from="colorb"  mul="1.0" max="1.0"/>

</particles>

Noticed that I named it red, I have to rename all of these files :crash:

The texture is right down here :jawdrop:

 

image.png

Edited by Allan
Link to comment
Share on other sites

Posted (edited)

There's still a problem : When I start building a new building with particles, the color is not updated. I warned the UpdateColor function and the values are changing good but the particles are not getting the color of the player :search:

image.thumb.png.3efb8c0640a706b86319864408fe919d.png

And when I change the diplomacy color with the button on the minimap, the particle color stay as the first color of the player, surecly because I have to call the UpdateColor function here

 

Edited by Allan
Link to comment
Share on other sites

That's because the foundation actor doesn't take it into account :) You have to change https://trac.wildfiregames.com/browser/ps/trunk/binaries/data/mods/public/simulation/templates/special/filter/foundation.xml
probably by adding <ParticlePlayerColor merge=""/>

Yeah we probably need a hook for the diplomacy color thingy, I'm not sure whether it sends an event message or not

Link to comment
Share on other sites

Posted (edited)

I changed the file that u said + the special/filter/construction.xml and nothing changed, the color is not applied to the particle, in construction preview and when it's constructed :search:

 

If I put the OnUpdate function, I clearly see that the color is updated after the construction, but I still don't have it on preview

Edited by Allan
Link to comment
Share on other sites

For the diplomacy color https://trac.wildfiregames.com/browser/ps/trunk/binaries/data/mods/public/simulation/components/GuiInterface.js#L903 you might need to add the IID_ParticlePlayerColor to that function (Create a file with just that function that will be called after the actual one)

 

GuiInterface.prototype.UpdateDisplayedPlayerColors = function(player, data)
{
    let updateEntityColor = (iids, entities) => {
        for (let ent of entities)
            for (let iid of iids)
            {
                let cmp = Engine.QueryInterface(ent, iid);
                if (cmp)
                    cmp.UpdateColor();
            }
    };

    let cmpRangeManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager);
    let numPlayers = Engine.QueryInterface(SYSTEM_ENTITY, IID_PlayerManager).GetNumPlayers();
    for (let i = 1; i < numPlayers; ++i)
    {
        const cmpDiplomacy = QueryPlayerIDInterface(i, IID_Diplomacy);
        if (!cmpDiplomacy)
            continue;

        QueryPlayerIDInterface(i, IID_Player).SetDisplayDiplomacyColor(data.displayDiplomacyColors);
        if (data.displayDiplomacyColors)
            cmpDiplomacy.SetDiplomacyColor(data.displayedPlayerColors[i]);

        updateEntityColor(data.showAllStatusBars && (i == player || player == -1) ?
            [IID_Minimap, IID_RangeOverlayRenderer, IID_RallyPointRenderer, IID_StatusBars] :
            [IID_Minimap, IID_RangeOverlayRenderer, IID_RallyPointRenderer, IID_ParticlePlayerColor],
        cmpRangeManager.GetEntitiesByPlayer(i));
    }
    updateEntityColor([IID_Selectable, IID_StatusBars], data.selected);
    Engine.QueryInterface(SYSTEM_ENTITY, IID_TerritoryManager).UpdateColors();
};

 

7 minutes ago, Allan said:

but not when it's constructed

When it's being constructed, or after it's been constructed ?

Link to comment
Share on other sites

Posted (edited)
4 minutes ago, Stan` said:

When it's being constructed, or after it's been constructed ?

I just see the good color on preview, not when I start the construction and not when it's constructed

+ It seems like the only building concerned by the good preview is my wall_tower, the other building doesn't have the good color on preview :search:

Edited by Allan
Link to comment
Share on other sites

Nope same color called on preview, when I start the construction by left-clicking, when the construction begin and when it's constructed. 

16 minutes ago, Stan&#x60; said:

(Create a file with just that function that will be called after the actual one)

What do you mean when you say this ? Because we actually use GuiInterface.js in our project so I don't know how to rename the file. So I added the IID_ParticlePlayerColor to the function in the basic .js file and it's not changing the color of the partcile when I change diplomacy color.

Link to comment
Share on other sites

Posted (edited)

Another starge thing is when the construction of the wall_tower is finished, the particle is grey (bad color) but when I change the diplomacy color from green to blue, the particle change to green :search:

 

Same with the other building which was "not working"

Edited by Allan
Link to comment
Share on other sites

56 minutes ago, Allan said:

Nope same color called on preview, when I start the construction by left-clicking, when the construction begin and when it's constructed. 

What do you mean when you say this ? Because we actually use GuiInterface.js in our project so I don't know how to rename the file. So I added the IID_ParticlePlayerColor to the function in the basic .js file and it's not changing the color of the partcile when I change diplomacy color.

In order to make mods more maintenable, we recommend users only override functions they touch rather than the whole files. You would usually have a file named ~GuiInterface.js with only the modified functions.

 

53 minutes ago, Allan said:

Another starge thing is when the construction of the wall_tower is finished, the particle is grey (bad color) but when I change the diplomacy color from green to blue, the particle change to green :search:

 

Same with the other building which was "not working"

After the Guiinterface change ?

Link to comment
Share on other sites

3 minutes ago, Stan&#x60; said:

In order to make mods more maintenable, we recommend users only override functions they touch rather than the whole files. You would usually have a file named ~GuiInterface.js with only the modified functions

That makes sense yes 

 

4 minutes ago, Stan&#x60; said:

After the Guiinterface change ?

Yep 

Link to comment
Share on other sites

The Guinterface forces a reload of the color, a bit like the on update :) That's why the color is changing. I'm wondering if we don't switch the color too early, causing the gaia color to be taken...

Link to comment
Share on other sites

Ok so :

When I start the game with two different players I have these parameters :

red 0.33 etc is the green one (me)

red : 0.58 etc is the blue one (petra)

 

image.png.9fddea4cdf5aeef2818a2ade5262ec53.png

When I click on a building to build it (preview) I have these and the building has the good particle color (green) : 

image.png.7d510aa9d6262e74686b853ae3f350bb.png

The same appears when the building starts being constructed and at the end of the construction, but the color is gaia when it finishes the construction.

 

When I change the diplomacy color, only one UpdateColor is being done, and the green color appears, even if i'm in the blue team

 

Link to comment
Share on other sites

I don't understand how the gaia color is being put in the particle, it seems like the code is working at every moment of the construction of the building so I don't see how to solve the problem :search:

 

Link to comment
Share on other sites

6 minutes ago, Allan said:

I don't understand how the gaia color is being put in the particle, it seems like the code is working at every moment of the construction of the building so I don't see how to solve the problem :search:

 

Well it's possible the owner isn't set when we set the color, and so it sets gaia instead of something else. Although from your logs it looks like the color is correct

Link to comment
Share on other sites

Posted (edited)

I tested this quickly and it didn't work, obviously

UpdateColor()
	{
		warn("UpdateColor");
		let cmpVisual = Engine.QueryInterface(this.entity, IID_Visual);
		if (!cmpVisual)
			return;
		const player = cmpPlayerManager.GetPlayerByID(player);
		
		let cmpOwnership = Engine.QueryInterface(ent, IID_Ownership);
		cmpOwnership.SetOwner(player);

		const color = QueryOwnerInterface(this.entity, IID_Player).GetColor();
		cmpVisual.SetVariable("colorr", color.r);
		cmpVisual.SetVariable("colorg", color.g);
		cmpVisual.SetVariable("colorb", color.b);
		warn("red : "+color.r);
		warn("green : "+color.g);
		warn("blue : "+color.b);
	}

But maybe it's the good way, like maybe we have to set the owner manually before setting the color ? :search:

 

Tried because after a certain big amount of researches, I didn't found where and when the owner is set 

Edited by Allan
Link to comment
Share on other sites

 

1 hour ago, Allan said:

		let cmpOwnership = Engine.QueryInterface(ent, IID_Ownership);
		cmpOwnership.SetOwner(player);

Well ent is not defined, and your setting the player to itself ^^ so it wouldn't change much

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...