Jump to content


Photo

AI to use Outpost Expansion Plots


  • Please log in to reply
5 replies to this topic

#1 JUS_SAURON

JUS_SAURON

    El Shaddai

  • Members
  • 1,581 posts
  • Location:Trinidad
  • Projects: BFME2 MOD - Power Of The Ring
  •   INI Coder

Posted 16 June 2020 - 04:15 AM

So I am very close to achieving BFME1 style in ROTWK or BFME2

 

I am able to get the AI to hunt for Econ Plots and Build Farms

I am able to get the Castle startup , and AI build varied Buildings on the plots

I am able to get the AI to hunt for Outposts Plots and Build the Outposts ( this has 3 Buildplots)

I cannot get the AI to build on these plots , they only build the Outpost but no additional buildings

 

The script below works up to the line to create a building

It is in Skirmish Men folder

So below works fine , the Base is unpacked , but the line to build a farm etc does not work 

 

PS : strange as this may seem , I sometimes get farms built on BASE_FLAG_8 only , only farm , never another building , never another Base_Flag

 

I hate scripting , it does not follow set logic 

Its not a money issue , as my buildings cost $5 resources


*** IF ***
     Unit 'BASE_FLAG_8' is unpackable for the player: Player 'Player_2'.
    *AND*  Unit 'BASE_FLAG_8' has Less Than threat level 5.00 within radius 250.00
*** THEN ***
   Player '<This Player>' gets $ 200 
  Unpack the base: Unit 'BASE_FLAG_8'and reference it as UnitRef 'AI_BASE_8'.
   Unit 'AI_BASE_8' is transferred to the command of Player 'Player_2'
  Build building 'GondorBarracks' in base Unit 'AI_BASE_8' and reference it as UnitRef 'BARRACKS' .






*** IF ***
     Unit 'BASE_FLAG_7' is unpackable for the player: Player 'Player_2'.
    *AND*  Unit 'BASE_FLAG_7' has Less Than threat level 5.00 within radius 250.00
*** THEN ***
   Player '<This Player>' gets $ 200 
  Unpack the base: Unit 'BASE_FLAG_7'and reference it as UnitRef 'AI_BASE_7'.
   Unit 'AI_BASE_7' is transferred to the command of Player 'Player_2'
  Build building 'GondorBarracks' in base Unit 'AI_BASE_7' and reference it as UnitRef 'BARRACKS' .



*** IF ***
     Unit 'BASE_FLAG_10' is unpackable for the player: Player 'Player_2'.
    *AND*  Unit 'BASE_FLAG_10' has Less Than threat level 5.00 within radius 250.00
*** THEN ***
   Player '<This Player>' gets $ 200 
  Unpack the base: Unit 'BASE_FLAG_10'and reference it as UnitRef 'AI_BASE_10'.
   Unit 'AI_BASE_10' is transferred to the command of Player 'Player_2'
  Build building 'GondorFarm' in base Unit 'AI_BASE_10' and reference it as UnitRef 'house1' .
  Build building 'GondorBattleTower' in base Unit 'AI_BASE_10' and reference it as UnitRef 'TOWER' .

Edited by JUS_SAURON, 16 June 2020 - 04:17 AM.


#2 Echo

Echo

    T3A:Online

  • T3A Staff
  • 1,069 posts
  • Location:Germany
  • Projects:Lot3A
  •  ~~
  • Division:BFME
  • Job:T3A Moderator
  • Donated

Posted 16 June 2020 - 10:12 PM

My first guess would be that the AI can't build immediately after the base is unpacked because while a base is under construction, you can usually not build there. So the conditions are true, but the actions can't be executed successfully, so they might get thrown away. Instead of trying to build the buildings immediately, try setting a timer instead (10 seconds could work). Then have another script react to the timer expiration, and build the buildings then.

I think there is also a script that goes along the lines of "If player can build at base xy". You could also try to use that somehow. But first I would check if setting a timer works.


26285.png


#3 JUS_SAURON

JUS_SAURON

    El Shaddai

  • Members
  • 1,581 posts
  • Location:Trinidad
  • Projects: BFME2 MOD - Power Of The Ring
  •   INI Coder

Posted 16 June 2020 - 10:49 PM

I think I solved it

BTW this is a HUGE DEAL , meaning soon I will have functional BFME 1 style in BFME2 and ROTWK

I have actually been trying this for YEARS

 

Here it is , it may not actually make sense but who cares as long as it works

 

In Player 4 etc , which is a player setup

 

CODE A



*** IF ***
    Timer 'PlyrCivilian/BUILD' has expired.
*** THEN ***
   Unit 'BASE_FLAG_10' is transferred to the command of Player '<This Player>'
  Control of Team 'PlyrCivilian/Player_4_Inherit' transfers to Player '<This Player>'
  Set Player '<This Player>''s money to $ 10000 
  Unpack the base: Unit 'BASE_FLAG_10'and reference it as UnitRef 'AI_BASE_10'.

In MenSkirmish which handles all things AI

CODE B

*** IF ***
     Unit 'BASE_FLAG_10' is unpackable for the player: Player 'Player_4'.
    *AND*  Unit 'BASE_FLAG_10' has Less Than threat level 5.00 within radius 250.00
*** THEN ***
   Player '<This Player>' gets $ 200 
  Unpack the base: Unit 'BASE_FLAG_10'and reference it as UnitRef 'AI_BASE_10'.
   Unit 'AI_BASE_10' is transferred to the command of Player 'Player_4'
  Build building 'GondorFarm' in base Unit 'AI_BASE_10' and reference it as UnitRef 'house' .

CODE C

*** IF ***
     Unit 'Player_4/AI_BASE_10' is owned by Player '<This Player>'
*** THEN ***
  Set Player '<This Player>''s money to $ 100000 
  Build building 'GondorBarracks' in base Unit 'Player_4/AI_BASE_10' and reference it as UnitRef 'BARRACKS' .
  Build building 'GondorArcherRange' in base Unit 'Player_4/AI_BASE_4' and reference it as UnitRef 'ARCHERY' .
  Build building 'GondorFarm' in base Unit 'Player_4/AI_BASE_10' and reference it as UnitRef 'ARCHERY' .


Code B , by itself , allows for AI unpacking

Base 10 is usually an outpost

 

Code  A and C , by themselves , allow for map startup , i.e your players get a Castle and a few buildings

Do this for BASE_FLAG_1 to BASE_FLAG_4

 

If you have ALL three , but Deactivate (not Delete) Code A

It allows for a AI to unpack and build its buildings

 

And you choose what buildings assigned to what Base 

 

I will be uploading a Clean TEST Template version , as I know many here still wanted true BFME1 style in BFME2 or ROTWK

 

Still much to test and code , but it works  fine so far with BASE_FLAG_10 ,

 

I just have to code for Men Base Flag 5-9 and then all 7  Factions Base Flag 1-10 , X4 for each player 

Then output that script for a few other map 

CODE A



#4 JUS_SAURON

JUS_SAURON

    El Shaddai

  • Members
  • 1,581 posts
  • Location:Trinidad
  • Projects: BFME2 MOD - Power Of The Ring
  •   INI Coder

Posted 16 June 2020 - 11:29 PM

Yes , so far it works , finished and tested Plots All for Men 

All AI can use these plots and buildings are built 

I have been coding 2 weeks to find this solution , for hours each day until midnight 

 

I can finally see AI coming to life 

In a few weeks a fully functional Map will be ready for All factions , with working AI for buildings on plots 


Edited by JUS_SAURON, 17 June 2020 - 09:28 AM.


#5 Echo

Echo

    T3A:Online

  • T3A Staff
  • 1,069 posts
  • Location:Germany
  • Projects:Lot3A
  •  ~~
  • Division:BFME
  • Job:T3A Moderator
  • Donated

Posted 18 June 2020 - 04:10 PM

Glad that it works, but why didn't you try to add BFME1's libraries to BFME2 and make them work? Or did you try that? Adding these scripts to every map sounds like a problematic solution, especially if you find an error and then have to reimport the scripts to every single map. But if the outcome works for you, then that's good news. Does the AI build upgrades?


26285.png


#6 JUS_SAURON

JUS_SAURON

    El Shaddai

  • Members
  • 1,581 posts
  • Location:Trinidad
  • Projects: BFME2 MOD - Power Of The Ring
  •   INI Coder

Posted 19 June 2020 - 05:48 PM

Yes I tried BFME1 scripts (Libraries for AI )

Its a buggy mess that I can’t unravel 

I guess if it was easy it would have been done before 

I think Edain Mod  has done most of it , but I can’t seem to understand , as its a very complex German mod 

 

Thus far I am able to do the following as well as Identify problems with solutions 

1. Get AI to hunt for and unpack Unpack farms , using forced command button usage (GetCommandButton if upgrade present )
2. Get AI to hunt for and unpack outposts , using scripts , if I force command button Usage , they unpack but never build buildings as the reference cannot work 

3. If I build on an outpost , and then demolish it , the AI never can use it , they never unpack it
So multiple usage of an outpost is not achieved 

So I have no choice but to redo code so the outpost is totally destroyed , the spawned again as brand new with scripting 

This allows for AI to unpack and build their buildings 
 

The downside is that once the Main citadel goes , everything  is destroyed 
 

If I can solve why an outpost does not revert to its original state when destroyed , it would be a great help

You can notice this visually as the bib does not show the second time it is packed / unpacked 






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users