Aller au contenu

Photo

Moving characters to non-safe locations


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

#1
BillHoyt

BillHoyt
  • Members
  • 109 messages
I have a cutscene which which several characters performing the ambient 'sit' animation take a part.  At the end of the scene, they are all moved (and sitting on nothing). I suspect that this is because characters who sit must be placed in a non-safe location (i.e. standing 'in' a couch) to start. My guess as to why they are moved is that when the cut is done, the game returns them to the nearest "safe" location.

But my question is not about cutscenes.  It's actually a 2-part question about how I move them back via script:

1.  What is the easiest way to move an NPC to a non-safe location? I have the lLocation and the oObject; I'm just not sure how to get oObject to lLocation when LLocation is not 'safe.'

2. The cut is performed from a script in a conversation - the script also sets plot flags and awards XP. However, the cut does not kick off until AFTER the conversation is finished. That means (I think) that I can't do the move in the same script even after the cut commands, as the NPCs will be placed in a safe location by the cut AFTER the script had moved them. I need to move them after the cut completes. So how do I kick off a scrip that will run AFTER the cut, when the cut itself runs after the conversation in which I could put a script?

Any insight would be appreciated.

#2
Proleric

Proleric
  • Members
  • 2 355 messages
IIRC a recent developer post mentioned that SetLocation could result in a non-safe outcome.

To start a second script after the cutscene, I've been using the parameters of CS_LoadCutscene to set a plot flag at the end. The plot event script does the business. Works like a charm so far.

#3
BillHoyt

BillHoyt
  • Members
  • 109 messages
Thanks, Proleric. I will give that a shot.

#4
Craig Graff

Craig Graff
  • Members
  • 608 messages
SetPhysicsController to false and use SetPosition. If it's still not working you may need to use a very short delayed event.

#5
BillHoyt

BillHoyt
  • Members
  • 109 messages
Proleric: that worked great. I have a feeling that's going to come in handy.

Craig: I haven't use SetPosition before and I'm a little confused by the wiki. Can you explain something to me?

//Put sitters back in their places
object oPatrond2 = GetObjectByTag("patrond2",0);
vector vPatrond2 = [1.0, 2.0, 3.0]; // coords from the wiki
SetPhysicsController(oPatrond2, 0); // allow unsafe placement
SetPosition(oPatrond2,vPatrond2,FALSE); //place dwarf patron 2
SetPhysicsController(oPatrond2, 1); // disallow unsafe placement

On setting the vector, the position I'm trying to get my NPC re-placed to is [10.3, -21.0, 0.0] and I had guessed that I merely had to place those in the brackets to get vPatrond2 set properly. However, the -21.0 gives me a "Parsing Constant Vector" error, so obviously I'm barking up the wrong tree, since Y=-21 is a valid location.

Can you or someone give me the quick version of what I'm doing wrong and how to SetPosition my dwarf back to [10.3, -21.0, 0.0]?

Thanks.

Modifié par BillHoyt, 13 juillet 2010 - 01:06 .


#6
_L_o_B_o_

_L_o_B_o_
  • Members
  • 117 messages

BillHoyt wrote...
vector vPatrond2 = [1.0, 2.0, 3.0]; // coords from the wiki


That's a mistery indeed. Any negative value leads to the Parsing constant vector error. Maybe you can try de following instead:

vector vPatrond2 = Vector(10.3f, -21.0f, 0.0f);

Modifié par _L_o_B_o_, 13 juillet 2010 - 05:04 .


#7
BillHoyt

BillHoyt
  • Members
  • 109 messages
Thanks, LOBO, that's progress. I got it to compile and run using that...

edit: but it was still calculating a 'safe' location. Anyhow, I switched from SetPosition to SetLocation to test it that way, and while I was testing, managed to make it work:

//Put Patron D2 back in her place
object oPatrond2 = GetObjectByTag("patrond2",0);
object oMainControlled = GetMainControlled();
SetPhysicsController(oPatrond2, FALSE);
location lPatrond2 = Location(GetArea(oMainControlled), Vector(10.4f, -21.0f, 0.0f), -90.0);
SetLocation(oPatrond2, lPatrond2);

I think now the main problem was turning the PhysicsController back on after
placement. So whether SetPosition or SetLocation is better I don't know.  But it's working, so I'll leave well enough alone.

Thanks, all, for the help.

Modifié par BillHoyt, 13 juillet 2010 - 08:51 .


#8
Sunjammer

Sunjammer
  • Members
  • 926 messages

BillHoyt wrote...

Can you or someone give me the quick version of what I'm doing wrong and how to SetPosition my dwarf back to [10.3, -21.0, 0.0]?

You weren't doing anything wrong: its a bug (at least as far as I'm concerned).

A vector literal is more typically used for setting default value of a parameter but there should be no reason (other than this bug) not to use it exactly as you are doing so. I've not checked they byte code but in theory it should be more efficient to use the literal than call a constructor when all the components are literal floats.

Anyway I've reported it as a bug and updated Lex.