Jump to content

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
Link to comment
https://gtaforums.com/topic/886718-pedestrian-traffic-signal-fix/
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
  • 1 year later...
8 hours ago, GroveStGTAV said:

I installed the mod. But its not working

 

Same location, but still same traffic light

The traffic light model trafficlight1.dff does not make an appearance in the world

 

Better read OP next time, unless you put that specific traffic light model in your map you're not going to encounter it.

  • Like 3
  • 8 months later...

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
  • 0 User Currently Viewing
    0 members, 0 Anonymous, 0 Guests

×
×
  • Create New...

Important Information

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