Jump to content


Photo

MultiMod detection system


  • Please log in to reply
43 replies to this topic

#21 Finaldeath

Finaldeath
  • Project Team
  • 188 posts
  • Location:UK

Posted 30 April 2006 - 07:14 PM

Cpu_DoString() in each night maps SCAR file would be the best idea, and also would remove any need for the AI to get the locally running mod.

The local.ini I never thoguht was a reliable way to get the currently running mod.

#22 ArkhanTheBlack

ArkhanTheBlack

    title available

  • Members
  • 814 posts

Posted 30 April 2006 - 08:46 PM

The price question is now:

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 Palii

Palii
  • Members
  • 6 posts

Posted 30 April 2006 - 10:50 PM

Thud! Good news here. Finaldeath wrote up a scar file, that could be a possible solution. I've it sent to you in email, it declares a variable to each player on any night map. I hope this works out.

Edited by Palii, 30 April 2006 - 10:52 PM.


#24 Finaldeath

Finaldeath
  • Project Team
  • 188 posts
  • Location:UK

Posted 30 April 2006 - 11:38 PM

Arkhan, if you read my thread, and the wiki link I put there with the final definitoin, you'll know it is just as if a AI script with those contents were exceuted - if you don't use "local" it'll be a global variable (just as anything in LUA!)

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 thudo

thudo

    Wacko AI Guy!

  • Division Leaders
  • 12,166 posts
  • Location:Lemonville North, Canada
  • Projects:DoW AI Scripting Project
  • Division:DoW
  • Job:Division Leader

Posted 01 May 2006 - 12:40 AM

Okay cool..

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" )

end
Somehow 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.
Advanced Skirmish AI Team Lead for the coolest Warhammer40k PC RTS out there:

Dawn of War Advanced AI Headquarters

Latest DoW Advanced AI Download!

#26 LarkinVB

LarkinVB

    title available

  • Members
  • 1,488 posts

Posted 01 May 2006 - 07:18 AM

Nope Thudo, wrong take.

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 Finaldeath

Finaldeath
  • Project Team
  • 188 posts
  • Location:UK

Posted 01 May 2006 - 07:18 AM

No, thud, we don't "create a function". We "set a variable"...
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 LarkinVB

LarkinVB

    title available

  • Members
  • 1,488 posts

Posted 01 May 2006 - 09:17 AM

Bingo ! Very close finish, Finaldeath. Beat you by some seconds ;)

#29 thudo

thudo

    Wacko AI Guy!

  • Division Leaders
  • 12,166 posts
  • Location:Lemonville North, Canada
  • Projects:DoW AI Scripting Project
  • Division:DoW
  • Job:Division Leader

Posted 01 May 2006 - 11:44 AM

Thanks chaps.. Missed it by a bit.. okay.. will extensively test tonight! ;)
Advanced Skirmish AI Team Lead for the coolest Warhammer40k PC RTS out there:

Dawn of War Advanced AI Headquarters

Latest DoW Advanced AI Download!

#30 thudo

thudo

    Wacko AI Guy!

  • Division Leaders
  • 12,166 posts
  • Location:Lemonville North, Canada
  • Projects:DoW AI Scripting Project
  • Division:DoW
  • Job:Division Leader

Posted 02 May 2006 - 01:29 AM

Update.. okay this is f**ed up..

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 then
However.. it does not work. BUT.. if I do this:
if "playing_night_map = 1" then
it 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?
Advanced Skirmish AI Team Lead for the coolest Warhammer40k PC RTS out there:

Dawn of War Advanced AI Headquarters

Latest DoW Advanced AI Download!

#31 thudo

thudo

    Wacko AI Guy!

  • Division Leaders
  • 12,166 posts
  • Location:Lemonville North, Canada
  • Projects:DoW AI Scripting Project
  • Division:DoW
  • Job:Division Leader

Posted 03 May 2006 - 12:17 AM

Sorry folks.. Revora was down.. anything you have re: above would be most welcome as to why its not working.
Advanced Skirmish AI Team Lead for the coolest Warhammer40k PC RTS out there:

Dawn of War Advanced AI Headquarters

Latest DoW Advanced AI Download!

#32 Finaldeath

Finaldeath
  • Project Team
  • 188 posts
  • Location:UK

Posted 03 May 2006 - 01:12 AM

I never ever tested the SCAR script and havn't had a chance to do any mapping or DOW work for a while - make sure that playing_night_map exists by using print to debug it.

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 LarkinVB

LarkinVB

    title available

  • Members
  • 1,488 posts

Posted 03 May 2006 - 06:08 AM

Send me the map with SCAR and I will start some debugging.

#34 thudo

thudo

    Wacko AI Guy!

  • Division Leaders
  • 12,166 posts
  • Location:Lemonville North, Canada
  • Projects:DoW AI Scripting Project
  • Division:DoW
  • Job:Division Leader

Posted 03 May 2006 - 11:55 AM

Larkin.. you have a copy of the latest Night_Shift Beta.. look in \Night_Shift\data\scenarios\mp and the map filenames "night_internal_2p_blood_river".. As for the scar file.. just use one of the messages above to create the .scar file and place it in the same folder where the map is (\Night_Shift\data\scenarios\mp) and call it: night_internal_2p_blood_river.scar Let me know.. I'll do more testing tonight as well. Thanks for your help!
Advanced Skirmish AI Team Lead for the coolest Warhammer40k PC RTS out there:

Dawn of War Advanced AI Headquarters

Latest DoW Advanced AI Download!

#35 Palii

Palii
  • Members
  • 6 posts

Posted 03 May 2006 - 07:40 PM

I started coding Scar a few days ago and I stumbled across a function. It supposed to enable an ai component.
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 LarkinVB

LarkinVB

    title available

  • Members
  • 1,488 posts

Posted 03 May 2006 - 08:08 PM

I just tested and it works flawlessly with Cpu_DoString(playerid, "playing_night_map = 1") and the check for playing_night_map == 1 !

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 :rolleyes:

Guess you are ready to go Palii !

#37 Palii

Palii
  • Members
  • 6 posts

Posted 03 May 2006 - 08:13 PM

Wow! Thank you for that great news LarkinVB! Everything is already in place and now we know it works! Congratulations to the whole AI team!

Edited by Palii, 04 May 2006 - 12:01 AM.


#38 thudo

thudo

    Wacko AI Guy!

  • Division Leaders
  • 12,166 posts
  • Location:Lemonville North, Canada
  • Projects:DoW AI Scripting Project
  • Division:DoW
  • Job:Division Leader

Posted 03 May 2006 - 08:14 PM

Larkin..

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!
Advanced Skirmish AI Team Lead for the coolest Warhammer40k PC RTS out there:

Dawn of War Advanced AI Headquarters

Latest DoW Advanced AI Download!

#39 LarkinVB

LarkinVB

    title available

  • Members
  • 1,488 posts

Posted 03 May 2006 - 08:47 PM

1. It does work with or without -dev.
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 ArkhanTheBlack

ArkhanTheBlack

    title available

  • Members
  • 814 posts

Posted 03 May 2006 - 09:10 PM

If we would set the variable for all players and not just for AI players, then it should also work with autoexec, right? At least if DOW doesn't crash when setting variables for real players...




5 user(s) are reading this topic

0 members, 5 guests, 0 anonymous users