Quantcast

Jump to content

» «
Photo

Help with a main.scm mission

6 replies to this topic
serabella
  • serabella

    Noob scripter

  • Members
  • Joined: 18 Jun 2009

#1

Posted 12 July 2013 - 02:54 PM

Hello!

So, I've just started coding again after a ~3 years break. I don't remember very much about it so sorry if I ask "too many" questions.

The mission I'm creating is kind of an introduction mission to my new story. It's a pretty simple mission where the player has to kill a ped. This will spawn a sphere which they player has to walk into. Once in the sphere, another sphere will spawn which the player has to step into to complete the mission.

The thing is that it doesn't work as I want it to. Nothing happens after you've killed the dude, no sphere spawns or anything.

This is my code:

The first part of the mission (which I guess isn't part of the problem)

CODE

:TUT_1
thread 'TUT 1'
gosub @TUT_1_47
if
wasted_or_busted
else_jump @TUT_1_38
gosub @TUT_1_385

:TUT_1_38
gosub @TUT_1_410
end_thread

:TUT_1_47
Model.Load(#KNIFECUR)
Model.Load(#BFYST)
038B: load_requested_models

:TUT_1_58
wait 0
if and
  Model.Available(#KNIFECUR)
  Model.Available(#BMYST)
else_jump @TUT_1_58
01B2: give_actor $PLAYER_ACTOR weapon 4 ammo 10000 // Load the weapon model before using this
01B9: set_actor $PLAYER_ACTOR armed_weapon_to 4
$VICTIM1 = Actor.Create(CivMale, #BMYST, 2265.723, -1105.599, 37.9766)
Actor.Angle($VICTIM1) = 155.0
03E5: show_text_box 'HELP101'  


This is where the spheres should be created if the requirements are met (I guess that it's something here which is fu*ked up)

CODE

:TUT_1_144
wait 0
if
  Actor.Dead($VICTIM1)
else_jump @TUT_1_144
jump @TUT_1_171

:TUT_1_171
$SPHERE_BEFOREJUMP = Marker.CreateIconAndSphere(0, 2287.116, -1120.849, 39.375)

:TUT_1_193
wait 0
if
00FF:   actor $PLAYER_ACTOR sphere 0 in_sphere 2287.116 -1120.849 39.375 radius 2.0 2.0 2.0 on_foot
else_jump @TUT_1_193
jump @TUT_1_252

:TUT_1_252
$SPHERE_AFTERJUMP = Marker.CreateIconAndSphere(0, 2287.091, -1132.956, 26.7332)


And this is the rest of the mission where the "mission complete" trigger etc are placed. As you can see, the mission should be completed once the player steps in the sphere but as it doesn't spawn, it isn't possible to complete it...

CODE

:TUT_1_274
wait 0
if
  Actor.Dead($PLAYER_ACTOR)
else_jump @TUT_1_301
jump @TUT_1_385

:TUT_1_301
00FF:   actor $PLAYER_ACTOR sphere 0 in_sphere 2287.091 -1132.956 26.7332 radius 2.0 2.0 2.0 on_foot
else_jump @TUT_1_274
0394: play_music 1
$MISSIONS_PASSED += 1
Player.Money($PLAYER_CHAR) += 10000
01E3: show_text_1number_styled GXT 'M_PASS' number 10000 time 5000 style 1  // MISSION PASSED!~n~~w~$~1~
return

:TUT_1_385
00BA: show_text_styled GXT 'M_FAIL' time 5000 style 1  // ~r~MISSION FAILED!
0555: remove_weapon 31 from_actor $PLAYER_ACTOR
return

:TUT_1_410
$ONMISSION = 0
Marker.Disable($VICTIM_MARKER)
Player.WantedLevel($PLAYER_CHAR) = 0
Model.Destroy(#BFYST)
Model.Destroy(#BMYST)
Model.Destroy(#M4)
mission_cleanup
return


Just in case if anyone bothers to read through the whole code, here it is:

CODE

:TUT_1
thread 'TUT 1'
gosub @TUT_1_47
if
wasted_or_busted
else_jump @TUT_1_38
gosub @TUT_1_385

:TUT_1_38
gosub @TUT_1_410
end_thread

:TUT_1_47
Model.Load(#KNIFECUR)
Model.Load(#BFYST)
038B: load_requested_models

:TUT_1_58
wait 0
if and
  Model.Available(#KNIFECUR)
  Model.Available(#BMYST)
else_jump @TUT_1_58
01B2: give_actor $PLAYER_ACTOR weapon 4 ammo 10000 // Load the weapon model before using this
01B9: set_actor $PLAYER_ACTOR armed_weapon_to 4
$VICTIM1 = Actor.Create(CivMale, #BMYST, 2265.723, -1105.599, 37.9766)
Actor.Angle($VICTIM1) = 155.0
03E5: show_text_box 'HELP101'  // In this tutorial, you are going to learn what it takes to be a hitman. See that guy with a marker above his head? Sneak up behind him and press and hold the right mouse button to aim at him while crouching with your knife equipped. While raising your knife behind him, press the left mouse button to execute him.

:TUT_1_144
wait 0
if
  Actor.Dead($VICTIM1)
else_jump @TUT_1_144
jump @TUT_1_171

:TUT_1_171
$SPHERE_BEFOREJUMP = Marker.CreateIconAndSphere(0, 2287.116, -1120.849, 39.375)

:TUT_1_193
wait 0
if
00FF:   actor $PLAYER_ACTOR sphere 0 in_sphere 2287.116 -1120.849 39.375 radius 2.0 2.0 2.0 on_foot
else_jump @TUT_1_193
jump @TUT_1_252

:TUT_1_252
$SPHERE_AFTERJUMP = Marker.CreateIconAndSphere(0, 2287.091, -1132.956, 26.7332)

:TUT_1_274
wait 0
if
  Actor.Dead($PLAYER_ACTOR)
else_jump @TUT_1_301
jump @TUT_1_385

:TUT_1_301
00FF:   actor $PLAYER_ACTOR sphere 0 in_sphere 2287.091 -1132.956 26.7332 radius 2.0 2.0 2.0 on_foot
else_jump @TUT_1_274
0394: play_music 1
$MISSIONS_PASSED += 1
Player.Money($PLAYER_CHAR) += 10000
01E3: show_text_1number_styled GXT 'M_PASS' number 10000 time 5000 style 1  // MISSION PASSED!~n~~w~$~1~
return

:TUT_1_385
00BA: show_text_styled GXT 'M_FAIL' time 5000 style 1  // ~r~MISSION FAILED!
0555: remove_weapon 31 from_actor $PLAYER_ACTOR
return

:TUT_1_410
$ONMISSION = 0
Marker.Disable($VICTIM_MARKER)
Player.WantedLevel($PLAYER_CHAR) = 0
Model.Destroy(#BFYST)
Model.Destroy(#BMYST)
Model.Destroy(#M4)
mission_cleanup
return


Thanks in advance! smile.gif

Silent
  • Silent

    Moderating Cookie Monster

  • Feroci
  • Joined: 01 Feb 2010
  • Poland
  • Most Helpful [GTA] 2013
    Most Helpful [Modding] 2013
    Most Talented [Modding] 2013
    Best Map 2013 "ViceCityStories PC Edition"
    Best Vehicle 2013 "III Aircraft"
    Most Helpful [Modding] 2012
    Modder of the Year 2012

#2

Posted 12 July 2013 - 07:16 PM

1) No point in using global variables for these, it'd be much better if you switch globals to locals.
2) The script was working fine - the problem is, 02A7 (Marker.CreateIconAndSphere) are supposed to be used with mission TRIGGERS and therefore they don't show with $ONMISSION flag set to 1.

I'd like to point some other minor issues too:

- Using 038B removes the need for checking if models are loaded - the opcode pauses the game and loads models as soon as possible - if all that stuff is done onscreen (I guess it is, since there's no fadeout afterwards) you might want to remove that opcode, or it may freeze the game for a short moment on slower PCs.
- No need to check if CJ died - the game does that internally and in case you're dead/wasted (hence not so accurate "wasted_or_busted" opcode definition at the very top of your code).

I have rewritten the code in high-level syntax - it may be a bit confusing for you now, but the sooner you learn it, the better. I have also made some other changes and documented them in the code:

CODE
:TUT_1
03A4: name_thread 'TUT 1'
gosub @TUT_1__MISSION
if 0112:   wasted_or_busted
then
   gosub @TUT_1__FAIL
end
gosub @TUT_1__CLEANUP
004E: end_thread

:TUT_1__MISSION
0247: load_model #KNIFECUR
0247: load_model #BMYST

// R* used that sort of loop - it's a bit better, since it looks clean when written in high-level and also won't execute WAIT even once
// if models are somehow loaded straight away
while true
   if or
       8248:   not model #KNIFECUR available
       8248:   not model #BMYST available
   jf break
   0001: wait 0 ms
end

01B2: give_actor $PLAYER_ACTOR weapon 4 ammo 1  // ammo 1 is enough for melee weapons
// 01B9 removed - given weapons are selected automatically
009A: 0@ = create_actor_pedtype 4 model #BMYST at 2265.723 -1105.599 37.9766    // Removed classes (Actor.Create) since they DON'T help keeping
// the code look clean and consistent + switched to a local variable
0173: set_actor 0@ Z_angle_to 155.0
03E5: show_text_box 'HELP101'  // In this tutorial, you are going to learn what it takes to be a hitman. See that guy with a marker above his head? Sneak up behind him and press and hold the right mouse button to aim at him while crouching with your knife equipped. While raising your knife behind him, press the left mouse button to execute him.
// 1) Isn't this text a bit too long?
// 2) I'd advice to replace 'right mouse button' and 'left mouse button' with proper keycodes - respectively ~k~~PED_LOCK_TARGET~ and ~k~~PED_FIREWEAPON~
// 3) There's no marker above his head;)

while 8118:   not actor 0@ dead
   0001: wait 0 ms     // For one check within a loop, you can shorten it like that - it gets compiled in the same way as the previous model loading check does
end

// Jump removed - no point to jump to a label which is directly below - labels aren't being compiled, the code is being executed line-by-line
018A: 1@ = create_checkpoint_at 2287.116 -1120.849 39.375   // I think that's what you wanted to achieve

while 80FF:   not actor $PLAYER_ACTOR sphere 1 in_sphere 2287.116 -1120.849 39.375 radius 2.0 2.0 2.0 on_foot   // Notice 'sphere 1'
   0001: wait 0 ms
end

0164: disable_marker 1@ // I think you'd want to add it aswell
018A: 2@ = create_checkpoint_at 2287.091 -1132.956 26.7332

while 80FF:   not actor $PLAYER_ACTOR sphere 1 in_sphere 2287.091 -1132.956 26.7332 radius 2.0 2.0 2.0 on_foot   // Notice 'sphere 1'
   0001: wait 0 ms
end

0164: disable_marker 2@
0394: play_music 1
$MISSIONS_PASSED += 1
0109: player $PLAYER_CHAR money += 10000
// R* always cleans wanted level after mission, but only after a success - you might prefer that way
0110: clear_player $PLAYER_CHAR wanted_level
01E3: show_text_1number_styled GXT 'M_PASS' number 10000 time 5000 style 1  // MISSION PASSED!~n~~w~$~1~
return

:TUT_1__FAIL
00BA: show_text_styled GXT 'M_FAIL' time 5000 style 1  // ~r~MISSION FAILED!
0555: remove_weapon 31 from_actor $PLAYER_ACTOR // Are you sure you wanted that?
return

:TUT_1__CLEANUP
0249: release_model #KNIFECUR
0249: release_model #BMYST
// Let's remove markers in case mission is failed - won't hurt
0164: disable_marker 1@
0164: disable_marker 2@
$ONMISSION = 0
mission_cleanup
return

serabella
  • serabella

    Noob scripter

  • Members
  • Joined: 18 Jun 2009

#3

Posted 13 July 2013 - 10:21 AM

Thank you very much! You can always except to get great help here at GTAF. Thanks again! smile.gif

serabella
  • serabella

    Noob scripter

  • Members
  • Joined: 18 Jun 2009

#4

Posted 13 July 2013 - 11:05 AM

Oh, I hate being so bad at coding sad.gif @SilentPL So, I followed your tutorial and it looked a lot better and cleaner than my code. However, I wanted to add one thing to the end which should be the mission complete trigger. It works together with my "bribe" mod, you should bribe the cops by pressing the "5" button to complete the mission after jumping down into the sphere.

I added this thing at the end of your code:

CODE

010D: set_player $PLAYER_CHAR wanted_level_to 3

while 80E1:   not player 0 pressed_key 53
   0001: wait 0 ms
end


The thing is that nothing happens. After I pressed the 5 button, nothing happens. If I add "00E1: player 0 pressed_key 53", the mission will complete as soon as you enter the sphere but with the "not key pressed", nothing happens sad.gif

Full code:

CODE

:TUT_1
03A4: name_thread 'TUT 1'
gosub @TUT_1__MISSION
if 0112:   wasted_or_busted
then
   gosub @TUT_1__FAIL
end
gosub @TUT_1__CLEANUP
004E: end_thread

:TUT_1__MISSION
0247: load_model #KNIFECUR
0247: load_model #BMYST

// R* used that sort of loop - it's a bit better, since it looks clean when written in high-level and also won't execute WAIT even once
// if models are somehow loaded straight away
while true
   if or
       8248:   not model #KNIFECUR available
       8248:   not model #BMYST available
   jf break
   0001: wait 0 ms
end

01B2: give_actor $PLAYER_ACTOR weapon 4 ammo 1  // ammo 1 is enough for melee weapons
// 01B9 removed - given weapons are selected automatically
009A: 0@ = create_actor_pedtype 4 model #BMYST at 2265.723 -1105.599 37.9766    // Removed classes (Actor.Create) since they DON'T help keeping
// the code look clean and consistent + switched to a local variable
0173: set_actor 0@ Z_angle_to 155.0
03E5: show_text_box 'HELP101'  // In this tutorial, you are going to learn what it takes to be a hitman. See that guy with a marker above his head? Sneak up behind him and press and hold the right mouse button to aim at him while crouching with your knife equipped. While raising your knife behind him, press the left mouse button to execute him.
// 1) Isn't this text a bit too long?
// 2) I'd advice to replace 'right mouse button' and 'left mouse button' with proper keycodes - respectively ~k~~PED_LOCK_TARGET~ and ~k~~PED_FIREWEAPON~
// 3) There's no marker above his head;)

while 8118:   not actor 0@ dead
   0001: wait 0 ms     // For one check within a loop, you can shorten it like that - it gets compiled in the same way as the previous model loading check does
end

// Jump removed - no point to jump to a label which is directly below - labels aren't being compiled, the code is being executed line-by-line
018A: 1@ = create_checkpoint_at 2287.116 -1120.849 39.375   // I think that's what you wanted to achieve

while 80FF:   not actor $PLAYER_ACTOR sphere 1 in_sphere 2287.116 -1120.849 39.375 radius 2.0 2.0 2.0 on_foot   // Notice 'sphere 1'
   0001: wait 0 ms
end

0164: disable_marker 1@ // I think you'd want to add it aswell
018A: 2@ = create_checkpoint_at 2287.091 -1132.956 26.7332

while 80FF:   not actor $PLAYER_ACTOR sphere 1 in_sphere 2287.091 -1132.956 26.7332 radius 2.0 2.0 2.0 on_foot   // Notice 'sphere 1'
   0001: wait 0 ms
end
0164: disable_marker 2@
010D: set_player $PLAYER_CHAR wanted_level_to 3

while 80E1:   not player 0 pressed_key 53
   0001: wait 0 ms
end

0394: play_music 1
$MISSIONS_PASSED += 1
0109: player $PLAYER_CHAR money += 500
// R* always cleans wanted level after mission, but only after a success - you might prefer that way
0110: clear_player $PLAYER_CHAR wanted_level
01E3: show_text_1number_styled GXT 'M_PASS' number 500 time 5000 style 1  // MISSION PASSED!~n~~w~$~1~
return

:TUT_1__FAIL
00BA: show_text_styled GXT 'M_FAIL' time 5000 style 1  // ~r~MISSION FAILED!
0555: remove_weapon 31 from_actor $PLAYER_ACTOR // Are you sure you wanted that?
return

:TUT_1__CLEANUP
0249: release_model #KNIFECUR
0249: release_model #BMYST
// Let's remove markers in case mission is failed - won't hurt
0164: disable_marker 1@
0164: disable_marker 2@
$ONMISSION = 0
mission_cleanup
return

Wesser
  • Wesser

    The complexity simplifier, the efficiency optimizer.

  • Feroci
  • Joined: 19 Aug 2006
  • Unknown

#5

Posted 13 July 2013 - 11:28 AM Edited by Wesser, 13 July 2013 - 11:32 AM.

The WHILE loop iterates the embedded code until its check becomes false. If you check whether a key is pressed when it hasn't been pushed yet, the while loop will break immediately because of the condition returning false. Plus, you test for the wrong key here. To show a list of all virtual key codes, go to Help->Contents->CLEO 3 Code Library->Virtual key codes (for 0AB0). If you choose to use Hex values you must add 0x before the number.

serabella
  • serabella

    Noob scripter

  • Members
  • Joined: 18 Jun 2009

#6

Posted 13 July 2013 - 11:37 AM

Ah okay, thanks for explaining. I'll try to rewrite it then.

fireguy109
  • fireguy109

    It's a long way to the top

  • The Connection
  • Joined: 30 Aug 2010
  • United-States

#7

Posted 14 July 2013 - 05:33 PM

QUOTE (Wesser @ Saturday, Jul 13 2013, 06:28)
The WHILE loop iterates the embedded code until its check becomes false. If you check whether a key is pressed when it hasn't been pushed yet, the while loop will break immediately because of the condition returning false. Plus, you test for the wrong key here. To show a list of all virtual key codes, go to Help->Contents->CLEO 3 Code Library->Virtual key codes (for 0AB0). If you choose to use Hex values you must add 0x before the number.

If this is all main.scm like he said, then 0AB0 won't work. He actually needs this list - http://www.gtamoddin....php?title=00E1




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users