Quantcast
Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
    1. Welcome to GTAForums!

    1. Red Dead Redemption 2

      1. Gameplay
      2. Missions
      3. Help & Support
    2. Red Dead Online

      1. Gameplay
      2. Find Lobbies & Outlaws
      3. Help & Support
    1. Crews & Posses

      1. Recruitment
    2. Events

    1. GTA Online

      1. Diamond Casino & Resort
      2. DLC
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Grand Theft Auto Series

    3. GTA 6

    4. GTA V

      1. PC
      2. Guides & Strategies
      3. Help & Support
    5. GTA IV

      1. Episodes from Liberty City
      2. Multiplayer
      3. Guides & Strategies
      4. Help & Support
      5. GTA Mods
    6. GTA Chinatown Wars

    7. GTA Vice City Stories

    8. GTA Liberty City Stories

    9. GTA San Andreas

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    10. GTA Vice City

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    11. GTA III

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    12. Top Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    13. Wiki

      1. Merchandising
    1. GTA Modding

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Mod Showroom

      1. Scripts & Plugins
      2. Maps
      3. Total Conversions
      4. Vehicles
      5. Textures
      6. Characters
      7. Tools
      8. Other
      9. Workshop
    3. Featured Mods

      1. DYOM
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Red Dead Redemption

    2. Rockstar Games

    1. Off-Topic

      1. General Chat
      2. Gaming
      3. Technology
      4. Programming
      5. Movies & TV
      6. Music
      7. Sports
      8. Vehicles
    2. Expression

      1. Graphics / Visual Arts
      2. GFX Requests & Tutorials
      3. Writers' Discussion
      4. Debates & Discussion
    1. News

    2. Forum Support

    3. Site Suggestions

CalvinC

CLEO - Detect when ped fires a weapon / Attacks with melee

Recommended Posts

CalvinC

Is there a way to detect when a ped fires a gun or punches somebody?
I'm trying to make police attack peds who are shooting or fighting eachother, i know how to make the police chase them and stuff.

Only problem is detecting if he's firing/punching.
Right now i've set the police to chase peds with a gun, but gang members usually walk around with their guns out, so it just creates riots all the time.

Share this post


Link to post
Share on other sites
ZAZ

opcode 0470: returns the weapon number of the actor, numbers smaller than 16 indicates melee and gift weapons
opcode 02E0: checks if actor use fire or throw weapon

if    02E0:   actor [email protected] firing_weaponthen    //actor use fire or throw weaponend



to check if actor attacks by using melee weapon needs to check if the other actor gets damage from first actor
opcode 051A: check if an actor is damaged by another actor
Note:
this code returns always true if an actor was damged
to check if the actor was damaged again needs to restore first the actors damage state by opcode 054E:

0470: [email protected] = actor [email protected] current_weaponif    051A:   actor [email protected] damaged_by_actor [email protected]    if        16 > [email protected]    then        //result = actor [email protected] used melee or gift weapon to damgage actor [email protected]    end    //then it needs to restore the actors damage state    054E: clear_actor [email protected] damageend

Share this post


Link to post
Share on other sites
CalvinC

I'm very new at scripting, but with the help of looking at some other scripts I've tried creating this:

{$CLEO}0000: STARTvar    [email protected] : intend:GetActor    0A8D: [email protected] = read_memory 0xB74490 size 4 virtual_protect 0    [email protected] += 0x4    0A8D: [email protected] = read_memory [email protected] size 4 virtual_protect 0    for [email protected] = 0 to 27904 step 0x100        0A8D: [email protected] = read_memory [email protected] size 1 virtual_protect 0        000A: [email protected] += 0x1        if and            0029: [email protected] >= 0x00             001B: 0x80 > [email protected]        then        005A: [email protected] += [email protected]        if 8118: not actor [email protected] dead           jf continue        gosub @Main        end         end:Main    if        02E0: actor [email protected] firing_weapon    then        09B6: set_char_wanted_by_police [email protected] to 1     end    return

Doesn't seem to work though.

Share this post


Link to post
Share on other sites
ZAZ

I fixed the script and replaced the codes of the "Main" block

{$CLEO}thread 'RANDACT'wait 2000var    [email protected] : intendwhile truewait 0    0A8D: [email protected] = read_memory 0xB74490 size 4 virtual_protect 0    [email protected] += 0x4    0A8D: [email protected] = read_memory [email protected] size 4 virtual_protect 0    for [email protected] = 0 to 27904 step 0x100        wait 0        0A8D: [email protected] = read_memory [email protected] size 1 virtual_protect 0        000A: [email protected] += 0x1        if and            0029: [email protected] >= 0x00             001B: 0x80 > [email protected]        then        005A: [email protected] += [email protected]        if  and            056D:   actor [email protected] defined             803C:   not  $PLAYER_ACTOR == [email protected] // (int)              8118: not actor [email protected] dead           jf continue        gosub @Main        end         endend:Main04C4: create_coordinate [email protected] [email protected] [email protected] from_actor [email protected] offset 0.0 0.0  1.2095C: create_smoke_at [email protected] [email protected] [email protected] velocity 0.0 0.0 1.0 RGBA 1.0 0.0  0.0  1.0 size 0.5 last_factor 0.1//red 095C: create_smoke_at [email protected] [email protected] [email protected] velocity 0.0 0.0 3.0 RGBA 1.0 0.0  0.0  1.0 size 0.5 last_factor 0.1//red 095C: create_smoke_at [email protected] [email protected] [email protected] velocity 0.0 0.0 5.0 RGBA 1.0 0.0  0.0  1.0 size 0.5 last_factor 0.1//red return

The smoke codes let appear red smoke at each ped that the script can find.

Test it to see that it works.

 

Then change the "Main" block, remove the smoke codes with this code 09B6: set_char_wanted_by_police [email protected] to 1

:Main        09B6: set_char_wanted_by_police [email protected] to 1 return

or just add this code, so that each founded ped will be wanted by police

Share this post


Link to post
Share on other sites
CalvinC

Hey, sorry for the late reply i haven't been able to play GTA SA before now.

The script seems to work if you make everyone wanted, but if i try to check if they're shooting it doesn't work, judging by the smoke the script is too slow at checking if the ped is firing a shot, unless you're extremely lucky.

This is what i got so far:

{$CLEO}thread 'RANDACT'wait 0var    [email protected] : intendwhile truewait 0    0A8D: [email protected] = read_memory 0xB74490 size 4 virtual_protect 0    [email protected] += 0x4    0A8D: [email protected] = read_memory [email protected] size 4 virtual_protect 0    for [email protected] = 0 to 27904 step 0x100        wait 0        0A8D: [email protected] = read_memory [email protected] size 1 virtual_protect 0        000A: [email protected] += 0x1        if and            0029: [email protected] >= 0x00             001B: 0x80 > [email protected]        then        005A: [email protected] += [email protected]        if  and            056D:   actor [email protected] defined             803C:   not  $PLAYER_ACTOR == [email protected] // (int)              8118: not actor [email protected] dead           jf continue        gosub @Main        end         endend:Main    04C4: create_coordinate [email protected] [email protected] [email protected] from_actor [email protected] offset 0.0 0.0  1.2    095C: create_smoke_at [email protected] [email protected] [email protected] velocity 0.0 0.0 1.0 RGBA 1.0 1.0  1.0  1.0 size 0.5 last_factor 0.1 // white    if        02E0: actor [email protected] firing_weapon    then            09B6: set_char_wanted_by_police [email protected] to 1                095C: create_smoke_at [email protected] [email protected] [email protected] velocity 0.0 0.0 1.0 RGBA 1.0 0.0  0.0  1.0 size 0.5 last_factor 0.1 // red    end return

Any way to make it quick enough?

Share this post


Link to post
Share on other sites
ZAZ

I noticed that 09B6: have not much effect
As i said, change the main block to this

:Main        09B6: set_char_wanted_by_police [email protected] to 1 return

without check for firing_weapon, so every ped that was found should wanted by police

but police do nothing

Share this post


Link to post
Share on other sites
The Eagle Eye

Hello everyone, i am new here and new gta mod maker. First of all i want to know how to make mod run on start-up/with the game.

Second, how to spawn vehicle near PED or PLAYER ? But vehicle should has driver, for example, if car destroyed...then spawn F.truck near car to extinguish fire.

Share this post


Link to post
Share on other sites
George Costanza

Create new topic for that in this subsection, instead of bumping old one

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • 1 User Currently Viewing
    0 members, 0 Anonymous, 1 Guest

×
×
  • Create New...

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.