News:

One Minute Game Review by The Happy Friar: https://ugetube.com/@OneMinteGameReviews
Also on Rumble: https://rumble.com/c/c-1115371

idTech 4 (aka Doom 3 tech) Discord Server! https://discord.gg/9wtCGHa

Main Menu

AI Teams/Relationships

Started by MrC, August 22, 2015, 01:02:51 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

motorsep

Quote from: The Happy Friar on August 23, 2015, 09:42:08 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

Quote from: MrC on August 23, 2015, 10:20:03 PM
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

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

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

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

Quote from: MrC on August 22, 2015, 01:02:51 AMI'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

Quote from: The Happy Friar on August 24, 2015, 07:08:59 AM
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

Quote from: Radegast on January 03, 2016, 12:20:16 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.

Quote from: argoon on January 03, 2016, 01:24:39 PM
Quote from: The Happy Friar on August 24, 2015, 07:08:59 AM
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

#23
Quote from: The Happy Friar on January 03, 2016, 01:27:34 PMEntity 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 (cpp) Select
-       if( actor->team != team )
+       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

Phrozo

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:

void Event_SetTeam( int newTeam );

in AI.cpp

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
const idEventDef AI_SetTeam( "setTeam", "f", 'v' ); // 1 float parameter, return void

// bind the script event to our function in code
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.