Quantcast
Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
    1. Welcome to GTAForums!   (85,248 visits to this link)

    2. News

    1. GTA Online

      1. Find Lobbies & Players
      2. Guides & Strategies
      3. Vehicles
      4. Content Creator
      5. Help & Support
    2. Crews

      1. Events
      2. Recruitment
    1. Grand Theft Auto Series

    2. GTA Next

    3. GTA V

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

      1. Episodes from Liberty City
      2. Multiplayer
      3. Guides & Strategies
      4. Help & Support
      5. GTA Mods
    5. GTA Chinatown Wars

    6. GTA Vice City Stories

    7. GTA Liberty City Stories

    8. GTA San Andreas

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    9. GTA Vice City

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    10. GTA III

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    11. Top Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    12. Wiki

      1. Merchandising
    1. GTA Modding

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Mod Showroom

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

      1. DYOM
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Red Dead Redemption 2

    2. Red Dead Redemption

    3. Rockstar Games

    1. Off-Topic

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

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

    2. Site Suggestions

spaceeinstein

Pedestrian Traffic Signal Fix

Recommended Posts

spaceeinstein

Introduction

Pedestrian Traffic Signal Fix is a plugin for Grand Theft Auto: Vice City. The traffic light model trafficlight1.dff does not make an appearance in the world, but if you were to use it in your world, the model does not display a pedestrian traffic signal at all as seen in the left image. In Grand Theft Auto III, the model features a fully functional signal but only some code for it was carried over to GTA: Vice City. This plugin ports over the missing code, fully reenabling the pedestrian traffic signal for the traffic light model as seen in the right image.

 

signal.gif

 

Installation

This mod has been tested only on VC v1.00 US but should theoretically work on v1.01 and Steam.

 

Source

 

 

#include #include #include class CVector{public:	float x, y, z;};class CShinyTexts{public:	CVector vec1;	CVector vec2;	CVector vec3;	CVector vec4;	float unk[8];	float distance;	uint8_t type;	uint8_t r;	uint8_t g;	uint8_t b;};static uint32_t jumpAddress = 0x00464BD9;static uint32_t shinyTextsJumpEnd = 0x00465BB8;static auto LightForPeds = (uint8_t(__cdecl *)(void))0x00465BE0;static auto ml = (CVector *(__cdecl *)(CVector *, void *, const CVector &))0x004DFF20;static uint32_t TheCamera = 0x007E4688;static CShinyTexts *aShinyTexts = reinterpret_cast(0x0094A218);static uint32_t &nTimeInMilliseconds = *reinterpret_cast(0x00974B2C);static uint32_t &NumShinyTexts = *reinterpret_cast(0x00978618);void RegisterOne(CVector vec1, CVector vec2, CVector vec3, CVector vec4, float f0, float f1, float f2, float f3, float f4, float f5, float f6, float f7, uint8_t type, uint8_t r, uint8_t g, uint8_t b, float maxDistance){	aShinyTexts[NumShinyTexts].distance = sqrt(		pow((vec1.x - *reinterpret_cast(TheCamera + 0x30)), 2) +		pow((vec1.y - *reinterpret_cast(TheCamera + 0x34)), 2) +		pow((vec1.z - *reinterpret_cast(TheCamera + 0x38)), 2));	if (aShinyTexts[NumShinyTexts].distance  maxDistance / 2.0f) {			float fade = 2.0f - 2.0f * aShinyTexts[NumShinyTexts].distance / maxDistance;			aShinyTexts[NumShinyTexts].r = static_cast(static_cast® * fade);			aShinyTexts[NumShinyTexts].g = static_cast(static_cast(g) * fade);			aShinyTexts[NumShinyTexts].b = static_cast(static_cast(b) * fade);		}		NumShinyTexts++;	}}void RegisterOneCall(void *mat){	CVector vec1 = {}, vec2 = {}, vec3 = {}, vec4 = {}, in1, in2, in3, in4;	if (LightForPeds() == 2) {		// don't walk		in1 = { 2.7, 0.706, -0.127 };		in2 = { 2.7, 1.256, -0.127 };		in3 = { 2.7, 0.706, -0.40166664 };		in4 = { 2.7, 1.256, -0.40166664 };		ml(&vec1, mat, in1);		ml(&vec2, mat, in2);		ml(&vec3, mat, in3);		ml(&vec4, mat, in4);		RegisterOne(vec1, vec2, vec3, vec4, 1.0, 0.0, 0.0, 0.0, 1.0, 1.0, 0.0, 1.0, 1, 255, 0, 0, 60.0);	} else if (LightForPeds() == 0 || nTimeInMilliseconds & 0x100) {		// walk		in1 = { 2.7, 0.706, -0.40166664 };		in2 = { 2.7, 1.256, -0.40166664 };		in3 = { 2.7, 0.706, -0.539 };		in4 = { 2.7, 1.256, -0.539 };		ml(&vec1, mat, in1);		ml(&vec2, mat, in2);		ml(&vec3, mat, in3);		ml(&vec4, mat, in4);		RegisterOne(vec1, vec2, vec3, vec4, 1.0, 0.5, 0.0, 0.5, 1.0, 1.0, 0.0, 1.0, 1, 255, 255, 255, 60.0);	}}void __declspec(naked) RegisterOneCallProxy(){	__asm	{		lea edi, [edi+4]		push edi		call RegisterOneCall		add esp, 4		jmp shinyTextsJumpEnd	}}BOOL APIENTRY DllMain(HMODULE, DWORD reason, LPVOID){	if (reason == DLL_PROCESS_ATTACH) {		if (*reinterpret_cast(jumpAddress) == 0x000FDAE9) {			DWORD flOldProtect;			VirtualProtect(reinterpret_cast(jumpAddress + 1), 4, PAGE_EXECUTE_READWRITE, &flOldProtect);			*reinterpret_cast(jumpAddress + 1) = reinterpret_cast(&RegisterOneCallProxy) - jumpAddress - 5;			VirtualProtect(reinterpret_cast(jumpAddress + 1), 4, flOldProtect, &flOldProtect);		}	}	return TRUE;}

 

Thanks to Silent and HM128 for showing that a fix is possible.

Edited by spaceeinstein

Share this post


Link to post
Share on other sites
gts.

First!

 

Wonderful job as always space. By the way, I've never noticed this bug on PS2. :O

Then R* forgot to add the rest of the code to the game?

Share this post


Link to post
Share on other sites
spaceeinstein

This specific traffic light model doesn't appear in the world by default. There are only Miami-style traffic lights. The model exists in the game files and can be placed in the world by editing the IPL file. The vehicular traffic signal works just fine but the pedestrian traffic signal doesn't.

Edited by spaceeinstein

Share this post


Link to post
Share on other sites
Napoleone

Which traffic light models are the Miami-style ones?

Share this post


Link to post
Share on other sites
Inadequate

All traffic lights in-game are Miami-style. You can reuse the trafficlight1 model though.

Share this post


Link to post
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

×

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.