Home   Help Search Login Register  

Author Topic: Scripts altering config?  (Read 1761 times)

0 Members and 1 Guest are viewing this topic.

Offline icarus_uk

  • Members
  • *
  • LiarLiarPants Inflame True
    • [furryclan]
Scripts altering config?
« on: 31 Dec 2002, 01:01:53 »
Can a script ran during a game alter the propeties of a weapon (via the config or simulated elsewhere)?

I want to be able to run a script from the action menu and have it increase the accuracy of the weapon?

This would all be incorporated into an addon, thus only one the addon weapons accuracy would be altered.

I realise its not possible to physically change the values of the config, but can it be done another way?  Either written into the config, or simulated during the game?

Liquid_Silence

  • Guest
Re:Scripts altering config?
« Reply #1 on: 31 Dec 2002, 01:58:49 »
You could use multiple weapons:

One: your base weapon
Two: an inherited copy of your base, but with the dispersion values changed...

e.g.: an accurate M16's config.cpp

**EDIT: Code removed, as the working version is below...

All you would need to do with the script then would be to switch between the two weapons...

Hope this helps...
« Last Edit: 31 Dec 2002, 03:40:48 by Liquid_Silence »

Offline icarus_uk

  • Members
  • *
  • LiarLiarPants Inflame True
    • [furryclan]
Re:Scripts altering config?
« Reply #2 on: 31 Dec 2002, 02:29:26 »
I like your moxy kid, ya got guts.  ;D

Problemo solved then it looks like.  Now the question I guess would be to figure out how to load the secondary weapon with the originals current ammo!  Now thats a tricky one.

Liquid_Silence

  • Guest
Re:Scripts altering config?
« Reply #3 on: 31 Dec 2002, 03:36:21 »
I think that they will use the same ammo...(cause of the inheritance, the other stuff from the M16 should stay the same: I'll test it out...

Ok: here's the config file and the .pbo file : you can add the accurate version with addWeapon M16_accurate

Only problem I've found is that you switch to an alternative when you remove then add the weapon (e.g. handgrenade)...not a big problem, as you can use the following to fix it (I couldn't even tell when the weapons switched :D )

Player selectWeapon "M16_accurate"

or if you're switching to the M16:

Player selectWeapon "M16"

The exact contents of the config.cpp is below, and the .pbo is attached

Code: [Select]
class CfgPatches
{
class M16_accurate
{
units[] = {};
weapons[] = {M16_accurate};
requiredVersion = 1.00;
};
};


class CfgModels
{
class default {};
class Weapon: default {};
class M16_accurate: Weapon {};
};

class CfgWeapons
{
class default {};
class MGun:default {};
class Riffle:MGun {};
class M16: Riffle{};
class M16_accurate:M16{
displayName="M16 (accurate)";
picture="M16"
class Single
{
dispersion=0.000100;//original's is 0.000200, an M21's is 0.000030
};
class Burst
{
dispersion=0.000300;//original's is 0.000400
};
};
};

class CfgNonAIVehicles
{
class ProxyWeapon {};
class ProxyM16_accurate: ProxyWeapon {};
};

Liquid_Silence

  • Guest
Re:Scripts altering config?
« Reply #4 on: 31 Dec 2002, 03:38:32 »
And the very basic example mission I used:

Offline icarus_uk

  • Members
  • *
  • LiarLiarPants Inflame True
    • [furryclan]
Re:Scripts altering config?
« Reply #5 on: 31 Dec 2002, 16:19:33 »
By ammo problems I mean;

If I shoot off all but 3 rounds from the mag, then swap the weapons, wont the accurate weapon effectively give me 30 rounds?

Its a pretty exploitable bug there.

Liquid_Silence

  • Guest
Re:Scripts altering config?
« Reply #6 on: 01 Jan 2003, 04:35:03 »
d/l the test mission: you will see :)

they use the same ammo: exactly the same ammo, and since all you do is removeweapon, addweapon, switchweapon (otherwise you'll be left holding a handgrenade :) ) you don't do anything to the mags, which means that there is nothing to exploit...

in the demo mission: look at your inventory, note the weapon's name...shoot off three rounds, then walk fowards, you will see text saying something like "weapons switched"...look at your ammo left...should be 27...look at your inventory...the weapon's name has changed :)

Liquid_Silence

  • Guest
Re:Scripts altering config?
« Reply #7 on: 01 Jan 2003, 04:38:26 »
oh, yeah: the e.g. mission isn't converted from the mission editor format, so you'll need to load it into your users\username\missions folder and try it from the mission editor...

Offline icarus_uk

  • Members
  • *
  • LiarLiarPants Inflame True
    • [furryclan]
Re:Scripts altering config?
« Reply #8 on: 01 Jan 2003, 04:49:02 »
OOO sexy.