Jump to content

Allan

Community Members
  • Posts

    56
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by Allan

  1. Sure ! Forgot to mention it my bad
  2. Hey 0.A.D Community ! The Robots Uprising Mod is now available on 0.A.D here : https://mod.io/g/0ad/m/robots-uprising Let us know if you like it by the comments below the page of the mod or dm me !
  3. To be honest I don't understand this concept, like how a simple timer crash the game ? It makes no sense
  4. It says this : ERROR: Cannot serialise JS objects of type 'function': (unnamed) ERROR: Script component ParticlePlayerColor of entity 1643 failed to serialize: Serialize_InvalidScriptValue Serializing: ({TimerTick:(function() { this.UpdateColor(); })})
  5. Yes we had all the same. When I deleted all the ParticlePlayerColor files it worked, maybe it crashes because of the cmpPlayer in the function
  6. I tested with particles enabled in multiplayer but the game crashes, and we are sure that the particles are the problem because we deleted them and it worked. Do you have an idea of what can cause this ?
  7. Ok, I think there are like 3 or 4 buildings with particles so it would be ok. Thank you for helping me with these particles, such a pleasure to interact with you ! Now we are finishing the details to release the project this week
  8. Nice it's working ! Are you sure that it will not be too expensive for the engine ? I mean updating the color every 1 sec, maybe we have to put this on 3 or 4 sec ?
  9. Ok thank you ! I only have one week left to do it, so I don't think I will follow this solution. I think I can do this, I just don't know where can I put this timer ? In what file ? Maybe these particules are only a detail, I'm hesitating, it's already working to be honest, I don't know if I will take time for this, because I have a lot of things to do :/
  10. Hey ! Did you find something ? My exams are tomorrow and Friday so I'll be back on this after my exams
  11. UpdateColor() { // warn("UpdateColor"); // let cmpFoundationOwnership = Engine.QueryInterface(this.entity, IID_Ownership); // let owner = cmpFoundationOwnership.GetOwner(); // if (cmpFoundationOwnership) // { // cmpFoundationOwnership.SetOwner(owner); // } // warn("Entity : " + this.entity + "Owner : " + owner) // var owner = Engine.QueryInterface(this.entity, IID_Ownership).GetOwner(); const cmpPlayer = QueryOwnerInterface(this.entity, IID_Player); let owner = Engine.QueryInterface(this.entity, IID_Ownership).GetOwner(); warn("Entity : " + this.entity + "Owner : " + owner); let cmpVisual = Engine.QueryInterface(this.entity, IID_Visual); if (!cmpVisual) return; if (cmpPlayer) { const color = cmpPlayer.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); } I think it doesn't get the good color untli the building is finally constructed, so that's why it applies the gaia color. But how to collect the owner of a building before its construction ? Something that I don't understand is that I call all the messages during the construction, it should be good but it's not
  12. If I put this in OnGlobalOwnershipChanged it doesn't work anymore, the color is not updated. The wallset.js in kind of empty to be honest, and I can't find another file attached to walls. Moreover, I don't understand why i've got a good preview (with the good color) with my wall tower but not with my other building (spacedock) I'll see this tomorrow I take a break
  13. Here is the "final" version of my UpdateColor function : UpdateColor() { const cmpPlayer = QueryOwnerInterface(this.entity, IID_Player); let owner = Engine.QueryInterface(this.entity, IID_Ownership).GetOwner(); warn("Entity : " + this.entity + "Owner : " + owner); let cmpVisual = Engine.QueryInterface(this.entity, IID_Visual); if (!cmpVisual) return; if (cmpPlayer) { const color = cmpPlayer.GetColor(); cmpVisual.SetVariable("colorr", color.r); cmpVisual.SetVariable("colorg", color.g); cmpVisual.SetVariable("colorb", color.b); } } OnOwnershipChanged(msg) { if (msg.to == INVALID_PLAYER) return; this.UpdateColor(); } OnGlobalOwnershipChanged(msg) { if (msg.to == INVALID_PLAYER) return; this.UpdateColor(); } OnEntityRenamed(msg) { if (msg.to == INVALID_PLAYER) return; this.UpdateColor(); } OnHealthChanged(msg) { if (msg.to == INVALID_PLAYER) return; this.UpdateColor(); } OnGlobalInitGame(msg) { if (msg.to == INVALID_PLAYER) return; this.UpdateColor(); } When I build a large wall (Tower + Wall + Tower), the particles of the first tower is gaia colored. When the wall is constructed, the first tower particles turns player colored. The third tower stays gaia colored since I build something else. I don't understand how is this possible to be honest
  14. Ok but how to use it ? I tried this but it makes the code not working again (does nothing without error) OnOwnershipChanged(msg) { warn("OwnershipChanged"); if (msg.to == INVALID_PLAYER) return; if (msg.ent) this.UpdateColor(); // warn("OwnershipChangedUpdateColor"); } And will it be really useful ? I mean is the problem comes from this or not ? + I don't know if my last post was clear after reading it :/
  15. Ok I think I found something interesting. I found this message in Player.js : Player.prototype.OnGlobalOwnershipChanged = function(msg) { if (msg.from != this.playerID && msg.to != this.playerID) return; let cmpCost = Engine.QueryInterface(msg.entity, IID_Cost); if (msg.from == this.playerID) { if (cmpCost) this.popUsed -= cmpCost.GetPopCost(); let panelIndex = this.panelEntities.indexOf(msg.entity); if (panelIndex >= 0) this.panelEntities.splice(panelIndex, 1); let barterIndex = this.barterEntities.indexOf(msg.entity); if (barterIndex >= 0) this.barterEntities.splice(barterIndex, 1); } if (msg.to == this.playerID) { if (cmpCost) this.popUsed += cmpCost.GetPopCost(); let cmpIdentity = Engine.QueryInterface(msg.entity, IID_Identity); if (!cmpIdentity) return; if (MatchesClassList(cmpIdentity.GetClassesList(), panelEntityClasses)) this.panelEntities.push(msg.entity); if (cmpIdentity.HasClass("Barter") && !Engine.QueryInterface(msg.entity, IID_Foundation)) this.barterEntities.push(msg.entity); } }; It's always called when you build something so I decided to test this in ParticlePlayer.js : OnGlobalOwnershipChanged(msg) { if (msg.to == INVALID_PLAYER) return; this.UpdateColor(); } And it works ! The building switch from gaia to player color during the building or when it's constructed BUT the UpdateColor function is being called 3-4 times every 5 seconds, which can be a problem ? I don't know + I understood how it works : Everytime I build something, the previous building is being Color updated. It means that if un build a large wall (with two towers), only the first tower will be color updated. To update the second one, I have to build another building
  16. After testing many things I think that it's true But how this works for the civili-centre (building placed at the beginning of the game) and not for other buildings being constructed during the game ? And if I can't pick my player from here, how can I do ?
  17. Ok, I've got these errors with the second one : So yes, itu says that is null, so how can I call my UpdateColor function if this is null ?
  18. I think I found something but I don't know how to use the UpdateColor function in another file. I tried this : let cmpParticlePlayerColor = Engine.RegisterInterface("ParticlePlayerColor"); if (cmpParticlePlayerColor) { cmpParticlePlayerColor.UpdateColor(); } And this : let cmpParticlePlayerColor = Engine.QueryInterface(this.entity, IID_ParticlePlayerColor); if (cmpParticlePlayerColor) { cmpParticlePlayerColor.UpdateColor(); } I think I understand why the second one doesn't work (wrong interface) but why the first one ? I'm trying this because i saw that the UpdateColor function is called before the owner is set, and I think that's the problem.
  19. I did this to the UpdateColor function : UpdateColor() { // warn("UpdateColor"); let cmpFoundationOwnership = Engine.QueryInterface(this.entity, IID_Ownership); if (cmpFoundationOwnership) { cmpFoundationOwnership.SetOwner(cmpFoundationOwnership.GetOwner()); } warn("Owner : " + cmpFoundationOwnership.GetOwner()) let cmpVisual = Engine.QueryInterface(this.entity, IID_Visual); if (!cmpVisual) return; 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); } I try to SetOwner at this moment but I think i'm doing it bad. I saw this function comes from a .cpp compoment and is quite simple. But how can I SetOwner the final building AND the foundation AND the preview ? I'm testing many things but I don't understand why when I print the owner of my 2 civil_centre at the beginning of the game I have this : It seems like the owner is changing 3 times before getting the right owner, maybe that is the problem Moreover, I'm not the best programmer in the team, that's why it's harder for me to understand these things, sorry for being a noob (Steph is not available)
  20. 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 ? Tried because after a certain big amount of researches, I didn't found where and when the owner is set
  21. 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
  22. 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) When I click on a building to build it (preview) I have these and the building has the good particle color (green) : 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
  23. Maybe we have to determine the color when the construction is finished, but how ?
×
×
  • Create New...