Jump to content
    1. Welcome to GTAForums!

    1. GTANet.com

    1. GTA Online

      1. Los Santos Drug Wars
      2. Updates
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Red Dead Online

      1. Blood Money
      2. Frontier Pursuits
      3. Find Lobbies & Outlaws
      4. Help & Support
    3. Crews

    1. Grand Theft Auto Series

      1. Bugs*
      2. St. Andrews Cathedral
    2. GTA VI

    3. GTA V

      1. Guides & Strategies
      2. Help & Support
    4. GTA IV

      1. The Lost and Damned
      2. The Ballad of Gay Tony
      3. Guides & Strategies
      4. Help & Support
    5. GTA San Andreas

      1. Classic GTA SA
      2. Guides & Strategies
      3. Help & Support
    6. GTA Vice City

      1. Classic GTA VC
      2. Guides & Strategies
      3. Help & Support
    7. GTA III

      1. Classic GTA III
      2. Guides & Strategies
      3. Help & Support
    8. Portable Games

      1. GTA Chinatown Wars
      2. GTA Vice City Stories
      3. GTA Liberty City Stories
    9. Top-Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    1. Red Dead Redemption 2

      1. PC
      2. Help & Support
    2. Red Dead Redemption

    1. GTA Mods

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Red Dead Mods

      1. Documentation
    3. Mod Showroom

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

      1. Design Your Own Mission
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Rockstar Games

    2. Rockstar Collectors

    1. Off-Topic

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

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

    2. Forum Support

    3. Suggestions

[c++ Spawned Ped Not Taking Attributes]


motorsport71
 Share

Recommended Posts

Hey all. i'm working on spawning a ped but it doesn't seem to be taking the ENTITY::SET_ENTITY_AS_MISSION_ENTITY flag. When i spawn a bodyguard using the same code they are fine, but regular pedestrians won't take the code. Does anyone have an idea what it could be? here's the example:

if (ZombieSpawn)
	{
		
		ZombieSpawn = false;

		Player player = PLAYER::PLAYER_ID();
		Ped playerPed = PLAYER::PLAYER_PED_ID();
		
		Ped ped2;
		int max = 80;
		int min = 70;

		int X = rand() % (max - min) + min;
		
		if (rand() % 2 == 0)
		{
			X = X * -1;

		}
		

		int y = rand() % (max - min) + min;

		if (rand() % 2 == 0)
		{
			y = y * -1;

		}

		Vector3 spawnPos;
		

		spawnPos = ENTITY::GET_OFFSET_FROM_ENTITY_IN_WORLD_COORDS(playerPed, 0.0, 0.0f, 0.0f);
		PED::CREATE_RANDOM_PED(spawnPos.x + X, spawnPos.y + y, -0.5);

		ENTITY::SET_ENTITY_AS_MISSION_ENTITY(ped2, true, true);


		STREAMING::REQUEST_ANIM_SET("[email protected]@verydrunk");
		PED::SET_PED_KEEP_TASK(ped2, true);
		PED::SET_PED_MOVEMENT_CLIPSET(ped2, "[email protected]@verydrunk", 1.0);
		PED::SET_BLOCKING_OF_NON_TEMPORARY_EVENTS(ped2, 1);
		PED::SET_PED_FLEE_ATTRIBUTES(ped2, 0, 0);
		PED::SET_PED_COMBAT_ATTRIBUTES(ped2, 46, 1);
		PED::SET_PED_HEARING_RANGE(ped2, 5);
		PED::SET_PED_SEEING_RANGE(ped2, 20);
		PED::SET_PED_DIES_INSTANTLY_IN_WATER(ped2, true);
		PED::SET_PED_MAX_HEALTH(ped2, 9999);
		PED::SET_PED_CAN_SWITCH_WEAPON(ped2, false);
		PED::SET_PED_AS_ENEMY(ped2, true);
		PED::SET_PED_MONEY(ped2, 0);
		PED::APPLY_PED_DAMAGE_PACK(ped2, "SCR_Torture", 0.0, 9.0);
		PED::APPLY_PED_DAMAGE_PACK(ped2, "SCR_Dumpster", 0.0, 9.0);
		PED::APPLY_PED_DAMAGE_PACK(ped2, "BigHitByVehicle", 0.0, 9.0);
		PED::SET_PED_CAN_PLAY_GESTURE_ANIMS(ped2, false);

		WEAPON::REMOVE_ALL_PED_WEAPONS(ped2, true);

		AI::SET_PED_PATH_CAN_DROP_FROM_HEIGHT(ped2, true);
		AI::SET_PED_PATH_PREFER_TO_AVOID_WATER(ped2, true);
		AI::SET_PED_PATH_CAN_USE_CLIMBOVERS(ped2, true);
		AI::SET_PED_PATH_CAN_USE_LADDERS(ped2, true);

		ENTITY::SET_ENTITY_MAX_HEALTH(ped2, 1200);
		ENTITY::SET_ENTITY_HEALTH(ped2, 1200);

		AUDIO::DISABLE_PED_PAIN_AUDIO(ped2, true);
		AUDIO::STOP_PED_SPEAKING(ped2, true);
		

		PED::SET_RELATIONSHIP_BETWEEN_GROUPS(RelationshipHate, playerPed, 580191176); //shark vs player
		PED::SET_RELATIONSHIP_BETWEEN_GROUPS(RelationshipHate, 580191176, playerPed); //shark vs player


		PED::SET_RELATIONSHIP_BETWEEN_GROUPS(RelationshipHate, 45677184, 580191176); //civmale vs shark

		PED::SET_RELATIONSHIP_BETWEEN_GROUPS(RelationshipHate,  580191176, 45677184);//shark vs civmale
		
		AI::TASK_COMBAT_HATED_TARGETS_AROUND_PED(ped2, 30.0f, 0);

	}

If you see what i'm missing please let me know. I set this on a keypress to test the peds reaction and they just stand there, and when there is gun fire they run like a non mission character.

Thanks for reading,

 

motorsport71

Link to comment
Share on other sites

I don't programme in C++ but from what I can see, you're not assigning the random ped to ped2. I think you need to do it like this:

ped2 = PED::CREATE_RANDOM_PED(spawnPos.x + X, spawnPos.y + y, -0.5);

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • 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.