Random peds stand in line?

Anything to do with GTA1/GTA2 modding (tools, scripts and more).
Post Reply
Rick
Car Jacker
Car Jacker
Posts: 33
Joined: 29 Jan 2012, 18:56
GH nick: Sequential

Random peds stand in line?

Post by Rick »

During my recent little bigger map project i wonder:
Is it possible to order some randomly spawned peds (not scripted peds) to stand in a queue?
Just a few like if you pick up instant gang.

I dont want to change their remaps.
If possible I would like to refer to them via script to let them do things and then make them a dummy again.
I also would like to know how to create a really overcrowded area (full of random peds walking around).
Should work in Multiplayer - will it decrease ped density in other areas?
Any tips?
Thanks!

User avatar
elypter
Immortal
Posts: 1121
Joined: 26 Dec 2009, 23:53
GH nick: elypter

Re: Random peds stand in line?

Post by elypter »

you could use code from this script
http://gtamp.com/forum/viewtopic.php?p=7899#p7899
make the first one elvis group leader and for the other members check if they see each other
yur sa'nok ngeyä

Rick
Car Jacker
Car Jacker
Posts: 33
Joined: 29 Jan 2012, 18:56
GH nick: Sequential

Re: Random peds stand in line?

Post by Rick »

Thanks Elypter! May be that´s what i have to think about and work with.
I tried Sektors god script and reduced the numbers of dummies who are affected on screen by using a counter.
But if i give occupations the game crashes directly or at least after a while.
Also: dummies doesn´t seem to see other characters but only a few armed gang members do. (see Sektor´s gods script when holding grenades: peds should explode when they spot the player)
Another problem is that it also affects scripted/declared bot characters (testet with remap changes)
I suck at understanding these byte stuff :( and I wish to understand these commands a little better.

My next idea is to work with more than one slot for the dummy characters and use counters to control them directly and check if they are already in use.
I don´t know if that makes sense - how many char_data slots will work anyway?
I am afraid it´ll make one heavy script because it´s going to be just one of certain features.
If i have something that works in some kind of way i´ll post it here.
Help is also appreciated.
Thank you! :)

User avatar
elypter
Immortal
Posts: 1121
Joined: 26 Dec 2009, 23:53
GH nick: elypter

Re: Random peds stand in line?

Post by elypter »

you could check the peds relative positions by using raw position data like in
http://gtamp.com/forum/viewtopic.php?f=4&t=700 or
http://gtamp.com/mapscript/maplist/list ... ap=tafl.7z
to avoid crashes you could maybe recreate a ped at the same position although that would change their remaps
yur sa'nok ngeyä

Rick
Car Jacker
Car Jacker
Posts: 33
Joined: 29 Jan 2012, 18:56
GH nick: Sequential

Re: Random peds stand in line?

Post by Rick »

A solution seems to come closer. :idea:
For now I end up with yet another while loop so my script now counts 3 of them.
I have created CHAR_DATA 6 slots for the dummies so far and want to use a few more.

[syntax=mis]
// originally decompiled from "MP1-6P.scr" Using Epic GTA2 Script Decompiler by T.M. //
// using script parts from SEKTOR´s god.mis //

////////////////////////////////////////////////////////////////////////////////////////////////////
// DECLARATION //
////////////////////////////////////////////////////////////////////////////////////////////////////


PLAYER_PED p1 = (62.50, 193.50, 2.00) 10 0
PLAYER_PED p2 = (83.50, 179.50, 2.00) 9 90
PLAYER_PED p3 = (115.50, 169.50, 2.00) 8 270
PLAYER_PED p4 = (53.50, 164.50, 2.00) 6 0
PLAYER_PED p5 = (77.50, 170.50, 2.00) 7 90
PLAYER_PED p6 = (84.50, 192.50, 2.00) 11 270
CHAR_DATA p
CHAR_DATA currentped
CHAR_DATA ped
CHAR_DATA ped_01
CHAR_DATA ped_02
CHAR_DATA ped_03
CHAR_DATA ped_04
CHAR_DATA ped_05
CHAR_DATA ped_06
CHAR_DATA ped_07
CHAR_DATA ped_08
CHAR_DATA ped_09
CHAR_DATA ped_10
CHAR_DATA ped_11
CHAR_DATA ped_12
CHAR_DATA ped_13
CHAR_DATA ped_14
CHAR_DATA ped_15
CHAR_DATA ped_16
CHAR_DATA ped_17
CHAR_DATA ped_18
CHAR_DATA ped_19
CHAR_DATA ped_20
CHAR_DATA b1 = (60.0, 193.4, 2.0) 1 180 CRIMINAL_TYPE2

RADIO_STATION radio1 = STATION_KRISHNA (242.50, 214.50)
RADIO_STATION radio2 = STATION_RUSSIAN (201.50, 21.50)
RADIO_STATION radio3 = STATION_ZAIBATSU (20.50, 230.50)
RADIO_STATION radio4 = STATION_INDUSTRIAL (110.50, 108.50)
PARKED_CAR_DATA auto1 = (81.90, 183.50, 255.00) 0 90 SPRITE
PARKED_CAR_DATA auto2 = (81.90, 182.50, 255.00) 1 90 VTYPE
PARKED_CAR_DATA auto3 = (81.90, 181.50, 255.00) 2 90 GT24640
PARKED_CAR_DATA auto4 = (88.40, 182.60, 255.00) 0 180 BUS
PARKED_CAR_DATA auto5 = (103.50, 193.60, 255.00) 0 0 MORGAN
PARKED_CAR_DATA auto6 = (105.50, 193.60, 255.00) 1 0 BMW
PARKED_CAR_DATA auto7 = (104.50, 196.40, 255.00) 2 180 FIAT
PARKED_CAR_DATA auto8 = (106.50, 196.40, 255.00) 0 180 SPIDER
MAP_ZONE pedzone1
GENERATOR gen1 = (59.90, 186.50, 4.00) 0 COLLECT_08 6000 6000 10
GENERATOR gen2 = (73.50, 179.50, 5.00) 0 COLLECT_17 6000 6000 4
GENERATOR gen3 = (71.50, 170.50, 3.00) 0 COLLECT_01 6000 6000 10
GENERATOR gen4 = (118.50, 177.50, 2.00) 0 COLLECT_18 8000 8000 10
GENERATOR gen5 = (113.90, 195.00, 2.00) 0 COLLECT_02 6000 6000 5
GENERATOR gen6 = (89.50, 185.50, 2.00) 0 COLLECT_34 6000 6000 4
GENERATOR gen7 = (60.90, 195.00, 2.00) 0 COLLECT_00 6000 6000 40
GENERATOR gen8 = (100.50, 172.50, 2.00) 0 COLLECT_31 6000 6000 3
GENERATOR gen9 = (97.90, 158.90, 2.00) 0 COLLECT_03 8000 8000 6
GENERATOR gen10 = (49.90, 176.90, 2.00) 0 COLLECT_10 6000 6000 30
GENERATOR gen11 = (111.50, 170.50, 2.00) 0 COLLECT_01 6000 6000 10
GENERATOR gen12 = (50.50, 172.50, 4.00) 0 COLLECT_04 6000 6000 8
GENERATOR gen13 = (62.90, 184.00, 2.00) 0 COLLECT_40 6000 6000 2
GENERATOR gen14 = (78.50, 192.50, 2.00) 0 COLLECT_06 6000 6000 12
GENERATOR gen15 = (92.50, 176.50, 2.00) 0 COLLECT_00 6000 6000 40
GENERATOR gen16 = (98.50, 188.50, 2.00) 0 COLLECT_05 6000 6000 12
GENERATOR gen17 = (61.50, 175.50, 2.00) 0 COLLECT_16 6000 6000 6
GENERATOR gen18 = (68.00, 194.50, 4.00) 0 COLLECT_04 6000 6000 8
GENERATOR gen19 = (62.50, 171.50, 4.00) 0 COLLECT_30 6000 6000 3

ARROW_DATA pfeil

COUNTER mainloop = 1
COUNTER currentped_busy
COUNTER current_ped
COUNTER current_player
COUNTER ped_01_busy
COUNTER ped_02_busy
COUNTER ped_03_busy
COUNTER ped_04_busy
COUNTER ped_05_busy
COUNTER ped_06_busy
COUNTER ped_07_busy
COUNTER ped_08_busy
COUNTER charpointer = 1320
COUNTER b1_objective
COUNTER b1_timer = 97
COUNTER b1_guarding = 1
COUNTER b1_area
COUNTER pweapon = 1 //counter for the current player - // gta2 loads values from one the following
// counters, use it for checks, changes them
// if necessary and write them back into
// the right counter slot //Thanks to Jones - this saves a lot of work!
COUNTER p1weapon = 0 //game stores values here for player ped1 when not processed
COUNTER p2weapon = 0 //game stores values here for player ped2 when not processed
COUNTER p3weapon = 0 //game stores values here for player ped3 when not processed
COUNTER p4weapon = 0 //game stores values here for player ped4 when not processed
COUNTER p5weapon = 0 //game stores values here for player ped5 when not processed
COUNTER p6weapon = 0 //game stores values here for player ped6 when not processed
////////////////////////////////////////////////////////////////////////////////////////////////////
// LEVELSTART //
////////////////////////////////////////////////////////////////////////////////////////////////////

LEVELSTART

SET_AMBIENT_LEVEL (0.40, 0)
SWITCH_GENERATOR (gen1, ON)
SWITCH_GENERATOR (gen2, ON)
SWITCH_GENERATOR (gen3, ON)
SWITCH_GENERATOR (gen4, ON)
SWITCH_GENERATOR (gen5, ON)
SWITCH_GENERATOR (gen6, ON)
SWITCH_GENERATOR (gen7, ON)
SWITCH_GENERATOR (gen8, ON)
SWITCH_GENERATOR (gen9, ON)
SWITCH_GENERATOR (gen10, ON)
SWITCH_GENERATOR (gen11, ON)
SWITCH_GENERATOR (gen12, ON)
SWITCH_GENERATOR (gen13, ON)
SWITCH_GENERATOR (gen14, ON)
SWITCH_GENERATOR (gen15, ON)
SWITCH_GENERATOR (gen16, ON)
SWITCH_GENERATOR (gen17, ON)
SWITCH_GENERATOR (gen18, ON)
SWITCH_GENERATOR (gen19, ON)
SET_PEDDENSITY (pedzone1, 1000)
ADD_GROUP_TO_CHARACTER (b1, 0)
SET_GROUP_TYPE (b1, CHAIN)
SET b1_objective = 0
SET_CHAR_BRAVERY_LEVEL ( b1 , LOONY )
SET_CHAR_THREAT_REACTION ( b1 , NO_REACTION )

WHILE_EXEC ( mainloop = 1 )
SET current_player=1 //to start Innerwhile with player 1 again

WHILE_EXEC(current_player<7) //perform "Innerwhile" if Counter "current_player" is not bigger than 6 (players)
SET current_ped=1

IF(current_player=1) //who is current player ped?
SET p=(p1+0) //set CHAR_DATA slot "p" = p1
SET pweapon=(p1weapon+0) //load his weapon counter values
ENDIF //End check (who is current player ped?)
IF(current_player=2)
SET p=(p2+0)
SET pweapon=(p2weapon+0)
ENDIF
IF(current_player=3)
SET p=(p3+0)
SET pweapon=(p3weapon+0)
ENDIF
IF(current_player=4)
SET p=(p4+0)
SET pweapon=(p4weapon+0)
ENDIF
IF(current_player=5)
SET p=(p5+0)
SET pweapon=(p5weapon+0)
ENDIF
IF(current_player=6)
SET p=(p6+0)
SET pweapon=(p6weapon+0)
ENDIF

WHILE_EXEC(current_ped<7) //14bots //perform "Innerwhile" if Counter "current_ped" is not bigger than 6 (bots)
IF(current_ped=1) //who is current bot ped?
SET currentped=(ped_01+0) //set CHAR_DATA slot "p" = p1 //load his weapon counter values
SET currentped_busy=(ped_01_busy+0)
ENDIF //End check (who is current bot ped?)
IF(current_ped=2)
SET currentped=(ped_02+0)
SET currentped_busy=(ped_02_busy+0)
ENDIF
IF(current_ped=3)
SET currentped=(ped_03+0)
SET currentped_busy=(ped_03_busy+0)
ENDIF
IF(current_ped=4)
SET currentped=(ped_04+0)
SET currentped_busy=(ped_04_busy+0)
ENDIF
IF(current_ped=5)
SET currentped=(ped_05+0)
SET currentped_busy=(ped_05_busy+0)
ENDIF
IF(current_ped=6)
SET currentped=(ped_06+0)
SET currentped_busy=(ped_06_busy+0)
ENDIF

SET charpointer = ( charpointer + 660 )
SET currentped = ( p + charpointer )
IF (b1_objective = 0)

//SET_CHAR_OBJECTIVE (b1, WAIT_ON_FOOT)
ADD_PATROL_POINT (b1, 52.5, 185.5, 2.0)
ADD_PATROL_POINT (b1, 58.5, 193.5, 2.0)
SET b1_objective = 1
ENDIF
IF (currentped_busy = 0)

ADD_EXISTING_CHAR_TO_GROUP (b1, currentped)
//CHANGE_CHAR_REMAP (currentped, 17)
//SET_CHAR_OBJECTIVE (currentped , GOTO_AREA_ON_FOOT, 61.5, 39.2, 2.0)
//POINT_ARROW_AT (pfeil, currentped)
//GIVE_WEAPON (ped_01, ROCKET_LAUNCHER)
//MAKE_ALL_CHARS_MUGGERS (on)
POINT_ARROW_AT (pfeil, currentped)
SET currentped_busy = 1
ENDIF //ped_01_busy = 0
IF (HAS_CHARACTER_DIED (ped_01))
//IF(NOT(IS_ITEM_ONSCREEN(ped_01)))
//DELETE_ITEM (ped_01)
SET currentped_busy = 0
//ENDIF
ENDIF //HAS_CHARACTER_DIED (ped_01)

IF ( charpointer > 32340 ) // 49 x 660 (each character has a struct of 660 bytes)
SET charpointer = 3960 // If you don't want to kill player 2-6, set to 3960 ( 6 x 660 )
ENDIF //charpointer > 32340

IF(current_ped=1) //who is current bot ped? //set CHAR_DATA slot "p" = p1 //load his weapon counter values
SET ped_01_busy =(currentped_busy+0)
ENDIF //End check (who is current bot ped?)
IF(current_ped=2)
SET ped_02_busy =(currentped_busy+0)
ENDIF
IF(current_ped=3)
SET ped_03_busy =(currentped_busy+0)
ENDIF
IF(current_ped=4)
SET ped_04_busy =(currentped_busy+0)
ENDIF
IF(current_ped=5)
SET ped_05_busy =(currentped_busy+0)
ENDIF
IF(current_ped=6)
SET ped_06_busy =(currentped_busy+0)
ENDIF
++current_ped //perform all the "WHILE 3 commands" on the next bot, please

ENDWHILE //End WHILE 3

++current_player //perform all the "WHILE 2 commands" on the next player, please

ENDWHILE //End WHILE 2

ENDWHILE//End WHILE 1
LEVELEND[/syntax]

Remaining problems:
When I stop the group leader the queue is not proper (now i use patrol points to let him walk)
I have to think about how to delete the dummies who died and get the slots free again for new ones.
This also seems to be necessary to avoid crashes due to many peds if I am right?

My scenario should actually be a queue in front of a techno club and from time to time one guy should join the club.
I want to delete him, move the queue one step forward and make a new one join the group / queue.
Attachments
dummyobjectives.7z
Ready to start, map name: dummy objectives
(5.49 KiB) Downloaded 355 times

User avatar
elypter
Immortal
Posts: 1121
Joined: 26 Dec 2009, 23:53
GH nick: elypter

Re: Random peds stand in line?

Post by elypter »

if the bots dont have anything t do with players the whiles do not have to be nested
yur sa'nok ngeyä

User avatar
Sektor
Boss
Boss
Posts: 1383
Joined: 04 Mar 2008, 06:51
GH nick: Sektor
Location: GTAMP.com
Contact:

Re: Random peds stand in line?

Post by Sektor »

You could use invisible conveyors but that would move the player too.

Rick
Car Jacker
Car Jacker
Posts: 33
Joined: 29 Jan 2012, 18:56
GH nick: Sequential

Re: Random peds stand in line?

Post by Rick »

if the bots dont have anything t do with players the whiles do not have to be nested
I think here they have to?
My thought was that if COUNTER current_player exceeds 6 the while loop stops until the counter is set back to 1
at the beginning of the mainloop and the picking of the dummyped is a player related thing?
->
SET charpointer = ( charpointer + 660 )
SET currentped = ( p + charpointer )

@Sektor: conveyors are a good idea, too but it will also look conveyor-like
I guess I will try different things here.
Now I have to figure out how many people I can control and how to make a neat waiting queue.
May be SET_CHAR_MAX_RUNSPEED is the key.

Can you explain what happens in your script?
I can not imagine how a counter with a number stored inside is able to to select a dummy ped in game. :roll:

User avatar
Sektor
Boss
Boss
Posts: 1383
Joined: 04 Mar 2008, 06:51
GH nick: Sektor
Location: GTAMP.com
Contact:

Re: Random peds stand in line?

Post by Sektor »

Rick wrote:Can you explain what happens in your script?
I can not imagine how a counter with a number stored inside is able to to select a dummy ped in game. :roll:
Those numbers are memory addresses. SET command can store the memory address of a declared character like a player in a counter. To get the memory address of an undeclared ped, I add 660 bytes to the player 1 memory location. That might be another declared ped/player but keep adding 660 and you'll eventually get to an undeclared dummy ped.

Jones
Psycho
Psycho
Posts: 51
Joined: 08 Aug 2012, 21:25

Re: Random peds stand in line?

Post by Jones »

Hi,
here is my version without any while loops (except the main one) :lol: :
[mis]// originally decompiled from "MP1-6P.scr" Using Epic GTA2 Script Decompiler by T.M. //
// using script parts from SEKTOR´s god.mis //

////////////////////////////////////////////////////////////////////////////////////////////////////
// DECLARATION //
////////////////////////////////////////////////////////////////////////////////////////////////////


PLAYER_PED p1 = (62.50, 193.50, 2.00) 10 0
PLAYER_PED p2 = (83.50, 179.50, 2.00) 9 90
PLAYER_PED p3 = (115.50, 169.50, 2.00) 8 270
PLAYER_PED p4 = (53.50, 164.50, 2.00) 6 0
PLAYER_PED p5 = (77.50, 170.50, 2.00) 7 90
PLAYER_PED p6 = (84.50, 192.50, 2.00) 11 270
CHAR_DATA p
CHAR_DATA ped
CHAR_DATA char
CHAR_DATA ped_01
CHAR_DATA ped_02
CHAR_DATA ped_03
CHAR_DATA ped_04
CHAR_DATA ped_05
CHAR_DATA ped_06
CHAR_DATA ped_07
CHAR_DATA ped_08
CHAR_DATA ped_09
CHAR_DATA ped_10
CHAR_DATA ped_11
CHAR_DATA ped_12
CHAR_DATA ped_13
CHAR_DATA ped_14
CHAR_DATA ped_15
CHAR_DATA ped_16
CHAR_DATA ped_17
CHAR_DATA ped_18
CHAR_DATA ped_19
CHAR_DATA ped_20
CHAR_DATA b1 = (60.0, 193.4, 2.0) 1 180 CRIMINAL_TYPE2

RADIO_STATION radio1 = STATION_KRISHNA (242.50, 214.50)
RADIO_STATION radio2 = STATION_RUSSIAN (201.50, 21.50)
RADIO_STATION radio3 = STATION_ZAIBATSU (20.50, 230.50)
RADIO_STATION radio4 = STATION_INDUSTRIAL (110.50, 108.50)
PARKED_CAR_DATA auto1 = (81.90, 183.50, 255.00) 0 90 SPRITE
PARKED_CAR_DATA auto2 = (81.90, 182.50, 255.00) 1 90 VTYPE
PARKED_CAR_DATA auto3 = (81.90, 181.50, 255.00) 2 90 GT24640
PARKED_CAR_DATA auto4 = (88.40, 182.60, 255.00) 0 180 BUS
PARKED_CAR_DATA auto5 = (103.50, 193.60, 255.00) 0 0 MORGAN
PARKED_CAR_DATA auto6 = (105.50, 193.60, 255.00) 1 0 BMW
PARKED_CAR_DATA auto7 = (104.50, 196.40, 255.00) 2 180 FIAT
PARKED_CAR_DATA auto8 = (106.50, 196.40, 255.00) 0 180 SPIDER
MAP_ZONE pedzone1
GENERATOR gen1 = (59.90, 186.50, 4.00) 0 COLLECT_08 6000 6000 10
GENERATOR gen2 = (73.50, 179.50, 5.00) 0 COLLECT_17 6000 6000 4
GENERATOR gen3 = (71.50, 170.50, 3.00) 0 COLLECT_01 6000 6000 10
GENERATOR gen4 = (118.50, 177.50, 2.00) 0 COLLECT_18 8000 8000 10
GENERATOR gen5 = (113.90, 195.00, 2.00) 0 COLLECT_02 6000 6000 5
GENERATOR gen6 = (89.50, 185.50, 2.00) 0 COLLECT_34 6000 6000 4
GENERATOR gen7 = (60.90, 195.00, 2.00) 0 COLLECT_00 6000 6000 40
GENERATOR gen8 = (100.50, 172.50, 2.00) 0 COLLECT_31 6000 6000 3
GENERATOR gen9 = (97.90, 158.90, 2.00) 0 COLLECT_03 8000 8000 6
GENERATOR gen10 = (49.90, 176.90, 2.00) 0 COLLECT_10 6000 6000 30
GENERATOR gen11 = (111.50, 170.50, 2.00) 0 COLLECT_01 6000 6000 10
GENERATOR gen12 = (50.50, 172.50, 4.00) 0 COLLECT_04 6000 6000 8
GENERATOR gen13 = (62.90, 184.00, 2.00) 0 COLLECT_40 6000 6000 2
GENERATOR gen14 = (78.50, 192.50, 2.00) 0 COLLECT_06 6000 6000 12
GENERATOR gen15 = (92.50, 176.50, 2.00) 0 COLLECT_00 6000 6000 40
GENERATOR gen16 = (98.50, 188.50, 2.00) 0 COLLECT_05 6000 6000 12
GENERATOR gen17 = (61.50, 175.50, 2.00) 0 COLLECT_16 6000 6000 6
GENERATOR gen18 = (68.00, 194.50, 4.00) 0 COLLECT_04 6000 6000 8
GENERATOR gen19 = (62.50, 171.50, 4.00) 0 COLLECT_30 6000 6000 3

ARROW_DATA pfeil

COUNTER mainloop = 1
COUNTER playerCount=1
COUNTER currentped_busy
COUNTER current_ped
COUNTER current_player
COUNTER ped_01_busy
COUNTER ped_02_busy
COUNTER ped_03_busy
COUNTER ped_04_busy
COUNTER ped_05_busy
COUNTER ped_06_busy
COUNTER ped_07_busy
COUNTER ped_08_busy
COUNTER charpointer = 3960
COUNTER b1_objective
COUNTER b1_timer = 97
COUNTER b1_guarding = 1
COUNTER b1_area
COUNTER pweapon = 1 //counter for the current player - // gta2 loads values from one the following
// counters, use it for checks, changes them
// if necessary and write them back into
// the right counter slot //Thanks to Jones - this saves a lot of work!
COUNTER p1weapon = 0 //game stores values here for player ped1 when not processed
COUNTER p2weapon = 0 //game stores values here for player ped2 when not processed
COUNTER p3weapon = 0 //game stores values here for player ped3 when not processed
COUNTER p4weapon = 0 //game stores values here for player ped4 when not processed
COUNTER p5weapon = 0 //game stores values here for player ped5 when not processed
COUNTER p6weapon = 0



//memory altering
COUNTER in
COUNTER out = 9000

COUNTER static = 6206716

ONSCREEN_COUNTER nagscreen
ONSCREEN_COUNTER screen1
ONSCREEN_COUNTER screen2


FORWARD mission_timer:

THREAD_TRIGGER mission_trigger = THREAD_WAIT_FOR_CHAR_IN_AREA_ANY_MEANS(
p1, 62.50, 193.50, 2.00, 4.0,4.0, mission_timer:)

mission_timer:
DELAY_HERE (60)
ADD_ONSCREEN_COUNTER(nagscreen,playercount)
DELAY_HERE (60)
CLEAR_ONSCREEN_COUNTER(nagscreen)
RETURN
//game stores values here for player ped6 when not processed
////////////////////////////////////////////////////////////////////////////////////////////////////
// LEVELSTART //
////////////////////////////////////////////////////////////////////////////////////////////////////

LEVELSTART

SET_AMBIENT_LEVEL (0.40, 0)
SWITCH_GENERATOR (gen1, ON)
SWITCH_GENERATOR (gen2, ON)
SWITCH_GENERATOR (gen3, ON)
SWITCH_GENERATOR (gen4, ON)
SWITCH_GENERATOR (gen5, ON)
SWITCH_GENERATOR (gen6, ON)
SWITCH_GENERATOR (gen7, ON)
SWITCH_GENERATOR (gen8, ON)
SWITCH_GENERATOR (gen9, ON)
SWITCH_GENERATOR (gen10, ON)
SWITCH_GENERATOR (gen11, ON)
SWITCH_GENERATOR (gen12, ON)
SWITCH_GENERATOR (gen13, ON)
SWITCH_GENERATOR (gen14, ON)
SWITCH_GENERATOR (gen15, ON)
SWITCH_GENERATOR (gen16, ON)
SWITCH_GENERATOR (gen17, ON)
SWITCH_GENERATOR (gen18, ON)
SWITCH_GENERATOR (gen19, ON)
SET_PEDDENSITY (pedzone1, 1000)
ADD_GROUP_TO_CHARACTER (b1, 0)
SET_GROUP_TYPE (b1, CHAIN)
SET b1_objective = 0
SET_CHAR_BRAVERY_LEVEL ( b1 , LOONY )
SET_CHAR_THREAT_REACTION ( b1 , NO_REACTION )

//determine player count
SET in = (static+0)
CHANGE_GANG_CHAR_RESPECT (in,out,104)
SET in = (out+35) //this contains the number of players
CHANGE_GANG_CHAR_RESPECT (in,playercount,101) //it's 1 byte, save to playercount counter
++playerCount


WHILE_EXEC ( mainloop = 1 )
IF (b1_objective = 0)
//SET_CHAR_OBJECTIVE (b1, WAIT_ON_FOOT)
ADD_PATROL_POINT (b1, 52.5, 185.5, 2.0)
ADD_PATROL_POINT (b1, 58.5, 193.5, 2.0)
SET b1_objective = 1
ENDIF

//Find new ped
IF(ped=0)
SET in = ( p1 + charpointer ) //all characters are stored after player 1

SET in = (in+360) // read sprite address of character
CHANGE_GANG_CHAR_RESPECT (in,out,104)

IF(NOT(out=0)) // check if sprite is existent, therefore character is walking around
SET ped= (p1 + charpointer) // store character in ped
ENDIF

SET charpointer = ( charpointer + 660 ) //advance to next character address
IF ( charpointer > 32340 ) // 49 x 660 (each ped is 660 bytes, including player 50 peds seemed about right)
SET charpointer = 3960 // If you don't want to kill player 2-6, set to 3960 ( 6 x 660 )
ENDIF //charpointer > 32340
ENDIF

//set ped to null if character has died
IF((NOT(CHECK_CHARACTER_HEALTH(ped,0))) OR (HAS_CHARACTER_DIED(ped)))
SET ped=0
ENDIF

//if ped is alive
IF(NOT(ped = 0))
//armageddon baby!
//EXPLODE (ped)
//SET ped=0

//add ped to group and set ped to null to find next random character
IF(NOT(CHECK_NUMBER_ALIVE_IN_GROUP (b1,9)))
SET_CHAR_GRAPHIC_TYPE ( ped , DUMMY_GRAPHIC , 26 )
ADD_EXISTING_CHAR_TO_GROUP (b1, ped)
SET ped=0
ENDIF
ENDIF


ENDWHILE//End WHILE 1
LEVELEND[/mis]
Sometimes its working alright, other times the peds are doing some dumb sh*. Hope its helping you Rick, feel free to ask further questions

User avatar
Sektor
Boss
Boss
Posts: 1383
Joined: 04 Mar 2008, 06:51
GH nick: Sektor
Location: GTAMP.com
Contact:

Re: Random peds stand in line?

Post by Sektor »

Nice work Jones. Reading the sprite address was a good idea to see if they are walking was a nice idea.

Post Reply