Jump to content

Easy Scripting Question...


TDL_Guvie

Recommended Posts

All I wanna know is why this script didn't work and what I did wrong. And someone to write it the way it should be. This would be very useful.

 

--TDL_Guvie

 

----------------------------------------------

Begin Cave_Guard

 

if ( GetDistance, player < 200 )

 

forcegreeting

 

endif

 

end Cave_Guard

---------------------------------------------

Link to comment
Share on other sites

You're going to have to be a bit more specific than "doesn't work --" is this an error during compile, an error within the game, or unexpected behavior? Two hundred units is quite a bit smaller than you would imagine; did you actually fulfull the condition during testing? Are you testing this under circumstances that would interfere with the normal operation of the greetings for the actor this is attached to?

 

Really... Think, people, think... However, I probably shouldn't have expected a coherent request from you, seeing as how you expected Serrieth to prepare a script.

Link to comment
Share on other sites

Well Marxist I figured out what I was doing wrong in the script, on my own.

 

Begin Cave_Guard

 

Short attackvar

 

if ( GetDistance, Player <= 500 )

if ( AttackVar == 0 )

force greeting

set attackvar to 1

endif

endif

 

end

 

As far as Sarrieth goes if he makes a post calling himself an advanced user I assume he does somewhat know what he's doing. Obviously that is not the case. So, if YOU could be so kind as to write that script out for me, or at least get me going in the right direction, I would appreciate it.

 

Again, all I want the script to do is make a big stone pillar I have against an Imperial keep to slide down once a switch is activated. All I really need to know is what function to use to make it move and perhaps a little explanation of the Time functions since i'm pretty sure you have to use that in this script. I'm not a scripter, but I do have a good sense of design. I learn pretty fast though and i'm starting to understand the language alot better. Just need a little guidance thats all.

Oh and marxist, To be honest with you, i'd rather get script help from you then anyone else just for the simple fact that EVERY script question i've ever asked was answered by you and answered in a fair amount of detail. Theres nothing I hate more then a half-A$$ answer. So, thanks.

 

 

--TDL_Guvie

Link to comment
Share on other sites

Ah, yes... If that's an insult shrouded in sarcasm, I applaud you -- the true mark of good sarcasm is if it is indistinguishable from a compliment. If it was a compliment, then all the same -- the true mark of a good compliment is if it is indistinguishable from sarcasm.

 

First things first -- forget what Serrieth has said. Not being able to have pop-up information, an attached script, or animation are the only limitations to statics when compared with activators -- they can, in fact, move quite easily; in addition to this, you will need not multiple scripts nor a global variable to do this, the position of an object can be determined without the use of a variable, that script will not work, the sky is blue, the grass is green, and scripting is most definitely not fun.

 

Since the vast majority of your posts are in this forum, you should know right from the start that the payload here will be repeated movement down the Z axis. This should happen after the player has activated the object that this script is attached to, and should stop once the boulder reaches a certain point. Thus, the simplest functional version of the script will be as follows:

 

Begin OMG_SWITCH_LOLOLOL_HE_LUVS_TEH_GUARZ
;WEN HE DREAMZ HE SES GIAR P0RN OLOLOLOLOLOLOLOLOL!!!11!

Short State

If ( OnActivate )

 Set State to 1

EndIf

If ( State > 0 )

 If ( OMG_STUNE_TAMPAL_PILOTZ_HAHA->GetPos Z < -100 )

   Set State to 0
   Return

 EndIf

 OMG_STUNE_TAMPAL_PILOTZ_HAHA->MoveWorld Z -20
;This command, along with the standard Move, takes units per second, not units per frame.  Don't ask me why.

EndIf

End

 

The first and last lines of that preliminary script will not change; since OnActivate is only true for one frame, but the action caused by activation takes multiple frames, the state variable will also be a constant. However, that's pretty much all that will stay the same, for this script has more than its share of problems -- you'd need to make sure that the player can get to the door without running into the rock's collision box (which doesn't move throughout the process, as it is, although the static itself does), you'd need to provide code that covers the PC pressing the button multiple times, you'd need to block execution of the movement commands while MenuMode is active, you'd need to cover the PC exiting the door concealed by the stone, you'd need to make the stone automatically go back up under certain conditions, and you'd need to provide a sound effect for the movement of the stone.

 

Getting the collision box to update is simple enough -- the rock just has to be disabled and re-enabled in the script whenever it is in motion. Since both commands would be executed for a single frame (and thus also before that frame is rendered), the player won't see the effect of the disabling. Code that handles the PC pressing that damned button multiple times is also relatively easy, but can be handled in a number of ways -- the method I use here will allow a second activation while the stone is moving, and will cancel that movement; any activation following the cancel, but while the rock is moving will simply be ignored. The MenuMode exclusion is ridiculously simple as its core -- even Serrieth got that one right -- but will get more complicated as more situations are accounted for. Checking for the PC coming outside from the interior cell that the concealed door leads to is also relatively easy; you will just need to move the DoorMarker to an area beyond the stone and then make it move up as if the downward movement has been canceled. Note (AS NOTE ONE) that the State conditions have been altered to allow for multiple states of State; also note (AS NOTE TWO) that a fire-once section at the beginning of the script will set the starting Z position of the stone as a variable. This has been done for the convenience of the section of the script that resets the stone's position by moving it upwards -- an accommodation for an accommodation, you may say, and a situation that you will often encounter.

 

Short DoOnce
Float InitialPos

If ( DoOnce < 1 )

 Set InitialPos to ( OMG_STUNE_TAMPAL_PILOTZ_HAHA->GetPos Z )
 Set DoOnce to 1

ElseIf ( CellChanged )
;ElseIf is used here simply to save space -- besides MenuMode, all of these conditions will be true quite rarely, and never in two consecutive frames.

 If ( OMG_STUNE_TAMPAL_PILOTZ_HAHA->GetDistance Player < 1024 )

   Set State to 2

 EndIf

ElseIf ( MenuMode )

 Return

ElseIf ( OnActivate )

 If ( State < 1 )

   Set State to 1

 ElseIf ( State == 1 )

   Set State to 2

 EndIf

EndIf

If ( State == 1 )

 If ( OMG_STUNE_TAMPAL_PILOTZ_HAHA->GetPos Z < -100 )

   Set State to 0
   Return

 EndIf

 OMG_STUNE_TAMPAL_PILOTZ_HAHA->MoveWorld Z -20
 Disable
 Enable

ElseIf ( State == 2 )

 If ( OMG_STUNE_TAMPAL_PILOTZ_HAHA->GetPos Z > InitialPos )

   Set State to 0
   Return

 EndIf

 OMG_STUNE_TAMPAL_PILOTZ_HAHA->MoveWorld Z 20
 Disable
 Enable

EndIf

 

The next situation that needs to be covered -- the automatic concealment of the door -- is only as difficult as you make it. Because you've shown an interest in time-keeping, the method I'll use here is one where the stone is reset at the turn of the nearest hour, but must be kept down for a minimum time of thirty seconds, real-time. To do this, a new state must first be added to the State variable -- this state being active will mean that the rock is ready to be reset:

 

Float Timer
Float InitialHour

[...]

ElseIf ( State == 3 )

 If ( Timer > 30 )

   If ( GameHour != InitialHour )
 ;GameHour is a global float set to the current in-game hour -- this is done automatically by the game

     Set State to 2
     Set Timer to 0

   EndIf

 Else

   Set Timer to ( Timer + GetSecondsPassed )
 ;GetSecondsPassed is a function that returns the time that has passed since the last frame was rendered
   Set InitialHour to GameHour

 EndIf

EndIf

 

...Alternatively, you could use distance from the stone...

 

ElseIf ( State == 3 )

 If ( OMG_STUNE_TAMPAL_PILOTZ_HAHA->GetDistance Player > 2048 )

   Set State to 2

 EndIf

EndIf

 

...Or a set of inequalities that will determine if the PC is within the area defined by one or multiple polygon(s)...

 

;Accepted Area (definitely not to scale)

;                 /| (1024)
;             /....|
;         /........|
;     /............|
; /................|
;|____________| (0)
;|.................|
;|.................|
;|.................|
;|.................|
;|____________| (-1024 )
;(-768)    (768)

Float Ymax_poly2
Set Ymax_poly2 to ( Player->GetPos X * ( 2 / 3 ) + 512 )
;Ymin_poly2 is always 0, and X min / max values for polygon 2 are dictated by first polygon.  The first polygon's boundaries are in the code itself.

[...]

ElseIf ( State == 3 )

 If ( Player->GetPos X < -768 )

   Set State to 2

 ElseIf ( Player->GetPos X > 768 )

   Set State to 2

 ElseIf ( Player->GetPos Y < -1024 )

   Set State to 2

 ElseIf ( Player->GetPos Y > Ymax_poly2 )

   Set State to 2

 EndIf

EndIf

 

You could also combine conditions -- have the stone moved up if the PC is out of a specified area, but also move it up regardless of position if the PC has been idle for too long. Any way you do it, however, you will only be required to modify one line of code to complete the integration:

 

If ( State == 1 )

 If ( OMG_STUNE_TAMPAL_PILOTZ_HAHA->GetPos Z < -100 )

   Set State to 3
   Return

 EndIf

 

Although it's not part of the list of functionality that must be added to the script, it would be a good idea at this point to have the button function as a "manual override" when State is equal to 3:

 

ElseIf ( OnActivate )

 If ( State < 1 )

   Set State to 1

 ElseIf ( State == 1 )

   Set State to 2

 ElseIf ( State > 2 )
 
   Set State to 2
   
 EndIf

EndIf

 

The last planned addition -- sounds that play upon movement of the rock -- is easily done by just using one of the game's included sounds. After making the necessary modifications, you should have something like this for testing:

 

Begin OMG_SWITCH_LOLOLOL_HE_LUVS_TEH_GUARZ

Short DoOnce
Short SoundPlayed
Short State
Float InitialHour
Float Timer
Float InitialPos

If ( DoOnce < 1 )

 Set InitialPos to ( OMG_STUNE_TAMPAL_PILOTZ_HAHA->GetPos Z )
 Set DoOnce to 1

ElseIf ( CellChanged )

 If ( OMG_STUNE_TAMPAL_PILOTZ_HAHA->GetDistance Player < 1024 )

   Set State to 2

 EndIf

ElseIf ( MenuMode )

 Return

ElseIf ( OnActivate )

 If ( State < 1 )

   Set State to 1

 ElseIf ( State == 1 )

   Set State to 2

 ElseIf ( State > 2 )
 
   Set State to 2
   
 EndIf

EndIf

If ( State == 1 )

 If ( OMG_STUNE_TAMPAL_PILOTZ_HAHA->GetPos Z < -100 )

   Set State to 3
   Set SoundPlayed to 0
   Return

 ElseIf ( SoundPlayed < 1 )
 
   OMG_STUNE_TAMPAL_PILOTZ_HAHA->PlaySound3D "Door Stone Close"
   Set SoundPlayed to 1
   
 EndIf

 OMG_STUNE_TAMPAL_PILOTZ_HAHA->MoveWorld Z -20
 Disable
 Enable

ElseIf ( State == 2 )

 If ( OMG_STUNE_TAMPAL_PILOTZ_HAHA->GetPos Z > InitialPos )

   Set State to 0
   Set SoundPlayed to 0
   Return

 ElseIf ( SoundPlayed < 1 )
 
   OMG_STUNE_TAMPAL_PILOTZ_HAHA->PlaySound3D "Door Stone Open"
   Set SoundPlayed to 1

 EndIf

 OMG_STUNE_TAMPAL_PILOTZ_HAHA->MoveWorld Z 20
 Disable
 Enable

ElseIf ( State == 3 )

 If ( Timer > 30 )

   If ( GameHour != InitialHour )

     Set State to 2
     Set Timer to 0

   EndIf

 Else

   Set Timer to ( Timer + GetSecondsPassed )
   Set InitialHour to GameHour

 EndIf

EndIf

End

 

The script should function appropriately, provided that your stone has only a single, persistent reference and you edited the values at lines 47, 60, and 79, along with the object IDs.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

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