Advertisement
Civilization Fanatics' Center  

Welcome to Civilization Fanatics' Center.

You are currently viewing our site as a guest which gives you limited access to our site features. By joining our free community, you will be able to participate in the discussions, search the forum, send private messages, vote in polls, upload your own screenshots to the gallery, and access many other special features. Registration is fast, simple and absolutely free, so sign up today! If you have any problems with the registration process or your account login, please contact support.

Go Back   Civilization Fanatics' Forums > CIVILIZATION V > Civ5 - Creation & Customization > Civ5 - SDK / LUA

Notices

Reply
 
Thread Tools
Old Jun 15, 2012, 09:25 AM   #1
Nefliqus
Prince
 
Nefliqus's Avatar
 
Join Date: Sep 2010
Location: Poland
Posts: 386
Trigger function before city capture

Task description:
I want to create new civ with UA that will let to save cultural building in captured city.

Problem description:
I want to create list of cultural building in the city before capturing. In this why I will be able to add it later. The problem is how to trigger function just before capturing. I think that I can monitor all move or attack of this civ units but maybe there is some better solution.

Question:
1) How to trigger function before city capturing?
2) Do you know other method to save building in the city captured by given civ?
3) What is name of function that decide to destroy or not to destroy building in captured city? I think that it is core game function but I could be mistaken.
4) Do you have any example of use RunCombatSim event?

EDIT:
I just have found this info:
Quote:
I would use Events.SerialEventCityCaptured, which passes: hexPos, playerID, cityID, and newPlayerID.

You can see an example of it in action in CivsAlive.lua in the Mongol Scenario.
I'm not sure if this fires when the capture isn't observed by the player tho, unfortunately some SerialEvents don't.

GameEvents.CityCaptureComplete
http://forums.civfanatics.com/archiv.../t-452749.html
I think that i can use it. Maybe this even is triggered before building destroying

Last edited by Nefliqus; Jun 15, 2012 at 11:28 PM.
Nefliqus is offline   Reply With Quote
Old Jun 15, 2012, 12:03 PM   #2
Pazyryk
Deity
 
Pazyryk's Avatar
 
Join Date: Jun 2008
Posts: 2,067
Please report back what you learn. I always want to know which of these Events work when not seen by human (no way to know unless someone tests it) and timing issues.

One issue about timing: Results are not always consistent for specific Events. I think this is because they are supposed to be for animations/graphics (which could be delayed by some other running animation) and not really game rule effects (even though we modders use them this way). The GameEvent should not have this problem, although I'd guess that it is too late for your need.

SciprtData is maybe another possibility: you could store all buildings there each turn. Strangely, the wiki lists SetScriptData under city object but not GetScriptData (I have not tested to see if these exist and work). But plot:SetScriptData and plot:GetScriptData work fine and there is only one unique plot for each city.
Pazyryk is offline   Reply With Quote
Old Jun 15, 2012, 01:53 PM   #3
Gedemon
Moderator
 
Gedemon's Avatar
 
Join Date: Oct 2004
Location: France
Posts: 3,655
Yes, please report your results.

I used RunCombatSim event in conjunction with unit:GetLastMissionPlot() to check if a city was about to be captured but it doesn't work anymore since the last patch

my guess is that with the new animation system, the result of the combat is calculated and applied before the actual animation start and RunCombatSim is called and unit:GetLastMissionPlot() does non longer return the plot the unit is going to attack, but the one it's on.
Gedemon is offline   Reply With Quote
Old Jun 15, 2012, 11:44 PM   #4
Nefliqus
Prince
 
Nefliqus's Avatar
 
Join Date: Sep 2010
Location: Poland
Posts: 386
Quote:
Originally Posted by Gedemon View Post
Yes, please report your results.

I used RunCombatSim event in conjunction with unit:GetLastMissionPlot() to check if a city was about to be captured but it doesn't work anymore since the last patch

my guess is that with the new animation system, the result of the combat is calculated and applied before the actual animation start and RunCombatSim is called and unit:GetLastMissionPlot() does non longer return the plot the unit is going to attack, but the one it's on.
But why didn't you use Events.SerialEventCityCaptured which passes: hexPos, playerID, cityID, and newPlayerID? Did you have any problem with this event?
The easiest solution for me is to add building list to city scriptdata or cityplot and check it after GameEvents.CityCaptureComplete. I can also build table with such information but it will need to run all cities loop every turn. It could add some additional turn time and I don't want to do it.
I plan to wait for GAK with all test.

Last edited by Nefliqus; Jun 16, 2012 at 12:15 AM.
Nefliqus is offline   Reply With Quote
Old Jun 16, 2012, 06:00 AM   #5
Gedemon
Moderator
 
Gedemon's Avatar
 
Join Date: Oct 2004
Location: France
Posts: 3,655
Events.SerialEventCityCaptured is called after the city has been captured. I need an event before.
Gedemon is offline   Reply With Quote
Old Jun 17, 2012, 08:31 AM   #6
Nefliqus
Prince
 
Nefliqus's Avatar
 
Join Date: Sep 2010
Location: Poland
Posts: 386
Quote:
Originally Posted by Gedemon View Post
Events.SerialEventCityCaptured is called after the city has been captured. I need an event before.
does anybody know what is happening between Events.SerialEventCityCaptured and GameEvents.CityCaptureComplete?
Nefliqus is offline   Reply With Quote
Old Jun 18, 2012, 07:47 AM   #7
Nefliqus
Prince
 
Nefliqus's Avatar
 
Join Date: Sep 2010
Location: Poland
Posts: 386
Austria UA save all building in the city. so I need just find relevant part of the code.
Nefliqus is offline   Reply With Quote
Reply

Bookmarks

Go Back Civilization Fanatics' Forums > CIVILIZATION V > Civ5 - Creation & Customization > Civ5 - SDK / LUA > Trigger function before city capture

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Advertisement

All times are GMT -6. The time now is 10:39 PM.


Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
This site is copyright © Civilization Fanatics' Center.
Support CFC: Amazon.com | Amazon UK | Amazon DE | Amazon CA | Amazon FR