• What Do You Need Help With? V8
    1,074 replies, posted
I'm trying to make a SWEP that the user can mark a location with, and then teleport anybody he shoots to that location. The location setting works, but I can't find out how to get the target to TP. I'm pretty new to this so some of these codes are from other SWEPS that do similar things, hence the erroneous comments. Bullet Script: [CODE] function SWEP:ShootGoon() local cone = self.Primary.Cone local bullet = {} bullet.Num = 1 bullet.Src = self.Owner:GetShootPos() bullet.Dir = self.Owner:GetAimVector() bullet.Spread = Vector( cone, cone, 0 ) bullet.Tracer = 1 bullet.Force = 2 bullet.Damage = 12 bullet.TracerName = self.Tracer bullet.Callback = SetPosTarget self.Owner:ViewPunch( Angle( math.Rand(-0.2,-0.1) * self.Primary.Recoil, math.Rand(-0.1,0.1) *self.Primary.Recoil, 0 ) ) self.Weapon:SendWeaponAnim( ACT_VM_PRIMARYATTACK ) -- View model animatio self.Owner:MuzzleFlash() -- Crappy muzzle light self:EmitSound( self.Primary.Sound ) self.Owner:FireBullets( bullet ) end [/CODE] (Broken) Teleport Code [CODE] function SetPosTarget(ent, teleport, path) local pos = teleport.pos local ang = teleport.ang local ent = path.Entity if not IsValid(ent) then return end if CLIENT and IsFirstTimePredicted() then if ent:GetClass() == "prop_ragdoll" then ScorchUnderRagdoll(ent) end return end if SERVER then local dur = ent:IsPlayer() and 5 or 10 if ent:IsPlayer() and (not GAMEMODE:AllowPVP()) then return end if ent:IsPlayer() then print("setting pos") ent:SetPos(pos) ent:SetEyeAngles(ang) end[/CODE]
[QUOTE=Pinku;52333365]I'm trying to make a SWEP [...][/QUOTE] [img]https://cdn.discordapp.com/attachments/180458689759674377/323377736275984384/unknown.png[/img] The subforum you're looking for is [URL="https://facepunch.com/forumdisplay.php?f=65"]here[/URL].
Is there any way that I can compute a scaling factor for a model that would keep the model at the same perceived size given an arbitrary distance? Usage example: I want to render a 3D mesh representing a 3D cursor in the world, and place it there in the world, but increase its scale as it gets further away but only enough to maintain its size. I've achieved a bit of a hack for it involving calculating where the gizmo lands on the screen converted to a fixed depth to maintain scaling, but I still need to know how much to scale the gizmo for mouse-intersection tests. I suppose I need to somehow undo or inverse a part of the distortion that occurs as a function of distance that the perspective matrix induces. I'll keep messing around with math haphazardly in the mean time. [editline]11th June 2017[/editline] Despite searching a around half a dozen times on the subject over multiple days, I gave it one last go and actually found [URL="https://www.opengl.org/discussion_boards/showthread.php/129996-Rendering-at-constant-size?p=972941&viewfull=1#post972941"]a solution[/URL] If I take the length of the difference between the desired object's origin (in this case wherever the 3D cursor is) and the camera, that length can be used directly as a scaling factor. I can then scale back the scaling factor itself to achieve a desired size.
My friend and I are wondering something: if we have a list of categories and each category has it's own subcategories, and each subcategory has an element we want to store, what is more efficient? (this is specifically in Python, but I'm curious about C/C++ as well) 1. A nested Map/Dictionary: The first dictionary uses the categories as keys and the values are the subcategories. The value actually points to a dictionary of elements in that subcategory. 2. Use a Tuple as the Key in a Dictionary: The key would be category + sub-category, and the value would contain the element. I figured #1 is faster since you're doing less lookups than #2, where you have to look up the key in a bigger pool of keys, but I'm not sure. This also gets more complicated if a category contains only two sub-categories, since we'd plan to use a BST in that case.
i'm trying to write a multithreaded a* pathfinder. it was all good until i introduced the multithreaded part. now it crashes when i try to find a path. whats the best way of finding out which part is causing it to crash?
[QUOTE=huntingrifle;52348597]My friend and I are wondering something: if we have a list of categories and each category has it's own subcategories, and each subcategory has an element we want to store, what is more efficient? (this is specifically in Python, but I'm curious about C/C++ as well) 1. A nested Map/Dictionary: The first dictionary uses the categories as keys and the values are the subcategories. The value actually points to a dictionary of elements in that subcategory. 2. Use a Tuple as the Key in a Dictionary: The key would be category + sub-category, and the value would contain the element. I figured #1 is faster since you're doing less lookups than #2, where you have to look up the key in a bigger pool of keys, but I'm not sure. This also gets more complicated if a category contains only two sub-categories, since we'd plan to use a BST in that case.[/QUOTE] #2 has less lookups, technically. You only have to do one. A good (dynamic) dictionary won't be strongly affected by the amount of keys when doing lookups anyway, though. The annoying part is that many languages don't have good default equality and hashing for touples, so you may have to implement that part. If you go with #2 and have to implement hashing [I]and[/I] care a lot about speed, pay a little bit of attention to the hashes not having an awful distribution. That's the only caveat afaik, really.
[QUOTE=Pat.Lithium;52351487]i'm trying to write a multithreaded a* pathfinder. it was all good until i introduced the multithreaded part. now it crashes when i try to find a path. whats the best way of finding out which part is causing it to crash?[/QUOTE] nvm, i'm just gonna redo the whole thing i've clearly fucked up some where and dont have a full understanding of my implementation so the best thing to do is redo the whole thing.
[QUOTE=Pat.Lithium;52351487]i'm trying to write a multithreaded a* pathfinder. it was all good until i introduced the multithreaded part. now it crashes when i try to find a path. whats the best way of finding out which part is causing it to crash?[/QUOTE] What language are you using and what operating system are you on?
c#, windows, using unity. the problem was in my path find, it was getting caught in a while loop, while (openSet.count > 0), for some reason the openSet never reached 0, but the pathfind itself never broke the loop when it found the destination (which is odd because it froze even if the objects had a clear path to each other). could have been a number of things, i think i'll create an automatic break condition and see if i can spout out some debug messages. [editline]13th June 2017[/editline] yeah still crashes even when i force the loop to break after 100 iterations.
i dont know if theres better place to ask source engine-related things but i know there are a couple of dudes experienced in this down here i am trying to make voice lines played on specific damage type kills [code] void CHL2_Player::Event_KilledOther( CBaseEntity *pVictim, const CTakeDamageInfo &info ) { BaseClass::Event_KilledOther( pVictim, info ); if (!(pVictim->GetDamageType() >= (DMG_BUCKSHOT))) { CPASAttenuationFilter filter(this); filter.UsePredictionRules(); EmitSound(filter, entindex(), "Player.Shotgun"); } else if (!(pVictim->GetDamageType() >= (DMG_BULLET))) { CPASAttenuationFilter filter(this); filter.UsePredictionRules(); EmitSound(filter, entindex(), "Player.Bullet"); } else if (!(pVictim->GetDamageType() >= (DMG_BLAST))) { CPASAttenuationFilter filter(this); filter.UsePredictionRules(); EmitSound(filter, entindex(), "Player.Explosive"); }[/code] whenever enemy is killed it plays the shotgun line no matter what was the damage type without the "!()" lines refuse to play at all please help or the mod lead will bite my head off
[QUOTE=Mattscreab;52352500]i dont know if theres better place to ask source engine-related things but i know there are a couple of dudes experienced in this down here i am trying to make voice lines played on specific damage type kills [code] void CHL2_Player::Event_KilledOther( CBaseEntity *pVictim, const CTakeDamageInfo &info ) { BaseClass::Event_KilledOther( pVictim, info ); if (!(pVictim->GetDamageType() >= (DMG_BUCKSHOT))) { CPASAttenuationFilter filter(this); filter.UsePredictionRules(); EmitSound(filter, entindex(), "Player.Shotgun"); } else if (!(pVictim->GetDamageType() >= (DMG_BULLET))) { CPASAttenuationFilter filter(this); filter.UsePredictionRules(); EmitSound(filter, entindex(), "Player.Bullet"); } else if (!(pVictim->GetDamageType() >= (DMG_BLAST))) { CPASAttenuationFilter filter(this); filter.UsePredictionRules(); EmitSound(filter, entindex(), "Player.Explosive"); }[/code] whenever enemy is killed it plays the shotgun line no matter what was the damage type without the "!()" lines refuse to play at all please help or the mod lead will bite my head off[/QUOTE] [URL="http://wiki.garrysmod.com/page/Enums/DMG"]Here's the damage type enumeration.[/URL] I assume it's not too different between Gmod and default Source. With your current set-up, you have to order them by descending value, or some of those cases will never be hit (e.g. with [I]DMG_BULLET[/I] (2) occluding DMG_BLAST (64)). You can (should) use [I]&[/I] instead of [I]>=[/I] to check for the flags being set here, which lets you specify any priority. [editline]13th June 2017[/editline] I probably should explain flags enums. The value you get will be a union of any number of these constants, since a single kill may have a composite damage type (like [I]DMG_ACID | DMG_POISON[/I]). If you want to check for specific composites, you need to compare the result of the [I]&[/I] operator to that composite (with [I]==[/I]) or it will react to any part already.
[QUOTE=Tamschi;52352792][URL="http://wiki.garrysmod.com/page/Enums/DMG"]Here's the damage type enumeration.[/URL] I assume it's not too different between Gmod and default Source. With your current set-up, you have to order them by descending value, or some of those cases will never be hit (e.g. with [I]DMG_BULLET[/I] (2) occluding DMG_BLAST (64)). You can (should) use [I]&[/I] instead of [I]>=[/I] to check for the flags being set here, which lets you specify any priority. [editline]13th June 2017[/editline] I probably should explain flags enums. The value you get will be a union of any number of these constants, since a single kill may have a composite damage type (like [I]DMG_ACID | DMG_POISON[/I]). If you want to check for specific composites, you need to compare the result of the [I]&[/I] operator to that composite (with [I]==[/I]) or it will react to any part already.[/QUOTE] still doesnt work i was told that !() is the odd one but yeah
[QUOTE=Mattscreab;52353154]still doesnt work i was told that !() is the odd one but yeah[/QUOTE] You need to remove that too. I thought you had that just for testing so I didn't mention it. Your code should look somewhat like this: [code]void CHL2_Player::Event_KilledOther( CBaseEntity *pVictim, const CTakeDamageInfo &info ) { BaseClass::Event_KilledOther( pVictim, info ); if (pVictim->GetDamageType() & DMG_BUCKSHOT) { CPASAttenuationFilter filter(this); filter.UsePredictionRules(); EmitSound(filter, entindex(), "Player.Shotgun"); } else if (pVictim->GetDamageType() & DMG_BULLET) { CPASAttenuationFilter filter(this); filter.UsePredictionRules(); EmitSound(filter, entindex(), "Player.Bullet"); } else if (pVictim->GetDamageType() & DMG_BLAST) { CPASAttenuationFilter filter(this); filter.UsePredictionRules(); EmitSound(filter, entindex(), "Player.Explosive"); } [...][/code], or e.g. [code]else if (pVictim->GetDamageType() & (DMG_ACID | DMG_BLAST) == (DMG_ACID | DMG_BLAST))[/code] if you want to check for a more specific damage type, though I'd probably use a function [code]bool hasDamageType(CBaseEntity const &pVictim, ? dmg) { // Replace the question mark with whatever those DMG_ values are. return pVictim.GetDamageType() & dmg == dmg; }[/code] at that point. (Someone who actually knows C++ please correct this if I got something wrong.)
doesnt work, really i figured out the proper way to do it if someone needs it [code] if (pVictim->IsNPC()) { if (info.GetDamageType() & DMG_BULLET) { CPASAttenuationFilter filter(this); filter.UsePredictionRules(); EmitSound(filter, entindex(), "Player.Bullet"); Msg("1"); } [/code] hope that someday somehow helps someone
How can I allow a user to modify the rotation of an object in a 3D editor when the system uses quaternions to store the orientation? Since quaternions can "decompose" into euler angles in more than 1 way, converting it into euler angles and having the user modify them and then converting it back won't always work as the axes can kind of change around when reaching gimbal lock or whatever. Right now I have modified my object class to store both a rotation and a quaternion so that when it builds its transformation it considers both, but since gimbal lock is a problem I've added a ui button that adds that bakes the two together. I just feel like I'm missing something, because other editors appear on the surface to not have as big of a deal with this sort of thing.
So I'm making my first Python GUI program with PyQt. I love how it works so far, but my code is a mess because I don't understand how PyQt uses inheritance to render windows. My main script looks like [URL="https://pastebin.com/DzJQbRu0"]this.[/URL] It's messy to me and feels too long. I'd like to maybe send some of the functions to other files if possible. With that said, I have two questions. Firstly, how do I open up a child window. I need to connect a function that opens an order info window (template already exists) when a row is double clicked in either the Recent Orders table or the regular Orders table. Secondly, if I want to move some of these functions to another module, how do I send the main window instance to the new module? (replace self. in everything)
I am making a window class. As members it has pointers to other classes (in this case SDL_window SDL_renderer and SDL_openlcontext). Contruction can fail sometimes so I need a way to handle that. I have found a stack overflow post describing something about an optional template contructor? See for yourself: [url]https://stackoverflow.com/questions/4989807/how-to-handle-failure-in-constructor-in-c[/url] I am referring to the first answer. Thats where my problem is. I dont understand how to use this. The description he gave me is rather, basic and I do not have a lot of experience with templates. Please clarify this post.
[url]http://-/view/dashboard/[/url] I'm trying to stretch the side-bar to the bottom of the page persistently, not just when there's content there, much like a navigation bar where you can stretch it indefinitely. Could anyone help? I'm not a designer by any means.
[QUOTE=MoustacheSpy;52377630]I am making a window class. As members it has pointers to other classes (in this case SDL_window SDL_renderer and SDL_openlcontext). Contruction can fail sometimes so I need a way to handle that. I have found a stack overflow post describing something about an optional template contructor? See for yourself: [url]https://stackoverflow.com/questions/4989807/how-to-handle-failure-in-constructor-in-c[/url] I am referring to the first answer. Thats where my problem is. I dont understand how to use this. The description he gave me is rather, basic and I do not have a lot of experience with templates. Please clarify this post.[/QUOTE] What's the problem with throwing an exception?
[QUOTE=JWki;52378871]What's the problem with throwing an exception?[/QUOTE] Nothing. I just want to go that route cause it sounds interesting
Trying to rewrite in NGINX conf to a MVC format. [CODE] location / { try_files $uri $uri/ @rules; } location @rules { rewrite ^/(.*)$ /index.php?url=$1; } [/CODE] [url]http://localhost/dashboard/[/url] Returns: [CODE] /dashboard//dashboard/ [/CODE] I can't figure out why it's repeating it twice, instead of once, any ideas?
Anyone see what's wrong with my code? I'm trying to get the snake tail in my snake clone to follow each other so the tail segments are independent of the head. So if the second to last tail segment has the direction 'r' or 'right', it'll store that in a lastDir variable in the tail object so the next segment knows which direction to go. This doesn't work like I want to though. The tail decides to go a different direction altogether which leaves me with no tail. [code] public void Update(GameTime gameTime) { speedCountdown += gameTime.ElapsedGameTime.TotalMilliseconds; KeyboardState state = Keyboard.GetState(); if (state.IsKeyDown(Keys.Right)) direction = 'r'; if (state.IsKeyDown(Keys.Left)) direction = 'l'; if (state.IsKeyDown(Keys.Up)) direction = 'u'; if (state.IsKeyDown(Keys.Down)) direction = 'd'; if (speedCountdown >= 250) { if (direction == 'r') position.X += speed; if (direction == 'l') position.X -= speed; if (direction == 'u') position.Y -= speed; if (direction == 'd') position.Y += speed; if (tail.Count > 1) { foreach (var tail in tail) { if (this.tail[this.tail.Count - 2].lastDir == 'r') tail.position.X += speed; if (this.tail[this.tail.Count - 2].lastDir == 'l') tail.position.X -= speed; if (this.tail[this.tail.Count - 2].lastDir == 'u') tail.position.Y -= speed; if (this.tail[this.tail.Count - 2].lastDir == 'd') tail.position.Y += speed; } } else if (tail.Count == 1) { if (lastDir == 'r') tail[0].position.X += speed; if (lastDir == 'l') tail[0].position.X -= speed; if (lastDir == 'u') tail[0].position.Y -= speed; if (lastDir == 'd') tail[0].position.Y += speed; } if (tail.Count > 0) { if (tail.Last().lastDir == 'n' && tail.Count == 1) tail.Last().lastDir = lastDir; else if (tail.Last().lastDir == 'n' && tail.Count > 1) { tail.Last().lastDir = tail[tail.Count - 2].lastDir; } } lastDir = direction; speedCountdown = 0; } }[/code] [vid]https://pred.me/videos/2017-06-30_19-17-01.mp4[/vid] I've been trying to solve this for the last few days without much result. You guys see what I'm doing wrong?
hey guys, so i really want something like the windows media player thing on the task bar for spotify (I'm using windows 10) [t]http://media.askvg.com/articles/images/WMP12_Mini_Taskbar_Toolbar_Taskband.png[/t] and couldn't find anything like that. Can someone give me like little guidance to where i can start from? So I've never made a program before for windows and don't really know where I should be starting. I've never really touched with c# before... and with c++, only used for school assignments with pre-added in codes. So i got visual studio 2015, is there something extra I would need for something like this? Would using spotify's web api be okay with this? I'd be running spotify desktop app on the side. I don't see anything about a desktop hook... I got lots of time in my hands right now, so starting off with something smaller wouldn't bother me at all... Don't know what I should be looking at though.
I'm trying to fix some bugs in some older mods for Killing Floor 2, and I'm a fairly big noob at UnrealScript/modding so please bear with me. If I have Classes A, B, and C, where Class A extends B, but B does not extend from C. Currently, Class A is using structs from Class C, but when I try to compile the mod I get an error saying that it doesn't know of those data types. Is there a way I can double extend Class A or be able to use Class C's structs?
Do you mean like have something that is 2 other things at once? Like:[code] struct Thing_That_Eats { }; struct Thing_That_Shits { }; struct Cat : public Thing_That_Eats, public Thing_That_Shits { }; [/code] ?
[QUOTE=Karmah;52430149]Do you mean like have something that is 2 other things at once? Like:[code] struct Thing_That_Eats { }; struct Thing_That_Shits { }; struct Cat : public Thing_That_Eats, public Thing_That_Shits { }; [/code] ?[/QUOTE] [del]Like that, but with using UnrealScript, and instead of structs they are all classes. Class A uses a struct defined in Class C, but does not inherit from Class C.[/del] Figured it out with some more Google-fu, I could use the dependsOn specifier for class delcaration like so: [code]Class A extends Class B dependsOn( Class C)[/code]
Should I be using a specular or a metallic workflow for my PBR materials in my engine? The idea is to use this engine for a game later on. At one point I decided on specular haphazardly, but I just renamed metalness textures to specular and IDK if I even use proper shader code for the workflow anyways.
[QUOTE=Karmah;52431799]Should I be using a specular or a metallic workflow for my PBR materials in my engine? The idea is to use this engine for a game later on. At one point I decided on specular haphazardly, but I just renamed metalness textures to specular and IDK if I even use proper shader code for the workflow anyways.[/QUOTE] If you're basing your stuff off the Unreal Engine presentations you're most likely implementing the roughness/metallic workflow - tbqh if you don't know what model you implemented you should revisit your code to figure it out first. I quite like roughness/metallic because it seems very intuitive to me, but I'm not an artist really.
[QUOTE=huntingrifle;52430171][del]Like that, but with using UnrealScript, and instead of structs they are all classes. Class A uses a struct defined in Class C, but does not inherit from Class C.[/del] Figured it out with some more Google-fu, I could use the dependsOn specifier for class delcaration like so: [code]Class A extends Class B dependsOn( Class C)[/code][/QUOTE] I've returned with pretty much the exact same issue: my solution to use the DependsOn( Class C ) specifier works, but only if Class C is inside the same mod. If I have two mods, where Classes A and B are inside Mod1 while Class C is in Mod2, and the same situation exists where Class A extends Class B but needs Class C, then what can I do? The current code is using this command: [code]const LoadClassC=Class'Mod2.ClassC';[/code] Then an instance of that class in made like so: [code]local ClassC myClassC;[/code] but I get a compiler error: [code]Error, Unrecognized type 'ClassC'[/code]
[QUOTE=JWki;52434560]If you're basing your stuff off the Unreal Engine presentations you're most likely implementing the roughness/metallic workflow - tbqh if you don't know what model you implemented you should revisit your code to figure it out first. I quite like roughness/metallic because it seems very intuitive to me, but I'm not an artist really.[/QUOTE] IIRC, I could never really find a unified tutorial on implementing physically based shaders, so I kinda winged it, learning from dozens of different websites. In my code I use specular + roughness, but the only places where my surface specular is used is in the brdf for the fresnel term, and for the diffuse ratio for energy conservation. I'm reviewing my code now, double checking all my maths, comparing them against [URL="http://graphicrants.blogspot.ca/2013/08/specular-brdf-reference.html"]this guide[/URL], and planning on switching over to a metallic workflow. I've downloaded a bunch of pbr textures and built materials out of them, and they all have metal/roughness.
Sorry, you need to Log In to post a reply to this thread.