THUG1 scripts Vehicle (in thug2) spawning location

Discuss thug2 modding, post your own, share your ideas, ask questions.
Anteara
Posts: 268
Joined: Thu Oct 14, 2010 2:55 am
Contact:

THUG1 scripts Vehicle (in thug2) spawning location

Postby Anteara » Tue Jul 05, 2011 1:41 pm

Hi, this is the only bug i need to fix before I can release my mod... I just can't find out where the spawning locations are, I have no idea, I've searched everywhere I can think of.

Vehicles (such as custom car) spawn at 0 X, 0 Y, and 0 Z. I figured it could be the default reset location as that's at 000, but that's not the function that vehicles use to set their spawn location.

Does anyone know how to change where they spawn?

Thanks.
quazz
Posts: 185
Joined: Sat May 01, 2010 5:57 pm
Contact:

Re: THUG1 scripts Vehicle (in thug2) spawning location

Postby quazz » Tue Jul 05, 2011 6:48 pm

R u kidding me

Code: Select all

   :i $skater$.$Obj_GetPosition$
      :i call $ToggleUserControlledVehicleMode$ arguments
         $VehicleSetup$ =  ($MinibajacarSetup$ + :s{$pos$ = %GLOBAL%$pos$:s})
Anteara
Posts: 268
Joined: Thu Oct 14, 2010 2:55 am
Contact:

Re: THUG1 scripts Vehicle (in thug2) spawning location

Postby Anteara » Wed Jul 06, 2011 6:28 am

quazz wrote:R u kidding me

Code: Select all

   :i $skater$.$Obj_GetPosition$
      :i call $ToggleUserControlledVehicleMode$ arguments
         $VehicleSetup$ =  ($MinibajacarSetup$ + :s{$pos$ = %GLOBAL%$pos$:s})


Thanks, I can't tell if you're being condescending though, but thanks for the script.

It, however didn't work perfectly, but I changed it to this and it worked perfectly.

Code: Select all

      :i call $createPlayerVehicle$ arguments
         $VehicleSetup$ =  ($CustomCarSetup$ + :s{$pos$ = %GLOBAL%$pos$:s})


Thanks.

Also, the reason I couldn't figure it out is because $VehicleSetup$ doesn't appear to be in the scripts, and the NonLocalPlayer VehicleSetup didn't work / I didn't even think about looking at that, I didn't think it would be worthwhile trying to figure out how it worked, If i knew how it worked I could have most definitely figured this out. I thought it was something to do with the restarts, etc, since it spawned at 000 XYZ. I have a habit of over-complicating things...
quazz
Posts: 185
Joined: Sat May 01, 2010 5:57 pm
Contact:

Re: THUG1 scripts Vehicle (in thug2) spawning location

Postby quazz » Wed Jul 06, 2011 7:07 am

The position thing isn't as big of a deal as you thought it was. It's just creating a composite object at a position, and this puts it right at the skater's position. Tehnically morten told/gave me that code a year or two ago so credit goes to him. :)

"ToggleUserControlledVehicleMode" is SUPPOSED to be the real way to toggle driving mode, but it doesn't work well for me in THUG2 either. CreatePlayerVehicleMode somewhat works but not as it should: it messes with the physics and camera, and makes it slightly awkward.. I've also tried messing with the scripts concerning "broadcasting" vehicle models to other players, used only by default in Goal Attack, but I've had no luck either.
Anteara
Posts: 268
Joined: Thu Oct 14, 2010 2:55 am
Contact:

Re: THUG1 scripts Vehicle (in thug2) spawning location

Postby Anteara » Wed Jul 06, 2011 10:39 am

quazz wrote:The position thing isn't as big of a deal as you thought it was. It's just creating a composite object at a position, and this puts it right at the skater's position. Tehnically morten told/gave me that code a year or two ago so credit goes to him. :)

"ToggleUserControlledVehicleMode" is SUPPOSED to be the real way to toggle driving mode, but it doesn't work well for me in THUG2 either. CreatePlayerVehicleMode somewhat works but not as it should: it messes with the physics and camera, and makes it slightly awkward.. I've also tried messing with the scripts concerning "broadcasting" vehicle models to other players, used only by default in Goal Attack, but I've had no luck either.


it messes with the physics and camera, and makes it slightly awkward..


I've actually been able to fix that part,

Code: Select all

:i function $Anteara_ExitVehicle$
   :i $Skater$.$GetCameraId$
   :i if NOT $GameIsPaused$
      :i %GLOBAL%$CameraId$.$unpause$
   :i endif
   :i call $SetActiveCamera$ arguments
      $id$ = %GLOBAL%$CameraId$
   :i $PlayerVehicle$.$Die$
   :i $PlayerVehicleCamera$.$Die$
   :i $Skater$.$UnsetDriving$
   :i $Skater$.$ReturnBoardToSkater$
   :i $Skater$.call $Obj_ShadowOn$ arguments
      $ShadowType$ = $Detailed$
   :i $Skater$.$ResetRigidBodyCollisionRadiusBoost$
   :i $GoalManager_HideAllGoalPeds$%i(0,00000000)
   :i call $change$ arguments
      $driving_parked_car$ = %i(0,00000000)
   :i call $MakeSkaterGoto$ arguments
      $SkaterInit$
   :i $exit_pause_menu$
:i endfunction


Code: Select all

:i function $car_fix_new$
   :i $Skater$.$BashOff$
   :i $Skater$.$NollieOff$
   :i $Skater$.$PressureOff$
   :i $Skater$.$LandSkaterTricks$
   :i $Skater$.$ResetSwitched$
   :i $Skater$.$ClearTrickQueues$
   :i $Skater$.$DestroyAllSpecialItems$
   :i $Skater$.$SparksOff$
   :i $Skater$.$VibrateOff$
   :i $Skater$.$StopBalanceTrick$
   :i $Skater$.$KillExtraTricks$
   :i $Skater$.call $SetExtraTricks$ arguments
      $NoTricks$
   :i $Skater$.$PausePhysics$
   :i $Skater$.$SkaterLoopingSound_TurnOff$
   :i $Skater$.$TakeBoardFromSkater$
   :i $Skater$.$Obj_ShadowOff$
   :i $GoalManager_HideAllGoalPeds$%i(1,00000001)
   :i call $Debounce$ arguments
      $X$
   :i call $Debounce$ arguments
      $Square$
      :i call $MakeSkaterGoto$ arguments
         $DrivingAi$
:i endfunction


It's essentially the core of ToggleUserControlledVehicle, but to be also used with CreatePlayerVehicle. It fixes the physics and camera issue, When I spawn a car I call exit vehicle, then vehicle fix, then call the actual vehicle, its complicated and messy, but hey, it fixes everything.

Edit: Under closer inspection, I've completely fixed the physics bugs, but the camera bugs still aren't fixed :(
quazz
Posts: 185
Joined: Sat May 01, 2010 5:57 pm
Contact:

Re: THUG1 scripts Vehicle (in thug2) spawning location

Postby quazz » Thu Jul 07, 2011 4:18 am

Nice work!
Morten1337
Posts: 132
Joined: Tue Jun 08, 2010 11:11 pm
Contact:

Re: THUG1 scripts Vehicle (in thug2) spawning location

Postby Morten1337 » Thu Jul 07, 2011 2:58 pm

camera fix:

Code: Select all

      :i call $SetActiveCamera$ arguments
         $Id$ = $PlayerVehicleCamera$
Anteara
Posts: 268
Joined: Thu Oct 14, 2010 2:55 am
Contact:

Re: THUG1 scripts Vehicle (in thug2) spawning location

Postby Anteara » Sun Jul 10, 2011 9:13 am

Thanks, that fixes the camera bug.

Hmm, I've found one other bug that i'm not sure how to fix...

When I change level, or start a game, while i'm in a vehicle, the screen will be black, and I can't do anything until the game ends, because the screen is completely black.

Does anyone know how to fix this?
Morten1337
Posts: 132
Joined: Tue Jun 08, 2010 11:11 pm
Contact:

Re: THUG1 scripts Vehicle (in thug2) spawning location

Postby Morten1337 » Sun Jul 10, 2011 2:33 pm

Anteara wrote:Thanks, that fixes the camera bug.
Hmm, I've found one other bug that i'm not sure how to fix...
When I change level, or start a game, while i'm in a vehicle, the screen will be black, and I can't do anything until the game ends, because the screen is completely black.
Does anyone know how to fix this?

Yes, since this game is not designed for driving there are lots of bugs... like when you change a level, it doesn't "go back" to skating.
So you'll need to run the exit vehicle function, which will set the camera back.

The reason why the screen is black is because you're displaying a camera that is deleted.
Anteara
Posts: 268
Joined: Thu Oct 14, 2010 2:55 am
Contact:

Re: THUG1 scripts Vehicle (in thug2) spawning location

Postby Anteara » Sun Jul 10, 2011 2:44 pm

Morten1337 wrote:
Anteara wrote:Thanks, that fixes the camera bug.
Hmm, I've found one other bug that i'm not sure how to fix...
When I change level, or start a game, while i'm in a vehicle, the screen will be black, and I can't do anything until the game ends, because the screen is completely black.
Does anyone know how to fix this?

Yes, since this game is not designed for driving there are lots of bugs... like when you change a level, it doesn't "go back" to skating.
So you'll need to run the exit vehicle function, which will set the camera back.

The reason why the screen is black is because you're displaying a camera that is deleted.


Ah, I see, well thanks, now that I know this I've fixed one of the two bugs, when the game requests a level, i've added this to the level request function;

Code: Select all

   :i if $ObjectExists$ arguments
      $Id$ = $PlayerVehicle$
   :i $Anteara_ExitVehicle_Working$
   :i endif


I'll try and find out how to do it when starting a game, but the game request function seems to be stored in the exe (?) and I'm not able to access it to add the exit vehicle function in to it, I'll keep looking though.
Morten1337
Posts: 132
Joined: Tue Jun 08, 2010 11:11 pm
Contact:

Re: THUG1 scripts Vehicle (in thug2) spawning location

Postby Morten1337 » Sun Jul 10, 2011 3:24 pm

Code: Select all

   :i if $Driving$
      :i $Anteara_ExitVehicle_Working$
   :i endif
Anteara
Posts: 268
Joined: Thu Oct 14, 2010 2:55 am
Contact:

Re: THUG1 scripts Vehicle (in thug2) spawning location

Postby Anteara » Sun Jul 10, 2011 6:21 pm

Thanks, I'll add that soon.

Sorry to be such a bother, even though I've been here a while and learned a lot from you guys I still have a lot to learn, This is (I hope) the last bug I need to fix before my mod is bug free, out of 30 or so bugs I've been able to fix most of them by myself, but this one I just can't figure out. I have a habit of over complicating things and I bet I'm doing that now, but, Do any of you think you would be able to help me comprehend / figure out this last part which needs fixing?

Problem: When starting a game (CM, Graff, TA, etc), black screen happens, must exit vehicle to get rid of black screen.

Cause: As morten stated, it's because I'm using a cam that is deleted.

Solution: Automatically exit vehicle upon entering a game.


The way I fixed the black screen upon changing levels bug was to add this to the $request_level$ function.

Code: Select all

:i function $request_level$
   :i if $ObjectExists$ arguments
      $Id$ = $PlayerVehicle$
   :i $Anteara_ExitVehicle_Working$
   :i endif
   :i if call $gotparam$ arguments
         $level$
      :i $RequestLevel$%GLOBAL%$level$
   :i else
      :i $script_assert$%s(33,"request_level needs a level param")
   :i endif
:i endfunction


So i've added an if statement to check for the cam, and then to exit vehicle.


I'm not sure if it's possible to do that another way, but it works.

Whilst trying to solve the bug upon entering a game (CM, TA, Graff, etc) I found this function... $chosen_start_game$

Inside the function it contains $StartNetworkGame$, which as it says, starts the network game... I tried to find the function so I could add the exit vehicle script to $StartNetworkGame$, but I couldn't find anything in any of the qb's. I found $StartNetworkGame$ in the exe however, but I don't know how to access it.

So that's my problem, I don't know how to automatically call the exit vehicle script, because I simply don't know where to put the function.

I probably seem a bit novice by asking for something this simple (I could solve it myself, but because I can't find the function I need, as it appears to be in the exe (?), I don't know what to do)

So do you any of you guys think you would be able to help me with this problem?

To summarize, Automatically exit vehicle upon starting a game (CM, TA, etc).

Sorry for the wall of text. >_<
Anteara
Posts: 268
Joined: Thu Oct 14, 2010 2:55 am
Contact:

Re: THUG1 scripts Vehicle (in thug2) spawning location

Postby Anteara » Mon Jul 11, 2011 7:51 am

Yeah, I've tried it, It works if you're the host, but not if you're not the host, probably because when you're not the host that function doesn't get called, it most likely goes straight to StartNetworkGame and skips it all together, I think.
Morten1337
Posts: 132
Joined: Tue Jun 08, 2010 11:11 pm
Contact:

Re: THUG1 scripts Vehicle (in thug2) spawning location

Postby Morten1337 » Mon Jul 11, 2011 3:28 pm

i got an idea.
try to add this to the start driving function;
might get lucky, some internal functions could toggle it off/on..

Code: Select all

   :i call $change$ arguments
         $Driving$ = %i(1,00000001)
Anteara
Posts: 268
Joined: Thu Oct 14, 2010 2:55 am
Contact:

Re: THUG1 scripts Vehicle (in thug2) spawning location

Postby Anteara » Wed Jul 13, 2011 11:57 am

Morten1337 wrote:i got an idea.
try to add this to the start driving function;
might get lucky, some internal functions could toggle it off/on..

Code: Select all

   :i call $change$ arguments
         $Driving$ = %i(1,00000001)



Wow, Amazing. It works now, thanks so much. I understand why you thought that would work, and it's so simple too! >_<
Changing driving to 1 didn't fix it, but I looked around the driving scripts and found this

Code: Select all

      :i $Skater$.$SetDriving$


And adding that to the start driving function fixed it.

Thanks.



Edit: Sigh, I'm seriously plagued with bugs. The $SetDriving$ function fixed the black screen bug, for both host, and anyone that isn't host. However, now when the host uses a vehicle, it will crash all people on the server, even if they're using the same mod. I removed $SetDriving$, and now the host no longer crashes people on the server. People on the server can't crash the host, but the host can crash them.

So annoying... any ideas? :S


Last bumped by Anteara on Wed Jul 13, 2011 11:57 am.

Return to “THUG2 modding”

Who is online

Users browsing this forum: No registered users and 23 guests