Post by Drew on Oct 19, 2014 21:10:38 GMT -5
This system has such potential, you can literally make gravity in RPGM2 with this system. Please note that all credit to this find belongs to Draygone, if you use it in your game it wouldn't be a bad idea to mention it. Anyway let's begin.
Create the following variables:
Height
Fall Z
Flags:
Falling
Still
We need also to make two objects:
InvisRug
InvisJump
You HAVE to make the InvisRug model the blue rug object (this is how the magic works)
Create the following events:
JumpRug
JumpEvent
Now the scripts:
[RugDupe]
Repeat flag=off
Data: Game Info Load
Height=Party Z-1 (This will make the event duplicate underneath the player's feet) X,Y,Z
If Event X < Party X
Event: Duplicate: JumpRug: 1,0,0
Temp Remove
End
If Event X > Party X
Event: Duplicate: JumpRug: -1,0,0
Temp Remove
End
If Event Y < Party Y
Event: Duplicate: JumpRug: 0,1,0
Temp Remove
End
If Event Y > Party Y
Event: Duplicate: JumpRug: 0,-1,0
Temp Remove
End
If Event Z < Height
Event: Duplicate: JumpRug: 0,0,1
Temp Remove
End
If Event Z > Height
Event: Duplicate: JumpRug: 0,0,-1
Temp Remove
End
Wait: 1f
Script Branch End
This script will go into the action slot of the "JumpRug" event place it on a map and test it out it should follow you around under your feet.
Now we need an event to constantly be on the ground for us to check when/when not to be "falling".
New action script:
[JumpEvent]
Repeat:Flag=off
Event: Bypass Objects: On
Event: Bypass Members: On
Data: Game Info Load
Event: Info Load
Fall Z=Event Z+0
If Event X < Party X
Event: Move E 0f
End
If Event X > Party X
EVent: Move W 0f
End
If Event Y < Party Y
Event Move: S 0f
End
If Event Y > Party Y
Event Move: N 0f
End
If Party Z < Fall Z
Falling=on
End
IF Party Z >= Fall Z
Falling=off
No Movement=off
End
Script Branch End
This is pretty much saying if the player is higher than the even to trip the flag "Falling". Which the falling script looks like so:
[Falling]
Repeat:Flag=off
If Falling=on
Repeat: Falling=On
Party:Vertical Move: -3 1f (anything lower and it's almost TOO fast)
End
Script Branch End
Script Branch End
Place the JumpEvent on your map and insert the JumpEvent action script to the action slot of the event. Test it walk to a ledge and you SHOULD fall over the edge.
To make a jump all you need to do is a make a Button Mapping script.
Repeat
Input Buttons Constant Wait
If User Button=6 [ ] for now
Party Vertical Move: 50/16 Add to current height 5f
End
Now if we test it and press [ ] we should go up and then come back down, but you'll notice that your feet will be somewhat in the ground, no worries there is a simple fix to it. Name it "Z Checker"
[Z Checker]
Repeat
Repeat: Party Z <= Fall Z
Vertical Move: 1 1F add to current
End
End
In your Enter Map script make sure you call the following:
Apply Together
[Inf.Vehicle]
[User Button]
[Z Checker]
[Fall Check]
In Order
There is one final problem that needs to be addressed this system doesn't work too well if you try to move and jump things can get wonky....but yet again there is a simple step check that can be done to fix this problem like so:
[StandStillChk]
Repeat
Data:Game Info Load
TempVar0=Player X
TempVar1=Player Y
Wait 8F
Data: Game Info Load
If TempVar0=Player X
If TempVar1=Player Y
If Still=Off
Still=On
End
End
End
If TempVar0=/=Player X
If Still=On
Still=Off
End
End
If TempVar1=/=Player Y
If Still=On
Still=Off
End
End
Script Branch End
Now on the conditions right before "Jumping" we need to add
If Still=On
Vertical Move: 50/16 5f add to current
End
Test it and you should only be able to jump up and move when you're standing still for at least 1 step.
I almost forgot you'll want to make a indirect step check to stop the player from moving in the air indefinitely the best way to make the player "drop" when you want is to just turn the system "No Movement" flag to on it will drop you dead in your tracks and fall straight down. Anyway enjoy! If you have any questions feel free to ask!
Create the following variables:
Height
Fall Z
Flags:
Falling
Still
We need also to make two objects:
InvisRug
InvisJump
You HAVE to make the InvisRug model the blue rug object (this is how the magic works)
Create the following events:
JumpRug
JumpEvent
Now the scripts:
[RugDupe]
Repeat flag=off
Data: Game Info Load
Height=Party Z-1 (This will make the event duplicate underneath the player's feet) X,Y,Z
If Event X < Party X
Event: Duplicate: JumpRug: 1,0,0
Temp Remove
End
If Event X > Party X
Event: Duplicate: JumpRug: -1,0,0
Temp Remove
End
If Event Y < Party Y
Event: Duplicate: JumpRug: 0,1,0
Temp Remove
End
If Event Y > Party Y
Event: Duplicate: JumpRug: 0,-1,0
Temp Remove
End
If Event Z < Height
Event: Duplicate: JumpRug: 0,0,1
Temp Remove
End
If Event Z > Height
Event: Duplicate: JumpRug: 0,0,-1
Temp Remove
End
Wait: 1f
Script Branch End
This script will go into the action slot of the "JumpRug" event place it on a map and test it out it should follow you around under your feet.
Now we need an event to constantly be on the ground for us to check when/when not to be "falling".
New action script:
[JumpEvent]
Repeat:Flag=off
Event: Bypass Objects: On
Event: Bypass Members: On
Data: Game Info Load
Event: Info Load
Fall Z=Event Z+0
If Event X < Party X
Event: Move E 0f
End
If Event X > Party X
EVent: Move W 0f
End
If Event Y < Party Y
Event Move: S 0f
End
If Event Y > Party Y
Event Move: N 0f
End
If Party Z < Fall Z
Falling=on
End
IF Party Z >= Fall Z
Falling=off
No Movement=off
End
Script Branch End
This is pretty much saying if the player is higher than the even to trip the flag "Falling". Which the falling script looks like so:
[Falling]
Repeat:Flag=off
If Falling=on
Repeat: Falling=On
Party:Vertical Move: -3 1f (anything lower and it's almost TOO fast)
End
Script Branch End
Script Branch End
Place the JumpEvent on your map and insert the JumpEvent action script to the action slot of the event. Test it walk to a ledge and you SHOULD fall over the edge.
To make a jump all you need to do is a make a Button Mapping script.
Repeat
Input Buttons Constant Wait
If User Button=6 [ ] for now
Party Vertical Move: 50/16 Add to current height 5f
End
Now if we test it and press [ ] we should go up and then come back down, but you'll notice that your feet will be somewhat in the ground, no worries there is a simple fix to it. Name it "Z Checker"
[Z Checker]
Repeat
Repeat: Party Z <= Fall Z
Vertical Move: 1 1F add to current
End
End
In your Enter Map script make sure you call the following:
Apply Together
[Inf.Vehicle]
[User Button]
[Z Checker]
[Fall Check]
In Order
There is one final problem that needs to be addressed this system doesn't work too well if you try to move and jump things can get wonky....but yet again there is a simple step check that can be done to fix this problem like so:
[StandStillChk]
Repeat
Data:Game Info Load
TempVar0=Player X
TempVar1=Player Y
Wait 8F
Data: Game Info Load
If TempVar0=Player X
If TempVar1=Player Y
If Still=Off
Still=On
End
End
End
If TempVar0=/=Player X
If Still=On
Still=Off
End
End
If TempVar1=/=Player Y
If Still=On
Still=Off
End
End
Script Branch End
Now on the conditions right before "Jumping" we need to add
If Still=On
Vertical Move: 50/16 5f add to current
End
Test it and you should only be able to jump up and move when you're standing still for at least 1 step.
I almost forgot you'll want to make a indirect step check to stop the player from moving in the air indefinitely the best way to make the player "drop" when you want is to just turn the system "No Movement" flag to on it will drop you dead in your tracks and fall straight down. Anyway enjoy! If you have any questions feel free to ask!