Page 1 of 2
Abilities on structures?
Posted: Tue Apr 25, 2017 6:57 pm
by johandenver2
Is there any way to use abilities (that typically are used on leaders) on structures?
Re: Abilities on structures?
Posted: Tue Apr 25, 2017 9:43 pm
by Bohémond
AFAIK, there is no way to se abilities with structures.
But you can use attributes (even Custom made) and associate events to the structures via the DB.
What is the goal of using abilities with structures ?
Regards
Re: Abilities on structures?
Posted: Wed Apr 26, 2017 11:34 am
by johandenver2
I was thinking about trying to create VMI, West Point, The Citadel etc. as places to train troops (in the same way McClellan can train troops with his ability)
Re: Abilities on structures?
Posted: Wed Apr 26, 2017 5:19 pm
by Bohémond
You can do it by
-Creating a custom structure with a script event associated.
Do you download the CW2 DB files ?
Let me know if you need some guidance to create the structure and the event.
Regards
Re: Abilities on structures?
Posted: Thu Apr 27, 2017 6:50 am
by johandenver2
I've created a custom structure and that seems to be working fine so it would just be creating the event that I'd need help with.
I haven't downloaded the db-files since I find them overwhelming to work with, I just edit everything directly instead.
I'd love some information about creating events :-)
Re: Abilities on structures?
Posted: Thu Apr 27, 2017 10:54 pm
by Bohémond
At the end of your str file add ;
ScriptFileName = Structures
ScriptName = STRScriptWestPoint
Create a .sct file names Structures.sct un Event game folder.
In it you should have something like this in it ;
StartEvent = STRScriptWestPoint|999|0|NULL|NULL|NULL|NULL
Conditions
Actions
SelectSubUnits = models $mdl_USA_Inf5
AlterCuSubUnit = ApplytoList; Attempts 2; Convert $mdl_USA_Inf1
EndEvent
Not tested but it should work.
Let me know if works as you expect.
Regards
Re: Abilities on structures?
Posted: Fri Apr 28, 2017 7:59 am
by johandenver2
Thanks a lot!
I'll try this and let you know how it works :-)
EDIT:
I tried creating a brigade of conscripts but they never upgraded to regular infantry.
In my brigade there are two regiments of INF5 and two INF6 but at least the two INF5 should have been upgraded I think.
Can I add multiple units to be upgraded in this way so that the event triggers for INF6 as well?
Re: Abilities on structures?
Posted: Fri Apr 28, 2017 8:41 pm
by johandenver2
How would I change the event to emulate "MasterDriller" instead of "Trainer"?
Also, would it be possible to do a similar event to remove manpower from the opposing side?
The idea here is to simulate a prison by removing a small amount of manpower from your enemy and also make your enemy want to destroy the prison if possible.
Another thing I'd like to do is to make an event to create hospitals.
Could I make an event using "MedicalService"?
Re: Abilities on structures?
Posted: Sat Apr 29, 2017 1:00 am
by Bohémond
johandenver2 wrote:Thanks a lot!
I'll try this and let you know how it works :-)
EDIT:
I tried creating a brigade of conscripts but they never upgraded to regular infantry.
In my brigade there are two regiments of INF5 and two INF6 but at least the two INF5 should have been upgraded I think.
Can I add multiple units to be upgraded in this way so that the event triggers for INF6 as well?
I will need your ScriptReportsfolder to analyze why it is not working.
You can use the same script to upgrade any models int any models
Regards
Re: Abilities on structures?
Posted: Sat Apr 29, 2017 11:51 am
by johandenver2
There are some content in the script reports about "West point" so it's obivously trying to run the script.
Sometimes one of the regiments in my brigade gets upgraded which leads me to think that the event is checking units everywhere to upgrade, not only in the city where the training camp is located.
Also, is there any guide to the contents of the structure file?
I know what some of the things in there are but not nearly all of them :-)
/J
Re: Abilities on structures?
Posted: Sat Apr 29, 2017 9:23 pm
by Bohémond
You are right, the script is looking for conscripts everywhere, please try this ;
StartEvent = STRScriptWestPoint|999|0|NULL|NULL|NULL|NULL
Conditions
Actions
SelectSubUnits = Region; models $mdl_USA_Inf5
AlterCuSubUnit = ApplytoList; Attempts 1; Convert $mdl_USA_Inf1
SelectSubUnits = Region; models $mdl_USA_Inf56
AlterCuSubUnit = ApplytoList; Attempts 1; Convert $mdl_USA_Inf2
EndEvent
If tyou want more informations about the structure file contents, you will have to download the DB files and I will try to answer your questions. DB files have a lot of comments from game designer that can help understand files contents.
Regards
Re: Abilities on structures?
Posted: Sat Apr 29, 2017 9:28 pm
by johandenver2
Thanks!
I've downloaded the DB-files and got a lot of information from them. I think I know how to simulate prisons by event but I still can't figure out the mechanism behind the ability "MedicalService" or how to use that in an event.
I'll read more in the DB-files and let you know if there's something specific I don't understand.
Thanks for all your help.
/Johan
Re: Abilities on structures?
Posted: Sun Apr 30, 2017 2:43 am
by Bohémond
If you want to ''associate'' the medical service ability to a structure, you will have to create a event associated with the structure that will be similar to ;
StartEvent = STRScriptHospital|999|0|NULL|NULL|NULL|NULL
Conditions
Actions
SelectSubUnits = Region
AlterCuSubUnit = ApplytoList; SetCohesionPerc Value 100
EndEvent
Regards
Re: Abilities on structures?
Posted: Sun Apr 30, 2017 10:32 am
by johandenver2
Thanks a million Bohémont, I really appriciate your information. I'll try all your suggestions and we'll see how it goes :-)
Re: Abilities on structures?
Posted: Sun Apr 30, 2017 5:42 pm
by Nikel
Bohémond is one of the ablest members of the forum , but posts too few.
Quite good that somebody gets him out of his cave

Re: Abilities on structures?
Posted: Thu May 04, 2017 2:31 am
by johandenver2
I tried the script below but the results are confusing me a bit.
For testing purposes I have created a brigade in the same city as the hospital is located and set their health and cohesion to 50. The brigade is organized as this:
ModelType0 = $mdl_USA_Inf5|1
ModelType1 = $mdl_USA_Inf5|1
ModelType2 = $mdl_USA_Inf6|1
ModelType3 = $mdl_USA_Inf6|1
ModelType4 = $mdl_USA_Shp2|1
The get the following names (in my game)
4th Missouri, 5th Missouri, 6th Missouri, 7th Missouri and 7th MO Sharpshooter Co
For some reason the script always picks 4th & 5th Missouri but it lowers cohesion to 15-16 and sets health to 600/600 (max amount of men)
I was expecting health to stay at 300/600 and cohesion to be 100.
Also I don't understand why the script never picks any of the other units.
I've attached the script log at the bottom of this message.
Code: Select all
StartEvent = STRScriptHospital|999|0|NULL|NULL|NULL|NULL
Conditions
Actions
SelectSubUnits = Region; models $mdl_USA_Inf5
AlterCuSubUnit = ApplytoList; SetCohesionPerc Value 100
SelectSubUnits = Region; models $mdl_USA_Inf5
AlterCuSubUnit = ApplytoList; SetCohesionPerc Value 100
DescEvent = evt_STRScriptHospital
GenMsg
EndEvent
Code: Select all
No error in this script
--------------START OF SCRIPT----------------
Line 0: Started processing event: STRScriptHospital
Line 0: This event is not yet referenced, base number of allowed occurences 999
Line 4: Entering triggered actions for event STRScriptHospital
Line 5: SelectSubUnits 1003271 5th Missouri added, List Count now at: 1
Line 5: SelectSubUnits 1003270 4th Missouri added, List Count now at: 2
Line 5: SelectSubUnits finished Regions Selected: 1 SubUnits Selected: 2
Line 6: AlterCuSubUnit 1003271 5th Missouri cohesion changed to 1
Line 6: AlterCuSubUnit 1003270 4th Missouri cohesion changed to 1
Line 7: SelectSubUnits 1003271 5th Missouri added, List Count now at: 1
Line 7: SelectSubUnits 1003270 4th Missouri added, List Count now at: 2
Line 7: SelectSubUnits finished Regions Selected: 1 SubUnits Selected: 2
Line 8: AlterCuSubUnit 1003270 4th Missouri cohesion changed to 1
Line 8: AlterCuSubUnit 1003271 5th Missouri cohesion changed to 1
Line 13: Finished processing event: STRScriptHospital
Line 13: ------------------------------
------------------------------
Error(s) found: 0
Warning(s) found: 0
--------------END OF SCRIPT----------------
Re: Abilities on structures?
Posted: Thu May 04, 2017 10:12 am
by johandenver2
StartEvent = STRScriptHospital|999|0|NULL|NULL|NULL|NULL
Conditions
Actions
SelectSubUnits = Region; models $mdl_USA_Inf5
AlterCuSubUnit = ApplytoList; SetCohesionPerc Value 100
SelectSubUnits = Region; models $mdl_USA_Inf6
AlterCuSubUnit = ApplytoList; SetCohesionPerc Value 100
DescEvent = evt_STRScriptHospital
GenMsg
Ok, I corrected the stupid mistake above so now all but one (4th Missouri) get full health and very low cohesion. Even the sharpshooter unit that I would think isn't included in the script above?
Re: Abilities on structures?
Posted: Thu May 04, 2017 12:58 pm
by johandenver2
I think I got it working ok with this script:
With this all units will get stronger than if the hospital wasn't there but not go to full health and cohesion within 1 turn.
Code: Select all
StartEvent = STRScriptHospital|999|0|NULL|NULL|NULL|NULL
Conditions
Actions
SelectSubUnits = Region
AlterCuSubUnit = ApplytoList; ChgCohesionPerc 25
SelectSubUnits = Region
AlterCuSubUnit = ApplytoList; ChgHealthPerc 25
DescEvent = evt_STRScriptHospital
GenMsg
EndEvent
Re: Abilities on structures?
Posted: Thu May 04, 2017 1:09 pm
by Bohémond
Nice job.
As you noted, there was a syntax error in my template (Value should not be there).
Regards
Re: Abilities on structures?
Posted: Thu May 04, 2017 3:46 pm
by Pocus
Good job and congrats also to Bohémond!
Re: Abilities on structures?
Posted: Thu May 04, 2017 11:20 pm
by johandenver2
Thanks, I'm quite pleased with the result, couldn't have done it without your help though :-)
Is it possible to get a news item out of this script as well?
I've tried the usual way, that works when dealing with regular events but I never get any news when my modded structures produce or alter stuff.
Re: Abilities on structures?
Posted: Fri May 05, 2017 12:10 am
by Bohémond
Do you add the event name to the localStrings file and switch the 0 to 1 in the StartEvent SctiptCommand ?
Re: Abilities on structures?
Posted: Fri May 05, 2017 12:52 am
by johandenver2
Arrrg, I forgot about changing 0 to 1...thanks. Now it's working as expected :-)
Re: Abilities on structures?
Posted: Sun May 07, 2017 10:40 pm
by johandenver2
Is there a way to make the messages appear only in a unit actually was trained/healed at a structure?
Right now I'm getting messages every turn even if no unit is present.
I suspect I could use some sort of eval-function but I don't know the syntax at all for this.
Re: Abilities on structures?
Posted: Mon May 08, 2017 12:51 am
by Bohémond
You can switch back the 1 to 0 in the StartEvent Scriptcommand.
Then add a GenTextMsg ScriptCommand (
http://www.ageod.net/agewiki/GenTextMsg) in the action Block.
Please let me know if it helps.
Regards
Re: Abilities on structures?
Posted: Tue May 09, 2017 12:36 am
by johandenver2
I tried this but the result is unfortunately the same.
Code: Select all
StartEvent = STRScriptHospital|999|0|NULL|NULL|NULL|NULL
Conditions
Actions
SelectSubUnits = Region
AlterCuSubUnit = ApplytoList; ChgCohesionPerc 25
SelectSubUnits = Region
AlterCuSubUnit = ApplytoList; ChgHealthPerc 25
GenTextMsg = evt_STRScriptHospital|999|NULL|NULL|NULL
EndEvent
Re: Abilities on structures?
Posted: Tue May 09, 2017 1:45 am
by Bohémond
The event is always true as the Conditions Block is empty.
You can try this ;
StartEvent = STRScriptHospital|999|0|NULL|NULL|NULL|NULL
Conditions
SelectSubUnits = Region
EvalSubUnitSel = NULL
Actions
SelectSubUnits = Region
AlterCuSubUnit = ApplytoList; ChgCohesionPerc 25
SelectSubUnits = Region
AlterCuSubUnit = ApplytoList; ChgHealthPerc 25
GenTextMsg = evt_STRScriptHospital|1|NULL|NULL|NULL
EndEvent
The event will fire only if at least one element is present in the region.
Note that change the 999 in the GenTextMsg to 1.
Let me know if it helps
Regards
Re: Abilities on structures?
Posted: Tue May 09, 2017 2:32 am
by johandenver2
That did the trick, thanks a lot (again) :-)
Re: Abilities on structures?
Posted: Tue May 09, 2017 5:51 pm
by Bohémond
You are welcome.
Do not hesitate to ask if you have any issue,
Regards
Re: Abilities on structures?
Posted: Wed May 10, 2017 3:23 pm
by johandenver2
Can I somehow reference the specific region in my message?
For example I'd like my final message to be something like,
"Units have been trained at Jefferson Barracks, St Louis"
Is that possible?