Aller au contenu

Photo

patrol: can commands be resumed?


  • Veuillez vous connecter pour répondre
10 réponses à ce sujet

#1
Capzason Achpea

Capzason Achpea
  • Members
  • 6 messages
 I have a little battle scenario going and I need guys to fight any enemies they happen to encounter, but then continue walking waypoints after enemies are dead. I seem to remember something like that for NWN, but I can't find anything like that on the dragon age wiki or in this forum.

So my question is: is there a way to make guys resume moving to locations, or is there a patrol setting that I am not aware of?

Ambient AI stuff is no good because the player may be more than 50 meters away from AI. The code below is how I am telling them to move to locations.

location [] flagLocations;            
SetObjectAlwaysVisible(OBJECT_SELF,0);            
flagLocations[0] = GetLocation(GetObjectByTag("way_left_0"));            
flagLocations[1] = GetLocation(GetObjectByTag("way_left_1"));            
flagLocations[2] = GetLocation(GetObjectByTag("way_left_2"));            
flagLocations[3] = GetLocation(GetObjectByTag("way_left_3"));            
flagLocations[4] = GetLocation(GetObjectByTag("way_left_4"));            
flagLocations[5] = GetLocation(GetObjectByTag("e_center_spawn"));            
command moveToFlags = CommandMoveToMultiLocations(flagLocations, FALSE, 0, FALSE);           AddCommand(OBJECT_SELF, moveToFlags, TRUE, FALSE);
[b]
[/b]If there is no such thing, I am planning on using EVENT_TYPE_COMBAT_END, but this has the drawback that the AI will sometimes have to go backwards before they continue forwards, making them look really stupid. 

Thanks for the help.

Modifié par Capzason Achpea, 22 juillet 2010 - 10:55 .


#2
Sunjammer

Sunjammer
  • Members
  • 925 messages
You can set the ambient to be always on for those creatures which means they will ignore the 50m rule. From the wiki: 0x10 (AMBIENT_SYSTEM_ALWAYSON): Ambient behaviour never stops, regardless of distance to player. This should rarely, if ever, be used but at least the functionality exists if needed.

So all you need to do is add 16 (0x10) to the current AMBIENT_SYSTEM_STATE value for those NPCs.

#3
Capzason Achpea

Capzason Achpea
  • Members
  • 6 messages
 Thanks for the reply.

Now that I am looking at the ambient behavior more closely, I notice that the AMBIENT_MOVE_PATH_PATROL actually uses the CommandMoveToMultiLocations()  the. So I am not sure if it will have the move, fight, keep moving kind of behavior that I am looking for. I will try it this way, but If you know of a more appropriate ambient behavior, please advise.

Sorry about the ugly code.

#4
FergusM

FergusM
  • Members
  • 460 messages
You can use Ambient_Start() and Ambient_Stop(), I think. Just use the ambient patrol system and add a little to the creature script. If the creature perceives hostiles, call Ambient_Stop(); when the combat is over, call Ambient_Start(). That should make them patrol, attack, and then resume their patrol.

EDIT: Actually, I am a little unsure, now. Ambient_Start() may make them go back to the very start of their patrol rather than resume it. Perhaps the pause thing is more what you want, but I'm unclear precisely how it works. More in a minute.

EDIT : 
Hrm, I see you have a bit of a potential dilemma here. Ambient behvaiour normally pauses in combat and continues afterwards, but you'll have the always on set. Maybe you could try using SetLocalInt to change the creature's ambient state when they perceive a hostile, and again when combat is over. The documentation says don't change them directly, but it's worth a shot.

The wiki references Ambient_Pause(), which doesn't exist.

Modifié par FergusM, 22 juillet 2010 - 11:06 .


#5
Capzason Achpea

Capzason Achpea
  • Members
  • 6 messages
I am going to try what you said in your last edit. I was having a bit of trouble understanding the Ambient_Start() function, but now I think I got it.

#6
Capzason Achpea

Capzason Achpea
  • Members
  • 6 messages
Ok, so now I really understand the Ambient_Start() and I also learned a bit about bitwise operators, so I am a better person now.



What I can not figure out is how to make any ambient behavior actually work except for the random roaming around. All other ambient behaviors do nothing.



An example of one of the many values I have tried:



AMBIENT_SYSTEM_STATE: 1



AMBIENT_MOVE_PATTERN: 1



AMBIENT_MOVE_PREFIX: ag_<tag> (default)



tags: ap_cr_dog_01 and ap_cr_dog_02



I have also tried to start it using Ambient_Start(). What am I missing here?

#7
FergusM

FergusM
  • Members
  • 460 messages
Provided that your tags are correct (and that the value is ap_<tag>, not ag_<tag>, presuming that's just a typo on here), that's precisely what I'm using for a patrolling guard and he moves along his waypoints fine.



If you're looking to make animations work, you have to set AMBIENT_ANIM_PATTERN and AMBIENT_ANIM_FREQ.

#8
Craig Graff

Craig Graff
  • Members
  • 608 messages

FergusM wrote...

EDIT : 
Hrm, I see you have a bit of a potential dilemma here. Ambient behvaiour normally pauses in combat and continues afterwards, but you'll have the always on set. Maybe you could try using SetLocalInt to change the creature's ambient state when they perceive a hostile, and again when combat is over. The documentation says don't change them directly, but it's worth a shot.

The wiki references Ambient_Pause(), which doesn't exist.



This should be entirely unnecessary. The ambient  system already stops when a creature enters combat. Always On just ignores the combat state of the game (based on the party's perception of hostile creatures), not the combat state of the creature with the ambient routine.

#9
FergusM

FergusM
  • Members
  • 460 messages

Craig Graff wrote...

This should be entirely unnecessary. The ambient  system already stops when a creature enters combat. Always On just ignores the combat state of the game (based on the party's perception of hostile creatures), not the combat state of the creature with the ambient routine.


Ah, really that makes quite a lot of sense.

#10
Capzason Achpea

Capzason Achpea
  • Members
  • 6 messages
Ok, thanks for the suggestions. I actually can't get the ambient behavior (except for random walking around) to work for love or money.



Once I figure that out I will try the suggestions here and let you know how it went.

#11
Capzason Achpea

Capzason Achpea
  • Members
  • 6 messages
Sorry for the length between posts. There was something strange going on that was breaking ambient behavior. I had to rebuild from scratch. I am posting this for the sake of anyone looking for the same solution I am. Based on my experimentation, ambient behavior is not going to work well as is in this situation. Every variation I have tried will, at best, cause the character to return to the first waypoint by the most direct route after combat. Ambient_RestoreBehaviour etc yielded no results.



If AMBIENT_MOVE_STATE is what I think it is, I might be able to use it to restore the character to the correct waypoint.



If this does not work, I am going to try to use EVENT_TYPE_REACHED_WAYPOINT with a new ambient name being set each time a waypoint is passed. It seems like EVENT_TYPE_REACHED_WAYPOINT is not called on the character, so I am hoping it gets called

on the waypoint. (no documentation on this one).



If that fails, I am going to do what I should have done to start with, go back to CommandMoveToMultiLocations() and add a bit of code to handle resume and battle.