It is a guessing game. With the parameters you use the game will likely crash. I couldn't find to right parameters for the function yet.
It is a guessing game. With the parameters you use the game will likely crash. I couldn't find to right parameters for the function yet.
create_agent("faction_key", "agent_key", x_position, y_position, "id", true)
First parameter is the faction key, second the agent key, third and fourth the X/Y coordinates, fourth is a string identifier likely useless to you, last parameter sets whether the command happens immediately (false) or at the next best moment (true, should always be true for modders).
The formal disclaimer: Any views or opinions expressed here are those of the poster and do not necessarily represent the views or opinions of The Creative Assembly or SEGA.
Thank you for dropping by.
So the region was not needed, actually haven't tried it without the region name...![]()
Thank you Mitch. I tried this in order to get a spy in sicily for debugging reasons (see what Syracuse AI will do an which units they recruit):
However, it doesn't work. Note that I used a dignitary instead of a spy to exclude agent limit as a possible bug.Code:local function CreateDebugSpy(context) local current_faction = context.string; if context:faction():is_human() == true and conditions.TurnNumber(context) == 2 then scripting.game_interface:create_agent(current_faction,"dignitary",295,574,"001S",true); end end scripting.AddEventCallBack("OnFactionTurnStart", CreateDebugSpy);
conditions.TurnNumber(context) ? Don't think this works.
Well, I took it from the CiG scripts, where something similar is actually working:
Code:if conditions.TurnNumber(context) == 1 and not CampaignUI.IsMultiplayer() and conditions.FactionIsLocal(context) then
I hope people are still around who are able to help. I have pored over and over this code. I am not sure the code is the problem so I am going to attach the whole mod in case I have missed something in the db tables.
This is a really simple supply script. But basically nothing happens. Originally I had the code as a separate file but in desperation I have now tried adding it to the end of the campaign script
Here is the code:
Code:-- KANKRUSHA'S SIMPLIFIED SUPPLY SCRIPT -- There are 4 levels of supply from very good which grants benefits to very poor which inflicts penalties -- Moving will lower supply. -- Keeping stationary while in your own region will improve supply -- Make the script a module one -- module(..., package.seeall); -- commented out now -- load libraries scripting = require "lua_scripts.EpisodicScripting" events = require "data.lua_scripts.events" require "data.lua_scripts.lib_export_triggers" local function kk_supply_script(context) if not char_is_general_with_army(context:character()) then return false end -- Remove all previous effects scripting.game_interface:remove_effect_bundle_from_characters_force("rom_supply_1", context:character():cqi()) scripting.game_interface:remove_effect_bundle_from_characters_force("rom_supply_2", context:character():cqi()) scripting.game_interface:remove_effect_bundle_from_characters_force("rom_supply_3", ccontext:character():cqi()) scripting.game_interface:remove_effect_bundle_from_characters_force("rom_supply_4", context:character():cqi()) -- Siege has its own system so don't want that here if character:has_garrison_residence() and character:garrison_residence():is_under_siege() then return end -- Increase supply if stationary if context:character():action_points_remaining_percent() >= 90 then if context:character():turns_in_own_regions() >= 2 then scripting.game_interface:apply_effect_bundle_to_characters_force("rom_supply_4", context:character():cqi(),-1) elseif context:character():turns_in_own_regions() >= 1 then scripting.game_interface:apply_effect_bundle_to_characters_force("rom_supply_3", context:character():cqi(),-1) elseif context:character():turns_in_enemy_regions() >= 5 then -- Supply always poor if in enemy territory too long scripting.game_interface:apply_effect_bundle_to_characters_force("rom_supply_1", context:character():cqi(),-1) else scripting.game_interface:apply_effect_bundle_to_characters_force("rom_supply_2", context:character():cqi(),-1) end end -- Decrease supply if moved this turn if context:character():action_points_remaining_percent() < 90 then if context:character():turns_in_enemy_regions() >= 2 then scripting.game_interface:apply_effect_bundle_to_characters_force("rom_supply_1", context:character():cqi(),-1) elseif context:character():turns_in_enemy_regions() >= 1 then scripting.game_interface:apply_effect_bundle_to_characters_force("rom_supply_2", context:character():cqi(),-1) else scripting.game_interface:apply_effect_bundle_to_characters_force("rom_supply_3", context:character():cqi(),-1) end end return true end scripting.AddEventCallBack("CharacterTurnEnd", kk_supply_script)
Last edited by Col.KanKrusha; April 26, 2016 at 03:07 PM.
~ Too soon old, too late smart ~
EncylopediaEntryRequested, CharacterSelected and others events does not work
Hi All!, please help me with this script:
function OnLEFUI(context)
if context:faction():name() == "rom_roxolani" and context:faction():is_human() == false then
scripting.game_interface:create_force("rom_roxolani", "Ste_Royal_Horse_Archers", "rom_scythia_scythia",510,430, "patrol1", true)
end;
end;
scripting.AddEventCallBack("SavingGame", OnLEFUI);
--more saves - more troops to AI
Hi
In the "context" of saving a game I think you would have to first identify the player
player_faction = GetPlayerFaction();
if player_faction ==
~ Too soon old, too late smart ~
local function OnSavingGame(context)
scripting.game_interface:create_force("rom_roxolani", "Ste_Royal_Horse_Archers", "rom_scythia_scythia",510,430, "patrol1", true)
end;
this code create army ? but then appear window about violation of boarders and UI freeze. How to fix it?
Where did you get the co-ordinates? Are they correct?
also I would Add a check that the faction still exists
I am worried this is going to run at the end of every turn with autosave
~ Too soon old, too late smart ~
Ok, I want spawn AI forces with events, but not with "FactionTurnStart". I try "SettlementSelected" but that no work. Coordinates is correct.
How about when settlement attackied? If you have Caesar in Gaul DLC there is a function In the campaign script that you could copy to main campaign
or whenever the human player spawns a new general (oncharactercreated) then you could have AI spawn one to match
~ Too soon old, too late smart ~
onCharacterCreated work, thanks. How i can get cursor or settlement coordinates?
ok, all done
Well done. You should feel a sense of achievement, my own script which looks perfect to me is still dead in the water.
~ Too soon old, too late smart ~
hmmm, someone else working command - create_agent?
I used this func, but not worked.
local function OnGenerateSpy(context)
if not CampaignUI.IsMultiplayer() then
scripting.game_interface:create_agent("rom_roxolani","spy",750,530,"dbspy",true)
end
end
and how i can get a settlement name from function context?
Have a look at page 1 of this thread
I think this will work (but haven't looked through code to check)
if context:region():name()== "rom_rome"
(from wrath of Sparta script)
there is is also a region_in_region_list function. Take this. It's dangerous to go alone
http://pastebin.com/GF4ubMMm
Last edited by Col.KanKrusha; May 09, 2016 at 02:31 PM.
~ Too soon old, too late smart ~