Jump to content

Advanced scripting question


soaren

Recommended Posts

Been having a lot of trouble with this one: Basically, I'm making an escort quest, and there are like 20 NPCS, and I want them to stay in formation that is relative to the leader of the npcs they are following, and I'm having issues where the NPCS are running all over the place in combat, and plus the follow package looks like crap, they are all crowded in a line, so what I'm trying to figure out is how I would go about scripting them to remain "x distance behind, and y distance to the side" from any particular npc, so I can script a "formation" style escort, where they stay in a rectangular formation, so it's easier for the player to keep track of/defend them.

 

I have posted many request for help with this on this forum over the past few months (and have popped into chat randomly MANY TIMES asking for advanced scripting help), and noone has been able to help me, I would really appreciate any help you can give me.

 

Thanks

 

soaren (Devlin S Healy)

Edited by soaren
Link to comment
Share on other sites

Been having a lot of trouble with this one: Basically, I'm making an escort quest, and there are like 20 NPCS, and I want them to stay in formation that is relative to the leader of the npcs they are following, and I'm having issues where the NPCS are running all over the place in combat, and plus the follow package looks like crap, they are all crowded in a line, so what I'm trying to figure out is how I would go about scripting them to remain "x distance behind, and y distance to the side" from any particular npc, so I can script a "formation" style escort, where they stay in a rectangular formation, so it's easier for the player to keep track of/defend them.

 

I have posted many request for help with this on this forum over the past few months, noone has been able to help me, I would really appreciate any help you can give me.

 

Thanks

 

soaren (Devlin S Healy)

 

Insanely tricky this one mate. Insanely. Have you tried asking them nicely? (j/k)

 

Other than create a set path for them go down, laying them out and AI Packaging them to 'walk' from markerA to markerB, there's not a fat lot you can do AFAIK.

Link to comment
Share on other sites

Been having a lot of trouble with this one: Basically, I'm making an escort quest, and there are like 20 NPCS, and I want them to stay in formation that is relative to the leader of the npcs they are following, and I'm having issues where the NPCS are running all over the place in combat, and plus the follow package looks like crap, they are all crowded in a line, so what I'm trying to figure out is how I would go about scripting them to remain "x distance behind, and y distance to the side" from any particular npc, so I can script a "formation" style escort, where they stay in a rectangular formation, so it's easier for the player to keep track of/defend them.

 

I have posted many request for help with this on this forum over the past few months (and have popped into chat randomly MANY TIMES asking for advanced scripting help), and noone has been able to help me, I would really appreciate any help you can give me.

 

Thanks

 

soaren (Devlin S Healy)

ok, this would be a purely conceptual thought, i'm not saying that this will actually in any way work or that i'm in any way recommending committing scripts like that :-)...:

i know you can do the following, because i just did it in a script to set a custom waiting location for a pet:

you set a token-item (a basketball in my case, doesn't seem to work with statics) persistant, give it a name and make it the npc's / creature's linked ref.

then you can set up an ai-package (travel in my case) that makes the npc move to it's linked ref.

 

in my waiting-spot-case, first i kill the token-object (my basketball) in any way i can, i've made a copy with collision: filter, set the reference to no ai-aqquire, initially disabled, the size is set to 0,0100 (geck won't let me set it to 0 in 3d-data) and then setscale it to 0 with script, pretty sure less would do, but i'm not sure which, so just make it dead and gone any way you can, as long as it has a name, is persistant and the npc's linked ref.

when i set the location now, this is per tokenREF.moveto npcREF. the token is now where the npc is and stays there, there fori (see above) i killed collision, disabled it and did whatever so no stupid havoc-stuff happens with it, and this is how the location is marked.

when i want it to return there now, i just make the package start, that makes the npc go back to it's linked ref, which is my disabled token where i wanted it.

 

so far, i can guarantee that that works. the rest is speculation:

you will need a creature, because you can't run a follow-package on a basketball (i think, at least), but i can't see a reason why this shouldn't go with say a rat as a token, setscale to 0, disable it, whatever, don't think killing will go with a follow package, but there's a funcion like i think setrestrained to completely stop ai-processing, so as good as dead.

so, for every npc in your formation, you'd need a token creature linkedREF, each one persistant and with a refname.

to explain it for a single one:

you set the npc, call him soldier, on follow linked ref (your token creature) package.

then, in the first step, you'd first moveTo player this soldier's disabled, zero-scaled whatever works token-beast and, from there, set it to the position relative to the pc you want the soldier using the various positioning functions like setpos and so on.. the soldier, who follows this creature, should now move there.

so you now could for example gameMode keep asking for GetDistance between player and the token creature (so it doesn't move tokens and run whole script every cycle, you'd have to do this for all of the token creatures after all), and if it falls below a certain value (depending on how close the formation should be), you moveto player the token and setpos it to the next position relative to the player you want the soldier, and if the soldier is set on a close enough distance to the token creature (closer than the formation should be so the ai thinks it needs to catch up), he should always try to get there without ever reaching, because before that, you'd moveto it away to the next location again (setting the token as starting location without setting an end location could help here too, but then the follow package would theoretically never really start, just always try to reach the start destination).

 

so basically, what this should get you would be something like a portable patrol marker.

or maybe you could set up a permanent ping-pong-patrol between two token items per soldier, always moving the one he's just left behind, i could imagine this could result in smoother movement...

 

so, like i said, just conceptual, speculative, inefficient and most likely plain dumb, but maybe it can set you on some kind of track, what do i know... :-)

Link to comment
Share on other sites

@stevie70,

 

Could you not just use xmarkerheadings instead of invisible basketballs?

 

Maybe two sets of xmarkers, two for each npc in formation.

 

Use the middle xmarker as the leader, the others are moved using the leader. When the NPCs reach their xmarker, move the the second set of xmarkers ahead ten meters. Set all the npcs linked ref to the new xmarkers. Repeat always placing the rear xmarker ahead when npcs reach the xmarkers.

NPCs have a patrol package follwing linked ref.

 

This would only be linear but you could accomplish turns by using setangle on the leader and making all the non leader xmarkers face the same way.

 

In the script block in which you place the rear xmarker forward, check to make sure that each NPC is < 5meters to their xmarker before moving them.

Edited by PaladinRider
Link to comment
Share on other sites

@stevie70,

Could you not just use xmarkerheadings instead of invisible basketballs?

basically, i think this should work with anything that can be moved (it definitely does not work with statics), if markers can be moved by script (dunno), this defintely sounds like a good idea :-)

 

This would only be linear but you could accomplish turns by using setangle on the leader and making all the non leader xmarkers face the same way.

i wouldn't use a leader-npc for that, i'd set each markers position always relative to the player. like, for a v-formation with say player in lead and 2*2 npc*s behind, you'd one time calculate all 4 positions, then, whenever you're moving (= getDistance to your control marker increasing), you only need to calculate new positions for the first 2-npc's-row, and move the markers for the second row (and third, fourth and so on) to where the ones for the first row were before, takes less calculation that way.

hm, well, when i think that through, this would be more two straight rows of soldiers behind the player than an actual v, but anyway, my point being, the less markers you need to actually _calculate_ new positions for, the better, how much of the position data you can recycle largely depends on the formation of course.

 

and for the turns, you could use something like getheadingangle and, with maths beyond my capability, i'm afraid, calculate curves using those angles, it just depends on in how close distance you set the markers and how exactly they form a bend, then you wouldn't need to setangle, because the npc's orient to the next marker themselves.

and for setangle as well as for rotate: using this once works fine.

but using this twice or more, produces really far out results, the more often you use this, the more random it gets where they're actually turned (almost freaked trying to use setangle on a creature just twice recently). i think it even says something about this being buggy in the geck-wiki. (same with the distance- and relative-position-parameters on placeatme, would be cool, but doesn't actually do anything)

Link to comment
Share on other sites

Hahaha. Some interesting Ideas, might have to fiddle around with them, but there's no way to do this without a masters degree in Gecktology?

 

All I want to do is have a row/column of 3 by 5 NPCS that stay a similar distance behind the one in front of them and the same distance beside the next one in a row, so they are in formation, and they set the pace the player has to follow, but not follow the player himself.

 

Stevie's post above did make it seem a little more difficult than I honestly thought it was gonna be (figured there was some kind of command you could use in script that would do the curve calculations for you, or maybe a command that controlled the npcs distance next to another ones), but maybe this just isn't possible?

 

Anyone else have any ideas?

Link to comment
Share on other sites

It won't look military, especially over uneven terrain. NPCs are very erratic and even if you give them patrol they aren't consistent enough.

 

You'd probably end up with one speeding up and stopping, and them turning into each other. You can't force them to follow a very specific path (if you can it'd probably be very difficulty)

Link to comment
Share on other sites

Stevie's post above did make it seem a little more difficult than I honestly thought it was gonna be

that doesn't necessarily mean there's no easier way, i've just been modding for about two months or so now.

yet, if paladin rider, who appears to be one of the most active people here, doesn't know anything easier either, i'd start to worry... ;-)

Link to comment
Share on other sites

Unpossible. The marker method's the best you can get, and from experience I can tell you it's horribly ineffective- if the player spends 5 hours fast travelling, the script won't run to move the marker during that period and the NPCs will stand around for 5 hours in one place. The engine makes use of follow package targets in things like interior-exterior/worldspace-worldspace transitions (so everyone following somebody will cell transition at once) so if they're all technically on travel packages they'll drip-feed into cells. Finally, as it's for a quest, if you put a moving XMarker as a quest target it causes stuttering when the script moves it.
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...