|
 |
| Author |
Message |
|
RxTEAM
|
Posted: 22 Mar, 2012
|
|
Joined: 02 Jun, 2010 Posts: 188
|
Hi, have seen in BO:Unleashed Balance mod that is is possible to change unit datas selective by human player or AI ... But the code here is set for Human player .... I need to change the Buildcosts (specialy the energy build costs) from a couple of buildings for AI players ONLY .... So any help here would be welcome  Regards R-TEAM
|
|
| Top |
|
 |
|
Domino
|
Posted: 22 Mar, 2012
|
|
Joined: 26 Feb, 2009 Posts: 2997
|
Hi, I did this for burnie in the total mayhem mod, it will also work for you.. http://pastebin.com/rSBYWCm2just put the unit bp ids of the units you want to lower the cost to build in Code: local LowerCostUnits = { } like EX: local LowerCostUnits = { 'uel0001', 'uel0002' } in lower case! you can also change the mult, 0.25 is a 25% decrease in cost for building mobile units.
_________________ Domino. ______________
|
|
| Top |
|
 |
|
phong1892
|
Posted: 22 Mar, 2012
|
|
Joined: 31 Mar, 2011 Posts: 128 Location: Hanoi, Vietnam
|
Domino wrote: Hi, I did this for burnie in the total mayhem mod, it will also work for you.. http://pastebin.com/rSBYWCm2just put the unit bp ids of the units you want to lower the cost to build in Code: local LowerCostUnits = { } like EX: local LowerCostUnits = { 'uel0001', 'uel0002' } in lower case! you can also change the mult, 0.25 is a 25% decrease in cost for building mobile units. Do I have to make a Blueprints.lua file in /mods/mymod/hook/lua/ and paste your code in? If not, how to make it work?
|
|
| Top |
|
 |
|
Domino
|
Posted: 23 Mar, 2012
|
|
Joined: 26 Feb, 2009 Posts: 2997
|
Hi, it would go in unit.lua in /hook/lua/sim/unit.lua 
_________________ Domino. ______________
|
|
| Top |
|
 |
|
liveordie
|
Posted: 23 Mar, 2012
|
|
Joined: 02 Jul, 2010 Posts: 1264
|
|
| Top |
|
 |
|
RxTEAM
|
Posted: 23 Mar, 2012
|
|
Joined: 02 Jun, 2010 Posts: 188
|
Hi, thanks Domino .... But i look more for an script like this in /hook/units/UAL0309/UAL0309_script.lua : Code: local prevClass = UAL0309
UAL0309 = Class(prevClass) { OnCreate = function(self) prevClass.OnCreate(self) if self:GetAIBrain().BrainType == 'Human' then self:AddBuildRestriction(categories.AEON * categories.BUILTBYTIER4COMMANDER) end end, } TypeClass = UAL0309
The only diff i need is (except i will change other units - to preciese ,the FABs ..) , i need the changes NOT for Human player - ONLY for AI player and i need to change the energy build costs ... Regards R-TEAM
|
|
| Top |
|
 |
|
DeadMG
|
Posted: 23 Mar, 2012
|
|
Joined: 15 Feb, 2007 Posts: 20036 Location: Presumably, at the time of posting, his computer.
|
|
AddBuildRestriction is an engine function. There may not be an equivalent function for changing build costs.
_________________ I'm watchin you!
|
|
| Top |
|
 |
|
RxTEAM
|
Posted: 24 Mar, 2012
|
|
Joined: 02 Jun, 2010 Posts: 188
|
Hi, so will this work ? : Code: local prevClass = UAL0309
UAL0309 = Class(prevClass) { OnCreate = function(self) prevClass.OnCreate(self) if self:GetAIBrain().BrainType != 'Human' then self:bp.Economy.BuildCostEnergy = bp.Economy.BuildCostEnergy * 0.25 end end, } TypeClass = UAL0309
have never doing scripts modding ... so i dont know which syntax/commands is available ...... Regards R-TEAM
|
|
| Top |
|
 |
|
Domino
|
Posted: 24 Mar, 2012
|
|
Joined: 26 Feb, 2009 Posts: 2997
|
|
Hi,
No pal, the only way i know of on how to lower the cost of building for the AI only via script is to use the code snippet i posted..
what it actually does is give the unit an adjacency buff bonus just for that build. its quick and easy and it works..
_________________ Domino. ______________
|
|
| Top |
|
 |
|
RxTEAM
|
Posted: 25 Mar, 2012
|
|
Joined: 02 Jun, 2010 Posts: 188
|
Hi, o.k. ... if this the only way then i musst it go  Have looked over the code and i think this should work to get the AI an 75% energy bonus by build the unit ual0309 (make it musst only pay 25% of the regulare energy) : Code: do local oldUnit=Unit Unit = Class(oldUnit) { OnStartBuild = function(self, unitBeingBuilt, order) oldUnit.OnStartBuild(self, unitBeingBuilt, order) if order == 'MobileBuild' then local LowerCostUnits = { ual0309 } local UBBBPID = unitBeingBuilt:GetBlueprint().BlueprintId local mult = 0.75 if table.find(LowerCostUnits, UBBBPID) then local AIBrain = self:GetAIBrain() if AIBrain.BrainType != 'Human' then self.EconChangedForIA = true self.EconChangedForIAValues = { Energy = self.EnergyBuildAdjMod } self.EnergyBuildAdjMod = mult self:UpdateConsumptionValues() end else if self.EconChangedForIA then local LastValues = self.EconChangedForIAValues self.EnergyBuildAdjMod = LastValues.Energy or nil self:UpdateConsumptionValues() self.EconChangedForIAValues = nil self.EconChangedForIA = nil end end end end, } end
But one thing i get confused : if order == 'MobileBuild' then.... If i understand this right - it only works is this unit build by an mobile builder (enginer as example ..) .. but i need to change the cost of the FABs IF it build by an enginer or IF it upgraded .... Regards R-TEAM
|
|
| Top |
|
 |
|
Domino
|
Posted: 26 Mar, 2012
|
|
Joined: 26 Feb, 2009 Posts: 2997
|
|
Hi,
IF you can wait til tomorrow, ill fix it to what you want it to do for factorybuild also and enhancing, ill also factor in the current buff if any and add that to the mult so you will end up with buffs + mult = cost..
im not doing any scripting tonight am recovering lol.
_________________ Domino. ______________
|
|
| Top |
|
 |
|
RxTEAM
|
Posted: 26 Mar, 2012
|
|
Joined: 02 Jun, 2010 Posts: 188
|
Hi, VERY Thanks Domino  To clarify it better ... I need this : Human Player Build FAB -> 100% Energy costs Upgrade FAB from T1 to T2 or T2 to T3 -> 100% Energy costs (so no need of change Human player values ..) AI Player Build FAB -> 25% Energy costs Upgrade -> 25% Energy costs The AI should get FABs and upgrades of FABs to lower energy costs The Unit IDs i know ....(this i can self set) Regards R-TEAM
|
|
| Top |
|
 |
|
Domino
|
Posted: 27 Mar, 2012
|
|
Joined: 26 Feb, 2009 Posts: 2997
|
Hi, Code: do local oldUnit=Unit Unit = Class(oldUnit) { OnStartBuild = function(self, unitBeingBuilt, order) oldUnit.OnStartBuild(self, unitBeingBuilt, order) local LowerCostUnits = { 'ual0309', 'upgradeunitid', 'nextupgradeunitid', 'and so on' } local UBBBPID = unitBeingBuilt:GetBlueprint().BlueprintId local mult = 0.25 -- 25% decrease in cost if table.find(LowerCostUnits, UBBBPID) then local AIBrain = self:GetAIBrain() if AIBrain.BrainType != 'Human' then self.EconChangedForIA = true self.EconChangedForIAValues = { Energy = self.EnergyBuildAdjMod, Mass = self.MassBuildAdjMod } self.EnergyBuildAdjMod = (self.EnergyBuildAdjMod or 0) + mult self.MassBuildAdjMod = (self.self.MassBuildAdjMod or 0) + mult self:UpdateConsumptionValues() end else if self.EconChangedForIA then local LastValues = self.EconChangedForIAValues self.EnergyBuildAdjMod = LastValues.Energy or nil self.MassBuildAdjMod = LastValues.Mass or nil self:UpdateConsumptionValues() self.EconChangedForIAValues = nil self.EconChangedForIA = nil end end end, } end so in this if any unit id is matched for the building of... its costs will get a 25% reduction from its current value, buffs included, so if if the unit already has a 10% buff add 25% to that will give it a 35% reduction.. just for AI units, you can use this to reduce the cost of any unit building or upgrading any other unit just enter the unit ids of the upgrade unit or the unit that is being built. The code goes in a hooked unit.lua using oldUnit as the unit hook identifier.
_________________ Domino. ______________
|
|
| Top |
|
 |
|
RxTEAM
|
Posted: 27 Mar, 2012
|
|
Joined: 02 Jun, 2010 Posts: 188
|
Hi, BIG Thanks Domino  If i remember my long time ago programming skills correct  ... then this should work, besides the filling with correct ID numbers for the units .. : Code: do local oldUnit=Unit Unit = Class(oldUnit) { OnStartBuild = function(self, unitBeingBuilt, order) oldUnit.OnStartBuild(self, unitBeingBuilt, order) local LowerCostUnits1 = { 'ual0309', 'upgradeunitid', 'nextupgradeunitid', 'and so on' } local LowerCostUnits2 = { 'ual0309', 'upgradeunitid', 'nextupgradeunitid', 'and so on' } local LowerCostUnits3 = { 'ual0309', 'upgradeunitid', 'nextupgradeunitid', 'and so on' } local UBBBPID = unitBeingBuilt:GetBlueprint().BlueprintId local mult1 = 0.75 -- 75% decrease in cost local mult2 = 0.50 -- 50% decrease in cost local mult3 = 0.33 -- 33% decrease in cost if table.find(LowerCostUnits1, UBBBPID) then local AIBrain = self:GetAIBrain() if AIBrain.BrainType != 'Human' then self.EconChangedForIA = true self.EconChangedForIAValues = { Energy = self.EnergyBuildAdjMod, Mass = self.MassBuildAdjMod } self.EnergyBuildAdjMod = (self.EnergyBuildAdjMod or 0) + mult1 self.MassBuildAdjMod = (self.self.MassBuildAdjMod or 0) self:UpdateConsumptionValues() end elseif table.find(LowerCostUnits2, UBBBPID) then local AIBrain = self:GetAIBrain() if AIBrain.BrainType != 'Human' then self.EconChangedForIA = true self.EconChangedForIAValues = { Energy = self.EnergyBuildAdjMod, Mass = self.MassBuildAdjMod } self.EnergyBuildAdjMod = (self.EnergyBuildAdjMod or 0) + mult2 self.MassBuildAdjMod = (self.self.MassBuildAdjMod or 0) self:UpdateConsumptionValues() end elseif table.find(LowerCostUnits3, UBBBPID) then local AIBrain = self:GetAIBrain() if AIBrain.BrainType != 'Human' then self.EconChangedForIA = true self.EconChangedForIAValues = { Energy = self.EnergyBuildAdjMod, Mass = self.MassBuildAdjMod } self.EnergyBuildAdjMod = (self.EnergyBuildAdjMod or 0) + mult3 self.MassBuildAdjMod = (self.self.MassBuildAdjMod or 0) self:UpdateConsumptionValues() end else if self.EconChangedForIA then local LastValues = self.EconChangedForIAValues self.EnergyBuildAdjMod = LastValues.Energy or nil self.MassBuildAdjMod = LastValues.Mass or nil self:UpdateConsumptionValues() self.EconChangedForIAValues = nil self.EconChangedForIA = nil end end end, } end
The only thing i am not sure is the "mass" part of the script ... I dont need to change anything on the mass (as my mod push mainly the energy costs, and the AI cant handle this good ....) and so i remove the "mult" from the mass lines ... or can i remove the lines with "mass" then completly ? (i am not sure musst the lines with "mass" still stay here ....) Regards R-TEAM
|
|
| Top |
|
 |
|
Domino
|
Posted: 27 Mar, 2012
|
|
Joined: 26 Feb, 2009 Posts: 2997
|
sure yeah that will work, if you dont need the mass stuff just remove it 
_________________ Domino. ______________
|
|
| Top |
|
 |
|
RxTEAM
|
Posted: 28 Mar, 2012
|
|
Joined: 02 Jun, 2010 Posts: 188
|
Hi, soooo ..... many thanks again Domino for the code  Have now testet (change the ..Braintype != Human to == Human  ) and found a couple of bugs ... but i get sortet all ... First the Buffs counting was wrong -> 0.25 get not an 25% buffer - it multiplied the base value WITH 0.25 and so you get an 75% buff .... And so its your code to add the buffs wrong too - as your asumed buff 0f 0.10 (10% i think you will get) is 0.90 ... and add to 0.25 the 0.90 you get over 1.x ....  Right it is -> 0.25 * 0.90. So here the corrected working code : Code: do local oldUnit=Unit Unit = Class(oldUnit) { OnStartBuild = function(self, unitBeingBuilt, order) oldUnit.OnStartBuild(self, unitBeingBuilt, order) local LowerCostUnits1 = { 'uab0202', 'uab0302', 'ueb0202', 'ueb0302', 'urb0202', 'urb0302', 'xsb0202', 'xsb0302' } local LowerCostUnits2 = { 'uab0201', 'uab0301', 'ueb0201', 'ueb0301', 'urb0201', 'urb0301', 'xsb0201', 'xsb0301' } local LowerCostUnits3 = { 'uab0203', 'uab0303', 'ueb0203', 'ueb0303', 'urb0203', 'urb0303', 'xsb0203', 'xsb0303' } local UBBBPID = unitBeingBuilt:GetBlueprint().BlueprintId local mult1 = 0.25 -- 75% decrease in cost local mult2 = 0.45 -- 65% decrease in cost local mult3 = 0.70 -- 30% decrease in cost if table.find(LowerCostUnits1, UBBBPID) then local AIBrain = self:GetAIBrain() if AIBrain.BrainType != 'Human' then self.EconChangedForIA = true self.EconChangedForIAValues = { Energy = self.EnergyBuildAdjMod } if self.EnergyBuildAdjMod > 0 then mult1 = mult1 * self.EnergyBuildAdjMod end self.EnergyBuildAdjMod = mult1 self:UpdateConsumptionValues() end elseif table.find(LowerCostUnits2, UBBBPID) then local AIBrain = self:GetAIBrain() if AIBrain.BrainType != 'Human' then self.EconChangedForIA = true self.EconChangedForIAValues = { Energy = self.EnergyBuildAdjMod } if self.EnergyBuildAdjMod > 0 then mult2 = mult2 * self.EnergyBuildAdjMod end self.EnergyBuildAdjMod = mult2 self:UpdateConsumptionValues() end elseif table.find(LowerCostUnits3, UBBBPID) then local AIBrain = self:GetAIBrain() if AIBrain.BrainType != 'Human' then self.EconChangedForIA = true self.EconChangedForIAValues = { Energy = self.EnergyBuildAdjMod } if self.EnergyBuildAdjMod > 0 then mult3 = mult3 * self.EnergyBuildAdjMod end self.EnergyBuildAdjMod = mult3 self:UpdateConsumptionValues() end else if self.EconChangedForIA then local LastValues = self.EconChangedForIAValues self.EnergyBuildAdjMod = LastValues.Energy or nil self:UpdateConsumptionValues() self.EconChangedForIAValues = nil self.EconChangedForIA = nil end end end, } end
The If/Then for "self.EnergyBuildAdjMod > 0" i have insert as i dont know like the engine mult operations again zero ...... Thanks for the Help Domino. Regards R-TEAM
|
|
| Top |
|
 |
|
Domino
|
Posted: 28 Mar, 2012
|
|
Joined: 26 Feb, 2009 Posts: 2997
|
Hi, Cool Beans! glad you figured it out, 
_________________ Domino. ______________
|
|
| Top |
|
 |
|
brandon007
|
Posted: 29 Mar, 2012
|
|
Joined: 16 Jan, 2010 Posts: 2908 Location: Draconis VII
|
Domino wrote: Hi, Cool Beans! glad you figured it out,  Look out! Hes got beans!
|
|
| Top |
|
 |
|
Domino
|
Posted: 29 Mar, 2012
|
|
Joined: 26 Feb, 2009 Posts: 2997
|
brandon007 wrote: Domino wrote: Hi, Cool Beans! glad you figured it out,  Look out! Hes got beans! LOL
_________________ Domino. ______________
|
|
| Top |
|
 |
|
RxTEAM
|
Posted: 26 Apr, 2012
|
|
Joined: 02 Jun, 2010 Posts: 188
|
Hi, as i have now the code working to reduce build costs for AI players (with big help from Domino  ) i thinking over if its possible to doing the same for Enhancement costs ? To clarify, to make the ACU upgrades for AI player cheaper. But i dont know how i set this up to this ... IF this possible .... (as i cant use the ACU UID ..... so it musst get other way to set this to an specific upgrade ....) Any help is welcome  Regards R-TEAM
|
|
| Top |
|
 |
|
Domino
|
Posted: 28 Apr, 2012
|
|
Joined: 26 Feb, 2009 Posts: 2997
|
|
Hi,
Do you ALL ai enhancements to be cheaper or just a select few?
_________________ Domino. ______________
|
|
| Top |
|
 |
|
RxTEAM
|
Posted: 28 Apr, 2012
|
|
Joined: 02 Jun, 2010 Posts: 188
|
|
Hi,
just a select few i need cheaper Domino ... ( all enginering updates T2/T3 and combat engenering T2/T3 , as the AI can build with T3 commander allready all T4 blackops units - the AI not need upgrade to T4 )
Regards R-TEAM
|
|
| Top |
|
 |
|
Domino
|
Posted: 30 Apr, 2012
|
|
Joined: 26 Feb, 2009 Posts: 2997
|
|
Hi,
Making just a select few more cheaper for AI is more difficult than making all AI enhancements cheaper, some kinda list has be made to say which ones are cheaper.. and by how much are they cheaper..
however if ALL AI built enh want to be cheaper its a simple function hook i can tell you how to do that.
_________________ Domino. ______________
|
|
| Top |
|
 |
|
RxTEAM
|
Posted: 30 Apr, 2012
|
|
Joined: 02 Jun, 2010 Posts: 188
|
Hi, its look its musst the hard way  As, i have an massive upgrade cost changing mod maked.But the AI dont play very well with this ... he dont can handle the higher costs.To change the AI is an very to big project - and i dont know can this be made as smart like an human player play with this high cost and found ways to negate the effect partialy .... So the easy way was to make the costs for the AI players like default (or around this value) ... but i have changed the upgrade costs for the ACU to higher tech levels too .. and here the AI still spend to much time and sucks ... so the best would be, make here the costs like default too .. as an side effect - the AI can now play much stronger as he have much easyer T2/T3 and Exp units as the Human player .. So i need to lower the energy/mass costs from the tech level upgrades to T2/T3 on the Black Ops ACU´s for the AI players only. Thanks for you Help Domino  Regards R-TEAM
|
|
| Top |
|
 |
|
RxTEAM
|
Posted: 04 Jun, 2012
|
|
Joined: 02 Jun, 2010 Posts: 188
|
|
Hi,
@Domino How would i make all enhancements to be cheaper for the AI ?
And btw. - i think it is not possible to reduce the energy usage from an Unit only for AI players. So i musst create an duplicate - can this be done easy (over scripting) or only with an full copy of the unit files ? And can i hide this new unit from the Human player - so it is only build by the AI(with propper AI integration) ..... ?
Regards R-TEAM
|
|
| Top |
|
 |
 |
 |
|