Quantcast

Jump to content

» «
Photo

[REL|SRC] SCM and DirectX Hooking Source Code

285 replies to this topic
Cowpat
  • Cowpat

    web schmeb

  • Members
  • Joined: 12 Feb 2004

#61

Posted 12 October 2004 - 11:08 AM

QUOTE (Kryptos @ Oct 11 2004, 21:11)
Yes, your right, you can use d3dx9.lib instead of d3dx8.lib, although it will bloat the DLL due to all the advancements in the 9.0 DirectX version. Word of advice; don't play around with things you're not suppose to, it'll only come back to haunt you in the end.

In one of my earlier posts I also mentioned d3d8.lib, I've been including that in the project settings for an unknown reason, but apparently you don't need it. Sorry for any misconceptions or nuisances. This shouldn't actually cause any issues, but it's not necessary to include this.

Also, in MSVC++, including d3dx9.lib instead of d3dx8.lib makes the DLL size approximately 1.57 MB, opposed to 848 KB when using d3dx8.lib.

I was just playing around with the script commands for a while. If anyone wants to update their list with some extra opcodes here's some new ones for custom.cpp:

I used the d3dx9.lib because Microsoft said to do so for MSVC 6.0. I actually compiled the project with the name d3d8.dll but was interested to note you could name it d3d9.dll and the game would still find it.

This extra script command stuff is great, I'll have a muck about with it later. I've not done any scm stuff before, am i right in thinking that scm files are basically a list of functions to be called, with the parameters to be passed? And more importantly, can I something like Spookies code to access anything outwith the opcode handler, things like collision detection and player xyz movement?

Kryptos
  • Kryptos

    Hacker

  • Members
  • Joined: 05 Nov 2003

#62

Posted 12 October 2004 - 07:35 PM

There are numerous ways of using the SCM hook, when I was playing around with it last night, as I believe I mentioned in my previous post, I merely threw all the script commands (opcodes) into a function in Custom.cpp, which contains much of the data that is used for the interface, i.e. CustomRender(...). All I did was threw in a call to my custom function in this function, since this function is executed quite frequently (whenever drawing routines are required) so it would execute any of the opcodes that need constant updating. Here's essentially what I mean:

CODE
void CustomRender(IDirect3DDevice8* pDevice)
{
CustomScript();
if ((pSpeedoSprite) && (pSpeedoTex) && (pNeedleSprite) && (pNeedleTex)) // If we have the goods...
{
 ScriptCommand(&set_weather, WEATHER_STORM);
 if ((*dwCanPlayRadio) && (!*bInMenu)) // If we're in the game (not in the menu)...
 {
  /*
   Why can't we use just (!*bInMenu)?

   Well, bInMenu is 1 while in the menu and 0 while in-game,
   BUT as the value isn't initalized until we reach the main
   menu, it's 0 when this function first gets executed.

   Theres bound to be a better "InGame" variable about,
   but until I go looking for it, this'll do.
  */
  if (ScriptCommand(&player_in_car, PLAYER_CHAR))  // Is the player in a car?...
  {
   float fCurrentSpeed = 0.0;
   DWORD dwPlayerCar = 0;
   ScriptCommand(&get_player_car, PLAYER_CHAR, &dwPlayerCar); // Get the player's car.
   ScriptCommand(&make_car_heavy, &dwPlayerCar, 1);   // Make the vehicle heavy.
   if (!ScriptCommand(&car_stopped, &dwPlayerCar))    // Is the car moving?...
   {
    ScriptCommand(&get_car_speed, &dwPlayerCar, &fCurrentSpeed); // Get the car speed :)
   }
   fCurrentSpeed *= fSpeedoMultiplier;  // (m/s * 2.24) = mph

   D3DSURFACE_DESC Desc;
   pSpeedoTex->GetLevelDesc(0, &Desc);   // Get the primary texture level description.
   if (Desc.Format == D3DFMT_A8R8G8B8)   // This should always be true, but blah.
   {
    D3DLOCKED_RECT Rect;
    pSpeedoTex->LockRect(0, &Rect, NULL, 0); // Lock the texture. Error checking here maybe? :s

    DWORD* pTexData = (DWORD*)Rect.pBits;  // Pointer to the raw texture data.
    int PixRow = Rect.Pitch / 4;    // Pitch of the texture in pixels.

    int nCurrentSpeed;
    _asm
    {
     finit     // Initialize FPU
     fld  fCurrentSpeed // Load speed from float
     fistp nCurrentSpeed // Store speed in int
    }
    if (nCurrentSpeed > 999) nCurrentSpeed = 999;  // Maybe they're driving the bat mobile!
    if (fCurrentSpeed > 200.0f) fCurrentSpeed = 200.0f; // We don't want the needle looping.
    int nDigit = nCurrentSpeed / 100;     // How many hundreds of miles per hour are we going?
    DrawDigit(pTexData, PixRow, 91, 149, nDigit);  // Draw first speed digit
    nCurrentSpeed -= (nDigit * 100);     // Subtract the hundreds
    nDigit = nCurrentSpeed / 10;      // Get tenths
    DrawDigit(pTexData, PixRow, 101, 149, nDigit);  // Draw second speed digit
    nDigit = nCurrentSpeed - (nDigit * 10);    // Subtract the tens
    DrawDigit(pTexData, PixRow, 111, 149, nDigit);  // Draw third speed digit
    BYTE* nGear = (BYTE*)GameGetVehicle(dwPlayerCar); // Get currently driven car's structure.
    nGear += 520;          // VEHICLE_STRUCT+520 = Gear
    DrawDigit(pTexData, PixRow, 72, 149, *nGear);  // Draw gear digit
    pSpeedoTex->UnlockRect(0);       // Unlock the texture.
   }

   pSpeedoSprite->Begin(); // This sets up render states and stuff. See the SDK dox.
   // Draw the speedometer sprite.
   pSpeedoSprite->Draw(pSpeedoTex, NULL, &vScaling, NULL, 0.0f, &vTranslation, 0xFFFFFFFF);
   // Draw the needle sprite.
   pNeedleSprite->Draw(pNeedleTex, NULL, &vScaling, &vRotCenter, fNeedleZero-(fNeedleUnit*fCurrentSpeed), &vNeedleTranslation, 0xFFFFFFFF);
   pSpeedoSprite->End(); // Cleanup. Reset render states etc. See SDK dox.

   
  }
 }
}
}

void CustomScript()
{
ScriptCommand(&set_weather, WEATHER_STORM);
ScriptCommand(&set_current_time, 0, 0);
if (ScriptCommand(&is_key_pressed, 0, 14))
{
 ScriptCommand(&set_gamespeed, 0.3);
}
else if (ScriptCommand(&is_key_pressed, 0, 6))
{
 ScriptCommand(&set_gamespeed, 0.3);
}
else if (ScriptCommand(&is_key_pressed, 0, 16))
{
 ScriptCommand(&set_gamespeed, 1.1);
}
}

Now I realize most people will tell you this is quite inefficient since opcodes such as set_weather and set_current_time (the clock remains at 00:00 during gameplay) only need to be called once, I believe the is_key_pressed opcodes must be embedded in a thread, which means that each time CustomRender(...) is called both set_weather and set_current_time are called which is improper use of CPU; but I was just messing around, so sue me.

The above CustomScript() function contains the simple, as can be seen, idea I mentioned previously, using the game's is_key_pressed function, which I added to the GameScripting.h (see my previous post), to check and see if a key is being pressed, and if it is modify the gamespeed to the appropriate float value, 1 being normal in a range of 0 - 2, 0 being nearly stopped and 2 being double the normal speed. Simple enough I hope.

Here you can see that in slow motion you can get some nice clips of carnage:

user posted image

user posted image

Ocram88, I believe you are referring to a .cfg file that contains opcodes that you want executed at runtime. You could possibly try adding a runtime interpreter to the code so anything within that configuration file is read by the script hook. Just a thought.

Cowpat
  • Cowpat

    web schmeb

  • Members
  • Joined: 12 Feb 2004

#63

Posted 12 October 2004 - 10:45 PM

woot!

I stuck in

CODE

else if (ScriptCommand(&is_key_pressed, 0, 15))
{
    ScriptCommand(&create_player, 0, 1.0, 30.0, 1.0, PLAYER_CHAR);
}



and had fun trying to control a bunch of Tommies on the golf course

Squiddy
  • Squiddy

    Back!

  • The Connection
  • Joined: 06 Oct 2004

#64

Posted 12 October 2004 - 10:57 PM Edited by _Squiddy_, 12 October 2004 - 11:00 PM.

Like this? biggrin.gif
http://gari.marway.o...dy/clones16.jpg

Reminds me at Matrix Revolutions. A little bit. biggrin.gif
http://gari.marway.o...dy/clones19.jpg

Edit: Ah, i forgot.
I was trying to get the actual position of the player. Seeing the actor_struct in gamescripting.h i tried to pass a pointer at the PLAYER_CHAR to retrieve the positions.
But i get compatibilitie errors. Can somebody post a bit code that works? smile.gif

Kryptos
  • Kryptos

    Hacker

  • Members
  • Joined: 05 Nov 2003

#65

Posted 12 October 2004 - 11:27 PM Edited by Kryptos, 13 October 2004 - 03:41 AM.

Just add this code to GameScripting.h:

CODE
const SCRIPT_COMMAND get_player_coords   = { 0x0054, "vfff" }; // var_player, x, y, z

Make sure you use PLAYER_CHAR for the first parameter. Simple enough.

Ever wanted to be as rich as Bill Gates?

CODE
const SCRIPT_COMMAND add_to_player_money  = { 0x0109, "vi" };  // PLAYER_CHAR, int

ScriptCommand(&add_to_player_money, PLAYER_CHAR, 20000); // Add $20000 each time called.

This essentially just adds $20000 each time the command is called, if you embed it in the CustomRender(...) function then you can just watch your money sky rocket.

user posted image

Yet another update. Just playing around with some explosions, and you can get some pretty cool results.

CODE
const SCRIPT_COMMAND create_explosion   = { 0x020C, "fffi" }; // x, y, z, int

void Pyro();

Pyro()
{
float i, j;
i = (float) (rand() % 30);
j = (float) ((rand() + 100) % 30);

ScriptCommand(&create_explosion, i, j, 30.0, 1);
}

It's always fun playing with fire.

user posted image

CODE
Pyro()
{
float i, j;
i = (float) (rand() % 100);
j = (float) ((rand() + 100) % 100);

ScriptCommand(&create_explosion, i, j, 30.0, 1);
}

user posted image

And yet again, this time playing around with multiple types of explosions to create some nice results.

CODE
Pyro()
{
float i, j;
i = (float) (rand() % 50);
j = (float) ((rand() + 100) % 50);

ScriptCommand(&create_explosion, i - 10, j, 30.0, 0);
ScriptCommand(&create_explosion, i + 10, j, 30.0, 1);
ScriptCommand(&create_explosion, i - 5, j, 30.0, 2);
ScriptCommand(&create_explosion, i + 5, j, 30.0, 3);
}

user posted image

Anyhow, just some fun stuff. You could almost create a realistic firefighting mission using this, assuming you distribute the flames across a larger area, I was just using the golf course for effect, and as long as you track the coordinates of the fires as they are created and perhaps use blips on the radar to define where they are. It would be a lot more fun trying to put out a forest fire, like in the first picture, then merely putting out vehicle fires.

Another humerous event occurred while I was trying to create a larger fire.

user posted image

user posted image

user posted image

DexX
  • DexX

    Black Hat

  • Feroci
  • Joined: 16 May 2002

#66

Posted 13 October 2004 - 04:40 AM Edited by ashdexx, 13 October 2004 - 04:43 AM.

ugh, i FINALLY got it to compile, and work ingame. i had all the same problems as cowpat.

Anyway, off to see what i can do with this. looks like you guys have got some nice progress going already biggrin.gif

is there a limit to how many players can be spawned before the game crashes?

Spooky
  • Spooky

    Prince of the Yolkfolk

  • Members
  • Joined: 13 Jan 2002

#67

Posted 13 October 2004 - 06:13 AM

QUOTE (Kryptos @ Oct 13 2004, 00:27)
Just add this code to GameScripting.h:

CODE
const SCRIPT_COMMAND get_player_coords   = { 0x0054, "vfff" }; // var_player, x, y, z

Make sure you use PLAYER_CHAR for the first parameter. Simple enough.

Actually the params for this would be "vvvv", and you should pass PLAYER_CHAR then 3 pointers to floats...

e.g.
GameScripting.h
CODE
const SCRIPT_COMMAND get_player_coords   = { 0x0054, "vvvv" }; // var_player, x, y, z

Custom.cpp
CODE
float fX, fY, fZ;
ScriptCommand(&get_player_coords, PLAYER_CHAR, &fX, &fY, &fZ);
conprintf("Player is at [%f, %f, %f]", fX, fY, fZ);


Otherwise it wouldn't be able to return the coord values, and would probably crash.

Cowpat
  • Cowpat

    web schmeb

  • Members
  • Joined: 12 Feb 2004

#68

Posted 13 October 2004 - 08:51 AM Edited by Cowpat, 13 October 2004 - 11:56 AM.

QUOTE (ashdexx @ Oct 13 2004, 04:40)
is there a limit to how many players can be spawned before the game crashes?

I read a whiles back it was 60 actors max

...but looking at Squiddy's images I wonder if that's true.

btw, those keypress values (L Shift=16, RTN=15, etc), are they germaine only to GTA or are they universal to keyboards in general, and where can I find a list of them?

TwoZero
  • TwoZero

    Ghetto Star

  • The Connection
  • Joined: 15 Apr 2003

#69

Posted 13 October 2004 - 12:54 PM

QUOTE (Cowpat @ Oct 13 2004, 10:51)
QUOTE (ashdexx @ Oct 13 2004, 04:40)
is there a limit to how many players can be spawned before the game crashes?

I read a whiles back it was 60 actors max

I tested it before, and my game crashed after spawning 139 actors, so including the player actor that would be a limit of 140 actors, loads of fun stuff possible with so many actors smile.gif

steve-m
  • steve-m

  • Feroci
  • Joined: 26 Jul 2002

#70

Posted 13 October 2004 - 01:40 PM

QUOTE (TwoZero @ Oct 13 2004, 14:54)
QUOTE (Cowpat @ Oct 13 2004, 10:51)
QUOTE (ashdexx @ Oct 13 2004, 04:40)
is there a limit to how many players can be spawned before the game crashes?

I read a whiles back it was 60 actors max

I tested it before, and my game crashed after spawning 139 actors, so including the player actor that would be a limit of 140 actors, loads of fun stuff possible with so many actors smile.gif

My limit adjuster has a value "Peds" which is 140 by default, I assume if you increase it you can create much more... smile.gif

DexX
  • DexX

    Black Hat

  • Feroci
  • Joined: 16 May 2002

#71

Posted 13 October 2004 - 02:49 PM

You could, but wouldnt that many more actors tend to slow the game down?

Granted, i would love to see them all trying to kill each other (hoo-wee!!) but i dont want 5fps either. Gotta find a reasonable limit. Of course the idea of a 200-person firefirefight does have its allure devil.gif

JernejL
  • JernejL

    Big Homie

  • Feroci
  • Joined: 11 Mar 2002

#72

Posted 13 October 2004 - 06:47 PM

QUOTE (TwoZero @ Oct 13 2004, 13:54)
QUOTE (Cowpat @ Oct 13 2004, 10:51)
QUOTE (ashdexx @ Oct 13 2004, 04:40)
is there a limit to how many players can be spawned before the game crashes?

I read a whiles back it was 60 actors max

I tested it before, and my game crashed after spawning 139 actors, so including the player actor that would be a limit of 140 actors, loads of fun stuff possible with so many actors smile.gif

gta-vc has an internal limit for cars / peds / planes etc of 150 objects, it reserves first 10 for 10 players (broken multiplayer..) what gives you 140 objects, then subtract 3 planes, one player, some cars..

Kryptos
  • Kryptos

    Hacker

  • Members
  • Joined: 05 Nov 2003

#73

Posted 13 October 2004 - 07:01 PM Edited by Kryptos, 13 October 2004 - 08:11 PM.

Sorry about that spooky. Yeah, that makes more sense. I didn't actually verify the code, I merely wrote it based on the entry for the database.

If I get a chance later I might try to make a more advanced jet pack mod, similar to that of LithJoe's except I want to extend the functionality to the z axis so the player moves exactly in whatever direction they are looking; opposed to merely parsing along the x and y axis as LithJoe did. This can all be achieved through relatively simplistic trigonumetric functions using math.h. I'm interested to see what can truly be accomplished with this external hook, since the entire arsenal of the C++ language is now at our disposal.

I forgot to add one little tidbit of code. This is essentially a speed governor, just to add that extra aspect of realism.

CODE
const SCRIPT_COMMAND stop_car     = { 0x02D4, "v" };  // var_car

if (fCurrentSpeed >= (120.0 / 2.24)) ScriptCommand(&stop_car, &dwPlayerCar); // If the car goes above 120 MPH shut off the engine.

It merely shuts down the engine when the vehicle travels at, or in excess of, 120 MPH.

Cowpat
  • Cowpat

    web schmeb

  • Members
  • Joined: 12 Feb 2004

#74

Posted 14 October 2004 - 10:02 PM


I wonder if someone would be so kind as to suggest what's wrong. I can create newplayers and any of the actors/peds in default.ide, but I still can't get the player coordinates right. If I start a game at the beach hotel hideout and create a new player, I always spawn at the little cul de sac in Vice Point, and If I spawn a ped instead, the peds spawn at the same place and I have to go over to Vice Point if I want to see them.

float fX=0,fY=0,fZ=0;//can be init to 0 or not, makes no difference

ScriptCommand(&get_player_coords, PLAYER_CHAR, &fX, &fY, &fZ);

ScriptCommand(&create_player, 0, fX, fY, fZ, PLAYER_CHAR); or
ScriptCommand(&create_actor, 0, 77, fX, fY, fZ, PLAYER_ACTOR);//skater babe


I'm getting the player coords both after the keypress, and in CustomRender()
after !*bInMenu has been tested, so the player coords should have been picked up. Any Ideas?

The Warlock
  • The Warlock

    Six men with guns drawn.

  • Members
  • Joined: 25 May 2003

#75

Posted 14 October 2004 - 11:46 PM

This might have already been posted, but the speedometer (and, I assume, any other 2d graphic placed on the screen using the same code) disappears temporarily while adjusting the radio station.

I wish I could help find the bug, but I don't know much C++ and I know even less VC .scm scripting.

Kryptos
  • Kryptos

    Hacker

  • Members
  • Joined: 05 Nov 2003

#76

Posted 15 October 2004 - 01:56 AM Edited by Kryptos, 15 October 2004 - 02:16 AM.

The reason the graphics flicker when the radio station is changed is because of this code:

CODE
if ((*dwCanPlayRadio) && (!*bInMenu)) // If we're in the game (not in the menu)...

This isn't really a bug, although it may appear to be. The if statement checks to see if the player is in a car and can play the radio and makes sure that the radio isn't playing because the player is viewing the radio menu option on the pause screen (this causes a game crash). To fix this a better pointer address, or something to that degree, is required to ensure the player is in a vehicle so the speedometer isn't displayed while the player is on foot.

Sorry Cowpat, I'd help you out with the get_player_coords problem except I can't get the DLL to run with the script command. Damn thing. It crashes after going through the movie, before loading the intro.txd, or whatever the file is called.

CODE
float fltPosX, fltPosY, fltPosZ; // Player coordinates.

ScriptCommand(&get_player_coords, PLAYER_CHAR, &fltPosX, &fltPosY, &fltPosZ);

DexX
  • DexX

    Black Hat

  • Feroci
  • Joined: 16 May 2002

#77

Posted 15 October 2004 - 02:09 AM

hmm. i know there's an opcode, that does checking to see if the player is driving, can't that be used instead somehow?

Kryptos
  • Kryptos

    Hacker

  • Members
  • Joined: 05 Nov 2003

#78

Posted 15 October 2004 - 02:30 AM Edited by Kryptos, 15 October 2004 - 02:48 AM.

You mean:

CODE
const SCRIPT_COMMAND is_player_driving   = { 0x00E0, "v" };  // PLAYER_CHAR

if (ScriptCommand(&is_player_driving, PLAYER_CHAR)); // Check to see if player is in car.

The utility already implements this:

CODE
if (ScriptCommand(&player_in_car, PLAYER_CHAR))  // Is the player in a car?...

Which also checks to see if the player is in a car. Sorry, a moderator can remove this post since it's seemingly pointless. I should have looked into the code again before posting off the top of my head.

DexX
  • DexX

    Black Hat

  • Feroci
  • Joined: 16 May 2002

#79

Posted 15 October 2004 - 03:39 AM

Problem: when using -
CODE

void Pyro();

Pyro()
{
float i, j;
i = (float) (rand() % 30);
j = (float) ((rand() + 100) % 30);

ScriptCommand(&create_explosion, i, j, 30.0, 1);
}


i get:
QUOTE
\Custom.cpp(371) : error C2556: 'int __cdecl Pyro(void)' : overloaded function differs only by return type from 'void __cdecl Pyro(void)'
\Custom.cpp(368) : see declaration of 'Pyro'
\Custom.cpp(371) : error C2371: 'Pyro' : redefinition; different basic types
\Custom.cpp(368) : see declaration of 'Pyro'


help please

Kryptos
  • Kryptos

    Hacker

  • Members
  • Joined: 05 Nov 2003

#80

Posted 15 October 2004 - 03:49 AM Edited by Kryptos, 15 October 2004 - 04:06 AM.

Where did you define the Pyro() function? It's easier to keep the function prototypes in Custom.h. After doing that add a call to it from the CustomRender() function so it executes frequently, or a derivation of that.

Oh, ashdexx, you merely forgot to put 'void' before pyro.

Here's my current function in Custom.cpp with the area where you encountered the problem:

CODE
void Pyro() // Your problem was here, you forgot 'void'.
{
float i, j;

/*
The modulus of 25 is used in this scenario to ensure that the
generated coordinates are nothing more then 25, thus everything
is isolated to the golf course for simplicity's sake. If you want
fires to randomly generate around Vice merely use %1500, or
whatever the appropriate boundary is.
*/

i = (float) (rand() % 25);
j = (float) ((rand() + 10) % 25);

ScriptCommand(&create_explosion, i + 5, j, 30.0, 1);
ScriptCommand(&create_explosion, i - 5, j, 30.0, 1);
ScriptCommand(&create_explosion, i, j + 5, 30.0, 1);
ScriptCommand(&create_explosion, i, j - 5, 30.0, 1);
}

And the prototype in Custom.h:

CODE
void Pyro();

From there I make a call to the function out of my custom script function, which contains all the code I want executed at runtime, as well as any threaded functions, or unthreaded functions for that matter, that I want to use. I suggest people use this method since it's much easier to maintain a homebrewed function then adding tidbits to an already populated one.

DexX
  • DexX

    Black Hat

  • Feroci
  • Joined: 16 May 2002

#81

Posted 15 October 2004 - 04:04 AM

Here's what i have, with the code around it kept in, so you know exactly where i have it pasted:
CODE

Custom.h
...
void CustomRender(IDirect3DDevice8* pDevice);
void CustomReset();
void Pyro();

#endif

CODE

custom.cpp
...
   pSpeedoSprite->Begin(); // This sets up render states and stuff. See the SDK dox.
   // Draw the speedometer sprite.
   pSpeedoSprite->Draw(pSpeedoTex, NULL, &vScaling, NULL, 0.0f, &vTranslation, 0xFFFFFFFF);
   // Draw the needle sprite.
   pNeedleSprite->Draw(pNeedleTex, NULL, &vScaling, &vRotCenter, fNeedleZero-(fNeedleUnit*fCurrentSpeed), &vNeedleTranslation, 0xFFFFFFFF);
   pSpeedoSprite->End(); // Cleanup. Reset render states etc. See SDK dox.
  }
 }
}
}


void Pyro();
Pyro()
{
float i, j;
i = (float) (rand() % 30);
j = (float) ((rand() + 100) % 30);

ScriptCommand(&create_explosion, i, j, 30.0, 1);
}


QUOTE
From there I make a call to the function out of my custom script function, which contains all the code I want executed at runtime, as well as any threaded functions, or unthreaded functions for that matter, that I want to use. I suggest people use this method since it's much easier to maintain a homebrewed function then adding tidbits to an already populated one.

yep. i am officially lost. Probably because im looking for more of a "cut this and paste it here" type of example, and know very little about this to begin with. my apologies for any annoying questions.

Kryptos
  • Kryptos

    Hacker

  • Members
  • Joined: 05 Nov 2003

#82

Posted 15 October 2004 - 04:17 AM

Okay, put the call to the Pyro() function here:

CODE
void CustomRender(IDirect3DDevice8* pDevice)
{
CustomScript();
if ((pSpeedoSprite) && (pSpeedoTex) && (pNeedleSprite) && (pNeedleTex)) // If we have the goods...
{
 Pyro(); // <- PUT HERE
 if ((*dwCanPlayRadio) && (!*bInMenu)) // If we're in the game (not in the menu)...
 {
  // Ignore this stuff...
 }
}
}

That should work. And you put the prototype of Pyro(), i.e. 'void Pyro();', twice when you should have only put it once in Custom.h. In other words, get rid of this:

CODE
Custom.cpp...

// void Pyro(); <- GET RID OF THIS
void Pyro() <- ADDED VOID TO THIS
{
float i, j;
i = (float) (rand() % 30);
j = (float) ((rand() + 100) % 30);

ScriptCommand(&create_explosion, i, j, 30.0, 1);
}

That should hopefully fix your problem.

DexX
  • DexX

    Black Hat

  • Feroci
  • Joined: 16 May 2002

#83

Posted 15 October 2004 - 04:49 AM

Touche! biggrin.gif
yea, it works. thanks a bunch. i did have to make one more alteration though.
i had to comment out this:

void CustomRender(IDirect3DDevice8* pDevice)
{
//CustomScript(); this had to go
if ((pSpeedoSprite

otherwise, this is wicked. thanks again!

Serero-Kuh
  • Serero-Kuh

    Player Hater

  • Members
  • Joined: 05 Mar 2004

#84

Posted 15 October 2004 - 12:45 PM Edited by Serero-Kuh, 15 October 2004 - 01:17 PM.

hi,
does anyone know if the DirectX Hook will work in Delphi and how? if anyone know this plz help me thx

JernejL
  • JernejL

    Big Homie

  • Feroci
  • Joined: 11 Mar 2002

#85

Posted 15 October 2004 - 05:56 PM

QUOTE (Serero-Kuh @ Oct 15 2004, 13:45)
hi,
does anyone know if the DirectX Hook will work in Delphi and how? if anyone know this plz help me thx

i think ST.MU is working on it..

Serero-Kuh
  • Serero-Kuh

    Player Hater

  • Members
  • Joined: 05 Mar 2004

#86

Posted 15 October 2004 - 07:46 PM

QUOTE (Delfi @ Oct 15 2004, 17:56)
QUOTE (Serero-Kuh @ Oct 15 2004, 13:45)
hi,
does anyone know if the DirectX Hook will work in Delphi and how? if anyone know this plz help me thx

i think ST.MU is working on it..

will he translate this from C++ to Delphi? i hope so wink.gif

Squiddy
  • Squiddy

    Back!

  • The Connection
  • Joined: 06 Oct 2004

#87

Posted 15 October 2004 - 10:46 PM Edited by _Squiddy_, 15 October 2004 - 11:50 PM.

QUOTE (Spooky @ Oct 7 2004, 03:27)
You can change the speed to kmh by editing the file Speedo.cfg, changing mul_speed 2.24 to mul_speed 3.6 - The MPH text on the speedometer will stay there, but the speed is now read as kmh.


Analog Speedometer now supports kmh

user posted image

Because many germans asked about kmh support i stopped working on my other mini mods and added the support.
As you will see inside the cfg you can change the speedo multiplier for both units. Switching kmh / mph is possible by changing dsp_speed.

I hope that will make some people more happier. biggrin.gif

Download
Right click -> Save as .zip

steve-m
  • steve-m

  • Feroci
  • Joined: 26 Jul 2002

#88

Posted 15 October 2004 - 11:08 PM

QUOTE (Serero-Kuh @ Oct 15 2004, 21:46)
QUOTE (Delfi @ Oct 15 2004, 17:56)
QUOTE (Serero-Kuh @ Oct 15 2004, 13:45)
hi,
does anyone know if the DirectX Hook will work in Delphi and how? if anyone know this plz help me thx

i think ST.MU is working on it..

will he translate this from C++ to Delphi? i hope so wink.gif

I was talking about translating the scm hook, not the whole DirectX stuff, since there's no real SDK for Delphi. Haven't started on that yet, though.

Good work, Squiddy!

Kryptos
  • Kryptos

    Hacker

  • Members
  • Joined: 05 Nov 2003

#89

Posted 15 October 2004 - 11:56 PM

QUOTE (_Squiddy_)
CODE
# Analog Speedometer Config

# Speed multiplier
#   Use 2.24 for mph.
mul_mph_speed 2.24

#   Use 3.60 for kmh.
mul_kmh_speed 3.60

# Speed Display
#   0 = mph, 1 = kmh
dsp_speed 1

As I can't see the code for this right now I'm just assuming everything beyond this point. If you are defining dsp_speed in the configuration file there's no real point in defining both KMH and MPH as well, as this can be done directly within the code and merely causes clutter in the configuration file. Perhaps an extra definition could be added, for example, the configuration file could appear as:

CODE
# Speed Display
#   0 = mph, 1 = kmh, 2 = other
dsp_speed 1

# Speed Multiplier
# Use if dsp_speed is defined as 2.
# Default is normal game speed.
mul_speed 1.0

And merely define both kmh and mph in the actual code. Then you'd merely have to put:

CODE
float fSpeedoMultiplier = 3.60f; // Default multiplier to 3.60 (kmh).

void ReadConfig()
{
// ...
if (strcmpi(cmd, "dsp_speed") == 0) // Compare for dsp_speed...
{
if (tok == 0) fSpeedoMultiplier = 2.24f; // Set fSpeedoMultiplier to mph.
else if (tok == 1) fSpeedoMultiplier = 3.60f; // Set fSpeedoMultiplier to kmh.
else if (tok == 2)
{
while (strcmpi(cmd, "mul_speed") != 0) line++; // Sorry for crappy code, I'm extremely tired.
fSpeedoMultiplier = (float) atof(tok); // Set fSpeedoMultiplier to other.
}
}
// ...
}

I realize this code is pretty crappy, I'm under heavy sleep deprevation so frankly it's taken me about five minutes just to write that damn code.

Squiddy
  • Squiddy

    Back!

  • The Connection
  • Joined: 06 Oct 2004

#90

Posted 16 October 2004 - 12:05 AM

That looks much better. smile.gif
You're right, theres no need in defining those two multipliers for mph and kmh in the configuration file. My code will look better now, i think.

Thanks for this Kryptos. smile.gif




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users