Jump to content

Get Info from Game


fkerber

Recommended Posts

Hey guys,

 

sorry for my bad english - I'm no native speaker but I try my best :thumbsup:

 

In the next few months I have to do my bachelor thesis and I took a topic related to computer games. The main aim is s.th. like an annotator agent which means a self-written program that is able to determine what is happening in the game and say s.th. about it. For example, hints like "Look, there is an enemy coming up".

 

Therefore I need a lot of information from the game. This is the point where I heard from th GemRB-engine and also heard, that it is open source.

 

Can you give me any hints or information if such an idea could be realized and where I should look for information. It would be great if I could get all fight information and character positions and things like that in a terminal (e.g. standard output).

 

Thanks in advance.

Best regards,

fkerber

Link to comment

"Interesting" topic.

You must know that this is a single player game, not some network based mmo, so i don't really know what use would this be.

The infinity engine already has a feature like this: autopause when enemy is seen.

There are built in scripting triggers like : AnyPCSeesEnemy, See([ENEMY]) etc...

Also, you cannot save the game if enemies are nearby.

 

Anyway, a code to tell if any enemy is near a PC (not seen) would be something like this:

Game *game = core->GetGame();
Map *map = game->GetCurrentArea();
int i=game->GetPartySize(1);
while(i--) {
  Actor *pc = game->GetPC(i,1);
  if(map->AnyEnemyNearPoint(pc->Pos)) {
//enemy near party member pc
 }
}

 

Or, there is actually code for actually seeing enemy: map->AnyPCSeesEnemy()

 

So, what you want is possible even using built in scripting commands that you could attach to a player character. But it has not much practical use...

 

You should be more ambitious and implement one or two features in GemRB :thumbsup:

Link to comment

If you need something else, you could always ask all actors from the map (see GetCurrentArea)

 

like:

int actorcount = map->GetActorCount(0);
while(actorcount--)
{
  Actor *actor = map->GetActor(i,0);
}

 

This will iterate through all actors in the area.

You can get an actor/pc's stats: actor->GetStat(<stat_id>). Stats contain all data like hitpoints, AC, enemy state, etc... You can look at ie_stats.h for the possible ids.

 

And you can do something like map->GetAllActorsInRadius(Pos, GA_NO_DEAD, 30);

(30 being the maximum seeing distance).

Link to comment

Hey,

 

cool, thanks for your answer.

I think, it is still not exactly clear what I want to do. I try to explain a little bit further:

Imagine I have a virtual character, let's say on a second screen, and this character can give me hints or more general, say s.th. about the game. For example like a commentator in a (real life) football game.

 

Therefore a lot of information is needed. It would be perfect, if there is a, let's say endless loop, which is called every second and where I could get all information (or where I could insert some code in the engine so that all information is printed to standard output for example). This could be for example actors position, health, items, enemys and so on.

I think the code snippets are a good start for this but I'm not really sure. Can you point out a little more, where I could find a place where to put such an "output-code"?

If I had all these information on standard output, I would be able to read it with an other program and work with it and use it for the virtual character.

 

Thanks in advance.

Best regards,

fkerber

Link to comment

Since the actors are always moving, you would need lots of spam to keep in sync, if you use code outside the engine.

I don't think it is a really viable alternative.

Depending on how much data you want to access, even if you want enemy/ally alerts, you will need to generate a new output line everytime an actor changes its EA stat, enters/leaves the map, changes its position.

Obviously the more data you need, the more checkpoints you will need to add to the code, so this will soon become unmanageable, even if you can handle the spam.

 

So, you will need your code INSIDE the engine. There are 2 ways.

1. modify the C code itself, this could be done by the code snippets i provided. You simply call them periodically, somewhere

in the script update cycle.

 

2. you just create an invisible actor with a running ingame script. Or just add the script to every of your watched actors (i guess the PCs). I hinted that i think it is possible to write game scripts for the stuff you mentioned as an example.

While the gamescript is not as flexible as custom C code it is easier to introduce into the game. It is also the safest way.

 

Yes, you could simply output all needed data every second (i would still suggest the AI update cycle). But this data is immense. You can do it by using the code i provided, adding a line in the loop after getting the actor.

 printf("%d %d %d %d\n", actor->globalID, actor->Pos.x, actor->Pos.y, actor->GetStat(IE_EA);

This will display an identifier, the x/y position of the actor and its enemy/ally stat.

Of course, you can add new data to the line.

Link to comment
Guest Edheldil

As Avenger advises, make a hook in the script update loop - that way you can get any interesting information without the need to do costly internal -> text -> internal conversion. There's really no need to do that, because you can get that info directly.

Link to comment
Guest Maverick

Hey Guys,

 

time has passed since the initial post.

I'm a friend of fkerber and because of writing our thesis in the same field, we changed the games we want to comment.

Now, it seems, that I will comment one of the roleplaying games :-).

 

Because I had started playing D&D with the 3.0 rules, I would prefer to comment an Icewind Dale 2 game. I had a test-run but it seems a bit sloppy, right now. If I want to choose a spell or a special feature, I get a lot of errors (searching for cdfb2g17.bam .... couldn't create animationfactory: cdfb2g17.)

 

The first question would be: exists there a fix?

 

Second qustion: How stable is IWD2? Are there any grave problems, which could be a problem?

Remember: My goal is to have a virtual agent that gives advises like, for example: "Don't attack him with the dagger, if you attack him with the sword you have in your inventory, you could achieve a better hit" . Therefore I need the information fkerber mentioned and also a (roleplaying) game which runs stable in fights - i.e. with access to spells, special features and so on. Is IWD2 suitable?

 

Thanks,

Mav

Link to comment
Guest Maverick

Depending on the amount of time I spent working to get my project run & depending how deeply I have to work through GemRB, this could be happen ;-).

Link to comment
Second qustion: How stable is IWD2? Are there any grave problems, which could be a problem?

 

To clarify some more: IWD2 is unusable in GemRB, for various reasons. I would guess that it would probably take far more time to patch it up to be usable for your purposes than you have, it is not just a question of a few bugs.

 

bg1, bg2 or iwd should be fine, though - they are completable, spells are working reasonably well, etc.

 

You could probably fairly easily add to our python scripting so it provides the data you want, and then write something in the main game loop which calls a python function every frame to do your analysis. I think that is probably what I'd do, anyway. :)

Link to comment

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...