Seite 2 von 5 ErsteErste 12345 LetzteLetzte
Ergebnis 11 bis 20 von 43

Thema: SENT Gravitationsdämpfer

  1. #11

    Standard AW: SENT Gravitationsdämpfer

    Wieso schaltest du die Schwerkraft so kompliziert ab? :V

    Geht viel leichter:
    http://wiki.garrysmod.com/wiki/?titl....EnableGravity

    Machst einfach:
    Code:
    ent:GetPhysicsObject():EnableGravity( false )
    und die Schwerkraft für das Objekt ist deaktiviert.
    Website: monky-town.de

    WildStar
    Server: Kazor
    Seite: Verbannte
    Char: Monkii (Arkanschütze)

  2. Folgender Benutzer sagt Danke zu monky2k6 für den nützlichen Beitrag:


  3. #12

    Standard AW: SENT Gravitationsdämpfer

    Lua Code:
    1. AddCSLuaFile( "cl_init.lua" )
    2. AddCSLuaFile( "shared.lua" )
    3. include( 'shared.lua' )
    4.       ENT.radius = 100
    5.       ENT.mode = 1
    6.       ENT.nextUseTime = CurTime()
    7.       ENT.ents = {}
    8. function ENT:SpawnFunction( ply, tr )
    9.  
    10. 	if ( !tr.Hit ) then return end
    11.  
    12. 	local SpawnPos = tr.HitPos + tr.HitNormal * 16
    13.  
    14. 	local ent = ents.Create( "sent_lowgrav" )
    15.         ent:SetPos( SpawnPos )
    16.         ent:Spawn()
    17.         ent:Activate()
    18.  
    19. 	return ent
    20.  
    21. end
    22.  
    23.  
    24. /*---------------------------------------------------------
    25.    Name: Initialize
    26. ---------------------------------------------------------*/
    27. function ENT:Initialize()
    28.  
    29. 	// Use the helibomb model just for the shadow (because it's about the same size)
    30. 	self.Entity:SetModel( "models/Combine_Helicopter/helicopter_bomb01.mdl" )
    31.  
    32. 	// Don't use the model's physics - create a sphere instead
    33. 	self.Entity:PhysicsInitSphere( 16, "metal_bouncy" )
    34.  
    35. 	// Wake the physics object up. It's time to have fun!
    36. 	local phys = self.Entity:GetPhysicsObject()
    37. 	if (phys:IsValid()) then
    38. 		phys:Wake()
    39. 	end
    40.  
    41. 	// Set collision bounds exactly
    42. 	self.Entity:SetCollisionBounds( Vector( -16, -16, -16 ), Vector( 16, 16, 16 ) )
    43.  
    44. end
    45.  
    46.  
    47. /*---------------------------------------------------------
    48.    Name: PhysicsCollide
    49. ---------------------------------------------------------*/
    50. function ENT:PhysicsCollide( data, physobj )
    51.  
    52. 	// Play sound on bounce
    53. 	if (data.Speed > 80 && data.DeltaTime > 0.2 ) then
    54. 		self.Entity:EmitSound( "Rubber.BulletImpact" )
    55. 	end
    56.  
    57. 	// Bounce like a crazy bitch
    58. 	local LastSpeed = data.OurOldVelocity:Length()
    59. 	local NewVelocity = physobj:GetVelocity()
    60. 	NewVelocity:Normalize()
    61.  
    62. 	LastSpeed = math.max( NewVelocity:Length(), LastSpeed )
    63.  
    64. 	local TargetVelocity = NewVelocity * LastSpeed * 0.9
    65.  
    66. 	physobj:SetVelocity( TargetVelocity )
    67.  
    68. end
    69.  
    70. /*---------------------------------------------------------
    71.    Name: OnTakeDamage
    72. ---------------------------------------------------------*/
    73. function ENT:OnTakeDamage( dmginfo )
    74.  
    75. 	// React physically when shot/getting blown
    76. 	self.Entity:TakePhysicsDamage( dmginfo )
    77.  
    78. end
    79.  
    80.  
    81. /*---------------------------------------------------------
    82.    Name: Use
    83. ---------------------------------------------------------*/
    84. function ENT:Use( activator, caller )
    85. 	if ( activator:IsPlayer() ) then
    86.         if self.nextUseTime > CurTime() then return end
    87.             self.nextUseTime = CurTime()+0.2
    88.         if self.mode == 0 then
    89.             activator:PrintMessage(3, "Mode: Disable Gravity")
    90.             self.mode = 1
    91.         elseif self.mode == 1 then
    92.             activator:PrintMessage(3, "Mode: Enable Gravity")
    93.             self.mode = 0
    94.         end
    95. 	end
    96. end
    97. function ENT:IsInTable(Table, WhatToFind)
    98.     local Return = false
    99.     for k,v in pairs(Table) do
    100.         if v == WhatToFind then
    101.             Return = true
    102.         end
    103.     end
    104.     return Return
    105. end
    106. function ENT:Check()
    107. local find = ents.FindInSphere(self.Entity:GetPos(),self.radius)
    108.     for k,v in pairs( self.ents ) do
    109.             if not self:IsInTable(find, v) then
    110.                 if v and v:IsValid() then
    111.                 local phys = v:GetPhysicsObject();
    112.                 if phys:IsValid() then
    113.                     phys:EnableGravity( true )
    114.                     phys:Wake()
    115.                 end
    116.                 end
    117.                 table.remove(self.ents,k)
    118.             end
    119.         end
    120. end
    121. function ENT:OnRemove()
    122.     for k,v in pairs( self.ents ) do
    123.         if v and v:IsValid() then
    124.             local phys = v:GetPhysicsObject()
    125.             if phys:IsValid() then
    126.                 phys:EnableGravity(true)
    127.                 phys:Wake();
    128.             end
    129.         end
    130.     end
    131. end
    132. function ENT:Think()
    133.     self:Check()
    134. 	local find = ents.FindInSphere( self.Entity:GetPos(), self.radius )
    135.     for k,v in pairs( find ) do
    136.         local entphys = v:GetPhysicsObject();
    137.         if entphys:IsValid() then
    138.             if self.mode == 1 then
    139.                 self.Entity:GetPhysicsObject():EnableGravity( false )
    140.                 self.Entity:GetPhysicsObject():Wake()
    141.                 if self.ents[k] != v and tostring(v:GetClass()) != "sent_lowgrav" and tostring(v:GetClass()) != "player" then
    142.                     self.ents[k] = v
    143.                 end
    144.                 if tostring(v:GetClass( )) != "sent_lowgrav" and tostring(v:GetClass()) != "player" then
    145.                     entphys:EnableGravity( false )
    146.                     entphys:Wake()
    147.                 end
    148.             elseif self.mode == 0 then
    149.                 self.Entity:GetPhysicsObject():EnableGravity( true )
    150.                 self.Entity:GetPhysicsObject():Wake()
    151.                 if tostring(v:GetClass( )) != "sent_lowgrav" and tostring(v:GetClass()) != "player" then
    152.                     entphys:EnableGravity( true )
    153.                     entphys:Wake()
    154.                 end
    155.             end
    156.         end 
    157.     end
    158. end

    Meinst du sowas in der art ?

  4. Folgender Benutzer sagt Danke zu ALL YOU CAN EAT für den nützlichen Beitrag:


  5. #13

    Standard AW: SENT Gravitationsdämpfer

    Was soll denn das Zeug in Zeile 141 und 142?

    -----

    Desweiteren hast du den Bouncing-Ball Code kopiert,
    welcher dein SENT noch dazu bringt zu springen xD

  6. Folgender Benutzer sagt Danke zu Pac_187 für den nützlichen Beitrag:


  7. #14

    Standard AW: SENT Gravitationsdämpfer

    Danke, dass mal jemand hilft

    Zitat Zitat von monky2k6 Beitrag anzeigen
    Wieso schaltest du die Schwerkraft so kompliziert ab? :V

    Geht viel leichter:
    http://wiki.garrysmod.com/wiki/?titl....EnableGravity

    Machst einfach:
    Code:
    ent:GetPhysicsObject():EnableGravity( false )
    und die Schwerkraft für das Objekt ist deaktiviert.
    Weil ich in garry's physprop script gesucht hab

    awesome thing is made by Araxiel-Sama

  8. #15

    Standard AW: SENT Gravitationsdämpfer

    Ich denke, dass ich es nicht spawnen kann (oder nicht richtig)
    liegt an der cl_init.
    Wie sollte sie am besten aussehen?
    Das funktioniert nicht: (von GCombat-SENT's)
    Lua Code:
    1.  include('shared.lua')     
    2.  //[[---------------------------------------------------------     
    3.  //Name: Draw     Purpose: Draw the model in-game.     
    4.  //Remember, the things you render first will be underneath!  
    5.  //-------------------------------------------------------]]  
    6.  function ENT:Draw()      
    7.  // self.BaseClass.Draw(self)  
    8.  -- We want to override rendering, so don't call baseclass.                                   
    9.  // Use this when you need to add to the rendering.        
    10.  self.Entity:DrawModel()       // Draw the model.   
    11.  end

    awesome thing is made by Araxiel-Sama

  9. #16

    Standard AW: SENT Gravitationsdämpfer

    so sollte es gehen
    Lua Code:
    1. include('shared.lua')
    2.  
    3. local matBall = Material( "sprites/sent_ball" )
    4.  
    5. /*---------------------------------------------------------
    6.    Name: Initialize
    7. ---------------------------------------------------------*/
    8. function ENT:Initialize()
    9.  
    10. 	local i = math.random( 0, 3 )
    11.  
    12. 	if ( i == 0 ) then
    13. 		self.Color = Color( 255, 0, 0, 255 )
    14. 	elseif ( i == 1 ) then
    15. 		self.Color = Color( 0, 255, 0, 255 )
    16. 	elseif ( i == 2 ) then
    17. 		self.Color = Color( 255, 255, 0, 255 )
    18. 	else
    19. 		self.Color = Color( 0, 0, 255, 255 )
    20. 	end
    21.  
    22. end
    23.  
    24.  
    25. /*---------------------------------------------------------
    26.    Name: DrawPre
    27. ---------------------------------------------------------*/
    28. function ENT:Draw()
    29.  
    30. 	local pos = self.Entity:GetPos()
    31. 	local vel = self.Entity:GetVelocity()
    32.  
    33. 	render.SetMaterial( matBall )
    34.  
    35. 	local lcolor = render.GetLightColor( pos ) * 2
    36. 	lcolor.x = self.Color.r * mathx.Clamp( lcolor.x, 0, 1 )
    37. 	lcolor.y = self.Color.g * mathx.Clamp( lcolor.y, 0, 1 )
    38. 	lcolor.z = self.Color.b * mathx.Clamp( lcolor.z, 0, 1 )
    39.  
    40.  
    41. 	for i = 1, 10 do
    42.  
    43. 		local col = Color( lcolor.x, lcolor.y, lcolor.z, 200 / i )
    44. 		render.DrawSprite( pos + vel*(i*-0.005), 32, 32, col )
    45.  
    46. 	end
    47.  
    48. 	render.DrawSprite( pos, 32, 32, lcolor )
    49.  
    50.  
    51.  
    52. end

  10. #17

    Standard AW: SENT Gravitationsdämpfer

    Ahahahah xD

    ALL YOU CAN EAT halte dich doch bitte aus dem Thread raus...

    Copy 'n Paste vom Bouncyball cl_init.lua ist kein Beweis dafür wie sie
    auszusehen hat!


    Lern lieber erstmal ein wenig bevor du anderen Leuten hilfst,
    denn mit dem Wissensstand bringst du die Leute nur durcheinander.

    Versuch überhaupt erstmal zu verstehen was du da gerade geposted hast.

    -----


    @WeltenSturm:

    So wie du sie jetzt hast ist es richtig es soll ja nur das SENT angezeigt werden ( also Model davon ) und das reicht ja schon.


    Bekommst du denn sonst noch irgendwo, irgendwelche Fehler?

  11. #18

    Standard AW: SENT Gravitationsdämpfer

    Wenn ich eine andere cl_init verwende, kommt der fehler nicht

    awesome thing is made by Araxiel-Sama

  12. #19

    Standard AW: SENT Gravitationsdämpfer

    Das hab ich jetzt gelöst (von GravToggleController auf gravtogglecontroller umbenennen xD)
    Aber ingame gibt er mir einen LUA-Fehler an (schreibt er komischerweise nicht in die console)
    (ohne Bouncy-ball Scheiß) nach der 60ten Zeile (63 oder so) schreibt er "then expected near ;"

    Aber der code ist mir sowieso zu kompliziert.
    Wie kann man die gravitation für alle constrainten sachen verändern?
    Und ist an dem etwas falsch?
    Lua Code:
    1. self.CreateWireInputs("Activate")
    2.  
    3.  
    4. if "Activate" == 1 
    5. then ent:GetPhysicsObject():EnableGravity( true )
    6. else ent:GetPhysicsObject():EnableGravity( false )
    7. end

    awesome thing is made by Araxiel-Sama

  13. #20
    Andrey
    Avatar von Andrey

    Standard AW: SENT Gravitationsdämpfer

    Zitat Zitat von WeltEnSTurm Beitrag anzeigen
    Lua Code:
    1. self.CreateWireInputs("Activate")
    2.  
    3.  
    4. if "Activate" 
    5.       then ent:GetPhysicsObject():EnableGravity( true )
    6.       else ent:GetPhysicsObject():EnableGravity( false )
    7. end
    Fehlt da nicht ein End?
    Ich kenn mich kaum aus mit Lua, aber ich glaube es fehlt ein End.

    Außerdem ist der "== 1" eh überflüssig. (oder?)

    Hab das mal rausgenohmen.

  14. Folgender Benutzer sagt Danke zu Andrey für den nützlichen Beitrag:


Berechtigungen

  • Neue Themen erstellen: Nein
  • Themen beantworten: Nein
  • Anhänge hochladen: Nein
  • Beiträge bearbeiten: Nein
  •