Script to make an object looks like its falling

Post » Sat May 28, 2011 1:25 pm

I want to make a boulder fall from the sky, I'm using the following script:

float zcord 4614Begin GameModeIf (GetStage PLArmouryQst ==100)Set zcord to (zcord - 0.1)Set zcord to (zcord - 0.1)FireBallRock1REF.SetPos z, zcordFireBallFlame1REF.SetPos z, zcordendifend


The condition "GetStage PLArmouryQst ==100" becomes true when I exit a door. I start off outside, I can see the boulder floating in the sky, I got inside and then outside (making GetStage PLArmouryQst ==100 true) and the boulder and flame are gone. Why doesn't this work? Surely a decay of 0.1 on the zcord wouldn't make it disappear in a flash (it is really really high up).

Any ideas?
User avatar
Victor Oropeza
 
Posts: 3362
Joined: Sun Aug 12, 2007 4:23 pm

Post » Sat May 28, 2011 8:28 am

Well, your zcord would be equal to 0 since its not initialized. So it would start at 0 and go into the negatives pretty quick.

It also depends on your FPS since with that method, it moves .1 per FPS cycle. That would be 40 per second if you get 40 FPS. And since you are subtracting it twice, that would be moving 80 units per second.

I would probably use this method instead.

float zcordBegin OnLoad	set zcord to FireBallRock1REF.GetPos zendBegin GameMode	If (GetStage PLArmouryQst == 100)		if zcord > 0			Set zcord to (zcord - GetSecondsPassed * 180)			FireBallRock1REF.SetPos z, zcord			FireBallFlame1REF.SetPos z, zcord		endif	endifend

You then increase the '180' to make it move faster if its going too slow.

You also want a way to 'stop' the script from running. I set it to stop once it gets to a z cord of zero.
User avatar
Hannah Whitlock
 
Posts: 3485
Joined: Sat Oct 07, 2006 12:21 am

Post » Sat May 28, 2011 10:07 am

Well, your zcord would be equal to 0 since its not initialized. So it would start at 0 and go into the negatives pretty quick.

It also depends on your FPS since with that method, it moves .1 per FPS cycle. That would be 40 per second if you get 40 FPS. And since you are subtracting it twice, that would be moving 80 units per second.

I would probably use this method instead.

float zcordBegin OnLoad	set zcord to FireBallRock1REF.GetPos zendBegin GameMode	If (GetStage PLArmouryQst == 100)		if zcord > 0			Set zcord to (zcord - GetSecondsPassed * 180)			FireBallRock1REF.SetPos z, zcord			FireBallFlame1REF.SetPos z, zcord		endif	endifend

You then increase the '180' to make it move faster if its going too slow.

You also want a way to 'stop' the script from running. I set it to stop once it gets to a z cord of zero.


It works great, a bit slow but I've increased the 180 as you suggested. Thank you very much!
User avatar
Elizabeth Davis
 
Posts: 3406
Joined: Sat Aug 18, 2007 10:30 am

Post » Sat May 28, 2011 3:46 pm

Ok I've built on your code and I've only just realised that the code doesn't work unless the player is outside (in the exterior where the boulder is) and an NPC comes out of the door and runs the script. If just the player walks out, the boulder does not move.

However when the player exits the interior and waits for an npc to exit, then the npc triggers the script and I see the boulder fall. I don't know how to correct this, any ideas?

ScriptName PLArmourySpawnKeepSoldiersshort check Begin OnActivateIf IsActionRef player == 1PLKeepSoldier1REF.SetPos x, 67904PLKeepSoldier1REF.SetPos y, 56309PLKeepSoldier1REF.SetPos z, 672PLKeepSoldier1REF.SetIgnoreFriendlyHits 1PLKeepSoldier1REF.EquipItem PLWeapSteelLongsword 1SetStage PLGateStart 2SetStage PLArmouryQst 100SetStage PLWaves 1Set check to 1endifPLArmouryExitREF.activateendfloat zcordBegin onload	set zcord to FireBallRock1REF.GetPos zendBegin GameMode	If (check == 1)		if zcord > 1870			Set zcord to (zcord - GetSecondsPassed * 540)			FireBallRock1REF.SetPos z, zcord			FireBallFlame1REF.SetPos z, zcord			PLFlameBouldTravelREF.SetPos z,zcordFireBallFlame1REF.EnablePLFlameBouldTravelREF.Enablemessage "moving" ,1else if zcord < 1870		FireBallFlame1REF.Disable		PLFlameBouldTravelREF.Disable		PLBoulderImpactREF.Enable		PLBoulderFlameHouseREF.Enablemessage "not moving" ,1		endif	endifend

User avatar
leigh stewart
 
Posts: 3415
Joined: Mon Oct 23, 2006 8:59 am

Post » Sat May 28, 2011 2:29 pm

double post
User avatar
Jonathan Windmon
 
Posts: 3410
Joined: Wed Oct 10, 2007 12:23 pm

Post » Sat May 28, 2011 8:20 pm

You probably need to use a 'trigger zone' instead. And put the trigger zone near the door so the player activates the trigger zone. You would then put the script on the trigger zone that 'OnTrigger' starts the boulder falling.
User avatar
JESSE
 
Posts: 3404
Joined: Mon Jul 16, 2007 4:55 am


Return to IV - Oblivion