Jump to content

havenphillip

Members
  • Content Count

    121
  • Joined

  • Last visited

Community Reputation

21 Excellent

About havenphillip

  • Rank
    Advanced Member

Profile Information

  • Gender
    Male

Recent Profile Visitors

503 profile views
  1. havenphillip

    Some HUD Elements Updated

    Thanks, man.
  2. havenphillip

    Some HUD Elements Updated

    Some hud elements I was able to make with help around the community. HUD Elements.zip
  3. havenphillip

    Trigger Question

    I have this enter/exit trigger from Aggror set up to hide my weapons when I walk on the trigger and show weapons when I walk off the trigger. My problem is when I stand perfectly still on the trigger the weapons show. I don't want that so how do I stop that from happening? I tried the player script's speed, moveSpeed, and playerMovement. You can see what I'm trying to do here: Script.enabled = true Script.entered = false Script.exited = false Script.collided = false function Script:Collision(entity, position, normal, speed) self.player = entity if self.enabled then self.collided = true if self.entered == false then self.entered = true self.exited = false entity.script.weapons[entity.script.currentweaponindex].entity:Hide() if entity:Stop() then -- right here what? entity.script.weapons[entity.script.currentweaponindex].entity:Hide() end end end end function Script:UpdatePhysics() if self.enabled then if self.entered then if self.collided == false then self.exited = true self.entered = false self.player.script.weapons[self.player.script.currentweaponindex].entity:Show() end end self.collided = false end end
  4. havenphillip

    Gamecrash; due to kill or respawn script changes something...

    I think the line self.entity:SetMass(0) was causing crash problems. Maybe uncomment that.
  5. havenphillip

    shader question

    Ah yes that worked perfectly, Ma-Shell. Thank you so much! GorzenDev that's the post I started from. The only thing was I needed to rotate the texture without rotating the quad/mask texture itself. Here's the script I'm using with the vertex and fragment of the shader for those wandering by: Script: Script.pos = Vec2(49,60) -- Vec2 "Position" Script.size = Vec2(210,215) -- Vec2 "Size" function Script:Start() self.shader = Shader:Load("HUD Elements/rotate attempt/weird.shader") self.intex = Texture:Load("Materials/Developer/bluegrid.tex") self.mask= Texture:Load("Materials/Developer/Flat Black.tex") self.angle=0 end function Script:UpdateWorld() self.angle = Time:GetCurrent()/1000 end function Script:PostRender(context) local a = self.a local x = self.pos.x local y = self.pos.y local w = self.size.x local h = self.size.y shd = context:GetShader() self.intex:Bind(1) self.shader:SetFloat("t", -1.0) self.shader:SetFloat("angle", self.angle) context:SetBlendMode(1) context:SetColor(1,1,1,1) context:SetShader(self.shader) context:DrawImage(self.mask, x, y , w, h) context:SetShader(shd) end ------------------------------------------------------------------------------ Fragment of shader: #version 400 uniform vec4 drawcolor; uniform sampler2D texture0; uniform sampler2D texture1; uniform float t; in vec2 vTexCoords0; in vec2 vTexCoords1; out vec4 fragData0; void main(void) { vec4 mask=texture(texture0,vTexCoords0); if (mask.r < 0.1 && mask.a > 0.0) { vec4 t0 = texture(texture0, vTexCoords0); vec4 t1 = texture(texture1, vTexCoords1); mask = mix(t0, t1, vec4(vTexCoords1.x >= t)); } else { discard; } fragData0 = mask; } ------------------------------------------------------------------------------ Vertex of shader: #version 400 uniform mat4 projectionmatrix; uniform mat4 drawmatrix; uniform vec2 position[5]; uniform vec2 texcoords[4]; uniform float angle = 0.0; out vec2 vTexCoords0; out vec2 vTexCoords1; void main(void) { float s = sin(angle); float c = cos(angle); mat2 RotationMatrix = mat2(c,-s,s,c); vec2 pos = position[gl_VertexID]; gl_Position = projectionmatrix * (drawmatrix * vec4(pos, 0.0, 1.0)); vTexCoords0 = texcoords[gl_VertexID]; vTexCoords1 = (texcoords[gl_VertexID] - vec2(0.5, 0.5)) * RotationMatrix + vec2(0.5, 0.5);; }
  6. havenphillip

    shader question

    Since the time I asked this question I made a little progress. I have it rotating now using the vertex, but I can't get it to rotate from the center. It centers at the top-left. Here it is: Fragment: #version 400 uniform vec4 drawcolor; uniform sampler2D texture0; uniform sampler2D texture1; uniform float t; // e.g. 0.4 in vec2 vTexCoords0; in vec2 vTexCoords1; out vec4 fragData0; void main(void) { vec4 mask=texture(texture0,vTexCoords1); if (mask.r < 0.1 && mask.a > 0.0) { vec4 t0 = texture(texture0, vTexCoords1); vec4 t1 = texture(texture1, vTexCoords0); mask = mix(t0, t1, vec4(vTexCoords1.x >= t)); } else { discard; } fragData0 = mask; } Vertex: #version 400 uniform mat4 projectionmatrix; uniform mat4 drawmatrix; uniform vec2 position[4]; uniform vec2 texcoords[4]; uniform float turn = 0.0; in vec3 vertex_position; in vec2 vertex_texcoords0; out vec2 vTexCoords0; out vec2 vTexCoords1; void main(void) { vec2 pos = position[gl_VertexID]; mat2 rot = mat2( cos( radians(turn)), -sin( radians(turn)), sin( radians(turn)), cos(radians(turn))); gl_Position = projectionmatrix * (drawmatrix * vec4(pos, 0.0, 1.0)); vTexCoords1 = texcoords[gl_VertexID]; vTexCoords0 = texcoords[gl_VertexID] * rot; }
  7. havenphillip

    shader question

    I have a shader that allows me to move a texture1 within the masked space of a texture0 but I'm only able to move it in a line. I need it to rotate. How can I do that? Here's the fragment shader: #version 400 uniform vec4 drawcolor; uniform sampler2D texture0; uniform sampler2D texture1; uniform float t; // e.g. 0.4 uniform vec2 bar = vec2(1.0,1.0); uniform bool isbackbuffer; in vec2 vTexCoords0; out vec4 fragData0; void main(void) { vec2 UV = (bar); if (isbackbuffer) UV.xy = 1.0 - UV.xy; vec4 mask=texture(texture0,vTexCoords0); if (mask.r < 0.1 && mask.a >0) { vec4 t0 = texture(texture0, vTexCoords0); vec4 t1 = texture(texture1, vTexCoords0+UV); mask = mix(t0, t1, vec4(vTexCoords0.x >= t)); } else { discard; } fragData0 = mask; } //vec2 turn = vec2(-(cos(2)*(UV.x/2) - sin(2)*(UV.y/2)),(-sin(2)*(UV.x/2) - cos(2)*(UV.y/2)));
  8. havenphillip

    Anybody got a 2D mask shader?

    I have this rotating thing I want to make a health half-circle but I need to mask half of it. How can I do it? Anyone come across a shader for that? Or can it be done in lua? I looked around but I haven't been able to find one that works for this. Here's my code, if that's useful: Script.player = nil -- entity "Player" Script.pos = Vec2(242,234) -- Vec2 "Position" Script.offset = Vec2(4,3) -- Vec2 "Offset" Script.csize = Vec2(200,200) -- Vec2 "Size" function Script:Start() self.player = self.entity:GetParent() self.tex = Texture:Load("Materials/Developer/bluegrid.tex") end function Script:PostRender(context) local a = Time:GetCurrent() /10 local w = self.csize.x local h = self.csize.y local x = self.pos.x-(Math:Cos(a)*(w/2) - Math:Sin(a)*(h/2)) local y = self.pos.y+(-Math:Sin(a)*(w/2) - Math:Cos(a)*(h/2)) local scale = 1 context:SetRotation(a) context:SetScale(1,1) context:SetBlendMode(Blend.Alpha) context:SetColor(1,1,1,1) context:DrawImage(self.tex, x, y, self.csize.x, self.csize.y) context:SetRotation(0) end
  9. havenphillip

    post render rotate

    I see. You have to reset context:SetRotation(0) at the bottom.
  10. havenphillip

    post render rotate

    Nope. I got the square moving all over the screen but it won't turn. Here's my script: Script.pos = Vec2(242,234) -- Vec2 "Position" Script.offset = Vec2(4,3) -- Vec2 "Offset" Script.csize = Vec2(200,200) -- Vec2 "Size" Script.square = Texture:Load("Materials/Developer/bluegrid.tex") function Script:PostRender(context) Time:Update() local a = Time:GetCurrent()*0.1 local x = self.pos.x local y = self.pos.y local w = self.csize.x local h = self.csize.y local scale = 1 --context:SetRotation(a) context:SetScale(scale,scale) context:SetBlendMode(Blend.Alpha) context:SetColor(1,1,1) context:DrawText(text,x,y) context:DrawImage(self.square, x-(Math:Cos(a)*(w) - Math:Sin(a)*(h)), y+(-Math:Sin(a)*(w) - Math:Cos(a)*(h)) , self.csize.x, self.csize.y) context:SetBlendMode(Blend.Solid) end
  11. havenphillip

    post render rotate

    Oh wait, I think I'm getting it.
  12. havenphillip

    post render rotate

    How can you rotate one thing in PostRender() without rotating everything? Is there a way without using shaders?
  13. havenphillip

    How can I fix this problem?

    Here's spectator.lua if you need it: Script.movespeed=5.0--float "Move speed" Script.movementsmoothing = 0.3--float "Move smoothness" Script.radius = 0.5--float "Radius" Script.lookspeed = 0.1--float "Look speed" Script.looksmoothing = 0.5--float "Look smoothness" function Script:Start() local window = Window:GetCurrent() self.mousepos = window:GetMousePosition() self.camerarotation = self.entity:GetRotation() if (self.entity:GetMass()==0) then self.entity:SetMass(10) end self.entity:SetGravityMode(false) self.entity:SetBuoyancyMode(false) self.entity:SetCollisionType(Collision.Projectile) if self.entity:GetShape()==nil then local shape = Shape:Sphere(0,0,0, 0,0,0, self.radius*2,self.radius*2,self.radius*2) self.entity:SetShape(shape) shape:Release() end self.entity:SetFriction(0,0) self.entity:SetElasticity(0) self.entity:SetSweptCollisionMode(true) self.listener = Listener:Create(self.entity) self.entity:SetBuoyancyMode(false) end --Collision filter so the spectator doesn't knock things over function Script:Overlap(entity) if entity:GetMass()==0 then return Collision.Collide else return Collision.None end end function Script:UpdateWorld() local window = Window:GetCurrent() local cx = Math:Round(context:GetWidth()/2) local cy = Math:Round(context:GetHeight()/2) local mpos = window:GetMousePosition() window:SetMousePosition(cx,cy) local centerpos = window:GetMousePosition() if self.started then mpos = mpos * self.looksmoothing + self.mousepos * (1-self.looksmoothing) local dx = (mpos.x - centerpos.x) * self.lookspeed local dy = (mpos.y - centerpos.y) * self.lookspeed self.camerarotation.x = self.camerarotation.x + dy self.camerarotation.y = self.camerarotation.y + dx self.mousepos = mpos else self.mousepos = Vec3(centerpos.x,centerpos.y,0) self.started=true end end function Script:UpdatePhysics() local move=0 local strafe=0 local ascension=0 local window = Window:GetCurrent() if window:KeyDown(Key.W) or window:KeyDown(Key.Up) then move = move + self.movespeed end if window:KeyDown(Key.S) or window:KeyDown(Key.Down) then move = move - self.movespeed end if window:KeyDown(Key.D) or window:KeyDown(Key.Right) then strafe = strafe + self.movespeed end if window:KeyDown(Key.A) or window:KeyDown(Key.Left) then strafe = strafe - self.movespeed end if window:KeyDown(Key.Q) or window:KeyDown(Key.PageDown) then ascension = ascension - self.movespeed end if window:KeyDown(Key.E) or window:KeyDown(Key.PageUp) then ascension = ascension + self.movespeed end local currentvelocity = self.entity:GetVelocity(false) local desiredvelocity = Vec3(strafe,0,move) + Transform:Vector(0,ascension,0,nil,self.entity) local velocity = currentvelocity * self.movementsmoothing + desiredvelocity * (1.0-self.movementsmoothing) self.entity:AddForce((desiredvelocity - currentvelocity) * self.entity:GetMass() / self.movementsmoothing,false) self.entity:PhysicsSetRotation(self.camerarotation.x,self.camerarotation.y,self.camerarotation.z) end
  14. havenphillip

    Headshot Kills?

    Well so I was able to create a script that I can child to the head and drag in the top parent as an entity. I like this because I don't have to do anything to other scripts. It works but the only problem is when I set the material to Invisible.mat I get no bullet wound texture when shooting the head. The invisible texture hides that, too. Is there an easy way to fix that in this script? I can live without it but it irks me a bit. Here's the script: Script.parent= "" --entity "Parent" Script.size = Vec3(0.30,0.34,0.34) -- Vec3 "Size" Script.pos = Vec3(0,0.1,-0.07) -- Vec3 "Offset" Script.damageMulti = 10 -- int "Damage Multiplier" function Script:Start() self.head = self.entity:GetParent() self.health = self.parent.script.health self.box = Model:Sphere(8) self.box:SetScale(self.size) self.box:SetKeyValue(self.parent:GetKeyValue("type")) self.box:SetPosition(self.head:GetPosition(true)) self.box:SetParent(self.entity,true) self.box:SetPickMode(self.parent:GetPickMode()) self.box:Translate(self.pos) self.box:SetShadowMode(0) self.material = Material:Load("Materials/Effects/Invisible.mat") self.box:SetMaterial(self.material) end function Script:Hurt(damage,distributorOfPain) if self.health>0 then self.health = self.health - (damage * self.damageMulti) self.parent.script.health = self.parent.script.health - damage * self.damageMulti if self.health<=0 then self.health = 0 self.parent.script.health = Math:Clamp(self.parent.script.health, 0, self.health) self.parent.script:SetMode("dying") self.box:Hide() end end return end
  15. havenphillip

    Headshot Kills?

    Ok I'll try it. Thanks guys.
×