Aller au contenu

Photo

Best way to define the PC object in a script


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

#1
UnrealJedi

UnrealJedi
  • Members
  • 113 messages
If I need to run a script that is executed because of an ExecuteScript function from another script, how would I define the PC object? This is related to the topic I posted two days ago (Gestalt Cutscene Issue - Henchman attacks NPC before cutscene ends). I want to have a cutscene script execute another script that causes the NPC's reputation to adjust and then have the NPC attack the PC. Since I can't get this to work in the cutscene script I thought I would try this method. However, I am not sure how to define the PC object when the PC is just in the area and hasn't triggered the script (e.g. by entering the area or trigger, or by conversation). Can anyone assist?

Thanks!

#2
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages
It all depends on where and how you are running the script.

IF you are not changing the object the script is running on and not adding a delay to the script, anything theat would work in the script you are calling from will work in the script you are running. In fact you are still in the same event. the event will not finish untill after the calling script finishes. the calling script will not finish untill the called script finishes. That is all assumeing that you are calling the script without delay and onto the same object that the first one is running on.

#3
UnrealJedi

UnrealJedi
  • Members
  • 113 messages
Hmmm...the event starts by the PC entering a trigger. The script on the trigger, in accordance with the Gestalt system, runs and executes a cutscene script (see the topic I posted two days ago for that script code). If I understand correctly, I should not have to define the objects (actors) used in the cutscene in a second called script because they have already been defined in the cutscene script. If that is the case then the called script will not compile correctly, but that should not matter. Because it is a called script it should run just fine.

Am I understanding correctly?

#4
meaglyn

meaglyn
  • Members
  • 811 messages
No, I don't think so...

The executed script does not have access to variables defined in the scope of the first script.

I think Lightfoot was saying you can get the PC object in the executed script the same way you got it in the first script. For example GetEnteringObject() if that's what you used.

#5
UnrealJedi

UnrealJedi
  • Members
  • 113 messages
Ah, okay. I think I have it now.

Thanks!

#6
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages
Yes that is what I was saying. however since gesalt runs mostly off of delayed commands the event accosors will not work. your best bet with what you are doing will be to run the script on oPC. THen the PC will be OBJECT_SELF in the script.

#7
UnrealJedi

UnrealJedi
  • Members
  • 113 messages
meaglyn and Lightfoot, might I ask a favor? Would you mind looking at the code I posted a couple of days back and help me figure out how to fix it? Gestalt has a function to make a cut scene actors attack the PC but not an AdjustReputation function. To my understanding, an NPC will not attack the PC unless reputation is also adjusted.

Thanks.

#8
Squatting Monk

Squatting Monk
  • Members
  • 446 messages
Normally, adjusting the reputation would be handled by the NPC's OnPhysicalAttacked or OnDamaged event. If you've removed those scripts or altered them so they no longer adjust the PC's reputation, you can just DelayCommand() your AdjustReputation() inside your cut-scene script.

#9
UnrealJedi

UnrealJedi
  • Members
  • 113 messages
Thanks SquattingMonk. I am trying that right now.

#10
UnrealJedi

UnrealJedi
  • Members
  • 113 messages
Okay, this is weird. I used DelayCommands as suggested. The DetermineCombatRound function has disappeared from the compiler so my script will not compile. I assume Gestalt may have removed it for some reason but sure why. Any thoughts?

#11
Squatting Monk

Squatting Monk
  • Members
  • 446 messages
DetermineCombatRound() requires nw_i0_generic. Did you remove an include directive pointing to that file?

#12
UnrealJedi

UnrealJedi
  • Members
  • 113 messages
Squatting Monk, that include file conflicts with Gestalt's Cutscene system. So I don't have to repeat myself, you can look at the topic referenced in my original post for details.

I think it works without the DetermineCombatRound. Just gotta get the cutscene timing down now.

#13
UnrealJedi

UnrealJedi
  • Members
  • 113 messages
Okay, it does not work without DetermineCombatRound. I tried altering Gestalt's cutscene system so it would not conflict with the standard NWN scripts but that didn't work either. I am back to trying to call the below script from the cutscene script I made. However, I am still getting compiler error messages, specifically UNKNOWN STATE IN COMPILER (for the line "object oTarget =  GetObjectByTag("Jacinn");". I am still a n00b to scripting so help is appreciated.

Thanks!


Here is the script:

1) #include "nw_i0_generic"
2)
3) void main()
4) {
5)
6) object oPC = GetLocalObject(GetModule()
7)
8) object oTarget =  GetObjectByTag("Jacinn");
9)
10) AdjustReputation(oPC, oTarget, -100);
11)
12) SetIsTemporaryEnemy(oPC, oTarget);
13)
14) AssignCommand(oTarget, ActionAttack(oPC));
15)
16) AssignCommand(oTarget, DetermineCombatRound(oPC));
17)
18) }
 

Modifié par UnrealJedi, 13 décembre 2013 - 05:01 .


#14
Squatting Monk

Squatting Monk
  • Members
  • 446 messages
You need a semicolon at the end of line 6.

#15
MrZork

MrZork
  • Members
  • 940 messages
And a closing parenthesis.

#16
UnrealJedi

UnrealJedi
  • Members
  • 113 messages
Thanks. It's nice to know I at least had my coding right. But as they say, the devil is in the details. :-) Thanks again!

#17
henesua

henesua
  • Members
  • 3 878 messages
actually if you are getting a local object set on the module, you also need the label you are using for that object. Line 6 looks like some of it was not included.

#18
ffbj

ffbj
  • Members
  • 593 messages
Think of the semi colon as a statement. variablex = something; (end of statement).
Then you have types of statements if then else if etc...
So the semi-colon would come after the implied then:
if x = y
(then Implied) Do this;


(else implied) Do nothing either return; or look for another condition if script is too continue.
You should check out Jaspers newb corner.
Also line 6 should probably be ObjectSelf.

You should also familarise yourself with other ways to denote tthe PC such as
GetFirstPC, get nearest, etc...

Modifié par ffbj, 17 décembre 2013 - 12:47 .