Vice City: Multiplayer

Server Development => Scripting and Server Management => Topic started by: killvn on Feb 19, 2015, 11:18 AM

Title: Can i edit the damage of the gun ?
Post by: killvn on Feb 19, 2015, 11:18 AM
In My Script before in PAWN i have setdamage function so i lower damage of some gun like stubby
it's very easy such as "SetWeaponDamage(21,10); for lower damage of stubby"
I wonder Squirrel have the fuction like that too ?

Tnank you for reading :)
Title: Re: Can i edit the damage of the gun ?
Post by: rObInX on Feb 19, 2015, 11:39 AM
http://wiki.vc-mp.org/wiki/Scripting/Squirrel/Functions#Weapon_Functions

Try GetWeaponDataValue see what it returns.
Then use SetWeaponDataValue.

Did you try SetWeaponDamage ?
In 0.3, it works.
Title: Re: Can i edit the damage of the gun ?
Post by: killvn on Feb 19, 2015, 11:47 AM
can u give me the example ? It's not working in 0.4 ...
Setweapondamage not work .. and i don't know how to use SetWeaponDataValue function in Squirrel to modifi the damage of gun ... i try SetWeaponDataValue(21,21,20) but still not work
Title: Re: Can i edit the damage of the gun ?
Post by: Sebastian on Feb 19, 2015, 12:17 PM
I'm pretty sure Get/Set Weapon Data Value is about all settings of it. (just like in the weapon.dat file from data folder)

[spoiler]Legend of weapon.dat, by R*

#
# Weapons data
#   A: Weapon name
#   B: Fire type
#   C: Range
#   D: Firing Rate
#   E: Reload
#   F: Amount of Ammunition
#   G: Damage
#   H: Speed
#   I: Radius
#   J: Life span
#   K: Spread
#   L,M,N: Fire offset vector
#   P: animation to play
#   Q: animation to play
#   R: animation loop start
#   S: animation loop end
#   T: point in animation where weapon is fired
#   U: animation2 loop start
#   V: animation2 loop end
#   W: point in animation2 where weapon is fired
#   X: point in anim where we can breakout of anim/attack and run away
#   Y: model id
#   Z: model2 id
#   a: Flags -> Stored in HEX... so (from right to left)
#      1st digit   1:USE_GRAVITY     2:SLOWS_DOWN     4:DISSIPATES     8:RAND_SPEED 
#      2nd digit   1:EXPANDS        2:EXPLODES     4:CANAIM      8:CANAIM_WITHARM
#      3rd digit   1:1ST_PERSON     2:HEAVY        4:THROW         8:RELOAD_LOOP2START
#      4th digit   1:USE_2ND      2:GROUND_2ND   4:FINISH_3RD   8:RELOAD
#      5th digit   1:FIGHTMODE      2:CROUCHFIRE   4:COP3_RD      8:GROUND_3RD
#      6th digit   1:PARTIALATTACK 2:ANIMDETONATE
#
#   b: Weapon Slot (Group to which this weapon belongs to, different from Fire type)
#
###### NOT USED IN THIS VERSION ##############
#   a:   1st person version of anim (using orig HGUN & PUMP cause they work better at mo')
#   b:   1st person vers of 2nd anim
#
#   FPS anims loaded (ie available):   FPS_PUNCH, FPS_BAT, FPS_UZI, FPS_PUMP, FPS_AK, FPS_M16, FPS_ROCKET
##############################################
[/spoiler]

EDIT: I also tested the GetWeaponDataValue function, and it doesn't give us much info: when I try to get the data 0 of weapon ID 26, it returns "0", and when I try to get the data 1+ it returns "1".
A developer should explain us how it works.
Title: Re: Can i edit the damage of the gun ?
Post by: killvn on Feb 19, 2015, 01:32 PM
yes ... because some gun like stubby shotgun is massive damage also about rocket laucher gun ... so i need to decrease a little amount of their damage ...

waiting for developer ...
Title: Re: Can i edit the damage of the gun ?
Post by: . on Feb 19, 2015, 01:44 PM
Quote from: killvn on Feb 19, 2015, 01:32 PMwaiting for developer ...

For what? Developers have their own things to worry and coding for the lazy is not among them. You've received more than enough information to take matters in your own hands and at least try something on your own.
Title: Re: Can i edit the damage of the gun ?
Post by: killvn on Feb 19, 2015, 02:16 PM
i don't understand how the function SetWeaponDataValue working ... i try it by my own hand but not find out yet ... if you know the fuction working ... show me ... i will use that to code by my self ... i think you was reading too fast so u misunderstand something ...
Title: Re: Can i edit the damage of the gun ?
Post by: . on Feb 19, 2015, 02:47 PM
bool SetWeaponDataValue( int weaponID, int fieldID, float value );
float GetWeaponDataValue( int weaponID, int fieldID );
bool ResetWeaponDataValue( int weaponID, int fieldID );
bool IsWeaponDataModified( int weaponID, int fieldID );
bool ResetWeaponData( int weaponID );
bool ResetAllWeaponData();
Title: Re: Can i edit the damage of the gun ?
Post by: killvn on Feb 19, 2015, 03:14 PM
bool SetWeaponDataValue( int weaponID, int fieldID, float value ); ... nt weaponID i think it's the weapon ID ... like stubbyshotgun with ID 21 ... float value may be the damage of the gun can make ... but what is the fieldID ?

I Try this  :
function onScriptLoad()
{
SetWeaponDataValue(21,21,1);
}
Still not working yet ? ... can u help me ... :(
Title: Re: Can i edit the damage of the gun ?
Post by: . on Feb 19, 2015, 03:34 PM
Quote from: killvn on Feb 19, 2015, 03:14 PMbut what is the fieldID ?

You'll find that in sseebbyy's answer.
Title: Re: Can i edit the damage of the gun ?
Post by: killvn on Feb 19, 2015, 03:58 PM
i read this but didn't understand ...
SetWeaponDataValue(21,21,1); is there the error in my scripts ?
Title: Re: Can i edit the damage of the gun ?
Post by: . on Feb 19, 2015, 05:20 PM
Well, I've been looking into what data can we actually edit. So I've began by using a small loop to test the range of the flagId:
function onServerStart()
{
for (local i = 0; i < 32; i++) {
print(i + " - " + GetWeaponDataValue(21, i));
}
}

Which resulted in:
[SCRIPT]  0 - 0
[SCRIPT]  1 - 1
[SCRIPT]  2 - 1
[SCRIPT]  3 - 1
[SCRIPT]  4 - 1
[SCRIPT]  5 - 1
[SCRIPT]  6 - 1
[SCRIPT]  7 - 1
[SCRIPT]  8 - 1
[SCRIPT]  9 - 1
[SCRIPT]  10 - 1
[SCRIPT]  11 - 1
[SCRIPT]  12 - 1
[SCRIPT]  13 - 1
[SCRIPT]  14 - 1
[SCRIPT]  15 - 1
[SCRIPT]  16 - 1
[SCRIPT]  17 - 1
[SCRIPT]  18 - 1
[SCRIPT]  19 - 1
[SCRIPT]  20 - 1
[SCRIPT]  21 - 1
[SCRIPT]  22 - 1
[SCRIPT]  23 - 1
[SCRIPT]  24 - 1
[SCRIPT]  25 - 1
[SCRIPT]  26 - 0
[SCRIPT]  27 - 0
[SCRIPT]  28 - 0
[SCRIPT]  29 - 0
[SCRIPT]  30 - 0
[SCRIPT]  31 - 0

So from there on I've noticed the ID's range from 1-25 (that is if ID 0 is ignored). So now that I know that I started looking. First try was the flags (http://spaceeinstein.altervista.org/weap_vc.php) from data\weapons.dat also mentioned by sseebbyy:
# a: Flags -> Stored in HEX... so (from right to left)
# 1st digit 1:USE_GRAVITY  2:SLOWS_DOWN  4:DISSIPATES  8:RAND_SPEED 
# 2nd digit 1:EXPANDS  2:EXPLODES  4:CANAIM 8:CANAIM_WITHARM
# 3rd digit 1:1ST_PERSON  2:HEAVY  4:THROW 8:RELOAD_LOOP2START
# 4th digit 1:USE_2ND 2:GROUND_2ND 4:FINISH_3RD 8:RELOAD
# 5th digit 1:FIGHTMODE 2:CROUCHFIRE 4:COP3_RD 8:GROUND_3RD
# 6th digit 1:PARTIALATTACK 2:ANIMDETONATE

But I've noticed they're 22 and they can't all be ON for a certain weapon. The reason I though they're the flags was that the values range from 0-1. And the flags are actually in binary from. In that they toggle certain weapon features. But then again, why take them as a double/float values?

So my second guess is that they work in the same way floating point colors work. Which is like the color intensity. 0.0 means no color at all. 0.5 means half that color intensity, 1.0 means full intensity, 2.0 means double the intensity... you see the pattern here.

Deriving from that idea I though that the double/float value actually represents the intensity of the original value. 0.3 means a third of the original value, 2.5 means two and a half times stronger than the original value. But still, I'm also a bit confused here.

So yeah, any clarification to the weapon data and the flags would be welcomed.
Title: Re: Can i edit the damage of the gun ?
Post by: Sebastian on Feb 19, 2015, 06:33 PM
Just found this in Stormeus'' script for Public Beta:

//SetWeaponDataValue(33, 2, 1.0); // FieldRange
//SetWeaponDataValue(33, 3, 2500); // FieldFiringRate
//SetWeaponDataValue(33, 4, 450); // FieldReload
//SetWeaponDataValue(33, 5, 1); // FieldClipSize
SetWeaponDataValue(33, 6, 0.001); // FieldDamage
/*SetWeaponDataValue(33, 15, 15); // FieldAnimGroup
SetWeaponDataValue(33, 16, 12.0); // FieldAnimLoopStart
SetWeaponDataValue(33, 17, 34.0); // FieldAnimLoopEnd
SetWeaponDataValue(33, 18, 15.0); // FieldAnimFirePos
SetWeaponDataValue(33, 19, 9.0); // FieldAnimTwoLoopStart
SetWeaponDataValue(33, 20, 26.0); // FieldAnimTwoLoopEnd
SetWeaponDataValue(33, 21, 13.0); // FieldAnimTwoFirePos
SetWeaponDataValue(33, 22, 30.0); // FieldAnimBreakoutPos
SetWeaponDataValue(33, 23, 277); // FieldModelId
SetWeaponDataValue(33, 24, -1); // FieldModelTwoId*/
//SetWeaponDataValue(33, 25, 0x020040); // FieldFlags
//SetWeaponDataValue(33, 25, 0x000200); // FieldFlags
//SetWeaponDataValue(33, 26, 7); // FieldWeaponSlot

EDIT: Just tested a few values, and it works ! :)
Title: Re: Can i edit the damage of the gun ?
Post by: . on Feb 19, 2015, 06:41 PM
Quote from: sseebbyy on Feb 19, 2015, 06:33 PMJust found this in Stormeu's script for Public Beta:
...

Finally :D
Title: Re: Can i edit the damage of the gun ?
Post by: Thijn on Feb 19, 2015, 08:43 PM
See, you'll all figure it out by yourself eventually :)
Title: Re: Can i edit the damage of the gun ?
Post by: Stormeus on Feb 19, 2015, 09:24 PM
For reference, these are all the field IDs. The values listed in the script may have been broken since they were actually guessed, and no reference was available.

FieldFireType = 1
FieldRange = 2
FieldFiringRate = 3
FieldReload = 4
FieldClipSize = 5
FieldDamage = 6
FieldSpeed = 7
FieldRadius = 8
FieldLifespan = 9
FieldSpread = 10
FieldFireOffsetX = 11
FieldFireOffsetY = 12
FieldFireOffsetZ = 13
FieldAnimGroup = 14
FieldAnimLoopStart = 15
FieldAnimLoopEnd = 16
FieldAnimFirePos = 17
FieldAnimTwoLoopStart = 18
FieldAnimTwoLoopEnd = 19
FieldAnimTwoFirePos = 20
FieldAnimBreakoutPos = 21
FieldModelId = 22
FieldModelTwoId = 23
FieldFlags = 24
FieldWeaponSlot = 25
Title: Re: Can i edit the damage of the gun ?
Post by: killvn on Feb 20, 2015, 05:22 AM
well ... my scripts :
SetWeaponDataValue(21, 6, 0.001); // For change damage of Stubby
I try to use alot of change number like that
SetWeaponDataValue(21, 6, 1); // For change damage of Stubby
SetWeaponDataValue(21, 6, 2); // For change damage of Stubby
SetWeaponDataValue(21, 6, 0.5); // For change damage of Stubby
SetWeaponDataValue(21, 6, 0.00005); // For change damage of Stubby
But it's can only make the damage of Stubby Shotgun (ID 21) Strongger ... can't be weaker ...
when i use :
SetWeaponDataValue(21, 6, -1);  .... it's make no damage or negative damage ... is there anything wrong ? I mean i only want to make damage of stubby shotgun lower ... for example original damage of stubby is 120 per shot and i just want to lower down to 50 damage ... but still not work ... can u give me some idea ? Thanks
Title: Re: Can i edit the damage of the gun ?
Post by: Gudio on Feb 20, 2015, 10:29 AM
Fixed GetWeaponDataValue in squirrel module. Compiling atm.
* Gudio slaps Stormeus for many copy&paste :D
Title: Re: Can i edit the damage of the gun ?
Post by: Sebastian on Feb 20, 2015, 12:35 PM
I just added the needed parameters and examples for all weapon functions, in wiki.
> Weapon Functions < (http://wiki.vc-mp.org/wiki/Scripting/Squirrel/Functions#Weapon_Functions)

The last 3 functions doesn't exist in 0.4, but in 0.3. (for creating ammu-nation shops)
Stormeus should remove them. :)
Title: Re: Can i edit the damage of the gun ?
Post by: Stormeus on Feb 20, 2015, 08:40 PM
Quote from: Gudio on Feb 20, 2015, 10:29 AMFixed GetWeaponDataValue in squirrel module. Compiling atm.
* Gudio slaps Stormeus for many copy&paste :D

oi

Quote from: sseebbyy on Feb 20, 2015, 12:35 PMI just added the needed parameters and examples for all weapon functions, in wiki.
> Weapon Functions < (http://wiki.vc-mp.org/wiki/Scripting/Squirrel/Functions#Weapon_Functions)

The last 3 functions doesn't exist in 0.4, but in 0.3. (for creating ammu-nation shops)
Stormeus should remove them. :)

They are removed; in the current Squirrel module they just yell at you telling you it's not a 0.4 function (in order to make 0.3 scripts more compatible), and in the upcoming Squirrel rewrite it's been removed entirely.
Title: Re: Can i edit the damage of the gun ?
Post by: Gulk on Mar 29, 2015, 07:17 AM
Hey, I added:

SetWeaponDataValue( 21 , 24, 200 ) - This should make jumping with the Stubby Shotgun impossible,  instead it acts weird.
Did I somehow get the code wrong? Values were Copy&pasted from weapon.mta (mta0.5's) weapon data.
Title: Re: Can i edit the damage of the gun ?
Post by: Sebastian on Mar 29, 2015, 11:08 AM
Quote from: Gulk on Mar 29, 2015, 07:17 AMHey, I added:

SetWeaponDataValue( 21 , 24, 200 ) - This should make jumping with the Stubby Shotgun impossible,  instead it acts weird.
Did I somehow get the code wrong? Values were Copy&pasted from weapon.mta (mta0.5's) weapon data.

Just disable/enable the jump switch. That should disable/enable the ability to jump with shotguns as far as I remember.

You can set the jump switch in server.conf, there is such a line:
<JumpSwitch>true</JumpSwitch>
or you can do it by script, using SetJumpSwitch( bool ) (http://wiki.vc-mp.org/wiki/Scripting/Squirrel/Functions/SetJumpSwitch)
Title: Re: Can i edit the damage of the gun ?
Post by: Stormeus on Mar 29, 2015, 08:07 PM
Quote from: Gulk on Mar 29, 2015, 07:17 AMHey, I added:

SetWeaponDataValue( 21 , 24, 200 ) - This should make jumping with the Stubby Shotgun impossible,  instead it acts weird.
Did I somehow get the code wrong? Values were Copy&pasted from weapon.mta (mta0.5's) weapon data.

It should be 0x200 as the weapon flags are stored in hexadecimal and not decimal. Other than that, you should be correct; judging from the flags you're marking the stubby as "Heavy" to make it harder to break out of the animation.

It looks like you might've cleared other flags on the stubby so if that doesn't work, try 0x20240.
Title: Re: Can i edit the damage of the gun ?
Post by: Stormeus on Apr 12, 2015, 06:49 PM
Bump @Gulk since I wasn't sure if you saw this.

Quote from: stormeus on Mar 29, 2015, 08:07 PM
Quote from: Gulk on Mar 29, 2015, 07:17 AMHey, I added:

SetWeaponDataValue( 21 , 24, 200 ) - This should make jumping with the Stubby Shotgun impossible,  instead it acts weird.
Did I somehow get the code wrong? Values were Copy&pasted from weapon.mta (mta0.5's) weapon data.

It should be 0x200 as the weapon flags are stored in hexadecimal and not decimal. Other than that, you should be correct; judging from the flags you're marking the stubby as "Heavy" to make it harder to break out of the animation.

It looks like you might've cleared other flags on the stubby so if that doesn't work, try 0x20240.
Title: Re: Can i edit the damage of the gun ?
Post by: Gulk on Apr 13, 2015, 03:02 PM
@sseebbyy JumpSwitch didnt change a thing. I'm sure JumpSwitch & FastSwitch are broken because I dont notice them changing anything. @stormeus What weapon stats do they change under the hood?

@stormeus I tried [ SetWeaponDataValue( 21 , 24, 0x200 ) //Stubby no crouch ] and as it says, it only disables crouching while shooting, forces the player to stand. Maybe theres other changes needed to acheive no jumping. I'm gonna finish all the weapon stat modifications today so I'll see how it goes and report back here. 0x20240 acts very strange
Title: Re: Can i edit the damage of the gun ?
Post by: Stormeus on Apr 13, 2015, 06:46 PM
Quote from: Gulk on Apr 13, 2015, 03:02 PM@stormeus What weapon stats do they change under the hood?

@Gulk It's basically the same as editing weapon.dat. Column B is field ID 1, C is field ID 2, and so on. Column Q is omitted since it's a duplicate of P.

If you want to prevent players from jumping while shooting (e.g. breaking out of the shooting anim) I believe that's disabling fast switch.
Title: Re: Can i edit the damage of the gun ?
Post by: Kratos_ on Apr 14, 2015, 03:52 AM
Quote from: Gulk on Apr 13, 2015, 03:02 PM@stormeus I tried [ SetWeaponDataValue( 21 , 24, 0x200 ) //Stubby no crouch ] and as it says , it only disables crouching while shooting , forces the player to stand .
It's Minigun's (http://www.gtamodding.com/wiki/Weapon.dat_%28VC%29) flag value which obviously will restrict crouch together with jump .

Quote0x20240 acts very strange

Try 0x020240 .

I'm not sure that jump switch will restrict the weapon shoot . Cuz , we have an entity called player.ShootInAir which will facilitate shooting while jumping ( ofc in air ) by toggling into . Jump Switch will player jump & Fast Switch will reduce the time lag between the weapon switchings . But , I'm not entirely sure about it .
If you're going to set Fast Switch as false then it will block that specific action as Stormeus mentioned above . But , it will get applied to all the weapons . I think only task left before us is to mark stubby as heavy in addition to other existing flags .
Title: Re: Can i edit the damage of the gun ?
Post by: Gulk on Apr 14, 2015, 08:15 AM
Okay, this is an exact copy of MTA 0.5's weapon.mta
Still cant get the anti-jump for stub, grenades & molotovs enabled.

Jumpswitch and Fastswitch disabled/enable makes no difference to wheter i can jump or not

//Weapon Settings
 #All Melee weapons left unmodified, because they now work in VCMP 0.4
 
 #Grenade
 SetWeaponDataValue( 12, 24, 0x200) //HEAVY flags
 
 #Molotov
 SetWeaponDataValue( 15, 24, 0x200) //HEAVY flags
 
 #Colt45
 SetWeaponDataValue( 17, 24, 0x480C0) //Unknown flags
 
 #Python
 SetWeaponDataValue( 18, 24, 0x0040) //Unknown flags
 
 #Shotgun
 SetWeaponDataValue( 19, 24, 0x200) //Unknown flags
 
 #StubbyShotgun
 SetWeaponDataValue( 21, 24, 0x200 ) //No crouch
 SetWeaponDataValue( 21, 21, 11 ) //point in anim where we can breakout of anim/attack and run away
 SetWeaponDataValue( 21, 6, 60 ) //Damage
 
 #Tec9
 SetWeaponDataValue( 22, 24, 0x80C0) //Unknown flags
 
 #Uzi
 SetWeaponDataValue( 23, 24, 0x8840) //Unknown flags
 
 #SilencedIngram
 SetWeaponDataValue( 24, 24, 0x80C0) //Unknown flags
 
 #Mp5
 SetWeaponDataValue( 25, 24, 0x8840) //Unknown flags
 
 #M4
 SetWeaponDataValue( 26, 24, 0x8050) //Unknown flags
 
 #Ruger
 SetWeaponDataValue( 27, 24, 0x8040) //Unknown flags
 
 #M60
 SetWeaponDataValue( 32, 6, 45 ) //Damage

EDIT: @stormeus, since lowering the damage on stubby and m60. now it is higher instead. ;s (blowing up cars with 1 bullet)
Title: Re: Can i edit the damage of the gun ?
Post by: Gulk on Apr 19, 2015, 04:10 PM
Any idea on how to modify the damage correctly @stormeus ?
Title: Re: Can i edit the damage of the gun ?
Post by: Gulk on Apr 30, 2015, 08:48 AM
info on a bugfix for the damage settings? or possible workaround?