Jump to content

Help on making researched techs have visible impact on entities' actors


azayrahmad
 Share

Recommended Posts

I'm trying to make researched techs to change the look of affected entities. For example, Greave technology that allows all soldiers to have greaves on their legs.

For this, I made custom actor based on basic infantry spearman, but the greave prop is separated into its own variant (similar to flag prop in garrison holder) named greave0 (without greave) and greave1 (with greave). To trigger the actor update, I made a new component, named VisibleTechnology. It will check if the player has researched the tech, and then set the actor variant based on the tech.

The problem is that it seems that the TechnologyManager component cannot be called. I tried to call it in UpdateActor() function during Init() and OnResearchFinished(). The call is like this:

    let cmpTechnologyManager = Engine.QueryInterface(this.entity, IID_TechnologyManager);
    if (!cmpTechnologyManager)
        return;

During Init(), it's always Null, and on OnResearchFinished(), the UpdateActor() isn't even called. I'm not sure what I did wrong here. Any help is truly appreciated.

NB: I replaced the Athenian CC to train this infantry spearman with researchable graves. I also put Greaves as tech in Athenian Forge. Easiest way to test this is by loading Sandbox Athenians and training infantry spearman from CC and then research the Greave tech in Forge.

The prototype is here: https://github.com/azayrahmad/visible-upgrade-A25

Thank you.

Edited by azayrahmad
  • Like 5
Link to comment
Share on other sites

A few things going on here:

  1. Technology manager is a component of the entity's owner (the player), not of the entity itself. Instead of Engine.QueryInterface, you'll need to call the helper function QueryOwnerInterface(this.entity, IID_TechnologyManager).
  2. When each component's Init() function is called, there is no guarantee that all the entity's other components have been initialized already. There's no neat solution to this, but the best solution that I have found is using OnOwnershipChanged instead for code that is dependent on other components. The event OwnershipChanged is fired when the entity is assigned to its initial owner, which occurs almost instantly after all components have been initialized. You'll want to check that the initialization code isn't called again when the entity's ownership changes, so do something like this:
    VisibleTechnology.prototype.OnOwnershipChanged = function()
    {
    	if (this.initialized)
    	  return;
    	<initialization code ...>
    	this.initialized = true;
    };

     

  3. OnResearchFinished is only called on the entity of the player that researched the tech. To have any individual entity respond to a tech being researched, use OnGlobalResearchFinished. The msg consists of the fields "player" and "tech", player being the ID of the player who researched the tech and tech being the name of the tech. You'll want to check that the player ID is the same as the entity's owner, or else you'll update the variant when any player researches the tech. Use the following code:
    const cmpOwnership = Engine.QueryInterface(this.entity, IID_Ownership);
    if (cmpOwnership.GetOwner() !== msg.player)
      return;

    Good luck with this! It's something I've always wanted to see in the game. I've thought about giving the Romans a "Corvus" tech to improve the power of their ships, which would give them with the boarding plank you see on the ships in A25.

  • Thanks 1
Link to comment
Share on other sites

  • azayrahmad changed the title to Help on making researched techs have visible impact on entities' actors
24 minutes ago, azayrahmad said:

Thank you very much @hopeless-ponderer! Now the visible technology is working as intended. GitHub prototype has been updated. I will update the Readme for instructions. Meanwhile, for your Corvus tech, what power do you want to give the ships? I can make the tech and actor variant.

bah, if I had 2 more months I could apply this to DE. lol It would be a huge amount of work though (tons of actor work), because I'd want to push it as far as I could. So, a body armor (Linothorakes, or something) tech would update the unit texture (swap the hoplite from a tunic texture to a linothorax texture), but do this with every blacksmith tech.

Link to comment
Share on other sites

4 minutes ago, wowgetoffyourcellphone said:

bah, if I had 2 more months I could apply this to DE. lol It would be a huge amount of work though (tons of actor work), because I'd want to push it as far as I could. So, a body armor (Linothorakes, or something) tech would update the unit texture (swap the hoplite from a tunic texture to a linothorax texture), but do this with every blacksmith tech.

Exactly what I thought when making this. Xiphos tech with actual xiphos added and linothorax with actual units get their tunic/bronze armor changed into linothorax would be really awesome, but yes each actor must be changed, which would take a long time.

I deliberately make it a new component so it should be possible to make it gradual i.e. even if the tech is affecting multiple unit types, you can apply visible tech to one unit type and it would be okay. I'm really looking forward to DE pushing the creativity of this component.

  • Like 1
Link to comment
Share on other sites

49 minutes ago, azayrahmad said:

Exactly what I thought when making this. Xiphos tech with actual xiphos added and linothorax with actual units get their tunic/bronze armor changed into linothorax would be really awesome, but yes each actor must be changed, which would take a long time.

I deliberately make it a new component so it should be possible to make it gradual i.e. even if the tech is affecting multiple unit types, you can apply visible tech to one unit type and it would be okay. I'm really looking forward to DE pushing the creativity of this component.

Essentially, the only thing to indicate rank, besides their rank insignia, would be headgear/helmets. Everything else would change appearance based on techs.

Link to comment
Share on other sites

No problem, @azayrahmad! Glad I could help.

On 24/07/2021 at 8:04 PM, azayrahmad said:

Thank you very much @hopeless-ponderer! Now the visible technology is working as intended. GitHub prototype has been updated. I will update the Readme for instructions. Meanwhile, for your Corvus tech, what power do you want to give the ships? I can make the tech and actor variant.

The Corvus was a gangplank that the Romans attached to the front of their ships that made it easy to board enemy ships. It was the key innovation that allowed them to compete with the Carthaginian navy in the First Punic War. Before the Corvus, the Roman navy was actually pretty poor compared to other Mediterranean powers. In reality, they never became great seamen, the Corvus allowed them to treat naval battles like infantry battles on land, which they excelled at.

You might have noticed that the Roman warships in A24 and A25 already have this feature: it's the long ramp that protrudes from the front of the ship. If I remember correctly they didn't have this in A23 and before (I could be wrong, it's been a while since I played A23). If so, you could use the A23 Roman ships as the variant without the Corvus and the new ships as the variant with the corvus. For the bonus, you could just increase the attack power or attack frequency. To make it 100% accurate you'd have to make ships use a melee attack or have the ability to capture other ships, but that's probably too complicated for the game atm.

Link to comment
Share on other sites

Honestly if someone can make a simple animation of the bridge, that would be neat. Just make the ship lowers the bridge as attack_capture animation, and put it up again otherwise. But I don't understand anything about 3D animation :(.

Meanwhile I could make it capture, perhaps on the weekend.

  • Like 1
Link to comment
Share on other sites

  • 1 month later...

@azayrahmad@Stan`Is there any existing trac ticket for raw mesh swapping? My understanding of the OP is that they made models for each change. My plan for items is to have prop points in an ARPG style, something like: Head/Neck/Shoulders/Back/Core/Arms/2xBracelets/4xRings/Pants/Boots and ideally swap each item model onto the unit model based on what is equipped.

Link to comment
Share on other sites

50 minutes ago, MoLAoS said:

@azayrahmad@Stan`Is there any existing trac ticket for raw mesh swapping? My understanding of the OP is that they made models for each change. My plan for items is to have prop points in an ARPG style, something like: Head/Neck/Shoulders/Back/Core/Arms/2xBracelets/4xRings/Pants/Boots and ideally swap each item model onto the unit model based on what is equipped.

You can already do that using variants in actor files.

That's how we switch weapons/gathering tools.

That's also how we add garrison flags

Also works for health levels in carthaginian buildings.

Units meshes have 53 prop points.  :)

Link to comment
Share on other sites

7 minutes ago, Stan&#x60; said:

You can already do that using variants in actor files.

That's how we switch weapons/gathering tools.

That's also how we add garrison flags

Also works for health levels in carthaginian buildings.

Units meshes have 53 prop points.  :)

But don't you have to hook things up in the actor files? That is what the word variants suggests to me. Like you can't have a set of, lets call them items, with models and set the JS code to stick the item model onto a prop point with an "equip" function, can you? This wouldn't really be described in the actor files in my personal conceptualization. It couldn't be because you'd want to be able to equip an arbitrary item to a prop point on an arbitrary unit model.

Sure if you had a tech to apply a change to a "unit type" such that when you research the tech all units get it and you only have a few techs you could define a variant model. But you couldn't for instance just add a unit type to a tech that upgrades and not alter the unit template/actor model w/e at all correct?

Link to comment
Share on other sites

Then no its not currently possible because it requires C++ changes. All the prop handling code is there.  The only exception would be the projectile prop point.

That is because all the art is purely visual, it has no impact on gameplay whatsoever it's completely decorelated

Link to comment
Share on other sites

8 minutes ago, Stan&#x60; said:

Then no its not currently possible because it requires C++ changes. All the prop handling code is there.  The only exception would be the projectile prop point.

That is because all the art is purely visual, it has no impact on gameplay whatsoever it's completely decorelated

Okay so I'd need to add C++ code but it would be mostly high level stuff about connecting models to prop points dynamically?

Link to comment
Share on other sites

1 minute ago, MoLAoS said:

Okay so I'd need to add C++ code but it would be mostly high level stuff about connecting models to prop points dynamically?

I believe most of the functions are in place on the "low level" code but the cmpVisual interface and CCmpVisualActor.cpp component file don't provide any access to it.

I had a patch https://code.wildfiregames.com/D1989

 

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...