Quantcast

Jump to content

» «
Photo

[SA] 0818 doesn't work properly with parachute

9 replies to this topic
jackusCTB
  • jackusCTB

    Peon

  • Members
  • Joined: 29 Jun 2012
  • Belgium

#1

Posted 09 July 2013 - 08:52 PM

Hello, writing this little snippet I could observe that the opcode 0818 doesn't return true (1 in the snippet) when the player is freefalling with a parachute.
As you can see, it returns false, 0 in this case.
user posted image
CODE
{$CLEO .cs}

0000: NOP

while true
   wait 0
       if
        0818:   actor $PLAYER_ACTOR in_air
           then
            0@ = 1
           else
            0@ = 0
       end
        01E5: show_text_1number_highpriority GXT 'NUMBER' number 0@ time 1 flag 1  // ~s~You need $~1~ to compete.
end

jackusCTB
  • jackusCTB

    Peon

  • Members
  • Joined: 29 Jun 2012
  • Belgium

#2

Posted 11 July 2013 - 09:25 PM

-bump-

aStiffSausage
  • aStiffSausage

    Formerly Oksu

  • Members
  • Joined: 30 Sep 2010
  • Finland

#3

Posted 11 July 2013 - 09:37 PM

Yep. Seems to do so.

There could be cheap workarounds for this, for example checking player's current animation played. Though, knowing what your aim is, would help a lot. smile.gif

toonskull
  • toonskull

    Necromancer

  • Members
  • Joined: 04 Aug 2009

#4

Posted 11 July 2013 - 10:38 PM Edited by toonskull, 12 July 2013 - 12:08 AM.

hmm... 0818 is a new one on me. Is that in Cleo 4? I never bothered to upgrade, too lazy I suppose.
Edit: My bad 0818 is there had my SB3 set on VC and forgot. tounge2.gif

Because I have this;

0819: 7@ = actor $PLAYER_ACTOR distance_from_ground

try this;
CODE
{$CLEO .cs}

0000: NOP

while true
  wait 0
0819: 7@ = actor $PLAYER_ACTOR distance_from_ground
      if
       7@ > 0.0
          then
           0@ = 1
          else
           0@ = 0
      end
       01E5: show_text_1number_highpriority GXT 'NUMBER' number 0@ time 1 flag 1  // ~s~You need $~1~ to compete.
end


I am here to upload my brother's old scripts today. You can find them here open that archive and look for the one called Flying Elvis. That shows how to do a whole skydive routine without the parachute.

---addendum---

After looking at how the main.scm uses this 0818 opcode, I would have called it;
0818: actor $PLAYER_ACTOR is_airborne or maybe is_falling?

Because you have to remember that these "definitions" are made by modders for other modders. They are stored in the Sanny Builder's data files under the SASCM.INI

0818: $PLAYER_ACTOR - is how the machine reads this and those additional words are for our benefit. wink.gif I applaud the fact that so many people figured this out so I would not have to do it myself.

it first appears in the casino mission "Saint Mark's Bistro" used as a check to see if you are flying to Liberty City and again back to San Andreas. It is used in the parachute mission to set a global variable. Also the global variable "$FreeFall_Stage" has multiple stages of falling. This opcode might be a checking for CJ to be in one of those stages.

jackusCTB
  • jackusCTB

    Peon

  • Members
  • Joined: 29 Jun 2012
  • Belgium

#5

Posted 12 July 2013 - 07:42 AM

Thanks but you know 01E5 can only display integer values, didn't you?
I already tried this work-around but it's not really accurate.
That's the fixed version of your snippet:
CODE
{$CLEO .cs}

0000: NOP

while true
wait 0
0819: 0@ = actor $PLAYER_ACTOR distance_from_ground
0092: 1@ = float 0@ to_integer
   if
    1@ > 1
       then
        2@ = 1
       else
        2@ = 0
   end      
    01E5: show_text_1number_highpriority GXT 'NUMBER' number 2@ time 1 flag 1
end

toonskull
  • toonskull

    Necromancer

  • Members
  • Joined: 04 Aug 2009

#6

Posted 13 July 2013 - 11:49 AM

What?! mercie_blink.gif What exactly are you trying to do here? ???

You submitted a script that gives a binary switch for the variable 0@ to show us that the opcode 0818 is false when CJ is wearing a parachute....

I assumed you needed a binary switch, so I tell you not to use that code, but opcode 0819 and show you working code as well. Then complicate the code with a float to integer conversion? WHY? You added an extra line for conversion and another variable for no reason. So I am now scratching my head trying to understand what you are trying to do other than confuse people.




jackusCTB
  • jackusCTB

    Peon

  • Members
  • Joined: 29 Jun 2012
  • Belgium

#7

Posted 13 July 2013 - 02:47 PM

QUOTE (jackusCTB @ Friday, Jul 12 2013, 07:42)
Thanks but you know 01E5 can only display integer values, didn't you?
I already tried this work-around but it's not really accurate.
That's the fixed version of your snippet:
CODE
{$CLEO .cs}

0000: NOP

while true
wait 0
0819: 0@ = actor $PLAYER_ACTOR distance_from_ground
0092: 1@ = float 0@ to_integer
   if
    1@ > 1
       then
        2@ = 1
       else
        2@ = 0
   end      
    01E5: show_text_1number_highpriority GXT 'NUMBER' number 2@ time 1 flag 1
end

That

aStiffSausage
  • aStiffSausage

    Formerly Oksu

  • Members
  • Joined: 30 Sep 2010
  • Finland

#8

Posted 13 July 2013 - 03:07 PM

Yeah, but you are displaying integer 2@ with 01E5, not 0@ or 1@, which are floats.

Wesser
  • Wesser

    The complexity simplifier, the efficiency optimizer.

  • Members
  • Joined: 19 Aug 2006
  • European-Union

#9

Posted 13 July 2013 - 03:44 PM

I managed to create some codes to check whether the player is in air even if it is playing an animation (I hope that's the point of your topic):
  • Method 1 (unrecommended, because of third party scripts which may assign an animation to the player while he is in air:
    CODE
    if or
       $FREEFALL_STAGE > 0
    0818:  actor $PLAYER_ACTOR in_air
    then
       // Player is in air.
    else
       // Player isn't in air.
    end

  • Method 2 (unrecommended, as it causes a performance loss if compared to the method below):
    CODE
    0A96: 0@ = actor $PLAYER_ACTOR struct
    0A8E: 1@ = 0@ + 0x46C // CPed.m_uiCheckFlag
    0A8D: 1@ = read_memory 1@ size 4 virtual_protect 0
    if
    08B4:  test 1@ bit 9 // CHECK_FLAG_IN_AIR
    then
       goto @in_air
    end
    if
    88B4:  not test 1@ bit 0 // CHECK_FLAG_IN_VEHICLE
    then
       0A8E: 2@ = 0@ + 0x470
       0A8D: 2@ = read_memory 2@ size 4 virtual_protect 0
       if and
       88B4:  not test 2@ bit 4
       88B4:  not test 2@ bit 31
       then
           goto @not_in_air
       end
    :in_air
       // Player is in air.
    else
    :not_in_air
       // Player isn't in air.
    end

  • Method 3 (recommended):
    CODE
    // Disable animation playing check.
    0A8C: write_memory 0x00473CFD size 1 value 0xE9 virtual_protect 0
    0A8C: write_memory 0x00473CFE size 4 value 0x00000238 virtual_protect 0
    if
    0818:  actor $PLAYER_ACTOR in_air
    then
       // Player is in air.
    else
       // Player isn't in air.
    end
    // Enable animation playing check.
    0A8C: write_memory 0x00473CFD size 1 value 0x8B virtual_protect 0
    0A8C: write_memory 0x00473CFE size 4 value 0x00047C87 virtual_protect 0

jackusCTB
  • jackusCTB

    Peon

  • Members
  • Joined: 29 Jun 2012
  • Belgium

#10

Posted 13 July 2013 - 07:17 PM

Thanks Wesser, accurate as always.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users