Aller au contenu

Photo

High Dragon Scripting?


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

#1
Qutayba

Qutayba
  • Members
  • 1 295 messages
There are about a half dozen posts over the last 6 months or so trying to figure out how to get the high dragon (or the smaller dragons, too, as seen in Awakening and Leliana's Song - My current goal is to have the smaller dragon jump like these encounters, but, of course, we don't have access to those scripts) to fly up and jump around at certain points in the fight - the high dragon doesn't actually move otherwise, though it does turn (the Flemeth dragon, for example, doesn't have the fly mechanic at all and merely rotates).  I still haven't figured it out, but I've dug pretty deep into the scripting and want to share what I've found to see if other people can fill in the gaps.

The High Dragon encounter on the Mountain Top during the Urn quest involves several scripts, possibly a plot, as well as package files.

The Area: there are several waypoints around the fight area on the mountain top and the climax fort roof called ai_move.

AIP_High_Dragon pacakage file: There are a set of unique commands called Fly/Turn, one of which says "fly to wp near enemy."  I've tested adding that line to a custom AIP for a dragon clone and filling an area with waypoints called "ai_move" and it hasn't been enough to get this behavior.

Scripts: There are several scripts I looked at, including the area scripts for the combat area, the unique creature scripts assigned to the creature, and a few includes.  The archdemon fight is a little more complicated, because it jumps to several stages at different phases of the fight (for example when it flies to the inaccessible platform, and when it flies to the final killing zone), so it only uses the jumping waypoints during a certain part of the fight.  The mountain top dragon seems to be able to use his throughout the fight.

urn_dragon_h: This has a function called UHD_DragonPounce which defines an action where the dragon jumps to the waypoint closest to the PC.  This seems different from the fly action where it seems to go to a random waypoint.  Are we dealing with two abilities then?

Creature counters: The dragon scripts seems to make use of the local variable Creature Counters, which seem to enable the jumping ability.  The archdemon encounter has some custom events in the area script that seem to regulate the stages to the fight and sets the creature counter.  The mountain top fight area script doesn't seem to do the same thing.  This seems to be handled by the "urn_dragon_h" include.

What I haven't been able to figure out, is how do you get the dragon to actually jump?  I found where the action is defined, but haven't yet found a place where the conditions for calling that action are set up.  I suspect there's something in the 2das, perhaps, but I've only found reference to the flying in the High Dragon AIP (where it's not a Use Ability function, but something different).   How do we script dragon jumps in other settings?  Has anyone had any luck? 

#2
FergusM

FergusM
  • Members
  • 460 messages
If you simply wish to have the dragon move close to targets/etc, the AIP is all you need. You say you're having trouble getting it to work; start from the existing AIP and figure out where your changes are breaking it. They can be a little finnicky, but in general doing a fly to wp command should be enough. I don't remember doing anything special for this.

If you want to script a particular jump, there's a few things to know. First, there are two kinds of jumps, long range and short range. For short range, you just use CommandFly(), which will make the dragon play a short flight animation. However, past a certain distance this command will fail. Here you will have to use a longer flight, where the dragon disappears into the sky. This is actually just setting the dragon inactive, moving it and then setting it active again; the activate/deactivate animations for dragons have them fly rather than simply disappear.

For example, here is how I handle it, with a custom event in the creature script. It's mostly taken from the archdemon's creature script. Sorry for the awful formatting.

case EVENT_TYPE_DRAGON_FLY:
{
location newloc = GetEventLocation(ev,0);

int isShortFlight = GetEventInteger(ev,1);
if (isShortFlight)
{
command fly = CommandFly(newloc,TRUE);
AddCommand(OBJECT_SELF,fly,TRUE);
}
else
{
//long flight
//ClearAllCommands(dragon);
SetObjectActive(OBJECT_SELF,FALSE,649);
//set inactive using special animation

//set up the flight down
event eFlyDown = Event(EVENT_TYPE_SET_OBJECT_ACTIVE);
float fFacing = GetFacingFromLocation(newloc);
eFlyDown = SetEventLocation(eFlyDown, 0, newloc);
eFlyDown = SetEventInteger(eFlyDown, 3, TRUE); // tells it to call an AI function
//NB I dont know what the above line does exactly, it's from the archdemon code
eFlyDown = SetEventInteger(eFlyDown, 4, flyto);
eFlyDown = SetEventFloat(eFlyDown, 0, fFacing);
//eFlyDown = SetEventInteger(eFlyDown, 5, TRUE); // force-perceive party when landing
DelayEvent(10.0, OBJECT_SELF, eFlyDown);

}
nEventHandled = TRUE;
break;
}

Modifié par FergusM, 07 août 2010 - 06:30 .


#3
Qutayba

Qutayba
  • Members
  • 1 295 messages
How do you get the Fly option that should be firing in the AIP associated with this event in the creature script? And how does the script know that "ai_move" is to be the Event Location?

#4
FergusM

FergusM
  • Members
  • 460 messages
Okay, so for the script above I simply specified a location myself. I set up that event somewhere like:



event fly = Event(EVENT_TYPE_DRAGON_FLY);

fly = SetEventLocation(ev,0,somelocation);

fly = SetEventInteger(ev,1,TRUEFALSE);

SignalEvent(dragon,ev);



And that can be called wherever you like. This script will not use ai_move waypoints, unless you specifically give it the location of such a waypoint.



If you use the AIP, then that automatically uses ai_move waypoints. You just need to use something like [14 Fly/Turn 7Fly to wp near enemy] with some ai_move waypoints in the area and it should just work with nothing else. This of course will just fire on whatever condition you give in the AIP, and you can't designate a particular wp (e.g. you can say move to random ai waypoint but you can't say "fly to this particular area).



So you can script it yourself, which is "custom ai" if you like, or you can use the existing system in the AIP.

#5
Qutayba

Qutayba
  • Members
  • 1 295 messages
OK, I've gotten it to work when it's the only condition in the AIP (must have had some conflicts before and it wasn't firing). So, I can rebuild the AI now, I think. Out of curiosity, do you know where the Subcommands that go with Fly are listed (or are the two (7: fly to wp near enemy & 1: turn to most hated) that appear in the High Dragon AIP the only 2)? Is there, for example, an option just to fly to a random wp, or a wp away from an enemy?  The ABI_base and AI_Tactics have most of the information one needs to construct a package, but the fly commands seem to be left out, as far as I can tell.

Modifié par Qutayba, 08 août 2010 - 01:02 .


#6
FergusM

FergusM
  • Members
  • 460 messages
I don't know where exactly they come from, but you may want to play around with numbers in the 1 to 10 range. You'll notice that in the high dragon AIP, the subcommand 2 is used for Fly to wp near enemy, whereas the same command is a 7 in the archdemon AIP.