Duke4.net Forums: Actor AI and enviroment - Duke4.net Forums

Jump to content

  • 2 Pages +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

Actor AI and enviroment

User is offline   Hank 

#1

I want to know, what of those four issues I can code myself and what needs to be done within EDuke32.
1 Is there a way for re-spawned actors to stay at the spot they've been placed? Right now they seem to wander around, stop and become easy targets right in my flight pass.
2 Is there a way for actors to become noise sensitive? Even if an actor can't 'see' the player, shooting, say a rocket, should at least make an actor become alive.
3 Is there a way for actors to co-operate? One attacks from the front, the other moves around and tries from the side, and perhaps a third one sneaks up from behind.
4 Is there a way to have zero gravity for a given sector, for all actors and player?
0

User is offline   Hendricks266 

  • Weaponized Autism

  #2

1. Yes, in EVENT_SPAWN you could say that if they are spawned by RESPAWN, changespritestat to a sleeper.

2. I'm not quite sure how the ifsound parameter works, but I think that it cannot be trusted because if sound is disabled or voices are set to a low number and the sound cannot play, it's as if the sound wasn't triggered at all. You're better off using setplayervar on a per-player gamevar for whatever circumstances sounds play, and having enemies use getplayervar to check if they should be awakened. Remember not to wake enemies up if you use a melee weapon and hit nothing. That's one thing Doom got wrong.

3. The short answer is yes, but you will have to code your own AI from the ground up.

4. I think you can set gravitationalconstant to 0, but this will strand you in your current z position, unless you jump, or you jetpack, which to me seems very realistic. I've seen mods do funky things with being underwater to simulate zero-G, but that's not realistic.

This post has been edited by Hendricks266: 02 August 2011 - 09:28 PM

1

User is offline   Hank 

#3

View PostHendricks266, on 02 August 2011 - 09:27 PM, said:

3. The short answer is yes, but you will have to code your own AI from the ground up.

Let's start here. This is very good news, that I can code from scratch, but how does EDuke accept an entire new code? In other words, when and where will the new code be parsed (compiled?) All I ever did was editing the game.con using the con FAQ. Where can I find guides for the modern EDuke32? Posted Image
0

User is offline   Hendricks266 

  • Weaponized Autism

  #4

Basically what I meant is that you will likely have to replace all the default CON "ai" commands with custom code, although it may be possible to just supplement them.

This means that you need to write new code within the actor blocks for the enemies.
0

User is offline   Hank 

#5

View PostHendricks266, on 03 August 2011 - 05:40 AM, said:

Basically what I meant is that you will likely have to replace all the default CON "ai" commands with custom code, although it may be possible to just supplement them.

This means that you need to write new code within the actor blocks for the enemies.

Yep, and this is the good news, but how do I store the data at run time? One actor's(and player's) action affects two others, so the other actors need to have some sort of access to an array or vector (not sure if this exist for C) to decide what action to take.

This post has been edited by Hank: 03 August 2011 - 06:15 AM

0

User is offline   Hendricks266 

  • Weaponized Autism

  #6

You can use setactorvar to set a "receiver variable" on another enemy. If you need to find the sprite id of the other enemy, findnearactor is one way to do it.
1

User is online   Danukem 

  • Duke Plus Developer

#7

View PostHank, on 02 August 2011 - 07:32 PM, said:

I want to know, what of those four issues I can code myself and what needs to be done within EDuke32.
1 Is there a way for re-spawned actors to stay at the spot they've been placed? Right now they seem to wander around, stop and become easy targets right in my flight pass.
2 Is there a way for actors to become noise sensitive? Even if an actor can't 'see' the player, shooting, say a rocket, should at least make an actor become alive.
3 Is there a way for actors to co-operate? One attacks from the front, the other moves around and tries from the side, and perhaps a third one sneaks up from behind.
4 Is there a way to have zero gravity for a given sector, for all actors and player?


Hendricks266 already answered these questions pretty well, but I just feel like taking a stab at it anyway.

1) Here's a code snippet showing what he was talking about:

onevent EVENT_SPAWN

ifspawnedby RESPAWN ifvare sprite[THISACTOR].statnum 1 changespritestat THISACTOR 2

endevent


Statnum determines how a sprite is handled. Statnum 1 sprites are actors (i.e. they run actor scripts), while statnum 2 sprites "sleep" (i.e. they do nothing until the player is nearby). Normally spawned monsters start life awake and ready to rumble, but the code above should make them start asleep.

2) I have code for this in DukePlus, which I have monsters using when the "advanced AI" feature is on. It doesn't do anything sophisticated like make them track the sound, it just makes them wake up when appropriate. The basic idea is that if they can "see" the impact of a bullet, or an explosion, then they awake. (They automatically awake when seeing the player, so there's no need to worry about that). In DUKEPLUS.CON, you will want to look at "state wakeupmonsters", and also "state wakemon". Let's say that a SHOTSPARK1 (a bullet impact) spawns. At the moment it spawns, the SHOTSPARK1 actor uses the wakeupmonsters state, which loops through all the statnum 2 monsters, and wakes up those with a line of sight to the bullet (not exactly the same as line of sound, but close enough for some purposes). It also sets their timetosleep so they don't immediately fall back asleep again. The EXPLOSION2 actor does the same thing, and maybe some others like the shrinker impact. You won't notice a big difference in monster behavior with this alone, but if used in conjunction with intelligence behavior it can make a big difference.

3) I have sometimes thought about coding cooperative behavior, but I have never really done it, because I have never had a project that made it seem worthwhile. Obviously, you will need to know how to transfer information between sprites and a lot of other stuff to have true group AI. But remember that as far as the player is concerned, the illusion of intelligence is just as good as the real thing. For example, let's say you have a situation in a map where the player enters a warehouse. There are enemies positioned so that some of them would do well to outflank him by running down a particular path and then taking up positions behind some crates to his rear. You could try to code a system that makes the actors figure this out on their own, but it's vastly easier in this case to simply have them follow a script that makes actors you have tagged in advance follow a trail of waypoint sprites to their optimal destinations when the player activates a touchplate. And importantly, make this also trigger a sound of one of the enemies saying, "Here he comes, let's get behind these crates!" or something equally idiotic which let's the player know they are doing something "smart". Since you have complete control of the maps, you can set up a relatively simple system whereby enemies use pre-scripted movements when the player arrives at certain locations. Of course, you also need to code some real AI, but the pre-scripted stuff could be a big help.
1

User is offline   Hank 

#8

Wow - Lot of stuff here! Thanks to both Hendricks266 and Deeper Thought.
Yes, I should explain what I want to create. For my Forests, I want a Killer Bee swarm, birds I know now how to do, WGRealms comes to mind :( . For my spooky basements I want ghosts. I want them to attack in groups, if the player intents to fight with those 'ghosts', since they do minimal damage at first and are technically only for ambience. And I dislike the Big Boss fights. I think it would be more interesting to fight with a vicious gang, and like gangs, they attack in groups, also. And this is where I want to start tinkering in debth with the cons. And for now I seem to have a good start. - Any further thoughts are obviously welcome.

But this is not a real mega project. Just something I love doing, tinkering, and I will post more questions. Cheers Posted Image

This post has been edited by Hank: 04 August 2011 - 06:03 PM

0

User is offline   Zaxtor 

#9

My mod Oblivion has some (noise sensitive traps).

Like if you use certain weap it triggers deadly spikes trap. Even player boots making noise from falling can trigger it.

You can't use weap sound used in menu or it will trigger it when you pop menu up.

So means your thing can be possible. Can wake up when it hears a sound even if you are not visible to it.

This post has been edited by Zaxtor: 04 August 2011 - 08:41 AM

0

User is offline   Hendricks266 

  • Weaponized Autism

  #10

View PostZaxtor, on 04 August 2011 - 08:38 AM, said:

You can't use weap sound used in menu or it will trigger it when you pop menu up.

It sounds like you used the ifsound parameter, which shouldn't be used for reasons I outlined in my first post.
0

User is offline   TerminX 

  • el fundador

  #11

Maybe an EVENT_SOUND should be added that triggers on any attempted sound playback, regardless of whether the playback attempt succeeded or failed. As a bonus the event could be used to manipulate the position and pitch and whatnot of a sound before the playback actually occurs. Thoughts?
1

User is offline   Jblade 

#12

View PostTX, on 04 August 2011 - 12:04 PM, said:

Maybe an EVENT_SOUND should be added that triggers on any attempted sound playback, regardless of whether the playback attempt succeeded or failed. As a bonus the event could be used to manipulate the position and pitch and whatnot of a sound before the playback actually occurs. Thoughts?

YES that would be amazing.
0

User is online   Danukem 

  • Duke Plus Developer

#13

View PostTX, on 04 August 2011 - 12:04 PM, said:

Maybe an EVENT_SOUND should be added that triggers on any attempted sound playback, regardless of whether the playback attempt succeeded or failed. As a bonus the event could be used to manipulate the position and pitch and whatnot of a sound before the playback actually occurs. Thoughts?


Well, yeah, I've requested something like that at least 3 times now.
0

#14

A lot of people have. A good idea ofcourse :)
0

User is offline   Hank 

#15

wait - the 'sound' stuff I will need is something that can trigger an event, i.e. alarm an actor(s) . Perhaps I misread the post from TX; yet I rather have this event checkable for true or false at least. Posted Image
0

User is offline   TerminX 

  • el fundador

  #16

Really? I must have missed those.
0

User is offline   Hendricks266 

  • Weaponized Autism

  #17

View PostTX, on 04 August 2011 - 12:04 PM, said:

Maybe an EVENT_SOUND should be added that triggers on any attempted sound playback, regardless of whether the playback attempt succeeded or failed. As a bonus the event could be used to manipulate the position and pitch and whatnot of a sound before the playback actually occurs. Thoughts?

Yes please!
0

User is offline   Hank 

#18

@ TX
Also, speaking of thoughts, the coder can set sound pitch variances in the user.con files under basic Duke.exe, I used this heavily.

from user.con
4. The numbers that are to the right of the sound file name are technical
   parameters which will not be explained here, except as follows...
   - The first 2 numbers define a random pitch variation range.  They
 	can be positive or negative numbers.
   - The 3rd number is a priority flag.
   - The 4th number is a bit parsed set of technical variables that identify
 	the type of sound it is in the game.
   - The 5th number is volume adjustment.



Will your new code depreciate this?

This post has been edited by Hank: 04 August 2011 - 05:08 PM

0

#19

We need to be able to control music volume too. And the volume in definesound command doesn't change anything?
0

User is offline   Hendricks266 

  • Weaponized Autism

  #20

View PostHank, on 04 August 2011 - 03:22 PM, said:

Will your new code depreciate this?

Any EVENT_SOUND will not deprecate (no 'i', we're not losing value :)) definesound definitions. Events are for mid-game modifications. Besides, you would still need definesound to add the sound file to the game. (unless you can do that with the sound def command alone...)

This may be helpful to you: Hendricks266's definesound documentation

View Postrasmus thorup, on 04 August 2011 - 04:49 PM, said:

We need to be able to control music volume too. And the volume in definesound command doesn't change anything?

The volume setting in definesound works just fine. Note that the numbers must be rather large to get a noticeable effect.
1

#21

Okay, i just can't hear the difference then :) And yea it HAS to be mid-game-editable.

This post has been edited by rasmus thorup: 05 August 2011 - 11:55 AM

0

User is offline   TerminX 

  • el fundador

  #22

The volume parameter is really just a modifier applied to the distance for the sound. It can't really be used to make a sound LOUDER than it would normally be when you're right next to it, but it can make a sound louder when you're at a distance where the playback would regularly be quieter.
0

#23

That explains a lot haha xD
-1

User is online   Danukem 

  • Duke Plus Developer

#24

View PostTX, on 05 August 2011 - 12:00 PM, said:

The volume parameter is really just a modifier applied to the distance for the sound. It can't really be used to make a sound LOUDER than it would normally be when you're right next to it, but it can make a sound louder when you're at a distance where the playback would regularly be quieter.



Since we are on the topic of sound volume...

One beef I have with Duke 3D sound is the way fadeout distance is handled. It seems like the sound is at full volume for most of the distance, and then it very quickly fades to nothing for the last part of the distance. I wish it were smoother.
0

User is offline   Helixhorned 

  • EDuke32 Developer

#25

I think this is a consequence of the linear fadeout vs. the logarithmic perception of loudness. Lezing did a non-linear fadeoff via CON, but hardcoding that would make everything sound very different from the original Duke3D.
1

User is offline   Hank 

#26

View PostHelixhorned, on 06 August 2011 - 03:09 AM, said:

I think this is a consequence of the linear fadeout vs. the logarithmic perception of loudness. Lezing did a non-linear fadeoff via CON, but hardcoding that would make everything sound very different from the original Duke3D.

This would not matter, well, to me. (Yes, selfish, I could care less how it sounded originally if the new sound routine sounds reasonable) Right now, when the player 'runs' the actor should wake up, or if a missile hits within say 10m, or a bullet within 1m. So all the best to TX or whoever makes a event_sound accessible to con coders. Posted Image
0

User is online   Danukem 

  • Duke Plus Developer

#27

View PostHelixhorned, on 06 August 2011 - 03:09 AM, said:

I think this is a consequence of the linear fadeout vs. the logarithmic perception of loudness. Lezing did a non-linear fadeoff via CON, but hardcoding that would make everything sound very different from the original Duke3D.



And I agree that would be bad because there are hundreds of maps where the level designer assumes that the player can hear certain sounds at certain places, and changing the fadeout method would mess that up.

But is it possible to make a more realistic fadeout as an option? Maybe it could be controlled by a new bit in the <type> parameter of the definesound command.
0

User is offline   Hank 

#28

View PostHendricks266, on 02 August 2011 - 09:27 PM, said:

4. I think you can set gravitationalconstant to 0, but this will strand you in your current z position, unless you jump, or you jetpack, which to me seems very realistic. I've seen mods do funky things with being underwater to simulate zero-G, but that's not realistic.

Can you or anyone else give me a hint?
I searched through the source code and user.con, how does GRAVITATIONALCONSTANT work? It's in the game as a game variable, and functions with g_spriteGravity. From there one could track it further on how this works. But if someone did the research already and knows how to use this (g_spriteGravity or equivalent) in the .con it would save me some time.

b.t.w. I don't want the entire map at 0 gravity, just specific sectors, and the G...CONSTANT does not work well. I jump the same height as in gravity, and actors don't fall after they are 'dead', etc.
Not sure who played Quake II, but in the Space set, when the gate was open and you came to close to it, you where sucked out into space, and died. I need/want similar effects.

This post has been edited by Hank: 08 August 2011 - 08:39 AM

0

User is offline   Hendricks266 

  • Weaponized Autism

  #29

Setting the gravitational constant to 0 won't activate realistic 0G effects like vacuums. You need code to adjust the player's jump height (there's a tutorial on the EDukeWiki for that), and you need code in EVENT_GAME to loop through all sprites and check for distance to a vacuum and if the object is supposed to move, move it.

This post has been edited by Hendricks266: 08 August 2011 - 02:03 PM

1

User is offline   Hank 

#30

View PostHendricks266, on 08 August 2011 - 12:13 PM, said:

Setting the gravitational constant to 0 won't activate realistic 0G effects like vacuums. You need code to adjust the player's jump height (there's a tutorial on the EDukeWiki for that, and you need code in EVENT_GAME to loop through all sprites and check for distance to a vacuum and if the object is supposed to move, move it.

Are you saying I can code my own EVENT_GAME? If so, you deserve more than a stinking green! Posted Image
0

Share this topic:


  • 2 Pages +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic


All copyrights and trademarks not owned by Voidpoint, LLC are the sole property of their respective owners. Play Ion Fury! ;) © Voidpoint, LLC

Enter your sign in name and password


Sign in options