• GMod Plus: swep_frag base broken, Operator_HandleAnimEvent?
    3 replies, posted
What in the world? So my swep_frag base is broken to all hell, which was dependent on a method I added, which it seems like Garry will be added (hopefully) in the beta proper. The method, Operator_HandleAnimEvent is what I've been using to trigger when to throw the grenade an so on, but because the method isn't actually in the game yet, I hacked it together using strings, instead of globals for the events, combined with checking said animations in the Think function of the base. [lua]//if ( !CLIENT ) then //----------------------------------------------------------------------------- // Purpose: // Input : *pEvent - // *pOperator - //----------------------------------------------------------------------------- function SWEP:Operator_HandleAnimEvent( pEvent, pOperator ) if ( self.fThrewGrenade ) then return; end local pOwner = self.Owner; self.fThrewGrenade = false; if( pEvent ) then if pEvent == "EVENT_WEAPON_SEQUENCE_FINISHED" then self.m_fDrawbackFinished = true; return; elseif pEvent == "EVENT_WEAPON_THROW" then self:ThrowGrenade( pOwner ); self:DecrementAmmo( pOwner ); self.fThrewGrenade = true; return; elseif pEvent == "EVENT_WEAPON_THROW2" then self:RollGrenade( pOwner ); self:DecrementAmmo( pOwner ); self.fThrewGrenade = true; return; elseif pEvent == "EVENT_WEAPON_THROW3" then self:LobGrenade( pOwner ); self:DecrementAmmo( pOwner ); self.fThrewGrenade = true; return; else return; end end local RETHROW_DELAY = self.Primary.Delay if( self.fThrewGrenade ) then self.Weapon:SetNextPrimaryFire( CurTime() + RETHROW_DELAY ); self.Weapon:SetNextSecondaryFire( CurTime() + RETHROW_DELAY ); self.m_flNextPrimaryAttack = CurTime() + RETHROW_DELAY; self.m_flNextSecondaryAttack = CurTime() + RETHROW_DELAY; self.m_flTimeWeaponIdle = FLT_MAX; //NOTE: This is set once the animation has finished up! end end //end[/lua] The method is more or less ripped directly from the SDK. In all honesty, I've been a giant douchebag with the project, and haven't released it publicly yet. This subproject in GMod+, called, "SWEP Bases" was designed to create SWEPs derived from the original HL2 weapons, without an additional few hundreds of lines of code. Within each base, (swep_ar2, swep_smg1, swep_rpg), are helper functions to make the process minimal. Basically, now I'm getting some funky errors which I cannot for the life of me understand why they are returning userdata values. Error: weapons\swep_frag\shared.lua:377: attempt to perform arithmetic on a userdata value [lua] // check a throw from vecSrc. If not valid, move the position back along the line to vecEye function SWEP:CheckThrowPosition( pPlayer, vecEye, vecSrc ) local tr; tr = {} tr.startpos = vecEye tr.endpos = vecSrc // line 33: // GRENADE_RADIUS = 4.0 // inches // ... // line 377: tr.mins = -Vector(GRENADE_RADIUS+2,GRENADE_RADIUS+2,GRENADE_RADIUS+2) tr.maxs = Vector(GRENADE_RADIUS+2,GRENADE_RADIUS+2,GRENADE_RADIUS+2) tr.mask = MASK_PLAYERSOLID tr.filter = pPlayer tr.collision = pPlayer:GetCollisionGroup() tr = util.TraceHull( tr ); if ( tr.Hit ) then vecSrc = tr.endpos; end end[/lua] userdata value? What the fuck?
Gmod Plus?...
Try replacing the "-" with "-1 * ".
[url]http://code.google.com/p/gmodplus/[/url], Garry's Mod Plus Designed to be a collective mass of new features, for the end user as well as developers to spice up the game. Said new features (a few examples): dynamic weather, SWEP bases, new maps, new weapons, Counter-Strike: Source gamemode, Campaign gamemode... Let me try that "-1 *", hold on. My only noggin-scratcher is that it worked flawlessly before. /:l Edit: Good lord! It worked? Now I'm having problems with a supposed nil value which is created upon the sent_grenade_frag initializing. Thus, something is broken here, badly. One moment. Edit: Have I obviously (to anyone other than myself) broken the Vector global ?/:/ Or is this suddenly now just processed differently in the game?
Sorry, you need to Log In to post a reply to this thread.