Can i edit the damage of the gun ?

Started by killvn, Feb 19, 2015, 11:18 AM

Previous topic - Next topic

killvn

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 :)

rObInX

#1
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.

killvn

#2
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

Sebastian

#3
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.

killvn

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 ...

.

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.
.

killvn

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 ...

.

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();
.

killvn

#8
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 ... :(

.

Quote from: killvn on Feb 19, 2015, 03:14 PMbut what is the fieldID ?

You'll find that in sseebbyy's answer.
.

killvn

i read this but didn't understand ...
SetWeaponDataValue(21,21,1); is there the error in my scripts ?

.

#11
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 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.
.

Sebastian

#12
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 ! :)

.

.

Thijn

See, you'll all figure it out by yourself eventually :)