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

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