Problems With A Timed Script

Post » Wed Dec 23, 2009 11:57 pm

I'm reworking an old mod I released when I was much more of an amateur. I have a statue holding a bowl at the end of a hallway. Inside the bowl is a ruby (it's ID is 'triggerruby"). Once the player approaches within so many feet of the statue (256 units I believe), a message displays (see below). After 30 seconds, the player is hit by a spell if he/she still remains within that general area. The problem i'm having is that the player isn't able to pick up the ruby. I'm assuming it has something to do with the script. This is the script I have attached to the ruby:

begin _TOH_ruby

short doOnce
float timer
;GLOBAL b_PickedUp (Gameplay->Globals)

if (MenuMode == 1 )
Return
endif

if ( OnActivate == 1 )
set b_PickedUp to 1
endif

if ( b_PickedUp == 1 )
Return
endif

if ( GetDistance Player < 256 )
if ( doOnce == 0 )
MessageBox "You come across a finely crafted marble statue holding out a bowl. A woman's voice calls out to you, seeming to come from everywhere. Speaking in unison with the woman's voice is a deeper, darker sounding voice. 'Through darkness into light the stranger has come, a path seldom traveled and conquered by none. For they who have overcome, I offer thee a gift. A gift for the strong, a gift for the swift.'".
set doOnce to 1
endif
set timer to ( timer + GetSecondsPassed )
if ( timer >= 30 )
if ( doOnce == 1 )
Cast "blood sacrifice" Player
set doOnce to 2
endif
endif
else
if ( timer != 0 )
set timer to 0
endif
if ( doOnce != 0 )
set doOnce to 0
endif
endif

end

I have no idea about scripting, so I don't know where the problem with picking up the ruby could be coming from. One thing I wanted to make sure of is that IF the player DOES pick up the ruby and leaves the area, the message will no longer be displayed and the spell will no longer be cast for the rest of the game, even if he/she returns to the statue. This might already be present in the script. If the player does NOT pick up the ruby, I do want the message to be displayed again, but not necessarily every time he/she approcahes the statue. In other words, I don't want this message fillinng up the screen. Maybe every so often to give each message time to disappear on it's own. Since I can't pick up the ruby, which triggers the script, I can't test any of this out, including the time delay and spell casting. Anyone have any ideas on what I should do?

Edit: I'm not exactly sure how to hide the script (or any other long entries in the forums) so it doesn't take up half the page. If someone could tell me how to do that, that would also be very appreciated by me (as well as anyone else reading).
User avatar
Miss K
 
Posts: 3458
Joined: Sat Jan 20, 2007 2:33 pm

Post » Thu Dec 24, 2009 7:46 am

The reason that the player cannot pick up the ruby is the absence of Activate following OnActivate in the script. Another problem is setting the global flag - it prevents the script from executing ever again after activation. Unless this variable is controlling some other aspect of your mod it is completely unnecessary (a local variable would mess things up just as well :P ). The message is long, perhaps too long (I do not know the buffer size). If the buffer is 256 characters, you may see some strange behavior. I am not certain that your ruby can cast a spell, but you will find out soon.

I do not understand the exact circumstances that you want to trigger the spell casting. If the player moves away and later returns the timer can continue to run, or it can be reset (I think that is what your script is attempting to do), or cease to track the player's movement. I have it terminate if the player picks up the ruby (not just activate) and reset the script to display the message after the player moves a certain distance from the statue (that distance is adjustable). Once the player is targeted by the spell it will not happen again.

Begin TOH_rubyshort doOncefloat timerfloat playerDistanceif ( menumode == 1 )    returnendifif ( doOnce == 2 )    returnendifif ( player->GetItemCount "triggerruby" >= 1 )    set doOnce to 2endifif ( doOnce == 0 )    if ( GetDistance player < 256 )        set doOnce to 1        messagebox "You come across a finely crafted marble statue holding out a bowl. A woman's voice calls out to you, seeming to come from everywhere. Speaking in unison with the woman's voice is a deeper, darker sounding voice. 'Through darkness into light the stranger has come, a path seldom traveled and conquered by none. For they who have overcome, I offer thee a gift. A gift for the strong, a gift for the swift.'"    endifendifif ( doOnce == 1 )    if ( GetDistance player > 512 ) ; player has moved away        set doOnce to 0 ; reset        set timer to 0 ; reset        return    endif    set timer to ( timer + GetSecondsPassed )    if ( timer < 30 )        return    endif    Cast "blood sacrifice" player    set doOnce to 2endifEnd

This code has not been tested.

Edit: Apparently I do not know how to make a scrolling box either.
User avatar
Sara Johanna Scenariste
 
Posts: 3381
Joined: Tue Mar 13, 2007 8:24 pm

Post » Thu Dec 24, 2009 1:36 pm

After the message is displayed, the player has 30 seconds to somehow get to the bowl (which is just beyond reach and would require a good jump or levitate to get to it), snatch the ruby then get clear of the area. If the player leaves the area, the spell will not go off. I do want it to be reset each time him/her returns to try to take the ruby though, even if he/she is hit by the spell and fails to get the ruby. If the player does get the ruby and does clear the area before 30 seconds is up, the script will never be triggered again. I'm not sure if this is possible or not. I suppose that the trigger actually should be when the player approaches the statue (and the message is displayed). I think I made the ruby the trigger to get the distance the player is from the statue. It's been a while so I don't exactly remember my intentions at the moment. I wonder if maybe the statue itself could be the trigger instead? Either way, whatever is easiest. If the message is too long, i'll have to think of another way to display it. Perhaps a plaque of some sort on or near the statue. The booming voice effect kind of adds to the suspense in my opinion though. Hopefully I didn't just repeat what I said earlier and gave a bit more detail in what I wanted to accomplish.
User avatar
Sammygirl
 
Posts: 3378
Joined: Fri Jun 16, 2006 6:15 pm

Post » Thu Dec 24, 2009 10:42 am

Thank you for the clarification. I think that placing the script on the statue is a better approach. Make the statue an activator and it should be able to cast the spell. I think this will meet your needs. The message is displayed only once. The timer is reset after each casting or if the player moves away from the statue. The threat ends if the player has the ruby.

Begin TOH_statueshort doOncefloat timerfloat playerDistanceif ( menumode == 1 )    returnendifif ( doOnce == 2 )    returnendifif ( ( player->GetItemCount "triggerruby" ) >= 1 )    set doOnce to 2endifif ( doOnce == 0 )    if ( ( GetDistance player ) < 256 )        set doOnce to 1        messagebox "You come across a finely crafted marble statue holding out a bowl. A woman's voice calls out to you, seeming to come from everywhere. Speaking in unison with the woman's voice is a deeper, darker sounding voice. 'Through darkness into light the stranger has come, a path seldom traveled and conquered by none. For they who have overcome, I offer thee a gift. A gift for the strong, a gift for the swift.'"    endifendifif ( doOnce == 1 )    if ( ( GetDistance player ) > 512 ) ; player has moved away        set timer to 0 ; reset        return    endif    set timer to ( timer + GetSecondsPassed )    if ( timer < 30 )        return    endif    Cast "blood sacrifice" player    set timer to 0 ; resetendifEnd

This code has not been tested.

Edit: tidy up
User avatar
katsomaya Sanchez
 
Posts: 3368
Joined: Tue Jun 13, 2006 5:03 am

Post » Thu Dec 24, 2009 12:35 am

Great. I'll test it out once I get a good night's sleep and a clear head. Then i'll report back here on how things work out. Thanks for the help.
User avatar
Marquis T
 
Posts: 3425
Joined: Fri Aug 31, 2007 4:39 pm

Post » Thu Dec 24, 2009 9:50 am

Ok. I've tested this out and it seems to work fine. I approcahed the statue, the message was displayed and I waited a bit and got hit by the spell. I left the area, came back and was hit by the spell again. Just what I wanted it to do. Thank you, cyran0.
User avatar
leigh stewart
 
Posts: 3415
Joined: Mon Oct 23, 2006 8:59 am


Return to III - Morrowind