Jump to content


Photo

Flag to detect easy/normal/hard/brutal game mode?

scripting ai game mode

  • Please log in to reply
11 replies to this topic

#1 Fox-1

Fox-1
  • Members
  • 8 posts
  • Location:NL

Posted 24 February 2015 - 12:36 PM

This is either trivial (and I'm stupid) or it's just not possible...   Is there a way to detect in what difficulty a skirmish AI opponent is playing?

 

I tried the "Active in Easy / Active in Hard / etc..." options from the script properties but they don't seem to be doing anything.

 

 

(unmodded Kane's Wrath / WorldBuilder 1.0 - 2008)



#2 Ravendark_c&c

Ravendark_c&c
  • Members
  • 6 posts

Posted 24 February 2015 - 04:20 PM

Player status, top right corner...or hit the O key by default....tells you exactly who you are playing.

 

Doing in through modding..pain in the ass...you can probably create a map script that displays the sides as text....but it seems more hassle then its worth.



#3 Fox-1

Fox-1
  • Members
  • 8 posts
  • Location:NL

Posted 24 February 2015 - 07:09 PM

Maybe I wasn't clear enough.

 

I don't need to know it when playing the game, which is obvious anyways as one selected the mode prior to starting the level themself.  I need the difficulty status in WorldBuilder to make scripts that adapt themselves to the selected AI mode.

 

 

Just something to get things like this to work:

 

if Local_Player's_Enemy="hard" then activate script1

  or

if Local_Player's_Enemy<>"easy" then activate script2

 

 

One would think that's what the "active in:" properties are for but these don't seem to make difference in script execution.



#4 Ravendark_c&c

Ravendark_c&c
  • Members
  • 6 posts

Posted 25 February 2015 - 12:00 PM

playing it as a custom map or skirmish map? Iirc there are some subtle diferences on how to set up the players and how they behave towards eachother.



#5 Fox-1

Fox-1
  • Members
  • 8 posts
  • Location:NL

Posted 25 February 2015 - 03:04 PM

playing it as a custom map or skirmish map?

 

Playing as a custom skirmish map.  Setup is like: player 1 and player 2 (either 2 human players or 1 player and a CPU opponent) with a third "creeps" player.

 

When playing with 1 human player, the custom AI of the third (Creeps) player is based on the difficulty level of the one playing as a CPU player, so if you selected "hard" for your CPU opponent the AI of the 3rd player also has to use the "hard" routines of the script.

 

According to the info in the manual this is what the "properties->Active In:" settings in the scripts are for, which should be obvious but it doesn't seem to work.  OTOH, the manual also writes about a function "[Team – Action] Attack or Hunt: Team attacks an Area:" which doesn't even exist.  It does for "[unit]" but not for [team], making me have to do a total redesign of the creeps AI.



#6 Ravendark_c&c

Ravendark_c&c
  • Members
  • 6 posts

Posted 26 February 2015 - 09:19 AM

Idd it seems so, you might be able to use attackmove instead and put a waypoint to the specific area, then use another script that triggers the attackhunt /hunt whne you enter the polygon area?

And yes in theory the difficulty settings 'should' work i guess. Have you tried testing simplisticly?

Create 2 waypoints..one goes left, one goes right. You disable Right for hard and left for easy. When you load your map select a difficulty. and see if that part of the code works by letting a unit execute the waypoint.



#7 Fox-1

Fox-1
  • Members
  • 8 posts
  • Location:NL

Posted 26 February 2015 - 02:54 PM

Attackmove...  this won't do.  It works for attacking enemy units (anything that moves or can fire) but not for destroying structures in a base.  I'm testing this with a team of different air units and the only buildings that will be destroyed are the result of splash damage when attacking units.  When all units are killed the attacking air units are just idling above the enemies base until a new unit rolls out a war factory which will be attacked and killed immediatly.

 

Tried all kind of attack variations (Team Attack Move, Team Attack Hunt, Team Attack Player, etc.) all with the same "no structures" result.

 

The only possibility that worked (as far as I tried) is letting each single unit attack a building, all one by one.  This won't do in the end because that way every single unit needs it's own attack script in where all possible buildings from all factions need to be defined.

 

 

As for testing the hard/easy modes,  I just placed 4 named objects on the map and made 4 seperate scripts that would delete each unit from the "world" 5 seconds after the start of the game .

 

Script1 set to "Active in: none"

Script2 set to "Active in: easy"

Script3 set to "Active in: normal"

Script4 set to "Active in: hard"

 

Depending in what game mode I started the game, it only affected 1 of the 4 units and it was always the same one (forgot which one as I didn't look any further into this as it didn't do the job anyways).



#8 Ravendark_c&c

Ravendark_c&c
  • Members
  • 6 posts

Posted 26 February 2015 - 05:31 PM

Attackmove...  this won't do.  It works for attacking enemy units (anything that moves or can fire) but not for destroying structures in a base.  I'm testing this with a team of different air units and the only buildings that will be destroyed are the result of splash damage when attacking units.  When all units are killed the attacking air units are just idling above the enemies base until a new unit rolls out a war factory which will be attacked and killed immediatly.

 

Tried all kind of attack variations (Team Attack Move, Team Attack Hunt, Team Attack Player, etc.) all with the same "no structures" result.

 

The only possibility that worked (as far as I tried) is letting each single unit attack a building, all one by one.  This won't do in the end because that way every single unit needs it's own attack script in where all possible buildings from all factions need to be defined.


 

Depending in what game mode I started the game, it only affected 1 of the 4 units and it was always the same one (forgot which one as I didn't look any further into this as it didn't do the job anyways).

Do they ignore buildings aswell in agressive stance, iirc you can set the production building to agressive stance and any unit that ventures from it will have that stance aswell?

 

As for the easy/hard thing. Could be that part of the scripting isnt working (right). iirc worldbuilder evolved out of the bfme engine and its possible some elements arent working anymore when it got repurposed for TW and KW. Or there are other prerequisites needed to get that part of the AI working.



#9 Zypherbullet

Zypherbullet
  • Project Team
  • 8 posts

Posted 04 March 2015 - 12:40 AM

The active in: flags in the script properties works fine. Also instead of attackmove you could make an object list, adding every structure (you could import one of the game's library maps. They have all the object lists added) and then have the unit/team attack the object list.

 

Tell me, what is it you're trying to achieve? Plus if you upload the map, I can take a look at it.


Posted Image


#10 Fox-1

Fox-1
  • Members
  • 8 posts
  • Location:NL

Posted 05 March 2015 - 11:56 PM

The active in: flags in the script properties works fine. Also instead of attackmove you could make an object list, adding every structure (you could import one of the game's library maps. They have all the object lists added) and then have the unit/team attack the object list.

 

Tell me, what is it you're trying to achieve? Plus if you upload the map, I can take a look at it.

 

"Active in:"...  If it works for you, I really wonder why it doesn't work when I try it myself.  It seems to be just a matter of clicking modes 'on' or 'off'.  How hard can that be?  (well, too hard as it seems).

 

"Object List"...  I figured out that could possibly work but I think this only works for units where I only use teams.

 

 

 

What I'm trying to do is probably harder to explain than to script :-)

 

 

The basic idea is:

 

player 1: starts on the left (human or CPU)

player 2: starts on the right (human or CPU)

'creeps' player: starts in the middle (CPU)

 

In the middle is a kind of fort with 'creeps'.  It has some defensive objects and units which are static (as in: placed on the map when designing).  Besides of that there are 2 spots in the fort where units will spawn.  These units are not built by the 'creeps' AI but are pre-configured teams.  Each team is duplicated so they can independently focus on player 1, player 2, or both.

 

The actions of player 1 and player 2 decides when 'creep' teams will spawn (and re-spawn).

In the most basic form: if player 1 has 12 or more units in area innerperimeter 1 that can attack, then spawn 'creeps'team 1A if not exist.

 

(There are rules with several different parameters and areas used to calculate which team will spawn and when, but it boils down to above example).

 

All of this works without problems.  The culprit is that these spawn-routines have to be adjusted to the mode a player is playing in.  Like: if the mode is changed from "normal" to "hard", more teams have to be spawned and the time to re-spawn has to be shorter.  There also have to be more defensive structures and units in the fort at the start of the game.

 

 

I'm afraid uploading the map won't be of any help.  Right now the script is a whole bunch of unstructured rules of which many are disabled because I first need to figure out how to properly attack a players base (structures and units) and how to deal with the 'mode' setting.

 

Also need to find out how the release a captured object when a player has been defeated.  As it is now, if a tiberium spike is captured by a CPU opponent, it keeps in his possession even after he is defeated (it's status will not reset to "civilian").  On my map a defeated player doesn't mean a victory for the other one because there are 4 other tasks that also have to be accomplished for a victory.



#11 Zypherbullet

Zypherbullet
  • Project Team
  • 8 posts

Posted 07 March 2015 - 07:56 PM

Darn I had written an entire explanation, but my browser crashed on upload xD...

 

Anyway, I'm assuming you are making a multiplayer map rather than a custom map.

 

Now with this is mind, you should consider that you *could* have 7 enemies, all with different difficulties. For this reason, you can't determine CREEPS's difficulty based on one player, even if this is the only other player in the game. If the game can't determine the difficulty options, then by default Normal/Medium is the active game mode.

 

So, what you need to do is place the scripts in the folder for the enemy player. Player_2 for example.

 

You can also make new scripts based on difficulty and set a flag if they're true, so for example make a script, call it "EASY ACTIVE" or what have you and then make it "Active In" Easy. Then under condition make it true and on if true make it set a flag to a value, like flag "Easy Active" to true. Do this for the other settings too.

 

Then for your CREEPS scripts, just make them evaluate if the flag is indeed true.

 

Hah, but only if things were just this easy. You see, the starting human player can take either starting position (Player_1_Start or Player_2_Start), so you would have to have the scripts in both folders. BUT! Since the game can't detect the difficulty for the human player, it defaults to the "Active In" Normal as well.

 

Say you're player 1 for this example. What happens is that the appropriate script for Player_2 fires correctly, so if the enemy is hard, then only the script active in hard will fire, but also the script active in medium will fire for Player_1.

 

What you'll need to fix this is a script that can determine whether a player is human or AI. And yeah, you've guessed it, there isn't one :p. Luckily though when working on a map with Predatore, I discovered a fault in the scripts system that does allow you to determine said condition. This is how it works:

 

Place a trigger area around your starting position. You will need the following condition for both players, of course changing the trigger area according to the player.


*** IF ***

     Player '<This Player>' has units in  area 'Player_1 Starting Area'.

The trick is that the game won't recognize AI units in the area from the start, but it WILL recognize human player units in the area. So effectively this script will only fire on human players. Make sure to disable the other script, because as soon as the AI moves units inside the trigger area, it will fire.

 

You can then set an action accordingly. A working method would be to have all the "Active In" scripts be disabled at the start (put them in a folder to make it easier) and have this script enable the scripts/folder of the opponent player.

 

Also "Active In" hard works for both hard and brutal difficulties.

 

I hope this helps you out! If not, come find me on GameReplays.org in the custom maps section, I always check there multiple times a day and browse here rarely ;).

 

As for your other issues:

Teams can attack object lists too, but only via attackmove. If you spawn the teams on aggressive stance, then they will blast anything away regardless.

 

How do you determine if your enemy was defeated? If you use

*** IF ***
    Everything belonging to  Player '<All Players>' has been destroyed.

then all you need to do is name the tech buildings in worldbuilder and have them transferred to SkirmishNeutral once the enemy has been declared defeated.

 

Good luck!


Edited by Zypherbullet, 07 March 2015 - 08:04 PM.

Posted Image


#12 Fox-1

Fox-1
  • Members
  • 8 posts
  • Location:NL

Posted 21 October 2015 - 10:04 PM

Just noticed I never replied to this... Thanks for all the info. The AI/Human trick with the trigger area is new for me and may be very useful for other projects. As for the the map in the subject, I stopped with that. The scripting became so messy I couldn't understand anything of it anymore when looking at it after a few weeks passed by. I'm now trying to solve issues with opening and closing "gates", which doesn't seem to be that easy as the AI isn't aware of any blocking structures that are placed or removed once the game is running.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users