Jump to content

havenphillip

Members
  • Posts

    550
  • Joined

  • Last visited

Everything posted by havenphillip

  1. 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
  2. How can you rotate one thing in PostRender() without rotating everything? Is there a way without using shaders?
  3. 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
  4. 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
  5. Ah ok. So this right here: function Script:UpdateWorld()... local enemy = self:FindScriptedParent(pickinfo.entity,"Hurt") Ok so now how do I actually get that? You're talking about modifying the gun script?
  6. Oh yeah in the gun code. This one? function Script:FindScriptedParent(entity,func) while entity~=nil do if entity.script then if type(entity.script[func])=="function" then --if entity.script.enabled~=false then return entity --else -- return nil --end end end entity = entity:GetParent() end return nil end
  7. Ok sorry I'm lost already. The pick position? Pass the pick and the Hurt() into the Headshot Box script? Actually that part makes sense but where is the pickposition? Are the entity children a table somewhere that I can iterate them? How do I find the exact limb? It's not as simple as: Hurt()... if self.headshotBox then damage = 100 end I can see I should have thought this through longer.
  8. You're saying I can reference the Hurt() function in the Headshot Box script?
  9. I tried making a hitbox like from your video, but in your video it's just one box and I can't make a distinction in damage on the limbs. I presume there is something I'm missing or did wrong, but I couldn't get that to work. In the AI script I referenced it in the Start() as: self.headshotBox=self.entity:FindChild("Headshot Box") I made a pivot and attached it to the head limb and attached a script that created a box there: function Script:Start() self.head = self.entity:GetParent() material = Material:Load("HUD Elements/Materials/_original.mat") self.box = Model:Box(0.35,0.35,0.35) self.box:SetMaterial(material) self.box:SetPosition(self.head:GetPosition(true)) self.box:SetParent(self.head,true) self.box:Translate(1,0,0) end The box works like this and reduces health with damage but now I don't know how to reference it. I'm assuming I could do something like in the AI script under the Hurt() function add an "if" statement but what? "If target? == self.headshotBox then...?" Or should I add some kind of Hurt() function to the box itself?
  10. What's the best way to approach headshots? I tried messing with the AI script in the Hurt() function. I tried making a script that created a box around the head. I tried making a pick...seems like the best way would be to add an "if" statement in the AI script Hurt(damage) function by declaring the head but how?
  11. Ok so I added this line in the HUD AI under ChooseTarget(): if d < self.sightradius then ..so it looks like this: function Script:ChooseTarget() local entities = GetEntityNeighbors(self.entity,self.sightradius,true) local k,entity for k,entity in pairs(entities) do if entity.script.teamid~=nil and entity.script.teamid~=0 and entity.script.teamid~=self.teamid then if entity.script.health>0 then local d = self.entity:GetDistance(entity) local pickinfo=PickInfo() if self.entity.world:Pick(self.entity:GetPosition()+Vec3(0,1.6,0),entity:GetPosition()+Vec3(0,1.6,0),pickinfo,0,false,Collision.LineOfSight)==false then if d < self.sightradius then --added so they don't charge from any distance return entity.script end end end end end end Not sure why that's not in the original script. So to OP just what Macklebee suggested above, plus change this one line in your HUD AI script, save it as a prefab if you're spawning them, and also I have to change this line in the minimap script from a 1 to a 2 for the dots to appear: local AABB = self.miniMapSphere:GetAABB(1) ...so it looks like: local AABB = self.miniMapSphere:GetAABB(2)
  12. Yeah that works. The sightrange is still off. I have to set it to -22 to walk up to the crawler. Should be at 0. Is there a way to compensate for that in the minimap script? Like add something to the table?
  13. Are you using the minimap? Looks like it may be the minimap sphere. I deleted it and they worked normally.
  14. How do you "loop over all entities in the world'? Talking about an AABB box?
  15. Thanks for the reply. I just tried your code here. Same problem. Not sure why but it's not working for me with the standard Leadwerks Main.lua. The only format that shows up is: context:DrawText("Ammo: "..clip.. " | " ..Ammo, 20,108) If I use Luawerks instead it works fine, they all show up. So if you have bought Luawerks you can switch the Main.lua back and forth and see. That's the best replication I have right now. I presumed someone would have encountered this and I know a lot of you guys can just troubleshoot these things in your head. Not sure what it is about the Luawerks system that makes it work that is missing in the original. Here's one of my scripts where the text isn't showing up in case you want to see if I'm doing something wrong: Script.overlayPath = "" --path "Texture" "Tex file (*tex):tex" Script.timeBarColor = Vec4(255,128,0,255) --color "Timebar Color" Script.fontColor = Vec4(1,1,1,0.8) -- color "Font Color" Script.maxTime = 150 --int "Countdown Time" Script.radius = 35 --int "Radius" Script.cirPos = Vec2(100,180) --Vec2 "Circle Position" function Script:Start() self.font = Font:Load("Fonts/arialbd.ttf", 10) self.player = self.entity:GetParent() self.camera = self.player.script.camera self.endtime = 0 self.timer = self.maxTime if self.overlayPath ~= "" then self.overlay = Texture:Load(self.overlayPath) end end function Script:UpdateWorld() self.timer = self.timer - Time:GetSpeed()/100 if self.timer < self.endtime then self.timer = 0 self:GameOver() end end function Script:GameOver() self.player.script.health = 0 self.player.script:Kill() self.entity:Release() end function Script:PostRender(context) local x = 0 local y = 0 local r = self.radius local G = 1000 local countdown = self.timer/self.maxTime local p = self.radius + self.radius/5 w = context:GetWidth()/context:GetWidth() + self.cirPos.x h = context:GetHeight()/2 + self.cirPos.y context:SetBlendMode(1) --draw overlay if self.overlayPath ~= nil then context:SetColor(1,1,1,0.45) context:DrawImage(self.overlay, w-p, h-p, p*2, p*2) end -- draw circle for k = 0, G do a = 360 / G * k *(countdown) X = -(r * Math:Sin(a)) + x Y = -(r * Math:Cos(a)) + y context:SetColor(self.timeBarColor) context:DrawRect(X + w, Y + h, X/5 , Y/5, 1) end --draw text context:SetColor(self.fontColor) context:SetFont(self.font) context:DrawText(string.format("%.0f",self.timer), w-14, h-14, 30, 30, Text.VCenter+Text.Center) end
  16. It appears this format shows up on start: context:DrawText("Ammo: "..clip.. " | " ..Ammo, 20,108) ...but this does not: context:DrawText(string.format("Ammo: "..clip.. " | " ..Ammo), 20, 108, 100, 30, Text.VCenter+Text.Center) It works fine with ReepBlue's Luawerks so perhaps there's something missing in the Leadwerks Main.lua or Menu.lua which accounts for this? I just don't know where to look.
  17. After I ESC and then click the mouse anywhere. You can see all the numbers are there:
  18. I just got a new computer I started having this problem. Seems like I've encountered this before but can't remember how to fix it but my numbers aren't showing up on start except for in one of the scripts. If I hit ESC then click somewhere random they appear and I can hit ESC again and it's fine. If I hit ESC and click randomly they appear but if I then hover the mouse over the words in the GUI they disappear again. How to fix this?
  19. lol! Same problem I had before. Needed to download this: Microsoft Visual C++ 2010 Redistributable Package (x86) Thanks.
  20. I got a new computer and downloaded Leadwerks but it won't start for some reason. I click and a window pops up "Preparing to launch Leadwerks Game Engine" then it disappears and nothing. No .dll errors or anything. Just won't start. What the heck?
  21. Some scripts I've managed to piece together from the community. HUD Elements.zip
  22. Oh awesome! That's exactly what I was looking for. I only need to do this and some PostRender() stuff but this is right. function NormalizeAngle(angle) if angle <= - 180 then return angle + 360 elseif angle >= 180 then return angle - 360 else return angle + 0 end end Here it is. Working perfectly: UI Elements.zip
×
×
  • Create New...