Coding

 Reply to this postStart new topic

[Q/Help] Spawn actors with arrays

jayd00
post Nov 25 2010, 02:54 AM
Post #1


Ameteur Member

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



This is my script

CODE
{$CLEO .cs}

thread 'NAKAGE'

29@ = 0  /// counter dead actors
30@ = 0 /// array index
31@ = -2.0

:NAKAGE_35
while true
wait 0
if
  Player.Defined($PLAYER_CHAR)
then
    if and
        044B:   actor $PLAYER_ACTOR on_foot
        not Actor.Driving($PLAYER_ACTOR)
    else_jump @NAKAGE_35
        if
            0ADC:   test_cheat "TST"
        else_jump @NAKAGE_35
        03E5: show_text_box 'CHEAT1'  // Cheat activated
        023C: load_special_actor 'SKIN321' as 2 // models 290-299
        038B: load_requested_models

:NAKAGE_36
wait 0
if
    023D:   special_actor 2 loaded
else_jump @NAKAGE_36

:NAKAGE_37
wait 0
if
    3 > 30@
then
    07AF: 26@ = player $PLAYER_CHAR group
    04C4: store_coords_to 15@ 16@ 17@ from_actor $PLAYER_ACTOR with_offset 31@ -1.5 0.2
    02CE: 17@ = ground_z_at 15@ 16@ 17@
    0@(30@,3i) = Actor.Create(Gang2, #SPECIAL02, 15@, 16@, 17@)
    095C: create_smoke_at 15@ 16@ 17@ velocity 0.0 0.0 0.0 RGBA 1.0 1.0 1.0 1.0 size 0.6 last_factor 0.5
    Actor.Health(0@(30@,3i)) = 1
    0631: put_actor 0@(30@,3i) in_group 26@
    04D8: set_actor 0@(30@,3i) drowns_in_water 0
    0446: set_actor 0@(30@,3i) immune_to_headshots 0
    07FE: set_actor 0@(30@,3i) fighting_style_to 6 6
    060B: set_actor 0@(30@,3i) decision_maker_to 32
    31@ += 2.0
    30@ += 1
    jump @NAKAGE_37
end // if
    0296: unload_special_actor 2
    30@ = 0

:NAKAGE_38
wait 0
if
    Actor.Dead(0@(30@,3i))
then
    29@ += 1
    Actor.DestroyInstantly(0@(30@,3i))
end // if
    
:NAKAGE_39
if
    3 > 29@
then
    jump @NAKAGE_38
end
    
    29@ = 0
    30@ = 0
    31@ = -2.0
    Actor.RemoveReferences(0@(30@,3i))
    jump @NAKAGE_35
    
end
end // while



but I have a small problem with it, I want that when I hit one of them, automatically dissapear

and it only works with one actor, not for the others two


how can I fix it?
some advice using arrays for this stuff??


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


Go to the top of the page
 
+Quote Post
Silent
post Nov 25 2010, 03:36 PM
Post #2


The master of cut retort

Group Icon

Posts: 239
From: Warsaw, PL
Joined: 21-July 10



SANNY
29@ = 0  /// counter dead actors
30@ = 0 /// array index
31@ = -2.0


Declaring 29@ and 30@ is useless smile.gif

SANNY
if
    3 > 30@
then
    07AF: 26@ = player $PLAYER_CHAR group
    04C4: store_coords_to 15@ 16@ 17@ from_actor $PLAYER_ACTOR with_offset 31@ -1.5 0.2
    02CE: 17@ = ground_z_at 15@ 16@ 17@
    0@(30@,3i) = Actor.Create(Gang2, #SPECIAL02, 15@, 16@, 17@)
    095C: create_smoke_at 15@ 16@ 17@ velocity 0.0 0.0 0.0 RGBA 1.0 1.0 1.0 1.0 size 0.6 last_factor 0.5
    Actor.Health(0@(30@,3i)) = 1
    0631: put_actor 0@(30@,3i) in_group 26@
    04D8: set_actor 0@(30@,3i) drowns_in_water 0
    0446: set_actor 0@(30@,3i) immune_to_headshots 0
    07FE: set_actor 0@(30@,3i) fighting_style_to 6 6
    060B: set_actor 0@(30@,3i) decision_maker_to 32
    31@ += 2.0
    30@ += 1
    jump @NAKAGE_37


It is better to make that loop using for...end construct.

SANNY

for 30@ = 0 to 2
    04C4: store_coords_to 15@ 16@ 17@ from_actor $PLAYER_ACTOR with_offset 31@ -1.5 0.2
    02CE: 17@ = ground_z_at 15@ 16@ 17@
    009A: 2@ = create_actor_pedtype 8 model #SPECIAL02 at 15@ 16@ 17@
    095C: create_smoke_at 15@ 16@ 17@ velocity 0.0 0.0 0.0 RGBA 1.0 1.0 1.0 1.0 size 0.6 last_factor 0.5
    0223: set_actor 0@(30@,1i) health_to 1
    0631: put_actor 0@(30@,1i) in_group $PLAYER_GROUP  // Player group has its constant global var
    04D8: set_actor 0@(30@,1i) drowns_in_water 0
    0446: set_actor 0@(30@,1i) dismemberment_possible 0 // It's new 'immune_to_headshots' opcode description
    07FE: set_actor 0@(30@,1i) fighting_style_to 6 moves 6
    060B: set_actor 0@(30@,1i) decision_maker_to 32
    000B: 31@ += 2.0
end


SANNY
:NAKAGE_38
wait 0
if
    Actor.Dead(0@(30@,3i))
then
    29@ += 1
    Actor.DestroyInstantly(0@(30@,3i))
end // if
    
:NAKAGE_39
if
    3 > 29@
then
    jump @NAKAGE_38
end
    
    29@ = 0
    30@ = 0
    31@ = -2.0
    Actor.RemoveReferences(0@(30@,3i))
    jump @NAKAGE_35


It's a bit confusing, so I've rewritten it.

SANNY
0006: 29@ = 0

while 001B:   3 > 29@
    wait 0
    
    for 30@ = 0 to 2
        if
            0118:   actor 0@(30@,1i) dead
        then
            000A: 29@ += 1
            009B: destroy_actor 0@(30@,1i)
        end
    end
        
end
        
0007: 31@ = -2.0


Hope that will help you smile.gif

This post has been edited by Silent: Nov 25 2010, 03:37 PM
Go to the top of the page
 
+Quote Post
jayd00
post Nov 26 2010, 05:26 AM
Post #3


Ameteur Member

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



cool! thanks man!
I got some problems with high level construct

I don't know how exactly moves between labels wacko.gif


I still have the same problem.. The first actor killed, dissapear instantly but the other two didn't.
only when I kill the 3 actors at the same time, they dissapear instantly
how can I fix it? huh.gif

thanks! thumbsup.gif


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


Go to the top of the page
 
+Quote Post
Silent
post Nov 26 2010, 02:15 PM
Post #4


The master of cut retort

Group Icon

Posts: 239
From: Warsaw, PL
Joined: 21-July 10



If you didn't make any changes in my script, then it should work OK.

And about high-construct - try to write some high-level threads and recompile it. It may help you smile.gif

Wait, I have some time now - I can explain some constructs here and now biggrin.gif

IF...THEN...END looks like this:

Before:
SANNY
if
    00E1:   player 0 pressed_key 19
then
    0003: shake_camera 40
end


After recompiling:

SANNY
if
00E1:   player 0 pressed_key 19
else_jump @SomeLabel
0003: shake_camera 40

:SomeLabel


IF...THEN...ELSE...END:

Before:
SANNY
if
    00E1:   player 0 pressed_key 19
then
    0003: shake_camera 40
else
    015D: set_gamespeed 0.5
end  


After:
SANNY
if
00E1:   player 0 pressed_key 19
else_jump @SomeLabel
0003: shake_camera 40
jump @SomeLabel2

:SomeLabel
015D: set_gamespeed 0.5

:SomeLabel2


If you want, I can dig thru The MAIN Project a bit and explain some constructs smile.gif
Go to the top of the page
 
+Quote Post
Deji
post Nov 26 2010, 02:43 PM
Post #5


Coding like a Rockstar!

Group Icon

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



I don't see why you even have to think of the labels with high construct.. that's the best thing tongue.gif


--------------------
Go to the top of the page
 
+Quote Post
jayd00
post Nov 27 2010, 02:58 AM
Post #6


Ameteur Member

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



Thanks for help!!

QUOTE (Silent @ Nov 26 2010, 08:15 AM) *
If you want, I can dig thru The MAIN Project a bit and explain some constructs smile.gif

sure! that will be really great! thumbsup.gif

mm no, I didn't changed anything, almost anything xD
here is my script:

SANNY

{$CLEO .cs}

thread 'NAKAGE'
31@ = -2.0

:NAKAGE_35
while true
wait 0
if
  Player.Defined($PLAYER_CHAR)
then
    if and
        044B:   actor $PLAYER_ACTOR on_foot
        not Actor.Driving($PLAYER_ACTOR)
    else_jump @NAKAGE_35
        if
            0ADC:   test_cheat "TST"
        else_jump @NAKAGE_35
        03E5: show_text_box 'CHEAT1'  // Cheat activated
        023C: load_special_actor 'SKIN321' as 2 // models 290-299
        038B: load_requested_models

    repeat
        wait 0
    until     023D:   special_actor 2 loaded

for 30@ = 0 to 2
    wait 0
    04C4: store_coords_to 15@ 16@ 17@ from_actor $PLAYER_ACTOR with_offset 31@ -1.5 0.2
    02CE: 17@ = ground_z_at 15@ 16@ 17@
    009A: 0@(30@,1i) = create_actor_pedtype 8 model #SPECIAL02 at 15@ 16@ 17@
    095C: create_smoke_at 15@ 16@ 17@ velocity 0.0 0.0 0.0 RGBA 1.0 1.0 1.0 1.0 size 0.6 last_factor 0.5
    0223: set_actor 0@(30@,1i) health_to 1
    0631: put_actor 0@(30@,1i) in_group $PLAYER_GROUP  // Player group has its constant global var
    04D8: set_actor 0@(30@,1i) drowns_in_water 0
    0446: set_actor 0@(30@,1i) dismemberment_possible 0 // It's new 'immune_to_headshots' opcode description
    07FE: set_actor 0@(30@,1i) fighting_style_to 6 moves 6
    060B: set_actor 0@(30@,1i) decision_maker_to 32
    000B: 31@ += 2.0
end
    0296: unload_special_actor 2
    0006: 30@ = 0

while 001B:   3 > 29@
    
    for 30@ = 0 to 2
        wait 0
        if
            0118:   actor 0@(30@,1i) dead
        then
            000A: 29@ += 1
            009B: destroy_actor 0@(30@,1i)
        end
    end
        
end
        
    0007: 31@ = -2.0
    0006: 30@ = 0
    0006: 29@ = 0
end
end // while


and I got the same problem, the first actor that I killed, dissapear instantly. The other two stay deads in ground

This post has been edited by jayd00: Nov 27 2010, 03:00 AM


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


Go to the top of the page
 
+Quote Post
Silent
post Nov 27 2010, 11:18 AM
Post #7


The master of cut retort

Group Icon

Posts: 239
From: Warsaw, PL
Joined: 21-July 10



Odd problem. Try to check them manually - check for 0@, 1@ and 2@ actors. I don't know why that isn't working.

That will be noobish, but meh - we'll see if that really works.

SANNY
        while 001B:   3 > 29@
            wait 0
            
            if
                0118:   actor 0@ dead
            then
                000A: 29@ += 1
                009B: destroy_actor 0@
            end
            
            if
                0118:   actor 1@ dead
            then
                000A: 29@ += 1
                009B: destroy_actor 1@
            end
            
            if
                0118:   actor 2@ dead
            then
                000A: 29@ += 1
                009B: destroy_actor 2@
            end
                
        end


btw. 038B is useless tongue.gif

This post has been edited by Silent: Nov 27 2010, 11:21 AM
Go to the top of the page
 
+Quote Post
jayd00
post Nov 28 2010, 07:23 PM
Post #8


Ameteur Member

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



QUOTE (Silent @ Nov 27 2010, 05:18 AM) *
btw. 038B is useless tongue.gif

thanks! yea, you already told me, but it's strange (I think) sometimes when I load more than 1 special actor my game crash but if I add the opcode 038B works nice.. huh.gif

SANNY

{$CLEO .cs}

thread 'NAKAGE'
31@ = -2.0

:NAKAGE_35
while true
wait 0
if
  Player.Defined($PLAYER_CHAR)
then
    if and
        044B:   actor $PLAYER_ACTOR on_foot
        not Actor.Driving($PLAYER_ACTOR)
    else_jump @NAKAGE_35
        if
            0ADC:   test_cheat "TST"
        else_jump @NAKAGE_35
        03E5: show_text_box 'CHEAT1'  // Cheat activated
        023C: load_special_actor 'SKIN321' as 2 // models 290-299

        repeat
        wait 0
        until      023D:   special_actor 2 loaded

for 30@ = 0 to 2
    wait 0
    04C4: store_coords_to 15@ 16@ 17@ from_actor $PLAYER_ACTOR with_offset 31@ -1.5 0.2
    02CE: 17@ = ground_z_at 15@ 16@ 17@
    009A: 0@(30@,3i) = create_actor_pedtype 8 model #SPECIAL02 at 15@ 16@ 17@
    095C: create_smoke_at 15@ 16@ 17@ velocity 0.0 0.0 0.0 RGBA 1.0 1.0 1.0 1.0 size 0.6 last_factor 0.5
    0223: set_actor 0@(30@,3i) health_to 1
    0631: put_actor 0@(30@,3i) in_group $PLAYER_GROUP  // Player group has its constant global var
    04D8: set_actor 0@(30@,3i) drowns_in_water 0
    0446: set_actor 0@(30@,3i) dismemberment_possible 0 // It's new 'immune_to_headshots' opcode description
    07FE: set_actor 0@(30@,3i) fighting_style_to 6 moves 6
    060B: set_actor 0@(30@,3i) decision_maker_to 32
    000B: 31@ += 2.0
end
    0296: unload_special_actor 2
    30@ = 0

    while 001B:   3 > 29@
        wait 0
        
        if and
            0118:   actor 0@ dead
            28@ == 0
        then
            009B: destroy_actor 0@
            000A: 29@ += 1
            28@ = 1
        end

        if and
            0118:   actor 1@ dead
            27@ == 0
        then
            009B: destroy_actor 1@
            000A: 29@ += 1
            27@ = 1
        end
            
        if and
            0118:   actor 2@ dead
            25@ == 0
        then
            009B: destroy_actor 2@
            000A: 29@ += 1
            25@ = 1
        end
    end // while
      
    0007: 31@ = -2.0
    0006: 30@ = 0
    0006: 29@ = 0
    0006: 28@ = 0
    0006: 27@ = 0
    0006: 25@ = 0
end
end // while


mmm as you said in noobish way, but I see that the script is always destroying the actor 0@ before the others, so I think that's the problem.. the actor 0@ is already dead, so there is no need to destroy him again

I tested my idea using more variables and it works!!! but I don't know how to make it work in this way:

SANNY

while 001B:   3 > 29@
    
    for 30@ = 0 to 2
    wait 0
        if
            0118:   actor 0@(30@,1i) dead
        then
            000A: 29@ += 1
            009B: destroy_actor 0@(30@,1i)
        end
    end
        
end
        
0007: 31@ = -2.0


thanks for help!! thumbsup.gif



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


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: