Quantcast

Jump to content

» «
Photo

Object detection

15 replies to this topic
Jack
  • Jack

    wanted level modifications

  • Feroci Racing
  • Joined: 06 Dec 2011
  • Serbia

#1

Posted 25 April 2012 - 11:31 AM Edited by JACK JONES, 25 April 2012 - 11:58 AM.

How to check is there is some building or other structure somewhere around the player (or vehicle). I need the conditional check opcode which could tell is there any (not specific) object around the player, car, helicopter... In other words I need to detect immovable objects (I mean buildings, trees, houses...) - everything that stands still forever. The problem is when I create coordinates from player and force some vehicle to go to those coordinates - the vehicle is not capable to predict the impact and therefore it smashes into the building (without even knowing what the hell just happened):
CODE
04C4: create_coordinate 0@ 1@ 2@ from_actor $PLAYER_ACTOR offset 10.0 0.0 0.0
02C2: car 3@ drive_to_point 0@ 1@ 2@
04C4: create_coordinate 4@ 5@ 6@ from_actor $PLAYER_ACTOR offset -10.0 5.0 30.0
04A2: heli 7@ fly_to 4@ 5@ 6@ speed 100

You see what's the problem - the drivers and pilots are blind and stupid. So how to make them to become smart?

Ashwin.Star
  • Ashwin.Star

    Back for Next ♪♫

  • Members
  • Joined: 14 Nov 2010
  • India

#2

Posted 25 April 2012 - 12:44 PM

::Solution::
create a small object,
disable its collision
put it to Z = -100.0
& read its Z coord then,
if it is more than Ground Level then there is a building, tree, or a Collision Object,

I hope you got me,
tell if not

Jack
  • Jack

    wanted level modifications

  • Feroci Racing
  • Joined: 06 Dec 2011
  • Serbia

#3

Posted 25 April 2012 - 07:07 PM Edited by JACK JONES, 25 April 2012 - 07:40 PM.

I'm not sure what exactly do you mean? Maybe something like this?
CODE
{$CLEO .cs}
thread 'TEST'

:Create
04C4: create_coordinate 4@ 5@ 6@ from_actor $PLAYER_ACTOR offset 0.0 0.0 -100.0
0107: 0@ = create_object #COLT45 at 4@ 5@ 6@

:Move
wait 0
04C4: create_coordinate 1@ 2@ 3@ from_actor $PLAYER_ACTOR offset 0.0 40.0 -100.0
01BC: put_object 0@ at 1@ 2@ 3@
0382: set_object 0@ collision_detection 0
04C4: create_coordinate 7@ 8@ 9@ from_actor $PLAYER_ACTOR offset 0.0 0.0 0.0
if
0025:   3@ > 9@  // (float)
else_jump @Move

:Move1
wait 0
010D: set_player $PLAYER_CHAR wanted_level_to 6 (test - if checking is working 6 stars will flash)
jump @Move
05DC: end_custom_thread

But it's not working (players wanted level is 0 starts).
I don't understand - why would some object change its Z coordinate if it's in a building area? Tell me more. Also I'm guessing that the code can't reach 010D because 04C4 was defined twice so 0025 can't recognize the value of 3@ variable (but I just don't know how to force some object to be attached to player AND to check players ground position AT THE SAME TIME without using 04C4 command).

LINK/2012
  • LINK/2012

    LIVIN' IN CODE

  • Feroci Racing
  • Joined: 30 Jan 2011
  • Brazil

#4

Posted 26 April 2012 - 03:12 AM

The Z coordinate must be <= -100.0 to create object at ground, not relative to player location. If for example player is at Z 400.0, get coords with offset -100.0 will return Z 300.0, Z now is not <= -100.0, failure in create object at ground.

CODE
00A0: store_actor $PLAYER_ACTOR position_to 0@ 1@ 2@
0107: 0@ = create_object #FAKETARGET at 0@ 1@ -100.0


use 00A0 instead of 04C4 if you doesn't need offset in coordinates.

Ashwin.Star
  • Ashwin.Star

    Back for Next ♪♫

  • Members
  • Joined: 14 Nov 2010
  • India

#5

Posted 26 April 2012 - 01:18 PM

QUOTE
the drivers and pilots are blind and stupid. So how to make them to become smart?

It is very difficult,
when you give them instruction to go somewhere
they calculate & follow smallest path rote
so, Add more paths to make them smart wink.gif

the thing i am telling you is
QUOTE
How to check is there is some building or other structure somewhere around the player


CODE

{$CLEO}
thread 'Ashwin'
wait 5000
model.Load(#COLT45)
038B: load_requested_models

:0
04C4: create_coordinate 1@ 2@ 3@ from_actor $3 offset 0.0 10.0 0.0
object.Create(0@, #COLT45, 1@, 2@, -100.0)
object.CollisionDetection(0@, 0)

:1
04C4: create_coordinate 1@ 2@ 3@ from_actor $3 offset 0.0 10.0 0.0
01BC: put_object 0@ at 1@ 2@ -100.0
wait 0
01BB: store_object 0@ position_to 4@ 5@ 6@
if
0035:   6@ >= 3@      //<--- checking if object Z height is more than player Actor
jf @1
// <--- If condition true then There is a building, tree, car, or any collision object at this place (1@ 2@ 3@) ---> //
//<--- Give them instruction what to do now --->//

using this script,
you will get that there is a object in front of it,
i am interested to know what instruction you will give them now lol.gif

Jack
  • Jack

    wanted level modifications

  • Feroci Racing
  • Joined: 06 Dec 2011
  • Serbia

#6

Posted 26 April 2012 - 02:16 PM

Hey Ashwin you are a genius. I spend almost whole day trying to activate objects Z checking but your code solves everything. In case you're still interested what I was trying to do:
My ultimate plan is to create 4 objects at player offset. These 4 objects will have the same movements as helicopter following player - the only diference is they will be around the helicopter and their job will be to alert the vehicle about the dangerous places. Helicopters movements (which is following player with a 04C4) are -x, +x, -y and +y so these 4 objects will be some kind of a helicopter radars - if any of these 4 protectors feal a building or a tree - helicopters speed will become 0 so it won't smash into the structure. And if all 4 objects don't feal anything the helis speed will be 100 again.
All thie wouldn't be possible without your code. Thanks man.

Silent
  • Silent

    Moderating Cookie Monster

  • Feroci Racing
  • 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

#7

Posted 26 April 2012 - 02:38 PM

Isn't it easier to just use 02CE to retrieve the Z coord?

_DK
  • _DK

    Where I Know You From

  • Feroci Racing
  • Joined: 12 Apr 2009
  • Ukraine

#8

Posted 26 April 2012 - 03:29 PM

Yes but the easiest way is using isLineOfSightClear wink.gif

Jack
  • Jack

    wanted level modifications

  • Feroci Racing
  • Joined: 06 Dec 2011
  • Serbia

#9

Posted 26 April 2012 - 04:00 PM

Hey guys I'm having some hard time finding the opcode that can make an object invisible - I searched SB opcodes, gtagaming and MB opcode DB - I couldn't find anything. Is there an opcode that can do this?

Ashwin.Star
  • Ashwin.Star

    Back for Next ♪♫

  • Members
  • Joined: 14 Nov 2010
  • India

#10

Posted 26 April 2012 - 04:06 PM

i don't think VC have such a Opcode,
you may make a Object Invisible by changing its Texture(using alpha)

_DK
  • _DK

    Where I Know You From

  • Feroci Racing
  • Joined: 12 Apr 2009
  • Ukraine

#11

Posted 26 April 2012 - 06:51 PM Edited by DK22Pac, 26 April 2012 - 07:07 PM.

CODE
// store needed coords
04C4: create_coordinate 0@ 1@ 2@ from_actor $3 offset 0.0 0.0 10.0
04C4: create_coordinate 4@ 5@ 6@ from_actor $3 offset 0.0 0.0 2.0
// get pointers to these coords
05F8: 3@ = var 0@ offset
05F8: 7@ = var 4@ offset
// check if there any collision between these points
05E2: call_function 0x4DA560 num_params 9 pop 9 0 0 0 1 1 1 1 7@ 3@ 8@
if
   8@ == 0
then
   // there's some collision
else
   // this space is free
end

Jack
  • Jack

    wanted level modifications

  • Feroci Racing
  • Joined: 06 Dec 2011
  • Serbia

#12

Posted 27 April 2012 - 06:20 PM

Thanks DK22Pac but I already started scrypting with the Ashwins idea and instead of creating 4 objects - my new plan is to create 1 object and force him to change its position around a vehicle (with 01BC) at every 250 ms (timers 16@ and 17@ could help me with that) - that way I don't have to use so meny local variables.
And Ashwin thanks for the tip about the making an object invisible - I know how to do that. By the way I did find some opcode in SB that checks if some object is invisible:
CODE
82CC:   not object $3502 bounding_sphere_visible
so that makes me wonder - why would exist conditional check opcode for objects visibility if there's no opcode for seting an objects visibility?


_DK
  • _DK

    Where I Know You From

  • Feroci Racing
  • Joined: 12 Apr 2009
  • Ukraine

#13

Posted 27 April 2012 - 07:13 PM

You had some problems with code which I've posted?

Jack
  • Jack

    wanted level modifications

  • Feroci Racing
  • Joined: 06 Dec 2011
  • Serbia

#14

Posted 28 April 2012 - 10:04 AM Edited by JACK JONES, 28 April 2012 - 11:13 AM.

Well I have to admit that I didn't work with this CLEO method before - I mean I never used opcodes then, else, end. Here's what I don't understand here:
Why should I check if a float value of 8@ variable is equal to 0 integer - why not 0.0 float and why did you choose exactly number 0? Also I have some example of this high level coding of CLEO and I didn't noticed jump or else_jump commands in it - if there are no loops then how the code works all the time? And yes I've tested your code but wanted level stars were 0 which means that the code didn't reach 010D even when I rotated player in all directions between some buildings:
CODE
{$CLEO}

04C4: create_coordinate 0@ 1@ 2@ from_actor $PLAYER_ACTOR offset 10.0 10.0 10.0
04C4: create_coordinate 4@ 5@ 6@ from_actor $PLAYER_ACTOR offset 10.0 10.0 2.0
05F8: 3@ = var 0@ offset
05F8: 7@ = var 4@ offset
05E2: call_function 0x4DA560 num_params 9 pop 9 0 0 0 1 1 1 1 7@ 3@ 8@
if
0039:   8@ == 0
then
010D: set_player $PLAYER_CHAR wanted_level_to 6
else
05DC: end_custom_thread
end

_DK
  • _DK

    Where I Know You From

  • Feroci Racing
  • Joined: 12 Apr 2009
  • Ukraine

#15

Posted 28 April 2012 - 11:33 AM

Yes, ut must be in a loop.
Low-level code cool.gif
CODE
{$CLEO}

wait 0
:loop
wait 0
if player.Defined(0)
jf @loop
04C4: create_coordinate 0@ 1@ 2@ from_actor $3 offset 0.0 0.0 10.0
04C4: create_coordinate 4@ 5@ 6@ from_actor $3 offset 0.0 0.0 2.0
05F8: 3@ = var 0@ offset // lineStart
05F8: 7@ = var 4@ offset // lineEnd
// check if there any collision on this line
05E2: call_function 0x4DA560 num_params 9 pop 9 0 0 0 checkObjects 1 checkPeds 1 checkVehicles 1 checkBuildings 1 lineEnd 7@ lineStart 3@ get_result_to 8@
if 8@ == 1 // if 0 - some collision there, if 1 - there no collisions
jf @loop
// there no collisions
jump @loop

Ashwin.Star
  • Ashwin.Star

    Back for Next ♪♫

  • Members
  • Joined: 14 Nov 2010
  • India

#16

Posted 28 April 2012 - 11:44 AM

do you know what
reading "Low level" sounds bad to me,
it should be easy & hard

Easy
CODE

if
 8@ == 0 // integer values
else_jump @NONAME_20
Player.WantedLevel($7) = 6
jump @NONAME_22

:NONAME_20
05DC: end_custom_thread

:NONAME_22


Hard
CODE

if
0039:   8@ == 0
then
010D: set_player $PLAYER_CHAR wanted_level_to 6
else
05DC: end_custom_thread
end


we all are compiling same thing then why Low & High level ?




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users