Uhm.. anyone knows how to access to Daimyo Honour?? I would like to add some events about it...
Uhm.. anyone knows how to access to Daimyo Honour?? I would like to add some events about it...
Consider the postage stamp: its usefulness consists in the ability to stick to one thing till it gets there.- Josh Billings
My Tools, Tutorials and Resources
The creatures outside looked from pig to man, and from man to pig, and from pig to man again; but already it was impossible to say which was which.- George Orwell
Another thing It would be posible to use grant unit outside a dilemma??
I have been trying something like grant_unit (#capital, "inf_yari_samurai_ronin") to add some units to the AI without success..
Use 'create_force'.
I don't know the exact syntax right now, but thats the one to create any kind of army at any co-ords.
In the patch 5 pack (or data.pack)'s script you can find how the AI spawn units around campaigns, where the coordinate is given in the script as well. Each point is the size of a single "banner" on the map, so it shouldn't be too difficult for you to pop in a field army if you want to have one. Though I'm not sure what happens if you spawn a force right next to an opponent and whether or not that little yellow zone thing would apply.
There is a problem with fixed coordinates, You don't know which provinces will be hold by a clan at any time. Making a rule that spawn units at capitals (like grant unit for dilemma rules) will solve that problem or we will have to create, at least, 1 rule for each province and several army options to make it works with diferent clans..
There must be an easier way than that to spawn an army inside a province....
There's two possible issues here. 1.) grant_unit doesn't work for the AI. 2.) You are possibly using it wrong. Could you post the useage code here so I can take a look? For reference, here is an example:
Code:scripting.game_interface:grant_unit("settlement:ita_milano:milan", "Inf_Light_Lombardy-Cisalpine_Legion")
Consider the postage stamp: its usefulness consists in the ability to stick to one thing till it gets there.- Josh Billings
My Tools, Tutorials and Resources
The creatures outside looked from pig to man, and from man to pig, and from pig to man again; but already it was impossible to say which was which.- George Orwell
I think the problem might be that he wasn't using the "scripting.game_interface" prefix, as in the missions scripts there is only "grant_unit..." ?
Consider the postage stamp: its usefulness consists in the ability to stick to one thing till it gets there.- Josh Billings
My Tools, Tutorials and Resources
The creatures outside looked from pig to man, and from man to pig, and from pig to man again; but already it was impossible to say which was which.- George Orwell
I always come to this point when scripting eventualy, where something you want to do becomes more work than its worth. =P
Is there a way to possibly create a mission, and have it autocomplete right away to just get the grantunit function to fire? Just throwing ideas out here..
Last edited by T.C.; June 18, 2011 at 11:19 AM.
Consider the postage stamp: its usefulness consists in the ability to stick to one thing till it gets there.- Josh Billings
My Tools, Tutorials and Resources
The creatures outside looked from pig to man, and from man to pig, and from pig to man again; but already it was impossible to say which was which.- George Orwell
Well it isn't too hard, just time-consuming and frustrating knowing that if we had access to those functions definitions we could make it easier..
I had the same idea, but I will try to avoid it as long as I can find a more elegant way..
Great!, It could be nice to have some guidance, I'm still in bad shape about scripting.., last time I did it was with Med2..
I would like to ask two things
How RecruitUnit works?, force you to train a unit? or spawn it?
and I have created a rule to make all players at peace, but I can't remove alliances and protectorates or find a function about that..
Is there something like force_break_alliance/protectorate out there??
I have found force_make_protectorate/peace/trade and force_declare_war, but noting else..
Last edited by Thorn; June 18, 2011 at 01:08 PM.
Hello again guys,
At last I have understood how events and dilemmas works without using scripts, but now I'm a bit stuck with this..
events.FactionTurnStart[#events.FactionTurnStart+1] = function(context)
local Region = CampaignUI.RegionsOwnedByFaction(context)
endfor i = 1, #Region do
effect.adjust_treasury(10000, context)
end
I cant find why it isn't working, any clue?
Consider the postage stamp: its usefulness consists in the ability to stick to one thing till it gets there.- Josh Billings
My Tools, Tutorials and Resources
The creatures outside looked from pig to man, and from man to pig, and from pig to man again; but already it was impossible to say which was which.- George Orwell
Where have you seen this function?
Not that I'm aware of.
Ok, we'll start off with this. First, look here (and wait till the page fully loads so it jumps to the anchor tag) to see the sort of output that that function gives. As you can see, when it was originally logged it was logged as key, value, \n, key, value type, value. (so ignore the string:, function: and so on bits). I've been misreading what you wanted out of this, so you can disregard my eralier comment about string keys, rather than numerical keys (I thought you wanted region names) So a modified version of your script goes as follows:
Notes:Code:events.FactionTurnStart[#events.FactionTurnStart+1] = function(context) --This might work, not sure tbh ------------------------------------- local FactionString = context.string ------------------------------------- --if that doesn't work then for i = 1, # FactionsTable do if conditions.FactionName(FactionsTable[i], context) then local Region = CampaignUI.RegionsOwnedByFactionOrByProtectorates(FactionsTable[i]) for i = 1, #Region do scripting.game_interface:treasury_mod(FactionsTable[i], 10000) end end end
- Getting the faction name from context should work - I'd run logging tests on it first to find out (it could be context.String or context.FactionName)
- If that works replace the table entires with the variable FactionString
- If the above doesn't work you'll need to make a table with the factions you want to effect, I've named it FactionsTable in the example there - in NTW there's a handy function to generate a table of that sort, IDT it exists in S2.
- I've added a better treasury adjustment function there, however it doesn't accept negative figures. But it is more reliable apart from that.
And here's something I said I'd do quite a while ago. This code is used to get a region's key:
Once you have the region's key you can compare it to a table with the type of settlement names used for grant_unit() (eg "settlement:ita_milano:milan") and from there use grant_unit. If you want me to write the full code for something like this I will.Code:local RegionKey = nil local RegionAddress = nil local PlayersFaction = CampaignUI.PlayersFactionKey() local RegionList = CampaignUI.RetrieveFactionRegionList(PlayersFaction) for k, v in ipairs(RegionList) do --Get the regions address from the settlements address RegionAddress = CampaignUI.SettlementsRegion(v.SettlementAddress) --And from the settlements address the region's key RegionKey = CampaignUI.RegionKeyFromAddress(RegionAddress) --from here do something with RegionKey, as it will be overwritten each time the loop iterates. end![]()
Consider the postage stamp: its usefulness consists in the ability to stick to one thing till it gets there.- Josh Billings
My Tools, Tutorials and Resources
The creatures outside looked from pig to man, and from man to pig, and from pig to man again; but already it was impossible to say which was which.- George Orwell
I can't remember right now, I think from ETW/NTW Script-o-Rama
Well I tried this way and it works
I'm looking for a better function to gradually increase income from provinces to lessen the AI inability for developing a strong economy, but this get +1800 per province at the end of the game time, maybe it could seems a bit much, however by this time the Human player will have a very strong positionCode:events.FactionTurnStart[#events.FactionTurnStart+1] = function(context) local Region = CampaignUI.RegionsOwnedByFactionOrByProtectorates(context.string) local provincias = 0 local turno = CampaignUI.CurrentTurn(context) local factor = math.floor((turno*5)/math.log(turno+1)) if not conditions.FactionIsHuman(context) then for k,v in pairs(Region) do provincias = provincias +1 end effect.adjust_treasury(provincias*factor, context) end if turno < 6 then effect.adjust_treasury(125, context) elseif turno < 12 then effect.adjust_treasury(125, context) elseif turno < 24 then effect.adjust_treasury(125, context) end end
This is exactly the same as the NTW script o rama. Anyway, the function is used by the UI. But it needs arguments that are very specific to the UI environment, we wouldn't be able to generate them from a campaign scripting point of view.
CampaignUI.CurrentTurn() doesn't need a context argument. Luckily Lua discards superflous arguments, saving a lot of errors
The function itself is good, you just need to play about with your mathematical formula's to get better results.
Consider the postage stamp: its usefulness consists in the ability to stick to one thing till it gets there.- Josh Billings
My Tools, Tutorials and Resources
The creatures outside looked from pig to man, and from man to pig, and from pig to man again; but already it was impossible to say which was which.- George Orwell