MultiMod detection system
#21
Posted 30 April 2006 - 07:14 PM
The local.ini I never thoguht was a reliable way to get the currently running mod.
#22
Posted 30 April 2006 - 08:46 PM
How is it possible to access the variables set with Cpu_DoString()? Are they simple globals in the AI environment or are there special functions required to read them?
Edited by ArkhanTheBlack, 30 April 2006 - 08:47 PM.
#23
Posted 30 April 2006 - 10:50 PM
Edited by Palii, 30 April 2006 - 10:52 PM.
#24
Posted 30 April 2006 - 11:38 PM
The script is this, if anyone wants to know:
------------------------------------------------- -- Night Map variable setting ------------------------------------------------- import("ScarUtil.scar") import("WXPScarUtil.scar") function OnGameRestore() -- Reload this variable just in case SetNightMod() end function OnInit() -- Set the variable on each CPU player SetNightMod() end function SetNightMod() -- For each player in the world, we set the Cpu variable for the night mod, if they are -- a cpu player. for i = 0, World_GetPlayerCount() - 1 do playerid = World_GetPlayerAt( i ) if Cpu_IsCpuPlayer( playerid ) then -- Set the variable to 1 Cpu_DoString(playerid, "playing_night_map = 1") -- set "blah" to "1" end end end Scar_AddInit(OnInit)
Currently untested however.
#25
Posted 01 May 2006 - 12:40 AM
So now I take the script should read, using SM for example..
if SetNightMod() == 1 then local light1_id = cpu_manager.stats:GetAbilityID( "marines_searchlight_rhino" ) Ability.DoAbilitySearchLight( self.squad_ai, light1_id, " vehicle" ) endSomehow I think I'm missing a function here set in our AI. However, this will, of course, be useful code down the road to know this.
Dawn of War Advanced AI Headquarters
Latest DoW Advanced AI Download!
#26
Posted 01 May 2006 - 07:18 AM
Try this
if playing_night_map == 1 then local light1_id = cpu_manager.stats:GetAbilityID( "marines_searchlight_rhino" ) Ability.DoAbilitySearchLight( self.squad_ai, light1_id, " vehicle" ) end
#27
Posted 01 May 2006 - 07:18 AM
if playing_night_map == 1 then local light1_id = cpu_manager.stats:GetAbilityID( "marines_searchlight_rhino" ) Ability.DoAbilitySearchLight( self.squad_ai, light1_id, " vehicle" ) end
#28
Posted 01 May 2006 - 09:17 AM
#29
Posted 01 May 2006 - 11:44 AM
Dawn of War Advanced AI Headquarters
Latest DoW Advanced AI Download!
#30
Posted 02 May 2006 - 01:29 AM
I have this in the \Night_Shift\data\scenarios\mp folder where the map is located that I am testing:
Mapname: night_internal_2p_blood_river
Filename of below: night_internal_2p_blood_river.scar
And its code:
------------------------------------------------- -- Night Map variable setting ------------------------------------------------- import("ScarUtil.scar") import("WXPScarUtil.scar") function OnGameRestore() -- Reload this variable just in case SetNightMod() end function OnInit() -- Set the variable on each CPU player SetNightMod() end function SetNightMod() -- For each player in the world, we set the Cpu variable for the night mod, if they are -- a cpu player. for i = 0, World_GetPlayerCount() - 1 do playerid = World_GetPlayerAt( i ) if Cpu_IsCpuPlayer( playerid ) then -- Set the variable to 1 Cpu_DoString(playerid, "playing_night_map = 1") -- set "blah" to "1" end end end Scar_AddInit(OnInit)Now the code that checks for the 1 being set:
if playing_night_map == 1 thenHowever.. it does not work. BUT.. if I do this:
if "playing_night_map = 1" thenit will work for Night maps but also for NON Night maps. AI uses its searchlights on non-night maps! Arghhh!
Could it be the scar file for the map causing this?
Dawn of War Advanced AI Headquarters
Latest DoW Advanced AI Download!
#31
Posted 03 May 2006 - 12:17 AM
Dawn of War Advanced AI Headquarters
Latest DoW Advanced AI Download!
#32
Posted 03 May 2006 - 01:12 AM
You can also add print to the SCAR file, eg:
------------------------------------------------- -- Night Map variable setting ------------------------------------------------- import("ScarUtil.scar") import("WXPScarUtil.scar") function OnGameRestore() -- Reload this variable just in case SetNightMod() end function OnInit() -- Set the variable on each CPU player SetNightMod() end function SetNightMod() -- For each player in the world, we set the Cpu variable for the night mod, if they are -- a cpu player. for i = 0, World_GetPlayerCount() - 1 do playerid = World_GetPlayerAt( i ) if Cpu_IsCpuPlayer( playerid ) then -- Debug: display this plus the index-0 player number. print("We are setting night map for CPU player number"..i) -- Set the variable to 1 Cpu_DoString(playerid, "playing_night_map = 1") end end end Scar_AddInit(OnInit)
Might be problems either end, but I did test this quite a bit when I had time before (noting the thread and wiki entry).
You can even call functions from Cpu_DoString(), basically any code, so no idea why this wouldn't work unless you needed something like "cpu_manager.value" or something...heh.
Ya, larkin, close finish, heh.
#33
Posted 03 May 2006 - 06:08 AM
#34
Posted 03 May 2006 - 11:55 AM
Dawn of War Advanced AI Headquarters
Latest DoW Advanced AI Download!
#35
Posted 03 May 2006 - 07:40 PM
Cpu_EnableComponent( PlayerID player, Boolean enable, Integer ct )I have no idea what an AI component is, but this seems like another communication channel between Map Scar and AI.
Example Usage from one of Relic's Missions:
Cpu_EnableComponent( g_Player3, false, CT_Attacking )
So CT_Attacking is an AI Component, that can be enabled/disabled. Can you guys relate to this?
Maybe a new dummy component can be created, that is enabled by the map, thus telling the AI about the night map.
#36
Posted 03 May 2006 - 08:08 PM
No idea why it didn't work for thudo. I debugged and the value is set as expected and working in the respective vehicletactic.ai files.
It does NOT work for the human player if he is set to be played by AI with the autoexec.lua trick. This is no real problem as we use it only for quick AI vs AI test battles.
Usually the mod will be played by a human player, right
Guess you are ready to go Palii !
#37
Posted 03 May 2006 - 08:13 PM
Edited by Palii, 04 May 2006 - 12:01 AM.
#38
Posted 03 May 2006 - 08:14 PM
1) Does it work with -dev ?
2) Which .scar did you use? The latest one from FD? Not that it matters..
3) As for it not working for Player0.. Hmm.. I wonder.. will test that ASAP.. Then once confirmed, its all for Palii!
Dawn of War Advanced AI Headquarters
Latest DoW Advanced AI Download!
#39
Posted 03 May 2006 - 08:47 PM
2. I did copy&paste scar code from this thread, post #32.
3. Seems the map SCAR Cpu_IsCpuPlayer() is not true for player 0 regardless of Cpu_ControlLocalPlayer() in autoexec.lua. Who cares ?
Edited by LarkinVB, 03 May 2006 - 08:58 PM.
#40
Posted 03 May 2006 - 09:10 PM
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users