Coding

 Reply to this postStart new topic

[Q/Help] Throw object with rotation

jayd00
post Dec 28 2010, 04:02 AM
Post #1


Ameteur Member

Posts: 42
From: Guatemala
Joined: 22-December 09



Hi!

I did this script, and it's working nice, but I need some help in the part when the object is colliding lol

I want that when the object colliding with a ped, the ped dies.. or maybe when the object colliding with him/her the ped makes an animation like when the knife cuts their throat.
But there is the problem xD I don't know which is the best way to "catch" the peds nearest to the object.


SANNY

{$CLEO}

0000: NOP

:Noname_2
wait 0
if
   Player.Defined($PLAYER_CHAR)
else_jump @Noname_2
if
0AB0:   key_pressed 8   /// backspace
else_jump @Noname_2
Model.Load(#KNIFECUR)
Model.Load(3065)

:Noname_47
if and
   not Model.Available(#KNIFECUR)
   not Model.Available(3065)
else_jump @Noname_79
wait 0
jump @Noname_47

:Noname_79
04C4: store_coords_to 10@ 11@ 12@ from_actor $PLAYER_ACTOR with_offset 0.0 2.0 0.5

1@ = Object.Create(3065, 10@, 11@, 12@)
0750: set_object 1@ visibility 0
04D9: object 1@ set_scripted_collision_check 1
Object.CollisionDetection(1@) = True
0906: set_object 1@ mass_to 3000.0 // float
0908: set_object 1@ turn_mass_to 3000.0 // float

2@ = Object.Create(#KNIFECUR, 0.0, 1.0, 500.0)
0750: set_object 2@ visibility 1
04D9: object 2@ set_scripted_collision_check 1
Object.CollisionDetection(2@) = True
0906: set_object 2@ mass_to 30000.0 // float
0908: set_object 2@ turn_mass_to 30000.0 // float
08D2: object 2@ scale_model 2.0

069A: attach_object 2@ to_object 1@ with_offset 0.0 0.0 0.0 rotation -90.0 0.0 0.0

5@ = Actor.Angle($PLAYER_ACTOR)
29@ = 51.1
02F6: 7@ = sine 5@ // (float)
02F7: 8@ = cosine 5@ // (float)
006B: 7@ *= 29@ // (float)
006B: 8@ *= 29@ // (float)
7@ *= -1.0

Object.ToggleInMovingList(1@) = True
Object.Throw(1@, 7@, 8@, 1.0)
wait 0
32@ = 0
Model.Destroy(#KNIFECUR)
Model.Destroy(3065)

:Noname_545
Object.StorePos(1@, 10@, 11@, 12@)
02CE: 27@ = ground_z_at 10@ 11@ 12@
0063: 12@ -= 27@ // (float)
if
  12@ > 1.1
else_jump @Noname_629
28@ = -2.0
jump @Noname_677

:Noname_629
if
  0.9 > 12@
else_jump @Noname_667
28@ = 2.0
jump @Noname_677

:Noname_667
28@ = 1.0

:Noname_677
Object.Throw(1@, 7@, 8@, 28@)
5@ = Actor.Angle($PLAYER_ACTOR)
005B: 6@ += 5@ // (float)
0453: set_object 1@ XY_rotation 0.0 0.0 angle 6@
if
  6@ > 360.0
else_jump @Noname_792
6@ -= 360.0

:Noname_792
wait 0
if or
  32@ > 1100
04DA:   has_object 1@ collided
else_jump @Noname_545

:Noname_828
Object.StorePos(1@, 10@, 11@, 12@)
0208: 18@ = random_float_in_ranges -3.0 3.0
0208: 19@ = random_float_in_ranges -3.0 3.0
0208: 20@ = random_float_in_ranges -3.0 3.0
08EB: create_sparks_at 10@ 11@ 12@ velocity_direction 18@ 19@ 20@ density 30
Object.Destroy(2@)
Object.Destroy(1@)
jump @Noname_2


thanks for help! thumbsup.gif

This post has been edited by jayd00: Jan 5 2011, 03:07 AM


--------------------


Go to the top of the page
 
+Quote Post
Nahiyan
post Dec 28 2010, 09:55 AM
Post #2


The New Guy!

Posts: 9
From: Bangladesh
Joined: 4-December 10



Just a quick though, maybe attach a object to all the peds and then if the knife collides with that object, attach the knife to the ped by calculating the offset (PedPos - KnifePos) and then make blooooooooooooooooooooooooooooooooooooooooooooooooood.
Go to the top of the page
 
+Quote Post
jayd00
post Dec 29 2010, 03:01 AM
Post #3


Ameteur Member

Posts: 42
From: Guatemala
Joined: 22-December 09



QUOTE (Nahiyan @ Dec 28 2010, 03:55 AM) *
Just a quick though, maybe attach a object to all the peds and then if the knife collides with that object, attach the knife to the ped by calculating the offset (PedPos - KnifePos) and then make blooooooooooooooooooooooooooooooooooooooooooooooooood.

yes, I already thought in that, but there still the problem of how to define the peds?

I did this for what are you talking about;

SANNY

:start
Object.StorePos(1@, 10@, 11@, 12@)
Actor.StorePos(30@, 13@, 14@, 15@)
050A: 17@ = distance_between_XYZ 10@ 11@ 12@ and_XYZ 13@ 14@ 15@

while  2.0 > 17@
end

//continue



but how to define the actor 30@ ??

I tried to use memory for catch all the peds but isn't working as I want xD



--------------------


Go to the top of the page
 
+Quote Post
Deji
post Dec 29 2010, 03:11 AM
Post #4


Coding like a Rockstar!

Group Icon

Posts: 1,468
From: ???
Joined: 28-May 09



CLEO 4 has this opcode:
SANNY
0AE1: $actor = random_actor_near_point 0@ 1@ 2@ in_radius 10.0 find_next 1 pass_deads 1


--------------------
Go to the top of the page
 
+Quote Post
jayd00
post Dec 31 2010, 04:32 AM
Post #5


Ameteur Member

Posts: 42
From: Guatemala
Joined: 22-December 09



QUOTE (Deji @ Dec 28 2010, 09:11 PM) *
CLEO 4 has this opcode:
SANNY
0AE1: $actor = random_actor_near_point 0@ 1@ 2@ in_radius 10.0 find_next 1 pass_deads 1

thanks!


--------------------


Go to the top of the page
 
+Quote Post
Reply to this postStart new topic

1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members: