DLL - Custom Missions via XML and Lua

Thanks for the reply S3rgeus, I did actually get this fixed in the end. I did have other issues with converting turns remaining but got that sorted as well. Thanks though the mission thing works really well.

Glad that's all sorted and that the mod is working well for you! Let me know if you run into any other problems, I'll try to reply a bit faster next time. :D
 
First off, Master S3rgeus, your DDL is fantastic. You turned a 5 hour chore into 15 mins of fun. And I thank you.

I am still struggling a little bit with bTestVisible, and I read most of your conversations between FramedArchitect but I still just cant grasp what I'm doing wrong.

This is what I want to happen:
Unqiue Unit: Clan Elite
Has Mission: Influence City State (A once off Trade Missions that does not kill the unit)
Requirement: Must have 200 gold.

Here is my code, I will refine it for more conditions later, but at this stage the button doesnt show up at all unless I have over 200 gold (I would like it to be greyed out between 0-199 G) :(

Code:
function CanDoInfluenceCS(playerID, unitID, bTestVisible)
	if (Players[playerID]:GetUnitByID(unitID):GetUnitType() ~= GameInfoTypes.UNIT_CLAN_ELITE) then
		return false
	end
	if (Players[playerID]:GetGold() < 200 and not bTestVisible) then
		return false
	end
	return true
end
GameEvents.CanDoInfluenceCS.Add(CanDoInfluenceCS)

Edit: found the problem. Silly me. had an extra paramater in function call
 
First off, Master S3rgeus, your DDL is fantastic. You turned a 5 hour chore into 15 mins of fun. And I thank you.

I am still struggling a little bit with bTestVisible, and I read most of your conversations between FramedArchitect but I still just cant grasp what I'm doing wrong.

This is what I want to happen:
Unqiue Unit: Clan Elite
Has Mission: Influence City State (A once off Trade Missions that does not kill the unit)
Requirement: Must have 200 gold.

Here is my code, I will refine it for more conditions later, but at this stage the button doesnt show up at all unless I have over 200 gold (I would like it to be greyed out between 0-199 G) :(

Code:
function CanDoInfluenceCS(playerID, unitID, bTestVisible)
	if (Players[playerID]:GetUnitByID(unitID):GetUnitType() ~= GameInfoTypes.UNIT_CLAN_ELITE) then
		return false
	end
	if (Players[playerID]:GetGold() < 200 and not bTestVisible) then
		return false
	end
	return true
end
GameEvents.CanDoInfluenceCS.Add(CanDoInfluenceCS)

Edit: found the problem. Silly me. had an extra paramater in function call

Glad you got it sorted and that the DLL is helping you out! :D Any more questions, don't hesitate to ask.
 
Glad you got it sorted and that the DLL is helping you out! :D Any more questions, don't hesitate to ask.

Will do. I released my mod today. Glorious custom mission and all, had to setup a nice string of bool gates to get the button grayed out... anyone who wants to have multiple checks, I recommend you do it this way.

Code:
-- Enhanced Gift Trait
function CanDoEnhancedGift(playerID, unitID, bTestVisible)
	local pPlayer = Players[playerID];
	if not pPlayer:IsAlive() then return false end

	-- Keep track of the icon grey-out
	local bHide = false;

	local pUnit = pPlayer:GetUnitByID(unitID);
	local pTeamID = pPlayer:GetTeam();

	-- If the unit does not have the Byakugan then display nothing!
	if ( not pUnit:IsHasPromotion(pBYAKUGAN) ) then return false end

	-- If the civ is not Hyuga then grey out the button.
	if ( pPlayer:GetCivilizationType() ~= HyugaID ) then bHide = true end

	-- If the unit is no territory then grey out the button.
	local pPlotOwnerID = pUnit:GetPlot():GetOwner();
	if pPlotOwnerID == -1  then
		bHide = true;
		pPlotOwnerID = playerID;
	end

	-- If the unit is not in City state territory then grey out the button.
	local pPlotOwner = Players[pPlotOwnerID];	
	if not pPlotOwner:IsMinorCiv() then bHide = true end
	
	-- If the unit is at war with the city state then grey out the button.
	local atWar = Teams[pPlotOwner:GetTeam()]:IsAtWar(pTeamID);
	if atWar then bHide = true end

	-- Check to see if bHide is true, if so then grey-out the button. Otherwise show the pressable button!
	if (bHide and not bTestVisible) then 
		return false;
	else
		return true;
	end
end
GameEvents.CanDoEnhancedGift.Add(CanDoEnhancedGift)
 
Hi Sergeus,

I've been using your Custom Missions and Notifications DLL for years (thank you!), and I'd like to make a few changes. I'm looking at your DLL on github. Which branch do I need to download and compile to in order to reproduce the DLL available here in this thread?

I'm glad it's been helping you out for all this time! You're probably better off looking at this repository since I updated it more recently.

If you clone the repository (you may want to fork it first if you want to upload your own stuff to Github separately) and then switch to the "CustomSystems" branch, that should give you the source for the Custom Missions and Notifications dll.
 
I'm glad it's been helping you out for all this time! You're probably better off looking at this repository since I updated it more recently.

If you clone the repository (you may want to fork it first if you want to upload your own stuff to Github separately) and then switch to the "CustomSystems" branch, that should give you the source for the Custom Missions and Notifications dll.

Thanks. In the customsystems DLL you disable both components in ModDefines.h with ENABLE_CUSTOM_NOTIFICATIONS and ENABLE_CUSTOM_MISSIONS -- apparently by default. Did a search, but couldn't find those globals. Where are they and how can I enable them?

Edit:
I just changed
Code:
#define CUSTOM_NOTIFICATIONS 0
to
Code:
#define CUSTOM_NOTIFICATIONS 1

and rebuild failed with 11 errors like following
Code:
1>CvNotifications.obj : error LNK2001: unresolved external symbol "public: bool __thiscall WoTNotificationInfo::IsAlwaysDismissable(void)const " (?IsAlwaysDismissable@WoTNotificationInfo@@QBE_NXZ)

Note that doing similar with CUSTOM_MISSIONS allows rebuild without errors.
 
Last edited:
Thanks. In the customsystems DLL you disable both components in ModDefines.h with ENABLE_CUSTOM_NOTIFICATIONS and ENABLE_CUSTOM_MISSIONS -- apparently by default. Did a search, but couldn't find those globals. Where are they and how can I enable them?

Edit:
I just changed
Code:
#define CUSTOM_NOTIFICATIONS 0
to
Code:
#define CUSTOM_NOTIFICATIONS 1

and rebuild failed with 11 errors like following
Code:
1>CvNotifications.obj : error LNK2001: unresolved external symbol "public: bool __thiscall WoTNotificationInfo::IsAlwaysDismissable(void)const " (?IsAlwaysDismissable@WoTNotificationInfo@@QBE_NXZ)

Note that doing similar with CUSTOM_MISSIONS allows rebuild without errors.

Yes, those defines get set to 0 if the ENABLE_CUSTOM_MISSIONS and ENABLE_CUSTOM_NOTIFICATIONS preprocessor directives aren't defined. (Otherwise they get set to 1, which is the behavior you're seeing, since you've set it up to define them to 1 in both cases.) I set up the project file to define ENABLE_CUSTOM_MISSIONS and ENABLE_CUSTOM_NOTIFICATIONS, but only the VS2013 one, since that's the one I use. If you're using the VS2010 or VS2012 files, you'll need to add those preprocessor directives via the options menu (right click the project, go to Properties -> Configuration Properties -> C/C++ -> Preprocessor, and then add them to the "Preprocessor Definitions" property (semi-colon delimited).

That's interesting that it doesn't compile unless you define both! I have only used the two in concert for a long time, so an error in where I've wrapped some things with #ifs may have crept in and caused that part.
 
... to add those preprocessor directives via the options menu (right click the project, go to Properties -> Configuration Properties -> C/C++ -> Preprocessor, and then add them to the "Preprocessor Definitions" property (semi-colon delimited).
Thanks! Never would have thought of this....

That's interesting that it doesn't compile unless you define both! I have only used the two in concert for a long time, so an error in where I've wrapped some things with #ifs may have crept in and caused that part.
I should have been more clear... if CUSTOM_NOTIFICATIONS are enabled with or without Custom Missions, the build fails. I'm using VS 2008 Express... though I don't think that would be an issue? I've attached the logs.. any ideas on how I can correct issues?
 

Attachments

Thanks! Never would have thought of this....


I should have been more clear... if CUSTOM_NOTIFICATIONS are enabled with or without Custom Missions, the build fails. I'm using VS 2008 Express... though I don't think that would be an issue? I've attached the logs.. any ideas on how I can correct issues?

Ah, sorry about the confusion! It looks like the older project files (VS2010 and VS2012 vcxprojs) don't include the WoTNotifications files that define the implementation of those functions. Try right clicking the project (the BNW dll, so Expansion2) and going to "Add" -> "Existing Item" and then add all of the "WoT*.h" and "WoT*.cpp" files (I think it's just WoTNotifications.h and WoTNotifications.cpp) that are in the source directory to the project. It should compile then! :)
 
Try right clicking the project (the BNW dll, so Expansion2) and going to "Add" -> "Existing Item" and then add all of the "WoT*.h" and "WoT*.cpp" files (I think it's just WoTNotifications.h and WoTNotifications.cpp) that are in the source directory to the project. It should compile then! :)
That was it! I looked through those files, but hadn't noticed they weren't loaded into the project!
 
If you ever update this DLL again I have a small request. Currently we have a lua method for changing unit combat strength (unit:SetBaseCombatStrength(int)), and I imagine there is a DLL side function to change a unit's ranged combat strength, too. Would it be possible to expose that function to lua? Something like unit:SetBaseRangedCombatStrength(int)?

Just wanted to let you know I got this little change into the DLL with a few edits, which really only saved me 460 lines of sql ^^. Thanks for your work here Sergeus!
 
Just wanted to let you know I got this little change into the DLL with a few edits, which really only saved me 460 lines of sql ^^. Thanks for your work here Sergeus!

Awesome, I'm glad you got that working and this mod is continuing to help you out!
 
Yep, great mod! Just curious, will the compiled GnK version work as the current BNW version does?

I don't think so, I stopped updating the G&K dll a while back, so it's probably missing some features that are present in the BNW one.
 
Top Bottom