//----------------------------------------------------------------------------- // Purpose: Find nearby objects and buff them. //----------------------------------------------------------------------------- void CObjectBuffStation::BuffNearbyObjects( CBaseObject *pObjectToTarget, bool bPlacing ) { // ROBIN: Disabled object buffing for now return; // Check for a team. if ( !GetTFTeam() ) return; // Am I ready to power anything? if ( IsBuilding() || ( !bPlacing && IsPlacing() ) ) return; // Am I already full? if ( m_nObjectCount >= BUFF_STATION_MAX_OBJECTS ) return; // Do we have a specific target? if ( pObjectToTarget ) { if( !pObjectToTarget->CanBeHookedToBuffStation() || pObjectToTarget->GetBuffStation() ) return; if ( IsWithinBuffRange( pObjectToTarget ) ) { AttachObject( pObjectToTarget, bPlacing ); } } else { // Find nearby objects for ( int iObject = 0; iObject < GetTFTeam()->GetNumObjects(); iObject++ ) { CBaseObject *pObject = GetTFTeam()->GetObject( iObject ); assert(pObject); if ( pObject == this || !pObject->CanBeHookedToBuffStation() || pObject->GetBuffStation() ) continue; // Make sure it's within range if ( IsWithinBuffRange( pObject ) ) { AttachObject( pObject, bPlacing ); // Am I now full? if ( m_nObjectCount >= BUFF_STATION_MAX_OBJECTS ) break; } } } }
void CreateSmallFireballOnObject (CObject *objP, fix size_scale, int bSound) { fix size; CFixVector vPos, vRand; short nSegment; vPos = objP->info.position.vPos; vRand = CFixVector::Random(); vRand *= (objP->info.xSize / 2); vPos += vRand; size = FixMul (size_scale, I2X (1) / 2 + d_rand () * 4 / 2); nSegment = FindSegByPos (vPos, objP->info.nSegment, 1, 0); if (nSegment != -1) { CObject *explObjP = /*Object*/CreateExplosion (nSegment, vPos, size, VCLIP_SMALL_EXPLOSION); if (!explObjP) return; AttachObject (objP, explObjP); if (bSound || (d_rand () < 8192)) { fix vol = I2X (1) / 2; if (objP->info.nType == OBJ_ROBOT) vol *= 2; audio.CreateObjectSound (SOUND_EXPLODING_WALL, SOUNDCLASS_EXPLOSION, objP->Index (), 0, vol); } } }
CPlayerController::CPlayerController( CPhysicsObject *pObject ) { m_pObject = pObject; m_handler = NULL; m_maxDeltaPosition = ConvertDistanceToIVP( 24 ); m_dampFactor = 1.0f; AttachObject(); }
CShadowController::CShadowController(CPhysicsObject* pObject, bool allowTranslation, bool allowRotation) { m_pObject = pObject; m_shadow.dampFactor = 1.0f; m_shadow.teleportDistance = 0; m_allowPhysicsMovement = allowTranslation; m_allowPhysicsRotation = allowRotation; AttachObject(); }
void CShadowController::SetObject( IPhysicsObject *pObject ) { CPhysicsObject *obj = (CPhysicsObject *)pObject; if ( obj == m_pObject ) return; DetachObject(); m_pObject = obj; AttachObject(); }
void CPhysicsMotionController::InitFromTemplate( const vphysics_save_motioncontroller_t &controllerTemplate ) { m_priority = controllerTemplate.m_nPriority; int nObjectCount = controllerTemplate.m_objectList.Count(); for ( int i = 0; i < nObjectCount; ++i ) { AttachObject( controllerTemplate.m_objectList[i] ); } }
CPlayerController::CPlayerController(CPhysicsEnvironment *pEnv, CPhysicsObject *pObject) { m_pObject = pObject; m_pEnv = pEnv; m_handler = NULL; m_maxDeltaPosition = ConvertDistanceToBull(24); m_dampFactor = 1.0f; m_ticksSinceUpdate = 0; m_lastImpulse = btVector3(0, 0, 0); m_linVelocity = btVector3(0, 0, 0); AttachObject(); }
CShadowController::CShadowController(CPhysicsObject *pObject, bool allowTranslation, bool allowRotation) { m_pObject = pObject; m_shadow.dampFactor = 1.0f; m_shadow.teleportDistance = 0; m_shadow.targetPosition.setZero(); m_shadow.targetRotation = btQuaternion::getIdentity(); m_flags = 0; m_ticksSinceUpdate = 0; SetAllowsTranslation(allowTranslation); SetAllowsRotation(allowRotation); AttachObject(); }
// Called when the game wants to swap hulls (such as from standing to crouching) void CPlayerController::SetObject(IPhysicsObject *pObject) { if (pObject == m_pObject) return; // HACK: Freeze our current object (so it doesn't fall through the world and create nastiness when the AABB overflows) m_pObject->EnableMotion(false); DetachObject(); m_pObject = (CPhysicsObject *)pObject; AttachObject(); // Enable motion for our new object m_pObject->EnableMotion(true); }
void ToggleAttachment( GUI_BUTTON *btn, INT32 reason ) { if( reason & MSYS_CALLBACK_REASON_LBUTTON_UP ) { INT32 i; UINT16 usAttachment; OBJECTTYPE temp; for( i = 0; i < NUM_ATTACHMENT_BUTTONS; i++ ) { //Loop through and find the button that was just modified switch( i ) { case 0: usAttachment = SILENCER; break; case 1: usAttachment = SNIPERSCOPE; break; case 2: usAttachment = LASERSCOPE; break; case 3: usAttachment = BIPOD; break; case 4: usAttachment = DUCKBILL; break; case 5: usAttachment = UNDER_GLAUNCHER; break; } if( guiAttachmentButton[ i ] != -1 && btn == ButtonList[ guiAttachmentButton[ i ] ] ) { //Found it, now check the state of the button. if( !gfAttachment[ i ] ) { gfAttachment[ i ] = TRUE; btn->uiFlags |= BUTTON_CLICKED_ON; CreateItem( usAttachment, gpItem->bGunStatus, &temp ); AttachObject( NULL, gpItem, &temp ); } else { //Button is out, so remove the attachment INT8 slot; gfAttachment[ i ] = FALSE; btn->uiFlags &= ~BUTTON_CLICKED_ON; slot = FindAttachment( gpItem, usAttachment ); if( slot != -1 ) RemoveAttachment( gpItem, slot, &temp ); } } } ReEvaluateAttachmentStatii(); } }
virtual void ProcessEvent( EFlowEvent event, SActivationInfo *pActInfo ) { CFlowEntityNodeBase::ProcessEvent(event,pActInfo); switch (event) { case eFE_Activate: { if (IsPortActive(pActInfo, eIP_Attach)) { AttachObject(pActInfo); } if (IsPortActive(pActInfo, eIP_Detach)) { DetachObject(pActInfo); } if (IsPortActive(pActInfo, eIP_Hide)) { HideAttachment(pActInfo); } else if (IsPortActive(pActInfo, eIP_UnHide)) { UnHideAttachment(pActInfo); } if (IsPortActive(pActInfo, eIP_RotationOffset) || IsPortActive(pActInfo, eIP_TranslationOffset)) { UpdateOffset(pActInfo); } break; } case eFE_Initialize: if (gEnv->IsEditor() && m_entityId) { UnregisterEvent(m_event); RegisterEvent(m_event); m_pNewAttachment = NULL; } } }
void WorldModel::OnEveryObjectCreated( ) { // Save if we are currently set up to be activated... uint32 dwFlags; g_pCommonLT->GetObjectFlags( m_hObject, OFT_User, dwFlags ); m_bCanActivate = !!(dwFlags & USRFLG_CAN_ACTIVATE); // Check for any objects to attach if( !m_hstrAttachments ) return; const char *pAttachments = g_pLTServer->GetStringData( m_hstrAttachments ); if( !pAttachments ) return; ConParse parse( pAttachments ); while( g_pCommonLT->Parse( &parse ) == LT_OK ) { // We have an object we want to attach... find it if( parse.m_nArgs > 0 && parse.m_Args[0] ) { ObjArray<HOBJECT, MAX_OBJECT_ARRAY_SIZE> objArray; g_pLTServer->FindNamedObjects( parse.m_Args[0], objArray ); for( uint i = 0; i < objArray.NumObjects(); i++ ) { AttachObject( objArray.GetObject( i ) ); } } } // Once they are added free the string because we don't want to re-add the objects // everytime this objects gets loaded. Our attachment list will take care of everything. FREE_HSTRING( m_hstrAttachments ); }
void ToggleCeramicPlates( GUI_BUTTON *btn, INT32 reason ) { if( reason & MSYS_CALLBACK_REASON_LBUTTON_UP ) { OBJECTTYPE temp; gfCeramicPlates ^= TRUE; if( gfCeramicPlates ) { btn->uiFlags |= BUTTON_CLICKED_ON; CreateItem( CERAMIC_PLATES, gpItem->bStatus[0], &temp ); AttachObject( NULL, gpItem, &temp ); } else { INT8 slot; btn->uiFlags &= ~BUTTON_CLICKED_ON; slot = FindAttachment( gpItem, CERAMIC_PLATES ); if( slot != -1 ) RemoveAttachment( gpItem, slot, &temp ); } } }
void ToggleDetonator( GUI_BUTTON *btn, INT32 reason ) { if( reason & MSYS_CALLBACK_REASON_LBUTTON_UP ) { OBJECTTYPE temp; if( !gfDetonator ) { gfDetonator = TRUE; btn->uiFlags |= BUTTON_CLICKED_ON; CreateItem( DETONATOR, gpItem->bStatus[0], &temp ); AttachObject( NULL, gpItem, &temp ); } else { //Button is out, so remove the attachment INT8 slot; gfDetonator = FALSE; btn->uiFlags &= ~BUTTON_CLICKED_ON; slot = FindAttachment( gpItem, DETONATOR ); if( slot != -1 ) RemoveAttachment( gpItem, slot, &temp ); } } }
void CWeaponGravityGun::EffectUpdate( void ) { Vector start, angles, forward, right; trace_t tr; CBasePlayer *pOwner = ToBasePlayer( GetOwner() ); if ( !pOwner ) return; m_viewModelIndex = pOwner->entindex(); // Make sure I've got a view model CBaseViewModel *vm = pOwner->GetViewModel(); if ( vm ) { m_viewModelIndex = vm->entindex(); } pOwner->EyeVectors( &forward, &right, NULL ); start = pOwner->Weapon_ShootPosition(); Vector end = start + forward * 4096; UTIL_TraceLine( start, end, MASK_SHOT, pOwner, COLLISION_GROUP_NONE, &tr ); end = tr.endpos; float distance = tr.fraction * 4096; if ( tr.fraction != 1 ) { // too close to the player, drop the object if ( distance < 36 ) { DetachObject(); return; } } if ( m_hObject == NULL && tr.DidHitNonWorldEntity() ) { CBaseEntity *pEntity = tr.m_pEnt; // inform the object what was hit ClearMultiDamage(); pEntity->DispatchTraceAttack( CTakeDamageInfo( pOwner, pOwner, 0, DMG_PHYSGUN ), forward, &tr ); ApplyMultiDamage(); AttachObject( pEntity, start, tr.endpos, distance ); m_lastYaw = pOwner->EyeAngles().y; } // Add the incremental player yaw to the target transform matrix3x4_t curMatrix, incMatrix, nextMatrix; QAngle ang(0.0f, pOwner->EyeAngles().y - m_lastYaw, 0.0f); AngleMatrix( m_gravCallback.m_targetRotation, curMatrix ); AngleMatrix( ang, incMatrix ); ConcatTransforms( incMatrix, curMatrix, nextMatrix ); MatrixAngles( nextMatrix, m_gravCallback.m_targetRotation ); m_lastYaw = pOwner->EyeAngles().y; CBaseEntity *pObject = m_hObject; if ( pObject ) { if ( m_useDown ) { if ( pOwner->m_afButtonPressed & IN_USE ) { m_useDown = false; } } else { if ( pOwner->m_afButtonPressed & IN_USE ) { m_useDown = true; } } if ( m_useDown ) { pOwner->SetPhysicsFlag( PFLAG_DIROVERRIDE, true ); if ( pOwner->m_nButtons & IN_FORWARD ) { m_distance = UTIL_Approach( 1024, m_distance, gpGlobals->frametime * 100 ); } if ( pOwner->m_nButtons & IN_BACK ) { m_distance = UTIL_Approach( 40, m_distance, gpGlobals->frametime * 100 ); } } if ( pOwner->m_nButtons & IN_WEAPON1 ) { m_distance = UTIL_Approach( 1024, m_distance, m_distance * 0.1 ); } if ( pOwner->m_nButtons & IN_WEAPON2 ) { m_distance = UTIL_Approach( 40, m_distance, m_distance * 0.1 ); } // Send the object a physics damage message (0 damage). Some objects interpret this // as something else being in control of their physics temporarily. pObject->TakeDamage( CTakeDamageInfo( this, pOwner, 0, DMG_PHYSGUN ) ); Vector newPosition = start + forward * m_distance; // 24 is a little larger than 16 * sqrt(2) (extent of player bbox) // HACKHACK: We do this so we can "ignore" the player and the object we're manipulating // If we had a filter for tracelines, we could simply filter both ents and start from "start" Vector awayfromPlayer = start + forward * 24; UTIL_TraceLine( start, awayfromPlayer, MASK_SOLID, pOwner, COLLISION_GROUP_NONE, &tr ); if ( tr.fraction == 1 ) { UTIL_TraceLine( awayfromPlayer, newPosition, MASK_SOLID, pObject, COLLISION_GROUP_NONE, &tr ); Vector dir = tr.endpos - newPosition; float distance = VectorNormalize(dir); float maxDist = m_gravCallback.m_maxVel * gpGlobals->frametime; if ( distance > maxDist ) { newPosition += dir * maxDist; } else { newPosition = tr.endpos; } } else { newPosition = tr.endpos; } CreatePelletAttraction( phys_gunglueradius.GetFloat(), pObject ); // If I'm looking more than 20 degrees away from the glue point, then give up // This lets the player "gesture" for the glue to let go. Vector pelletDir = m_gravCallback.m_worldPosition - start; VectorNormalize(pelletDir); if ( DotProduct( pelletDir, forward ) < 0.939 ) // 0.939 ~= cos(20deg) { // lose attach for 2 seconds if you're too far away m_glueTime = gpGlobals->curtime + 1; } if ( m_pelletHeld >= 0 && gpGlobals->curtime > m_glueTime ) { CGravityPellet *pPelletAttract = m_activePellets[m_pelletAttract].pellet; g_pEffects->Sparks( pPelletAttract->GetAbsOrigin() ); } m_gravCallback.SetTargetPosition( newPosition ); Vector dir = (newPosition - pObject->GetLocalOrigin()); m_movementLength = dir.Length(); } else { m_gravCallback.SetTargetPosition( end ); } if ( m_pelletHeld >= 0 && gpGlobals->curtime > m_glueTime ) { Vector worldNormal, worldPos; GetPelletWorldCoords( m_pelletAttract, &worldPos, &worldNormal ); m_gravCallback.SetAutoAlign( m_activePellets[m_pelletHeld].localNormal, m_activePellets[m_pelletHeld].pellet->GetLocalOrigin(), worldNormal, worldPos ); } else { m_gravCallback.ClearAutoAlign(); } }
//------------------------------------------------------- // //------------------------------------------------------- BOOL APIENTRY DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved ) { switch (ul_reason_for_call) { case DLL_PROCESS_ATTACH: { Loaded = false; ConfigOn = false; // do a version check to make sure users dont have older versions of HGooey if (!HGVersionCheck(HGVersion)) return FALSE; // load and create stuff here (ie load extensions, create textures/images/objects/etc) // make sure the no one moved the extension if (GetFileAttributes("HGooey Files/XenDLL/Extensions/Frames_Per_Sec/HG_SDK.dll") == 0xFFFFFFFF) return FALSE; // make sure the menu item texture exists if (GetFileAttributes("HGooey Files/XenDLL/Extensions/Frames_Per_Sec/Frames_Per_Sec.bmp") == 0xFFFFFFFF) return FALSE; /* example of creating an extension w/ no menu item to start with // create the extension Frames_Per_Sec = CreateExtension(); // set the menu item SetExtensionMenuItem( Frames_Per_Sec, CreateIDDTextureFromFile(64.0f, 64.0f, "HGooey Files/XenDLL/Extensions/Frames_Per_Sec/Frames_Per_Sec.bmp", COLOR_RED)); */ // create the texture for the menu item and create the extension IDDTexture* texture = CreateIDDTextureFromFile("HGooey Files/XenDLL/Extensions/Frames_Per_Sec/Frames_Per_Sec.bmp", COLOR_RED); if (!texture || !(Frames_Per_Sec = CreateExtension(texture))) return FALSE; float Scale = 1.0f; FPS_Display = CreateTextBar( "? Frames Per Second", Scale, Scale); if (!AttachObject(Frames_Per_Sec,FPS_Display)) { UnloadExtension(Frames_Per_Sec); Frames_Per_Sec = NULL; return FALSE; } FPS_Display->SetBorderWidth(6.0f * Scale); FPS_Display->SetBorderHeight(5.0f * Scale); FPS_Display->MoveBySize((ScreenWidth() / GuiScaleX()) - FPS_Display->GetWidth(),0.0f); FPS_Display->SetAcceptAction(false); FPS_Display->SetCancelClick(false); const char* Data; bool write = false; if (Data = ReadConfigItem("MenuItemIO", "HGooey Files/XenDLL/Extensions/Frames_Per_Sec/Frames_Per_Sec.xml")) { if (strcmp(Data, "true") == 0) SetExtMenuIO(Frames_Per_Sec, true); else if (strcmp(Data, "false") == 0) SetExtMenuIO(Frames_Per_Sec, false); else { SetExtMenuIO(Frames_Per_Sec, false); write = true; } } else { write = true; } if (write) { WriteConfigItem("MenuItemIO", "false", "HGooey Files/XenDLL/Extensions/Eye_Map/Eye_Map.xml"); write = false; } Loaded = true; } break; case DLL_PROCESS_DETACH: { if (!Loaded) return TRUE; Loaded = false; // unload and destroy stuff here (ie unload extensions) if (CheckExtMenuIO(Frames_Per_Sec)) WriteConfigItem("MenuItemIO", "true", "HGooey Files/XenDLL/Extensions/Frames_Per_Sec/Frames_Per_Sec.xml"); else WriteConfigItem("MenuItemIO", "false", "HGooey Files/XenDLL/Extensions/Frames_Per_Sec/Frames_Per_Sec.xml"); UnloadExtension(Frames_Per_Sec); Frames_Per_Sec = NULL; } break; } return TRUE; }
void CWeaponGravityGun::EffectUpdate( void ) { Vector start, forward, right; trace_t tr; CBasePlayer *pOwner = ToBasePlayer( GetOwner() ); if ( !pOwner ) return; pOwner->EyeVectors( &forward, &right, NULL ); start = pOwner->Weapon_ShootPosition(); TraceLine( &tr ); Vector end = tr.endpos; float distance = tr.fraction * 4096; if ( m_hObject == NULL && tr.DidHitNonWorldEntity() ) { CBaseEntity *pEntity = tr.m_pEnt; AttachObject( pEntity, GetPhysObjFromPhysicsBone( pEntity, tr.physicsbone ), tr.physicsbone, start, tr.endpos, distance ); } // Add the incremental player yaw to the target transform QAngle angles = m_gravCallback.TransformAnglesFromPlayerSpace( m_gravCallback.m_targetRotation, pOwner ); CBaseEntity *pObject = m_hObject; if ( pObject ) { if ( m_useDown ) { if ( pOwner->m_afButtonPressed & IN_USE ) { m_useDown = false; } } else { if ( pOwner->m_afButtonPressed & IN_USE ) { m_useDown = true; } } if ( m_useDown ) { #ifndef CLIENT_DLL pOwner->SetPhysicsFlag( PFLAG_DIROVERRIDE, true ); #endif if ( pOwner->m_nButtons & IN_FORWARD ) { m_distance = Approach( 1024, m_distance, gpGlobals->frametime * 100 ); } if ( pOwner->m_nButtons & IN_BACK ) { m_distance = Approach( 40, m_distance, gpGlobals->frametime * 100 ); } } if ( pOwner->m_nButtons & IN_WEAPON1 ) { m_distance = Approach( 1024, m_distance, m_distance * 0.1 ); } if ( pOwner->m_nButtons & IN_WEAPON2 ) { m_distance = Approach( 40, m_distance, m_distance * 0.1 ); } IPhysicsObject *pPhys = GetPhysObjFromPhysicsBone( pObject, m_physicsBone ); if ( pPhys ) { if ( pPhys->IsAsleep() ) { // on the odd chance that it's gone to sleep while under anti-gravity pPhys->Wake(); } Vector newPosition = start + forward * m_distance; Vector offset; pPhys->LocalToWorld( &offset, m_worldPosition ); Vector vecOrigin; pPhys->GetPosition( &vecOrigin, NULL ); m_gravCallback.SetTargetPosition( newPosition + (vecOrigin - offset), angles ); Vector dir = (newPosition - pObject->GetLocalOrigin()); m_movementLength = dir.Length(); } } else { m_targetPosition = end; //m_gravCallback.SetTargetPosition( end, m_gravCallback.m_targetRotation ); } }
void WorldModel::HandleAttachMsg( const CParsedMsg &cMsg, const char *szClass ) { if( cMsg.GetArgCount() >= 2 && !szClass ) { // Look for the specific objects we want to attach for( uint i = 1; i < cMsg.GetArgCount( ); i++ ) { const char *pObjName = cMsg.GetArg(i).c_str(); if( !pObjName ) break; ObjArray<HOBJECT, 1> objArray; g_pLTServer->FindNamedObjects( const_cast<char*>(pObjName), objArray ); if( objArray.NumObjects() ) { AttachObject( objArray.GetObject( 0 ) ); } } } else { if( m_vAttachDir.MagSqr() > 1.0f ) { // Grab an object in the direction of the attach vector and attach it IntersectQuery IQuery; IntersectInfo IInfo; g_pLTServer->GetObjectPos( m_hObject, &IQuery.m_From ); IQuery.m_To = IQuery.m_From + m_vAttachDir; IQuery.m_Flags = INTERSECT_OBJECTS | IGNORE_NONSOLID; if( g_pLTServer->IntersectSegment( &IQuery, &IInfo ) ) { // Only attach objects of a specific class type... if( IInfo.m_hObject && IsKindOf( IInfo.m_hObject, szClass )) { if( m_hAttachDirObj ) DetachObject( m_hAttachDirObj ); m_hAttachDirObj = IInfo.m_hObject; AttachObject( m_hAttachDirObj ); } } } else { LTVector vPos; LTRotation rRot; LTMatrix mMat; g_pLTServer->GetObjectPos( m_hObject, &vPos ); g_pLTServer->GetObjectRotation( m_hObject, &rRot ); rRot.ConvertToMatrix( mMat ); LTVector vMin, vMax, vDims; g_pPhysicsLT->GetObjectDims( m_hObject, &vDims ); vMin = mMat * (vPos - vDims); vMax = mMat * (vPos + vDims); ObjectList *pObjList = g_pLTServer->GetBoxIntersecters( &vMin, &vMax ); if( !pObjList ) return; HOBJECT hObj; ObjectLink *pLink = pObjList->m_pFirstLink; while( pLink ) { hObj = pLink->m_hObject; if( hObj && IsKindOf( hObj, szClass )) { AttachObject( hObj ); // add it to our list of objects attached via the ATTACH message... LTObjRefNotifier ref( *this ); ref = hObj; m_AttachMsgObjList.push_back( ref ); } pLink = pLink->m_pNext; } g_pLTServer->RelinquishList( pObjList ); pObjList = NULL; } } }
void CWeaponGravityGun::EffectUpdate( void ) { Vector start, forward, right; trace_t tr; CBasePlayer *pOwner = ToBasePlayer( GetOwner() ); if ( !pOwner ) return; pOwner->EyeVectors( &forward, &right, NULL ); start = pOwner->Weapon_ShootPosition(); TraceLine( &tr ); Vector end = tr.endpos; float distance = tr.fraction * 4096; if ( tr.fraction != 1 ) { // too close to the player, drop the object if ( distance < 36 ) { DetachObject(); return; } } if ( m_hObject == NULL && tr.DidHitNonWorldEntity() ) { CBaseEntity *pEntity = tr.m_pEnt; AttachObject( pEntity, start, tr.endpos, distance ); m_lastYaw = pOwner->EyeAngles().y; } // Add the incremental player yaw to the target transform matrix3x4_t curMatrix, incMatrix, nextMatrix; AngleMatrix( m_gravCallback.m_targetRotation, curMatrix ); AngleMatrix( QAngle(0,pOwner->EyeAngles().y - m_lastYaw,0), incMatrix ); ConcatTransforms( incMatrix, curMatrix, nextMatrix ); MatrixAngles( nextMatrix, m_gravCallback.m_targetRotation ); m_lastYaw = pOwner->EyeAngles().y; CBaseEntity *pObject = m_hObject; if ( pObject ) { if ( m_useDown ) { if ( pOwner->m_afButtonPressed & IN_USE ) { m_useDown = false; } } else { if ( pOwner->m_afButtonPressed & IN_USE ) { m_useDown = true; } } if ( m_useDown ) { #ifndef CLIENT_DLL pOwner->SetPhysicsFlag( PFLAG_DIROVERRIDE, true ); #endif if ( pOwner->m_nButtons & IN_FORWARD ) { m_distance = Approach( 1024, m_distance, gpGlobals->frametime * 100 ); } if ( pOwner->m_nButtons & IN_BACK ) { m_distance = Approach( 40, m_distance, gpGlobals->frametime * 100 ); } } if ( pOwner->m_nButtons & IN_WEAPON1 ) { m_distance = Approach( 1024, m_distance, m_distance * 0.1 ); #ifdef CLIENT_DLL if ( gpGlobals->maxClients > 1 ) { gHUD.m_bSkipClear = false; } #endif } if ( pOwner->m_nButtons & IN_WEAPON2 ) { m_distance = Approach( 40, m_distance, m_distance * 0.1 ); #ifdef CLIENT_DLL if ( gpGlobals->maxClients > 1 ) { gHUD.m_bSkipClear = false; } #endif } IPhysicsObject *pPhys = pObject->VPhysicsGetObject(); if ( pPhys && pPhys->IsAsleep() ) { // on the odd chance that it's gone to sleep while under anti-gravity pPhys->Wake(); } Vector newPosition = start + forward * m_distance; Vector offset; pObject->EntityToWorldSpace( m_worldPosition, &offset ); m_gravCallback.SetTargetPosition( newPosition + (pObject->GetAbsOrigin() - offset), m_gravCallback.m_targetRotation ); Vector dir = (newPosition - pObject->GetLocalOrigin()); m_movementLength = dir.Length(); } else { m_targetPosition = end; //m_gravCallback.SetTargetPosition( end, m_gravCallback.m_targetRotation ); } }
//------------------------------------------------------- // //------------------------------------------------------- BOOL APIENTRY DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved ) { switch (ul_reason_for_call) { case DLL_PROCESS_ATTACH: { Loaded = false; ConfigOn = false; // do a version check to make sure users dont have older versions of HGooey if (!HGVersionCheck(HGVersion)) return FALSE; // load and create stuff here (ie load extensions, create textures/images/objects/etc) // make sure the no one moved the extension if (GetFileAttributes("HGooey Files/XenDLL/Extensions/Eye_Map/HG_SDK.dll") == 0xFFFFFFFF) return FALSE; // make sure the menu item texture exists if (GetFileAttributes("HGooey Files/XenDLL/Extensions/Eye_Map/Eye_Map.bmp") == 0xFFFFFFFF) return FALSE; // make sure the menu memory file exists if (GetFileAttributes("HGooey Files/XenDLL/Common/Memory.xml") == 0xFFFFFFFF) return FALSE; /// const char* Data; bool write = false; bool not_found = false; if (Data = ReadConfigItem("Location X", "HGooey Files/XenDLL/Common/Memory.xml")) { // check the location x memory address try { Location_X = (DWORD*)atoi(Data); } catch (...) { return FALSE; } } else { return FALSE; } if (Data = ReadConfigItem("Location Y", "HGooey Files/XenDLL/Common/Memory.xml")) { // check the location y memory address try { Location_Y = (DWORD*)atoi(Data); } catch (...) { return FALSE; } } else { return FALSE; } if (Data = ReadConfigItem("Screen", "HGooey Files/XenDLL/Common/Memory.xml")) { // check the screen memory address try { Screen = (DWORD*)atoi(Data); } catch (...) { return FALSE; } } else { return FALSE; } if (Data = ReadConfigItem("Chatmode", "HGooey Files/XenDLL/Common/Memory.xml")) { // check the chatmode memory address try { Chatmode = (DWORD*)atoi(Data); } catch (...) { return FALSE; } } else { return FALSE; } /// bZoomIN = false; bZoomOUT = false; Eye_Map = CreateExtension(); IDDTexture* texture = CreateIDDTextureFromFile("HGooey Files/Images/list.bmp", COLOR_RED); // set the menu item SetExtensionMenuItem( Eye_Map, CreateIDDTextureFromFile("HGooey Files/XenDLL/Extensions/Eye_Map/Eye_Map.bmp", COLOR_RED)); /// if (Data = ReadConfigItem("Hide/Show Using DIK_[Key]", "HGooey Files/XenDLL/Extensions/Eye_Map/Eye_Map.xml")) { if ((HIDESHOW_KEY = convertDIK_Name(Data)) == 0x00) not_found = true; } else { not_found = true; } if (not_found) { HIDESHOW_KEY = 0x00; WriteConfigItem("Hide/Show Using DIK_[Key]", "DIK_", "HGooey Files/XenDLL/Extensions/Eye_Map/Eye_Map.xml"); } /// if (Data = ReadConfigItem("MenuItemIO", "HGooey Files/XenDLL/Extensions/Eye_Map/Eye_Map.xml")) { if (strcmp(Data, "true") == 0) SetExtMenuIO(Eye_Map, true); else if (strcmp(Data, "false") == 0) SetExtMenuIO(Eye_Map, false); else { SetExtMenuIO(Eye_Map, false); write = true; } } else { write = true; } if (write) { WriteConfigItem("MenuItemIO", "false", "HGooey Files/XenDLL/Extensions/Eye_Map/Eye_Map.xml"); write = false; } /// RECT rect; SetRect(&rect, DefaultList_left, DefaultList_top, DefaultList_right, DefaultList_bottom); Background = CreateImage( 1.0f, 1.0f, texture, &rect); if (!AttachObject(Eye_Map, Background)) { UnloadExtension(Eye_Map); Eye_Map = NULL; return FALSE; } /// ZoomIN = CreateButton(" + ", 1.0f); if (!AttachObject(Background, ZoomIN)) { UnloadExtension(Eye_Map); Eye_Map = NULL; return FALSE; } /// ZoomOUT = CreateButton(" - ", 1.0f); if (!AttachObject(Background, ZoomOUT)) { UnloadExtension(Eye_Map); Eye_Map = NULL; return FALSE; } /// ZoomRESET = CreateButton("reset", 1.0f); if (!AttachObject(Background, ZoomRESET)) { UnloadExtension(Eye_Map); Eye_Map = NULL; return FALSE; } /// MapButtonText[0] = "Main"; MapButtonText[1] = "2"; MapButtonText[2] = "3"; /// // set a default and then read the config file bool DisplayMoveAlways = false; if (Data = ReadConfigItem("DisplayMoveAlways", "HGooey Files/XenDLL/Extensions/Eye_Map/Eye_Map.xml")) { if (_stricmp(Data, "true") == 0) DisplayMoveAlways = true; else if (_stricmp(Data, "false") != 0) write = true; } else { write = true; } if (write) { WriteConfigItem("DisplayMoveAlways", "false", "HGooey Files/XenDLL/Extensions/Eye_Map/Eye_Map.xml"); write = false; } if (DisplayMoveAlways) Background->SetMoveable(MOVE_ALWAYS); else Background->SetMoveable(MOVE_LIMITED); float DisplaySizeOriginal = 128.0f; DisplaySize = DisplaySizeOriginal; if (Data = ReadConfigItem("DisplaySizeScale", "HGooey Files/XenDLL/Extensions/Eye_Map/Eye_Map.xml")) { DisplaySize *= (float)atof(Data) / 100.0f; } else { char buffer[64]; sprintf_s(buffer, 64, "%f", 100.0f); WriteConfigItem("DisplaySizeScale", buffer, "HGooey Files/XenDLL/Extensions/Eye_Map/Eye_Map.xml"); } DisplayInitialScale = DisplaySizeOriginal / DisplaySize; /// if (Data = ReadConfigItem("MapButtonText[0]", "HGooey Files/XenDLL/Extensions/Eye_Map/Eye_Map.xml")) { MapButtonText[0] = restring(Data, 0, strlen(Data)); } else { WriteConfigItem("MapButtonText[0]", MapButtonText[0], "HGooey Files/XenDLL/Extensions/Eye_Map/Eye_Map.xml"); } MapFile[0] = "xenmap0.bmp"; if (GetFileAttributes(MapFile[0]) == 0xFFFFFFFF) MapFile[0] = "HGooey Files/XenDLL/Extensions/Eye_Map/Eye_Map.bmp"; if (Data = ReadConfigItem("Map[0] Filename", "HGooey Files/XenDLL/Extensions/Eye_Map/Eye_Map.xml")) { if (GetFileAttributes(Data) != 0xFFFFFFFF) MapFile[0] = restring(Data, 0, strlen(Data)); } else { WriteConfigItem("MapFile[0] Filename", MapFile[0], "HGooey Files/XenDLL/Extensions/Eye_Map/Eye_Map.xml"); } MapF2GX[0] = 6.2890625f; if (Data = ReadConfigItem("Map[0] File2Game X", "HGooey Files/XenDLL/Extensions/Eye_Map/Eye_Map.xml")) { MapF2GX[0] = (float)atof(Data); } else { char buffer[64]; sprintf_s(buffer, 64, "%f", MapF2GX[0]); WriteConfigItem("Map[0] File2Game X", buffer, "HGooey Files/XenDLL/Extensions/Eye_Map/Eye_Map.xml"); } MapF2GY[0] = 6.2890625f; if (Data = ReadConfigItem("Map[0] File2Game Y", "HGooey Files/XenDLL/Extensions/Eye_Map/Eye_Map.xml")) { MapF2GY[0] = (float)atof(Data); } else { char buffer[64]; sprintf_s(buffer, 64, "%f", MapF2GY[0]); WriteConfigItem("Map[0] File2Game Y", buffer, "HGooey Files/XenDLL/Extensions/Eye_Map/Eye_Map.xml"); } MapTexture[0] = CreateIDDTextureFromFile(MapFile[0], COLOR_DEFAULT); SetRect(&Zoom, 0, 0, (int)(DisplaySize * DisplayInitialScale), (int)(DisplaySize * DisplayInitialScale)); Map[0] = CreateImage( 1.0f, 1.0f, MapTexture[0], &Zoom); if (!AttachObject(Background, Map[0])) { UnloadExtension(Eye_Map); Eye_Map = NULL; return FALSE; } /// for (int i = 1; i < 3; i++) { char bufffffer[128]; sprintf_s(bufffffer, 128, "MapButtonText[%d]", i); if (Data = ReadConfigItem(bufffffer, "HGooey Files/XenDLL/Extensions/Eye_Map/Eye_Map.xml")) { MapButtonText[i] = restring(Data, 0, strlen(Data)); } else { WriteConfigItem(bufffffer, MapButtonText[i], "HGooey Files/XenDLL/Extensions/Eye_Map/Eye_Map.xml"); } MapFile[i] = "HGooey Files/XenDLL/Extensions/Eye_Map/Eye_Map.bmp"; sprintf_s(bufffffer, 128, "Map[%d] Filename", i); if (Data = ReadConfigItem(bufffffer, "HGooey Files/XenDLL/Extensions/Eye_Map/Eye_Map.xml")) { if (GetFileAttributes(Data) != 0xFFFFFFFF) MapFile[i] = restring(Data, 0, strlen(Data)); } else { WriteConfigItem(bufffffer, MapFile[i], "HGooey Files/XenDLL/Extensions/Eye_Map/Eye_Map.xml"); } MapF2GX[i] = 0.0f; sprintf_s(bufffffer, 128, "Map[%d] File2Game X", i); if (Data = ReadConfigItem(bufffffer, "HGooey Files/XenDLL/Extensions/Eye_Map/Eye_Map.xml")) { MapF2GX[i] = (float)atof(Data); } else { char buffer[64]; sprintf_s(buffer, 64, "%f", MapF2GX[i]); WriteConfigItem(bufffffer, buffer, "HGooey Files/XenDLL/Extensions/Eye_Map/Eye_Map.xml"); } MapF2GY[i] = 0.0f; sprintf_s(bufffffer, 128, "Map[%d] File2Game Y", i); if (Data = ReadConfigItem(bufffffer, "HGooey Files/XenDLL/Extensions/Eye_Map/Eye_Map.xml")) { MapF2GY[i] = (float)atof(Data); } else { char buffer[64]; sprintf_s(buffer, 64, "%f", MapF2GY[i]); WriteConfigItem(bufffffer, buffer, "HGooey Files/XenDLL/Extensions/Eye_Map/Eye_Map.xml"); } MapTexture[i] = CreateIDDTextureFromFile(MapFile[i], COLOR_DEFAULT); SetRect(&Zoom, 0, 0, (int)(DisplaySize * DisplayInitialScale), (int)(DisplaySize * DisplayInitialScale)); Map[i] = CreateImage( 1.0f, 1.0f, MapTexture[i], &Zoom); if (!AttachObject(Background, Map[i])) { UnloadExtension(Eye_Map); Eye_Map = NULL; return FALSE; } } /// for (int i = 0; i < 3; i++) { MapButton[i] = CreateButton(MapButtonText[i], 1.0f); if (!AttachObject(Background, MapButton[i])) { UnloadExtension(Eye_Map); Eye_Map = NULL; return FALSE; } MapButton[i]->SetStickyIO(true); } MapButton[0]->SetIO(true); /// Location = CreateImage( 1.0f, 1.0f, CreateIDDTextureFromFile("HGooey Files/XenDLL/Extensions/Eye_Map/location.bmp", COLOR_RED)); if (!AttachObject(Background, Location)) { UnloadExtension(Eye_Map); Eye_Map = NULL; return FALSE; } Location->SetAcceptAction(false); Location->SetCancelClick(false); /// float DisplayBorder = 7.5f * (DisplaySize / DisplaySizeOriginal); float MapButtonBorder = 2.5f * (DisplaySize / DisplaySizeOriginal); for (int i = 0; i < 3; i++) MapButton[i]->ReScale((DisplaySize / 3.0f) / MapButton[i]->GetWidth(), (DisplaySize / 3.0f) / MapButton[i]->GetWidth()); ZoomIN->ReScale((DisplaySize / 3.0f) / ZoomIN->GetWidth(), (DisplaySize / 3.0f) / ZoomIN->GetWidth()); ZoomOUT->ReScale((DisplaySize / 3.0f) / ZoomOUT->GetWidth(), (DisplaySize / 3.0f) / ZoomOUT->GetWidth()); ZoomRESET->ReScale((DisplaySize / 3.0f) / ZoomRESET->GetWidth(), (DisplaySize / 3.0f) / ZoomRESET->GetWidth()); // should all be the same, but... whatever... float largerHeight0 = MapButton[0]->GetHeight(); if (MapButton[1]->GetHeight() > largerHeight0) largerHeight0 = MapButton[1]->GetHeight(); if (MapButton[2]->GetHeight() > largerHeight0) largerHeight0 = MapButton[2]->GetHeight(); float largerHeight1 = ZoomIN->GetHeight(); if (ZoomOUT->GetHeight() > largerHeight1) largerHeight1 = ZoomOUT->GetHeight(); if (ZoomRESET->GetHeight() > largerHeight1) largerHeight1 = ZoomRESET->GetHeight(); float largerHeight2 = largerHeight0 + largerHeight1; Background->ReScale( (DisplaySize + (DisplayBorder*2.0f)) / (float)DefaultList_width, (DisplaySize + (DisplayBorder*2.0f) + MapButtonBorder + largerHeight2) / (float)DefaultList_height); DisplayX = 0.0f; if (Data = ReadConfigItem("DisplayX", "HGooey Files/XenDLL/Extensions/Eye_Map/Eye_Map.xml")) { DisplayX = (float)atof(Data); if (DisplayX < 0.0f) { DisplayX = 0.0f; write = true; } else if ((DisplayX + Background->GetWidth()) * GuiScaleX() > ScreenWidth()) { DisplayX = (ScreenWidth() / GuiScaleX()) - Background->GetWidth(); write = true; } } else { write = true; } if (write) { char buffer[64]; sprintf_s(buffer, 64, "%f", DisplayX); WriteConfigItem("DisplayX", buffer, "HGooey Files/XenDLL/Extensions/Eye_Map/Eye_Map.xml"); write = false; } DisplayY = 0.0f; if (Data = ReadConfigItem("DisplayY", "HGooey Files/XenDLL/Extensions/Eye_Map/Eye_Map.xml")) { DisplayY = (float)atof(Data); if (DisplayY < 0.0f) { DisplayY = 0.0f; write = true; } else if ((DisplayY + Background->GetHeight()) * GuiScaleY() > ScreenHeight()) { DisplayY = (ScreenHeight() / GuiScaleY()) - Background->GetHeight(); write = true; } } else { write = true; } if (write) { char buffer[64]; sprintf_s(buffer, 64, "%f", DisplayY); WriteConfigItem("DisplayY", buffer, "HGooey Files/XenDLL/Extensions/Eye_Map/Eye_Map.xml"); write = false; } Background->MoveBySize( DisplayX, DisplayY); MapButton[0]->MoveBySize( DisplayBorder, DisplayBorder); MapButton[1]->MoveBySize( DisplayBorder + (DisplaySize / 2.0f) - (MapButton[1]->GetWidth() / 2.0f), DisplayBorder); MapButton[2]->MoveBySize( DisplayBorder + DisplaySize - MapButton[2]->GetWidth(), DisplayBorder); ZoomIN->MoveBySize( DisplayBorder, DisplayBorder + largerHeight0); ZoomOUT->MoveBySize( DisplayBorder + (DisplaySize / 2.0f) - (ZoomOUT->GetWidth() / 2.0f), DisplayBorder + largerHeight0); ZoomRESET->MoveBySize( DisplayBorder + DisplaySize - ZoomRESET->GetWidth(), DisplayBorder + largerHeight0); for (int i = 0; i < 3; i++) { Map[i]->MoveBySize( DisplayBorder, DisplayBorder + MapButtonBorder + largerHeight2); } Location->MoveBySize( DisplayBorder, DisplayBorder + MapButtonBorder + largerHeight2); Loaded = true; } break; case DLL_PROCESS_DETACH: { if (!Loaded) return TRUE; Loaded = false; // unload and destroy stuff here (ie unload extensions) char buffer[64]; sprintf_s(buffer, 64, "%f", Background->GetX() / GuiScaleX()); WriteConfigItem("DisplayX", buffer, "HGooey Files/XenDLL/Extensions/Eye_Map/Eye_Map.xml"); sprintf_s(buffer, 64, "%f", Background->GetY() / GuiScaleY()); WriteConfigItem("DisplayY", buffer, "HGooey Files/XenDLL/Extensions/Eye_Map/Eye_Map.xml"); if (CheckExtMenuIO(Eye_Map)) WriteConfigItem("MenuItemIO", "true", "HGooey Files/XenDLL/Extensions/Eye_Map/Eye_Map.xml"); else WriteConfigItem("MenuItemIO", "false", "HGooey Files/XenDLL/Extensions/Eye_Map/Eye_Map.xml"); UnloadExtension(Eye_Map); Eye_Map = NULL; } break; } return TRUE; }