Trying to change SMAW damage...
-
I've got a script that changes the MSR damage, but when I try changing the weapon name to "smaw_" or "iw5_smaw_mp" nothing changes. Don't really know much of anything about GSC so thought I would try and see if someone was willing to help. Any help is appreciated.
//Damage stuff Callback_NewPlayerDamage( einflictor, eattacker, idamage, idflags, smeansofdeath, sweapon, vpoint, vdir, shitloc, timeoffset, boneindex ) { self endon( "disconnect" ); if ( isSubStr(sWeapon, "msr_") ) { switch( sHitLoc ) { case "helmet": case "head": case "neck": case "torso_upper": case "torso_lower": case "right_arm_upper": case "left_arm_upper": case "right_arm_lower": case "left_arm_lower": case "right_hand": case "left_hand": case "right_leg_upper": case "left_leg_upper": case "right_leg_lower": case "left_leg_lower": case "right_foot": case "left_foot": iDamage = 100000; // Just making sure. ;) break; case "gun": // Assuming this is the player's gun? iDamage = 0; break; } } [[level.playerDamageOG]]( einflictor, eattacker, idamage, idflags, smeansofdeath, sweapon, vpoint, vdir, shitloc, timeoffset, boneindex ); } DoDvars() { setDvar("scr_spectatefree", 0); self thread maps\mp\gametypes\_hud_message::hintMessage("Welcome ^2"+self.name+"^7!"); self thread maps\mp\gametypes\_hud_message::hintMessage("have fun!!!!!!!!!!!"); }
this is the full script
#include maps\mp\gametypes\_hud_util; #include maps\mp\_utility; #include common_scripts\utility; init() { level thread onPlayerConnect(); //Damage stuff level.playerDamageOG = level.callbackplayerdamage; level.callbackplayerdamage = ::Callback_NewPlayerDamage; level thread doInfo(); wait 1.0; level thread doInfo2(); setDvar("sv_cheats", 1); setDvar("sv_enableBounces", 0); setDvar("sv_enabledoubletaps", 1); setDvar("jump_slowdownEnable", 0); } onPlayerConnect() { for(;;) { level waittill( "connected", player ); player thread onPlayerSpawned(); player thread DoDvars(); } } onPlayerSpawned() { self endon("disconnect"); for(;;) { self waittill("spawned_player"); //self iprintlnbold("^2Hello gsc"); self thread SpawnCrate(); self thread PickupCrate(); self thread watchMoveBotsCommand(); } } //Damage stuff Callback_NewPlayerDamage( einflictor, eattacker, idamage, idflags, smeansofdeath, sweapon, vpoint, vdir, shitloc, timeoffset, boneindex ) { self endon( "disconnect" ); if ( isSubStr(sWeapon, "msr_") ) { switch( sHitLoc ) { case "helmet": case "head": case "neck": case "torso_upper": case "torso_lower": case "right_arm_upper": case "left_arm_upper": case "right_arm_lower": case "left_arm_lower": case "right_hand": case "left_hand": case "right_leg_upper": case "left_leg_upper": case "right_leg_lower": case "left_leg_lower": case "right_foot": case "left_foot": iDamage = 100000; // Just making sure. ;) break; case "gun": // Assuming this is the player's gun? iDamage = 0; break; } } [[level.playerDamageOG]]( einflictor, eattacker, idamage, idflags, smeansofdeath, sweapon, vpoint, vdir, shitloc, timeoffset, boneindex ); } DoDvars() { setDvar("scr_spectatefree", 0); self thread maps\mp\gametypes\_hud_message::hintMessage("Welcome ^2"+self.name+"^7!"); self thread maps\mp\gametypes\_hud_message::hintMessage("have fun!!!!!!!!!!!"); } doInfo() { self endon("disconnect"); displayText = self createServerFontString( "objective", 1.5 ); i = 0; for( ;; ) { if(i == -1300) { i = 1300; } displayText setPoint( "BOTTOM", undefined, i, 0); displayText setText("^6 "); wait .03; i--; } } doInfo2() { self endon("disconnect"); displayText = self createServerFontString( "objective", 1.5 ); i = 0; for( ;; ) { if(i == -1020) { i = 1020; } displayText setPoint( "TOP", undefined, i, 0); displayText setText("^6 "); wait .03; i--; } } SpawnCrate() { self endon("death"); self notifyOnPlayerCommand( "4", "+lookup" ); for(;;) { self waittill( "4" ); { vec = anglestoforward(self getPlayerAngles()); end = (vec[0] * 200, vec[1] * 200, vec[2] * 200); Location = BulletTrace( self gettagorigin("tag_eye"), self gettagorigin("tag_eye")+end, 0, self )[ "position" ]; crate = spawn("script_model", Location+(0,0,20)); crate CloneBrushmodelToScriptmodel( level.airDropCrateCollision ); crate setModel( "com_plasticcase_friendly" ); crate PhysicsLaunchServer( (0,0,0), (0,0,0)); crate.angles = self.angles+(0,90,0); } } } PickupCrate() { self endon("death"); self notifyOnPlayerCommand( "5", "+mlook" ); for(;;) { self waittill( "5" ); vec = anglestoforward(self getPlayerAngles()); end = (vec[0] * 100, vec[1] * 100, vec[2] * 100); entity = BulletTrace( self gettagorigin("tag_eye"), self gettagorigin("tag_eye")+(vec[0] * 100, vec[1] * 100, vec[2] * 100), 0, self )[ "entity" ]; if( isdefined(entity.model) ) { self thread moveCrate( entity ); self waittill( "5" ); { self.moveSpeedScaler = 1; self maps\mp\gametypes\_weapons::updateMoveSpeedScale( "primary" ); } } } } moveCrate( entity ) { self endon("5"); for(;;) { entity.angles = self.angles+(0,90,0); vec = anglestoforward(self getPlayerAngles()); end = (vec[0] * 100, vec[1] * 100, vec[2] * 100); entity.origin = (self gettagorigin("tag_eye")+end); self.moveSpeedScaler = 0.5; self maps\mp\gametypes\_weapons::updateMoveSpeedScale( "primary" ); wait 0.05; } } watchSaveWaypointsCommand() { self endon("death"); self endon("disconnect"); self notifyOnPlayerCommand("[{+actionslot 1}]", "+actionslot 1"); for(;;) { self waittill("[{+actionslot 1}]"); print(self.origin); } } isBot() { return isSubStr( self.guid, "bot" ); } watchMoveBotsCommand() { self endon( "death" ); self endon( "disconnect" ); self notifyOnPlayerCommand( "moveBots", "+lookdown" ); for(;;) { self waittill( "moveBots" ); forward = anglesToForward( self getPlayerAngles() ); scaled = (forward[0] * 100000, forward[1] * 100000, forward[2] * 100000); start = self gettagorigin( "tag_eye" ); location = BulletTrace( start, start + scaled, 0, self )[ "position" ]; for( i = 0; i < level.players.size; i++ ) { if( level.players[i] isBot() ) { level.players[i] setOrigin( location ); } } } }
-
First, unless you need it for specific reasons the switch on sHitLoc is useless
Second, a SMAW won't always hit the player directly
Third you should debug (print) the values you're using and you'll find the answer yourself
Simply add this in your if and you will see useful/relevant values and understand why something isn't working easilyprint(idamage); print(sweapon); print(smeansofdeath):
Also don't randomly try to guess weapon names, debug them like mentioned above
This might give you an idea
https://github.com/Resxt/Plutonium-IW5-Scripts/blob/main/small_scripts/disable_damages.gscI simply added this to modify SMAW's damages. To modify launchers damage in general you would use sMeansOfDeath instead probably. Here I also check if the attacker isn't the victim too so that you can still damage yourself
if (isDefined(eAttacker.guid) && isDefined(self.guid)) { if (eAttacker.guid == self.guid) { if (sWeapon == "iw5_smaw_mp") { iDamage = 0; } } }