Author Topic: AI Teams/Relationships  (Read 2001 times)

0 Members and 1 Guest are viewing this topic.

motorsep

  • Hero Member
  • *****
  • Posts: 967
  • Karma: +74/-128
  • Artist
    • View Profile
    • Kot in Action Creative Artel
Re: AI Teams/Relationships
« Reply #15 on: August 23, 2015, 10:39:15 PM »
Not sure why the AI in D3 can't walk backwards.  There's currently no animation to do it so they can't, but the flyers can go backwards.

It can (see our drone, when it scans player and player gets close, it backs away). Doom 3 just doesn't have anims for backpedaling and logic to tell AI to get away playing backpedal anim.

The Happy Friar

  • Happy Happy Joy Joy
  • Administrator
  • Hero Member
  • *****
  • Posts: 858
  • Karma: +42/-4
  • Semi-Newbie.
    • View Profile
    • EarthQuake
Re: AI Teams/Relationships
« Reply #16 on: August 24, 2015, 07:08:59 AM »
Anyway I should probably clarify that I wasn't talking about scripted sequences but rather some of the differences b/w the two, like the decision making process (tasks and schedules in making better decisions during combat) and in terms of the whole default relationship table / disposition which helped give the illusion of a living world by having some creatures target others over the player instead of just seeing the player as you pointed out. The table made it really easy to add a new NPC that behaved accordingly toward another NPC. Again, all possible with the current set of entities and triggers mentioned in earlier posts here.

I would say that was doable from a mod perspective because you modified the C++ code for the game.    In essence, we all agree if you modify the C++ code of D3 you can get the exact same results, so it requires no extra work compared to HL1. 

It's just id made it so easy to mod things w/o SDK in D3 that we don't want to touch the code.  :)

VGames

  • PD3 Beta Testers
  • Hero Member
  • *
  • Posts: 754
  • Karma: +17/-69
    • View Profile
Re: AI Teams/Relationships
« Reply #17 on: August 24, 2015, 08:50:36 AM »
Yeah I hate adding anything to the SDK. If it can be done through script I always go that route.
Get the latest on Perfected Doom 3 here - http://www.moddb.com/mods/perfected-doom-3-version-500

BielBdeLuna

  • Full Member
  • ***
  • Posts: 242
  • Karma: +8/-20
  • Doom Newbie
    • View Profile
    • my Github repositories
Re: AI Teams/Relationships
« Reply #18 on: August 24, 2015, 04:00:08 PM »
my problem with the idtech4 AI scripting as it is in d3 is that the movement is actually controlled by the c++ code, it checks the enemy position by request of the scripting, and form it it gets the turndelta (the ammount of turning he needs to do to get to it's ideal turn form his current turn, turn being the angle form his forward direction in his z axis)

now if the monster wants to move towards the his left, or to a specified angle, I have to place a point or an entity there, so I get a new turn delta, but the goal of the movement can't differ from the enemy and blah blah blah... it's a system controlled by two controllers, it would be much easier to control it all in the script or in c++

an option is to do all the states of the FSM in c++ and leave just the animation stuff to the scripting, but this would pose a big change from the current state of the AI in doom3, hence a complicated one

bkt

  • Jr. Member
  • **
  • Posts: 96
  • Karma: +12/-2
  • Doom Newbie
    • View Profile
Re: AI Teams/Relationships
« Reply #19 on: August 24, 2015, 04:23:33 PM »
If you want AI teams, take a look at the Quake 4 SDK.

In my last project I was able to change the team of an enemy with either a key/val pair or 1 line of script (one or the other).  I set a 'monster_tactical' to be on the 'marine' team and then let the AI of another monster take over to shoot him.  So long as the code's exposed in the SDK you'll have a solution in there.


Radegast

  • Newbie
  • *
  • Posts: 27
  • Karma: +3/-1
  • Alpha Labs scientist
    • View Profile
    • ET: Legacy
Re: AI Teams/Relationships
« Reply #20 on: January 03, 2016, 12:20:16 PM »
I'm not sure if this amounts to a scripting question or a C++ issue but I'm wondering if anyone could help point me in the right direction in terms of assigning AI default like/hate/neutral relationships towards other AI?

I did play around with Teams/Ranks key/val but so far have only managed to get AI that either does or doesn't just attack the player but seems to ignore other AI, unless I've misunderstood what Teams and Ranks are (probably).

Changing teams in scripts through setKey("team", 3) has no effect. It would appear that the value actually changed when you retrieve it again with getKey("team"), but the engine function idAI::ReactionTo which decides if the opposite entity is a friend or foe still sees the original spawn value of "team". However, changing other stuff such as npc's name through setKey("npc_name", "Leeroy Jenkins") works and is immediately visible in game. I am trying to figure out why.

If you change the "team" value directly in defs, you can have multiple factions which fight each other. Team management in Doom 3 is very simplistic, but I think it does suffice. Let's say you are team 0 and you spawn a soldier whose team is also 0, a soldier who is in team 1 and has rank 1, a soldier who is in team 1 and has rank 2 and two soldiers who are in team 3. Teams fight other teams, but if a soldier from team 1 with rank 2 is damaged by his teammate who is rank 1, he will be pissed off and kill him too.

Hell, but I would really like to know why changing team value in script after spawning an entity has no effect.

argoon

  • Sr. Member
  • ****
  • Posts: 275
  • Karma: +21/-81
  • Doom Newbie
    • View Profile
Re: AI Teams/Relationships
« Reply #21 on: January 03, 2016, 01:24:39 PM »

It's just id made it so easy to mod things w/o SDK in D3 that we don't want to touch the code.  :)

If that is true can you explain to me (i'm no coder btw) how to make a mouse over ability (like old Quake) not using the interactive GUI system or c++ but only using script?

The Happy Friar

  • Happy Happy Joy Joy
  • Administrator
  • Hero Member
  • *****
  • Posts: 858
  • Karma: +42/-4
  • Semi-Newbie.
    • View Profile
    • EarthQuake
Re: AI Teams/Relationships
« Reply #22 on: January 03, 2016, 01:27:34 PM »
Hell, but I would really like to know why changing team value in script after spawning an entity has no effect.

Entity is already spawned, that's why.  Those are spawn variables.  I'd imagine someone could make a "read real time" variable for use in something like this.


It's just id made it so easy to mod things w/o SDK in D3 that we don't want to touch the code.  :)

If that is true can you explain to me (i'm no coder btw) how to make a mouse over ability (like old Quake) not using the interactive GUI system or c++ but only using script?

The GUI system is scripting.  Doesn't require the C++ code.  I don't know how to use it but there are some others who have done good things with it.

Radegast

  • Newbie
  • *
  • Posts: 27
  • Karma: +3/-1
  • Alpha Labs scientist
    • View Profile
    • ET: Legacy
Re: AI Teams/Relationships
« Reply #23 on: January 03, 2016, 02:58:15 PM »
Entity is already spawned, that's why.  Those are spawn variables.  I'd imagine someone could make a "read real time" variable for use in something like this.
You were right. I figured out the value is stored in the member variable of the AI class on creation and the "team" cvar is never used again (maybe only for reading). I guess it's because they never needed to change teams in the game, but I don't see why trebor or the OpenTechEngine guys would not change it in the engine since it is only a one line patch:

Code: C++
  1. -       if( actor->team != team )
  2. +       if( actor->team != spawnArgs.GetInt( "team", "1" ) )

Edit: ok, turns out it's not a one line patch since there are checks for team in other places besides idAI::ReactionTo, but still... I think it would be a worthwhile change for scripters
« Last Edit: January 03, 2016, 03:07:15 PM by Radegast »

Phrozo

  • Mr. Phrozo
  • Jr. Member
  • **
  • Posts: 89
  • Karma: +15/-1
  • :3
    • View Profile
    • Mod Page
Re: AI Teams/Relationships
« Reply #24 on: January 03, 2016, 03:23:31 PM »
Right, it has no effect because key/values are simply a reference for the game code/script to read from, and key values used as spawn arguments are only retrieved on spawn and never again.

If you are willing, you could add a new script function that directly sets team.
In AI.h, add something like this:

Code: [Select]
void Event_SetTeam( int newTeam );
in AI.cpp

Code: [Select]
void idAI::Event_SetTeam( int newTeam ) {
    gameLocal.Printf( "setting '%s' to team '%i'\n", name, newTeam );
    team = newTeam;
}

in AI_events.cpp

// this makes our new callable script function
Code: [Select]
const idEventDef AI_SetTeam( "setTeam", "f", 'v' ); // 1 float parameter, return void
// bind the script event to our function in code
Code: [Select]
EVENT( AI_SetTeam, idAI::Event_SetTeam)
You may have to add this one last line in the doom_events.script

void setTeam( float newTeam );

I haven't tested this but hopefully it should work.