Jump to content

Scripting Help


pieceoshu

Recommended Posts

Alright. Here is the best I could do you guys. If anybody wants to force a character movement just use this for info.

I couldn't get everything just right but all the details are there. I jsut don't know what mm means.

 

I do however know what it does. If you notice that mm = distance/time.

What it does is pretty much the moveto function at very small intervals. This was just the way they came up with to do that. Pretty ingenious. It divides the time it will take to get there and how far you want to go and makes it load a new position every ( I'm not actually sure how long.) second maybe? At least thats how I think it works.

 

Let me know what you think.

 

 

SCN aaCubeQuestActivaterScript

Short global

Float YAxisPosition

Float YAxis

Float XAxisPosition

Float XAxis

Float ZAxisPosition

Float ZAxis

Float timer

Short State

Short zeropointcoordinate

Short mm

Short distance

Short time

Short position

Short finalposition

Short DoOnce

Short RemoveIT

Short RemoveEnergy

 

 

Begin GameMode

 

if (global == 0)

ForceActiveQuest aaCubeQuest01 " aaCubeQuest01" 1

SetObjectiveDisplayed " aaCubeQuest01" 1 1

Set global to 1

endif

End

 

Begin GameMode

 

if (RemoveIT == 0)

if (CubeVar > = 350)

Player.UnequipItem aaCubeArmor 1 1

Player.RemoveItem aaCubeArmor 1 1

Set RemoveIT to -1

endif

endif

 

if (RemoveEnergy == 0)

if (CubeVar == 97) & & (Player.GetItemCount, " aaCubeEnergySmelter" == 1)

Player.UnequipItem aaCubeEnergySmelter 1 1

Player.RemoveItem aaCubeEnergySmelter 1 1

Set RemoveEnergy to -1

endif

endif

End

 

; ======================= Refuse look =============================

 

Begin GameMode

 

if (CubeVar == -1)

Set zeropointcoordinate to Player.GetPos Y

Set timer to 0

Set distance to 405

Set time to 10

Set mm to (distance/time)

Set CubeVar to -2

endif

 

if (CubeVar == -2)

Set timer to timers + GetSecondsPassed

Set position to timer * mm

Set finalposition to (zeropointcoordinate + position)

Player.SetPos Y final position

 

if (timer > = time)

Set CubeVar to -3

endif

endif

End

 

; ======================= generator look =============================

 

Begin GameMode

 

if (CubeVar == -4)

Set zeropointcoordinate to Player.GetPos Z

Set timer to 0

Set distance to 1214

Set time to 7

Set mm to (distance/time)

Set CubeVar to -5

endif

 

if (CubeVar == -5)

Set timer to timer + GetSecondsPassed

Set position to timer * mm

Set finalposition to (zeropoin coordinate + position)

Player.SetPos Z final position

 

if (timer > = time)

Set CubeVar to -6

endif

endif

End

 

 

Begin GameMode

 

if (CubeVar == 2)

Set YAxisPosition to Player.GetPos Y

Set YAxis to YaxisPosition +2

Player.SetPos Y Yaxis

endif

End

 

 

Begin GameMode

 

if (CubeVar == 4)

Set YAxisPosition to Player.GetPos Y

Set YAxis to YaxisPosition +4

Player.SetPos Y Yaxis

endif

End

 

 

Begin GameMode

 

; CubeStationIIMove01MarkerRef

if (CubeVar == 21)

Set YAxisPosition to Player.GetPos Y

Set YAxis to YaxisPosition -6

Player.SetPos Y Yaxis

endif

 

; CubeStationIIMove02MarkerRef

if (CubeVar == 22)

Set XAxisPosition to Player.GetPos X

Set XAxis ton of XaxisPosition +8

Player.SetPos X Xaxis

endif

 

; CubeStationIIMove03MarkerRef

if (CubeVar == 23)

Set YAxisPosition to Player.GetPos Y

Set YAxis to YaxisPosition -8

Player.SetPos Y Yaxis

endif

 

; CubeStationIIMove04MarkerRef

if (CubeVar == 24)

Set XAxisPosition to Player.GetPos X

Set XAxis to XaxisPosition -8

Player.SetPos X Xaxis

endif

 

; CubeStationIIMove05MarkerRef

if (CubeVar == 25)

Set ZAxisPosition to Player.GetPos Z

Set ZAxis to ZaxisPosition -15

Player.SetPos Z Zaxis

endif

 

; CubeStationIIMove06MarkerRef

if (CubeVar == 26)

Set XAxisPosition to Player.GetPos X

Set XAxis to XaxisPosition -15

Player.SetPos X Xaxis

endif

 

; CubeStationIIMove07MarkerRef

if (CubeVar == 27)

Set YAxisPosition to Player.GetPos Y

Set YAxis to YaxisPosition +15

Player.SetPos Y Yaxis

endif

 

; CubeStationIIMove08MarkerRef

if (CubeVar == 28)

Set XAxisPosition to Player.GetPos X

Set XAxis to XaxisPosition +15

Player.SetPos X Xaxis

endif

 

; CubeStationIIMove09MarkerRef

if (CubeVar == 29)

Set YAxisPosition to Player.GetPos Y

Set YAxis to YaxisPosition -15

Player.SetPos Y Yaxis

endif

 

; CubeStationIIMove10MarkerRef

if (CubeVar == 30)

Set XAxisPosition to Player.GetPos X

Set XAxis to XaxisPosition +20

Player.SetPos X Xaxis

endif

 

; CubeStationIIMove11MarkerRef

if (CubeVar == 31)

Set YAxisPosition to Player.GetPos Y

Set YAxis to YaxisPosition +20

Player.SetPos Y Yaxis

endif

 

; CubeStationIIMove12MarkerRef

if (CubeVar == 32)

Set XAxisPosition to Player.GetPos X

Set XAxis to XaxisPosition -20

Player.SetPos X Xaxis

endif

 

; CubeStationIIMove13MarkerRef

if (CubeVar == 33)

Set ZAxisPosition to Player.GetPos Z

Set ZAxis to ZaxisPosition -30

Player.SetPos Z Zaxis

endif

 

; CubeStationIIMove14MarkerRef

if (CubeVar == 34)

Set YAxisPosition to Player.GetPos Y

Set YAxis to YaxisPosition -20

Player.SetPos Y Yaxis

endif

 

; CubeStationIIMove15MarkerRef

if (CubeVar == 35)

Set XAxisPosition to Player.GetPos X

Set XAxis to XaxisPosition -20

Player.SetPos X Xaxis

endif

 

; CubeStationIIMove16MarkerRef

if (CubeVar == 36)

Set YAxisPosition to Player.GetPos Y

Set YAxis to YaxisPosition +15

Player.SetPos Y Yaxis

endif

 

; CubeStationIIMove17MarkerRef

if (CubeVar == 37)

Set XAxisPosition to Player.GetPos X

Set XAxis to XaxisPosition +15

Player.SetPos X Xaxis

endif

 

; CubeStationIIMove18MarkerRef

if (CubeVar == 38)

Set YAxisPosition to Player.GetPos Y

Set YAxis to YaxisPosition +5

Player.SetPos Y Yaxis

endif

 

; CubeStationIIMove19MarkerRef

if (CubeVar == 39)

Set XAxisPosition to Player.GetPos X

Set XAxis to XaxisPosition +10

Player.SetPos X Xaxis

endif

 

; CubeStationIIMove20MarkerRef

if (CubeVar == 40)

Set YAxisPosition to Player.GetPos Y

Set YAxis to YaxisPosition -5

Player.SetPos Y Yaxis

endif

 

; CubeStationIIMove21MarkerRef

if (CubeVar == 41)

Set XAxisPosition to Player.GetPos X

Set XAxis to XaxixPosition +2

Player.SetPos X Xaxis

endif

End

 

 

 

 

 

; CubeRefugeElevator

Begin GameMode

 

if (CubeVar == 70)

Set ZAxisPosition to Player.GetPos Z

Set ZAxis to ZaxisPosition +5

Player.SetPos Z Zaxis

endif

End

 

Begin GameMode

if (CubeVar == 75)

Set ZAxisPosition to Player.GetPos Z

Set ZAxis to ZaxisPosition +5

Player.SetPos Z Zachse

endif

End

 

; ======================= [station III CubeFanJump] ===========================

 

Begin GameMode

if (CubeVar == 95)

Set zero point coordinate to Player.GetPos Z

Set timer to 0

Set distance to 7360

Set time to 10

Set mm to (distance/time)

Set CubeVar to 96

endif

 

if (CubeVar == 96)

Set timer to timer + GetSecondsPassed

Set position ton of timer * mm

Set final position to (zero point coordinate + position)

Player.SetPos Z final position

 

if (timer > = time)

Set CubeVar to 97

endif

endif

End

 

; CubeEscapeToVertibird

Begin GameMode

 

if (CubeVar == 130)

Set XAxisPosition to Player.GetPos X

Set XAxis to XaxisPosition -3.5

Player.SetPos X Xaxis

endif

 

; CubeEscapeVertibird

 

End

Link to comment
Share on other sites

Alright. Here is the best I could do you guys. If anybody wants to force a character movement just use this for info.

I couldn't get everything just right but all the details are there. I jsut don't know what mm means.

 

I do however know what it does. If you notice that mm = distance/time.

What it does is pretty much the moveto function at very small intervals. This was just the way they came up with to do that. Pretty ingenious. It divides the time it will take to get there and how far you want to go and makes it load a new position every ( I'm not actually sure how long.) second maybe? At least thats how I think it works.

 

Let me know what you think.

 

--->8---

 

Cool :) TapControl/TapKey pales in comparison :D

Still alot more convoluted than I had anticipated though.

If only we could define functions... (Label and Goto are just ridiculous)

 

 

BTW: "mm" is simply another variable, used to store the speed at which the object needs to move (the distance to travel in a given amount of time, thus distance/time), remember the Rule of Three? :)

 

BTW2: Please put it in a codebox next time.

 

BTW3: There's still some residual vars & logic at the top, specifically

Short RemoveIT 
Short RemoveEnergy 


Begin GameMode 

  if (global == 0) 
      ForceActiveQuest aaCubeQuest01  " aaCubeQuest01" 1 
      SetObjectiveDisplayed " aaCubeQuest01" 1 1 
      Set global to 1 
  endif 
End 

Begin GameMode 

  if (RemoveIT == 0) 
     if (CubeVar > = 350) 
        Player.UnequipItem aaCubeArmor 1 1 
        Player.RemoveItem aaCubeArmor 1 1 
        Set RemoveIT to -1 
     endif 
  endif 

  if (RemoveEnergy == 0) 
     if (CubeVar == 97) & & (Player.GetItemCount, " aaCubeEnergySmelter" == 1) 
        Player.UnequipItem aaCubeEnergySmelter 1 1 
        Player.RemoveItem aaCubeEnergySmelter 1 1 
        Set RemoveEnergy to -1 
     endif 
  endif 
End 

Link to comment
Share on other sites

Sorry those are for a gun you get on the mod itself. It has infinite ammo and you can only use in the world space that the mod takes place. And yes I will use a code box next time.

 

I still can't get it to work correctly, but at least we have the general Idea.

Link to comment
Share on other sites

Sorry those are for a gun you get on the mod itself. It has infinite ammo and you can only use in the world space that the mod takes place. And yes I will use a code box next time.

 

I still can't get it to work correctly, but at least we have the general Idea.

Link to comment
Share on other sites

Is there any reason in particular why there are 11 separate GameMode blocks? While I suppose in certain obscure situations it might make sense to use more than one GameMode block in a script, this is certainly not one of them. All of the code that should run during GameMode should be in the same GameMode block.

 

After running the script through my Script Validator, I noticed that there are a few errors in the "set" commands that I would expect to prevent the script from compiling. Specifically:

Accompanying "to" required for "set" command on line 133
Accompanying "to" required for "set" command on line 297
Accompanying "to" required for "set" command on line 307
Accompanying "to" required for "set" command on line 308

 

I also noticed that there are a very large number of variables. While this in itself is not a bad thing, it can make them easier to lose track of, and I notice that there are a couple of unused variables. I have no way of knowing if they've been used remotely from other scripts, so I just though I'd make sure that you realise that they aren't referenced in this script. The unused variables are "State" and "DoOnce".

 

The number of variables could also be considerably reduced if the following variables are "combined":

  • YAxisPosition
  • YAxis
  • XAxis
  • XAxisPosition
  • ZAxis
  • ZAxisPosition

For example, the code could be changed in the following way:

; CubeStationIIMove05MarkerRef
if (CubeVar == 25)
Set ZAxisPosition to Player.GetPos Z
Set ZAxis to ZaxisPosition -15
Player.SetPos Z Zaxis
endif

; CubeStationIIMove06MarkerRef
if (CubeVar == 26)
Set XAxisPosition to Player.GetPos X
Set XAxis to XaxisPosition -15
Player.SetPos X Xaxis
endif

; CubeStationIIMove05MarkerRef
if (CubeVar == 25)
set position to player.GetPos Z - 15
player.SetPos Z position
endif

; CubeStationIIMove06MarkerRef
if (CubeVar == 26)
set position to player.GetPos X - 15
player.SetPos X position
endif

There are also various other errors that I can see in the script that I would expect to prevent it from compiling, such as extra whitespace in operators (eg "& &" instead of "&&" on line 42) and enclosing EditorIDs in quotation marks.

 

How exactly is it not working at the moment?

 

Cipscis

Link to comment
Share on other sites

The multitude of GameMode blocks suggests the original developer tested his code in small self-contained chunks and neglected to optimize afterwards.

 

As for the unused variables: The original code was hooked to a switch so "DoOnce" was set in the OnActivate block, and "State" most probably refers to the door which the switch activated.

 

The fact that it's so terribly convoluted (not to mention tedious) may suggest there's a proper way of doing this (similar to AnimGroups?), though I don't recall seeing any behaviour of this kind in Bethesda's releases, so it's possible they just didn't bother.

 

 

I'd suggest testing the script incrementally, and verifying that all the conditional statements return true when supposed to.

 

Also, some fat could be trimmed here and there by using for-loops.

Link to comment
Share on other sites

That's not the actual script it's a translation. Here is the actual script:

 

SCN aaCubeQuestActivaterScript

Short Global

Float YAchsePosition
Float YAchse
Float XAchsePosition
Float XAchse
Float ZAchsePosition
Float ZAchse

Float Timer

Short State
Short NullpunktKoordinate
Short MM
Short Strecke
Short Zeit
Short Position
Short Endposition
Short DoOnce
Short RemoveIT
Short RemoveEnergy


Begin GameMode
if ( Global == 0 )
ForceActiveQuest aaCubeQuest01
SetStage "aaCubeQuest01" 1
SetObjectiveDisplayed "aaCubeQuest01" 1 1
Set Global to 1
endif
End

Begin GameMode
if ( RemoveIT == 0 )
if ( CubeVar >= 350 )
	Player.UnequipItem aaCubeArmor 1 1
	Player.RemoveItem aaCubeArmor 1 1
	Set RemoveIT to -1
endif
endif

if ( RemoveEnergy == 0 )
if ( CubeVar == 97 ) && ( Player.GetItemCount, "aaCubeEnergySmelter" == 1 )
	Player.UnequipItem aaCubeEnergySmelter 1 1
	Player.RemoveItem aaCubeEnergySmelter 1 1
	Set RemoveEnergy to -1
endif
endif


End

;======================= Refuse Look =============================

Begin GameMode
if ( CubeVar == -1 )
Set NullpunktKoordinate to Player.GetPos Y
Set Timer to 0
Set Strecke to 405
Set Zeit to 10
Set MM to (Strecke / Zeit)	
Set CubeVar to -2
endif

if ( CubeVar == -2 )
Set Timer to Timer + GetSecondsPassed	
Set Position to Timer * MM						
Set Endposition to (Nullpunktkoordinate + Position)
Player.SetPos Y Endposition							

if ( Timer >= Zeit )
	Set CubeVar to -3				
endif

endif
End

;======================= Generator Look =============================

Begin GameMode
if ( CubeVar == -4 )
Set NullpunktKoordinate to Player.GetPos Z
Set Timer to 0
Set Strecke to 1214
Set Zeit to 7
Set MM to (Strecke / Zeit)		
Set CubeVar to -5
endif

if ( CubeVar == -5 )
Set Timer to Timer + GetSecondsPassed	
Set Position to Timer * MM						
Set Endposition to (Nullpunktkoordinate + Position)
Player.SetPos Z  Endposition							

if ( Timer >= Zeit )
	Set CubeVar to -6	
endif

endif
End





Begin GameMode
if ( CubeVar == 2 )
	Set YAchsePosition to Player.GetPos Y
	Set YAchse to YachsePosition +2
	Player.SetPos Y Yachse
endif
End

Begin GameMode
if ( CubeVar == 4 )
	Set YAchsePosition to Player.GetPos Y
	Set YAchse to YachsePosition +4
	Player.SetPos Y Yachse
endif
End



Begin GameMode;CubeStationIIMove01MarkerRef
if ( CubeVar == 21 )
	Set YAchsePosition to Player.GetPos Y
	Set YAchse to YachsePosition -6
	Player.SetPos Y Yachse
endif

;CubeStationIIMove02MarkerRef
if ( CubeVar == 22 )
	Set XAchsePosition to Player.GetPos X
	Set XAchse to XachsePosition +8
	Player.SetPos X Xachse
endif

;CubeStationIIMove03MarkerRef
if ( CubeVar == 23 )
	Set YAchsePosition to Player.GetPos Y
	Set YAchse to YachsePosition -8
	Player.SetPos Y Yachse
endif

;CubeStationIIMove04MarkerRef
if ( CubeVar == 24 )
	Set XAchsePosition to Player.GetPos X
	Set XAchse to XachsePosition -8
	Player.SetPos X Xachse
endif


;CubeStationIIMove05MarkerRef
if ( CubeVar == 25 )
	Set ZAchsePosition to Player.GetPos Z
	Set ZAchse to ZachsePosition -15
	Player.SetPos Z Zachse
endif


;CubeStationIIMove06MarkerRef
if ( CubeVar == 26 )
	Set XAchsePosition to Player.GetPos X
	Set XAchse to XachsePosition -15
	Player.SetPos X Xachse
endif

;CubeStationIIMove07MarkerRef
if ( CubeVar == 27 )
	Set YAchsePosition to Player.GetPos Y
	Set YAchse to YachsePosition +15
	Player.SetPos Y Yachse
endif

;CubeStationIIMove08MarkerRef
if ( CubeVar == 28 )
	Set XAchsePosition to Player.GetPos X
	Set XAchse to XachsePosition +15
	Player.SetPos X Xachse
endif

;CubeStationIIMove09MarkerRef
if ( CubeVar == 29 )
	Set YAchsePosition to Player.GetPos Y
	Set YAchse to YachsePosition -15
	Player.SetPos Y Yachse
endif

;CubeStationIIMove10MarkerRef
if ( CubeVar == 30 )
	Set XAchsePosition to Player.GetPos X
	Set XAchse to XachsePosition +20
	Player.SetPos X Xachse
endif

;CubeStationIIMove11MarkerRef
if ( CubeVar == 31 )
	Set YAchsePosition to Player.GetPos Y
	Set YAchse to YachsePosition +20
	Player.SetPos Y Yachse
endif

;CubeStationIIMove12MarkerRef
if ( CubeVar == 32 )
	Set XAchsePosition to Player.GetPos X
	Set XAchse to XachsePosition -20
	Player.SetPos X Xachse
endif

;CubeStationIIMove13MarkerRef
if ( CubeVar == 33 )
	Set ZAchsePosition to Player.GetPos Z
	Set ZAchse to ZachsePosition -30
	Player.SetPos Z Zachse
endif

;CubeStationIIMove14MarkerRef
if ( CubeVar == 34 )
	Set YAchsePosition to Player.GetPos Y
	Set YAchse to YachsePosition -20
	Player.SetPos Y Yachse
endif

;CubeStationIIMove15MarkerRef
if ( CubeVar == 35 )
	Set XAchsePosition to Player.GetPos X
	Set XAchse to XachsePosition -20
	Player.SetPos X Xachse
endif

;CubeStationIIMove16MarkerRef
if ( CubeVar == 36 )
	Set YAchsePosition to Player.GetPos Y
	Set YAchse to YachsePosition +15
	Player.SetPos Y Yachse
endif

;CubeStationIIMove17MarkerRef
if ( CubeVar == 37 )
	Set XAchsePosition to Player.GetPos X
	Set XAchse to XachsePosition +15
	Player.SetPos X Xachse
endif

;CubeStationIIMove18MarkerRef
if ( CubeVar == 38 )
	Set YAchsePosition to Player.GetPos Y
	Set YAchse to YachsePosition +5
	Player.SetPos Y Yachse
endif

;CubeStationIIMove19MarkerRef
if ( CubeVar == 39 )
	Set XAchsePosition to Player.GetPos X
	Set XAchse to XachsePosition +10
	Player.SetPos X Xachse
endif

;CubeStationIIMove20MarkerRef
if ( CubeVar == 40 )
	Set YAchsePosition to Player.GetPos Y
	Set YAchse to YachsePosition -5
	Player.SetPos Y Yachse
endif

;CubeStationIIMove21MarkerRef
if ( CubeVar == 41 )
	Set XAchsePosition to Player.GetPos X
	Set XAchse to XachsePosition +2
	Player.SetPos X Xachse
endif
End

; CubeRefugeElevator

Begin GameMode
if ( CubeVar == 70 )
	Set ZAchsePosition to Player.GetPos Z
	Set ZAchse to ZachsePosition +5
	Player.SetPos Z Zachse
endif
End

Begin GameMode
if ( CubeVar == 75 )
	Set ZAchsePosition to Player.GetPos Z
	Set ZAchse to ZachsePosition +5
	Player.SetPos Z Zachse
endif
End

; =======================[ Station III CubeFanJump ]===========================

Begin GameMode	

if ( CubeVar == 95 )
Set NullpunktKoordinate to Player.GetPos Z
Set Timer to 0
Set Strecke to 7360
Set Zeit to 10
Set MM to (Strecke / Zeit)		
Set CubeVar to 96
endif

if ( CubeVar == 96 )
Set Timer to Timer + GetSecondsPassed	
Set Position to Timer * MM						
Set Endposition to (Nullpunktkoordinate + Position)
Player.SetPos Z  Endposition							

if ( Timer >= Zeit )
	Set CubeVar to 97			
endif

endif
End


; CubeEscapeToVertibird
Begin GameMode	

if ( CubeVar == 130 )
	Set XAchsePosition to Player.GetPos X
	Set XAchse to XachsePosition -3.5
	Player.SetPos X Xachse
endif


; CubeEscapeVertibird




End

 

 

Oh and please if you know how to Set xp to max using script please let me know. We need to not have people level up in our mod. Of course there will be variables set for afterwards based on the number of creatures of each type they killed and the experience given by them. It will add up in the end but we really need that scripting.

Link to comment
Share on other sites

You can use SetInChargen to prevent/allow levelling up without affecting experience gain.

 

To be honest, I think you'd be far better off writing your own script from scratch instead of editing one like this where you don't understand everything that's going on. At the moment it's pretty convoluted and requires an appropriate external setup in order to function correctly, and it could be written much more cleanly as well.

 

Cipscis

Link to comment
Share on other sites

Thank you very much for the SetInCharGen function. We were going to do that manually. Setlevel to 30. Then get a count for each creature killed in the mod ( type and experience given) and RewardXp that much in the end. But that just helps us with about an hour or two of scripting.

 

I was only planning on seeing how they actullaly moved the character. I didn't realize that the setpos function just moved whatever object is referenced to whatever distance and direction was given. I had originally tried to use the moveto command. Hopefully I can finally get them to work the way that I want.

 

Thank you all for your help.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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