Trouble with script - please help

Post » Fri Jun 10, 2011 10:42 pm

I have a small section added to a companion script that triggers events if the player comes near a person or object

i went to test it today and the game refused to load saying there was an expression error in my script it says it couldn't find the object ac_shrine_stopmoon - this is the shrine in the Vivec temple area that commemorates vivec stopping the moon.

The section of script goes like this

If [ GetJournalIndex "BM_Nine" == 4 ]    if [ GetDistance "ac_shrine_stopmoon" <= 512 ]        ForceGreeting        Journal BM_Tour 4    endifendif


Any ideas on why the game can't find ac_shrine_stopmoon?

I can get around it by putting my own activator in the cell but I would rather just reference an object that is already there - in this case the shrine is the only one of its kind in the game
User avatar
TOYA toys
 
Posts: 3455
Joined: Sat Jan 13, 2007 4:22 am

Post » Sat Jun 11, 2011 3:05 am

im no expert, but have you tried putting a player call in there? as in

If [ GetJournalIndex "BM_Nine" == 4 ]
if [ player->GetDistance "ac_shrine_stopmoon" <= 512 ]
ForceGreeting
Journal BM_Tour 4
endif
endif


could that work?
User avatar
Tai Scott
 
Posts: 3446
Joined: Sat Jan 20, 2007 6:58 pm

Post » Sat Jun 11, 2011 8:18 am

Obviously adding a forcegreeting command to an object wont work, cos they dont have access to dialogue (although there IS actually a way to simulate this ive found) but yes, ID's are very important. Never assume that just because a command is attached to a person that that command will ACT on that person. It is far more reliable and gives you more control to use ID's for everything.
User avatar
Ebony Lawson
 
Posts: 3504
Joined: Fri Feb 16, 2007 11:00 am

Post » Sat Jun 11, 2011 3:41 am

I'm not sure I understand

The script is attached to a companion who in dialogue asks to be taken to the shrine - what I wanted to happen was the greeting to be forced when close to the object - I know i have named it correctly as I copied and pasted its id from the CS into the script.

What I don't understand is why the game can't find the object when I try to load the game - it keeps telling me there is an expression error in the companion's script and it can't find ac_shrine_stopmoon - yet it is clearly in Vivec cell 3, -13 ?

Do i need to put my own named activator there instead? Or am I writing this section of the script wrong?
User avatar
jeremey wisor
 
Posts: 3458
Joined: Mon Oct 22, 2007 5:30 pm

Post » Sat Jun 11, 2011 7:14 am

I did something like this with an activator. Whenever the player got close enough to it, the script on the activator would cause the companion to forcegreet the player and say her dialog. What you want is something like this on the activator:

If ( GetJournalIndex "BM_Nine" == 4 )      if ( player->GetDistance <= 512 )          "npc_id" -> ForceGreeting           Journal BM_Tour 4      endif endif

User avatar
Bereket Fekadu
 
Posts: 3421
Joined: Thu Jul 12, 2007 10:41 pm

Post » Sat Jun 11, 2011 8:49 am

In order for a script to reference an object as you have, the object needs to exist in the world (it is) and it needs to have been checked 'references persist' (a look in the construction set indicates it is not). This is likely the reason for the error message.

As for the solution, you could check 'references persist' for this official object, but that creates the possibility of conflicts with other mods that might alter the same object. That would be the objection to placing a script on the shine as Jac suggests (although that would certainly work). Better is to create your own new invisible activator with either Jac's script attached or 'references persist' checked.

I wonder if it would be better to add the journal entry before the forced greeting (in case the script stops processing at that point).

An altogether different approach would be to determine a set of x and y values that surround the shrine. When the player is within the minimum and maximum values of x and y that indicate he or she is near the shrine the greeting is triggered. This also has the virtue of being a more efficient use of system resources than distance checks.
User avatar
leni
 
Posts: 3461
Joined: Tue Jul 17, 2007 3:58 pm

Post » Sat Jun 11, 2011 6:50 am

Sounds like trigonometry to me cyran0 :) Thanks for checking out the references persist issue - why is it that the simplest things can sometimes trip us up?

I've gone and tried putting an invisible activator in the cell - which while i would have preferred not to for testing purposes alone it is worth taking an easy option before i go any further.

If i have any more issues I'll come back to this thread

Thanks to everyone who took the time to post a reply - it is genuinely very much appreciated.
User avatar
Nuno Castro
 
Posts: 3414
Joined: Sat Oct 13, 2007 1:40 am

Post » Fri Jun 10, 2011 7:56 pm

Sounds like trigonometry to me cyran0 :)
No trig, a little geometry :yes: , just test player is inside a rectangle centered on the shrine
if ( GetJournalIndex "BM_Nine" == 4 ); shrine x=31856, y=-102288; test for player inside (x-200,y-200) (x+200,y+200)	if ( player->GetPos X > 31656 )		if ( player->GetPos X < 32056 )			if ( player->GetPos Y > -102488 )				if ( player->GetPos Y < -102088 )					Journal BM_Tour 4					"NPC_id"->ForceGreeting   ; better using no spaces around -> operator and Forcegreeting as last command				endif			endif		endif	endifendif

User avatar
Angela
 
Posts: 3492
Joined: Mon Mar 05, 2007 8:33 am


Return to III - Morrowind