Jump to content

Help with a new Victory Condition?


 Share

Recommended Posts

Hi. So, I made a new Victory Condition for DE, called Conquest Civic Centers. Basically, win by destroy or capture the enemy Civic Centers. Here is the code of the script:

 

var cmpTrigger = Engine.QueryInterface(SYSTEM_ENTITY, IID_Trigger);
cmpTrigger.conquestClassFilter = "CivilCentre";

var data = {"enabled": true};
cmpTrigger.RegisterTrigger("OnOwnershipChanged", "ConquestHandlerOwnerShipChanged", data);
cmpTrigger.RegisterTrigger("OnStructureBuilt", "ConquestAddStructure", data);

cmpTrigger.DoAfterDelay(0, "ConquestStartGameCount", null);

 

 

This works fine... until I use an Upgrade feature to upgrade my Civic Center. I made it so I can upgrade my Civic Center to a Fortified Civic Center. The Fortified Civic Center inherits from the Civic Center template, so has all the same classes, etc. There may be a brief moment where the game think I don't have a Civic Center, so it makes me lose. Even though the enemy didn't destroy or capture it. Can I edit something in the script to prevent this? Perhaps that last line that mentions Delay?

Edited by wowgetoffyourcellphone
Link to comment
Share on other sites

When upgrading an entity, the old one is deleted and a new one is created. So the old one will count as lost (OnOwnershipChanged to -1). That will be initiated from ChangeEntityTemplate from Upgrade.js.

As we can see in that function in Transform.js, an EntityRenamed message is sent just before deleting the entity, so the victory condition could listen to that and replace the remembered entityID before it's deleted.

Link to comment
Share on other sites

  • 2 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...