Actor AI and enviroment
#1 Posted 02 August 2011 - 07:32 PM
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?
#2 Posted 02 August 2011 - 09:27 PM
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
#3 Posted 03 August 2011 - 05:15 AM
Hendricks266, on 02 August 2011 - 09:27 PM, said:
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?
#4 Posted 03 August 2011 - 05:40 AM
This means that you need to write new code within the actor blocks for the enemies.
#5 Posted 03 August 2011 - 06:14 AM
Hendricks266, on 03 August 2011 - 05:40 AM, said:
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
#6 Posted 03 August 2011 - 06:40 AM
#7 Posted 03 August 2011 - 09:59 AM
Hank, on 02 August 2011 - 07:32 PM, said:
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.
#8 Posted 03 August 2011 - 04:33 PM
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
This post has been edited by Hank: 04 August 2011 - 06:03 PM
#9 Posted 04 August 2011 - 08:38 AM
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
#10 Posted 04 August 2011 - 11:25 AM
Zaxtor, on 04 August 2011 - 08:38 AM, said:
It sounds like you used the ifsound parameter, which shouldn't be used for reasons I outlined in my first post.
#11 Posted 04 August 2011 - 12:04 PM
#12 Posted 04 August 2011 - 01:11 PM
TX, on 04 August 2011 - 12:04 PM, said:
YES that would be amazing.
#13 Posted 04 August 2011 - 01:59 PM
TX, on 04 August 2011 - 12:04 PM, said:
Well, yeah, I've requested something like that at least 3 times now.
#15 Posted 04 August 2011 - 02:43 PM
#17 Posted 04 August 2011 - 03:06 PM
TX, on 04 August 2011 - 12:04 PM, said:
Yes please!
#18 Posted 04 August 2011 - 03:22 PM
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
#19 Posted 04 August 2011 - 04:49 PM
#20 Posted 04 August 2011 - 05:26 PM
Hank, on 04 August 2011 - 03:22 PM, said:
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
rasmus thorup, on 04 August 2011 - 04:49 PM, said:
The volume setting in definesound works just fine. Note that the numbers must be rather large to get a noticeable effect.
#21 Posted 05 August 2011 - 11:55 AM
This post has been edited by rasmus thorup: 05 August 2011 - 11:55 AM
#22 Posted 05 August 2011 - 12:00 PM
#24 Posted 05 August 2011 - 12:54 PM
TX, on 05 August 2011 - 12:00 PM, said:
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.
#25 Posted 06 August 2011 - 03:09 AM
#26 Posted 06 August 2011 - 07:40 AM
Helixhorned, on 06 August 2011 - 03:09 AM, said:
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.
#27 Posted 06 August 2011 - 08:57 AM
Helixhorned, on 06 August 2011 - 03:09 AM, said:
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.
#28 Posted 08 August 2011 - 06:26 AM
Hendricks266, on 02 August 2011 - 09:27 PM, said:
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
#29 Posted 08 August 2011 - 12:13 PM
This post has been edited by Hendricks266: 08 August 2011 - 02:03 PM
#30 Posted 08 August 2011 - 02:02 PM
Hendricks266, on 08 August 2011 - 12:13 PM, said:
Are you saying I can code my own EVENT_GAME? If so, you deserve more than a stinking green!