Jump to content
  • Advertisement

Guy Meh

Member
  • Content Count

    70
  • Joined

  • Last visited

Community Reputation

122 Neutral

About Guy Meh

  • Rank
    Member
  1. This was already asked before, but the solution provided relied on a bitwise operator (I'm using Lua) and the coordinate system used isn't the same as mine anyway. I also found this article but I couldn't identify some of the constants being used and I wasn't sure whether or not it was assuming a top-down view of the hexes, where my own hexes are viewed at a slant. My hexes are 64x32, with the sloping part being 16 pixels wide. The y value increases as you go south, and the x value increases as you go southeast. My hex grid P.S. I can't seem to embed images into my post properly. Are those not allowed in this forum?
  2. Guy Meh

    Blending method for glow shader

    Hm. So when I render the glowing parts to the glow texture, I render them a bit darker so that they don't brighten up the scene too much in the final render. Or I pick colours that don't produce extreme brightening effects after the blending. Now, this assumes that I'm rendering the glowing parts on top of a black background in the glow texture, such that the texture is completely opaque. Would it be possible though to create a texture that is completely transparent, render the glowing parts opaquely to that texture (I don't expect to have any objects that are alreayd transparent), then modify the alpha values instead of the colours themselves when doing the blur. The glow texture would be a partially transparent overlay that I could place on top of the scene texture when making the final render, where I can use standard alpha blending to make the final image. Because all I want is to be able to set different regions of the scene to have fuzzy edges; they don't necessarily have to be brightened.
  3. There are certain parts of a scene/model that I've set to glow. I don't want HDR and do not intend to use floating point textures. I just want the colours of the glowing parts to bleed into their surroundings to give a fuzzy outline...as if they were glowing. As far as I understand, the standard technique is to render the scene to one texture, render the glowing parts to a second texture (with a black background), blur the glow texture (rendering to a couple more textures), then render the original scene texture and the blurred glow texture on top of each other to the screen using some kind of blending. The blending part I'm not sure of. I keep reading that additive blending is typical. But wouldn't that cause many colours to approach white or otherwhise not preserve their original colour. For example, if I have an orange (R= 0.5, G = 1.0, B = 0.0) face that's set to be glowing, and I render the face to the scene texture and the glow texture and then blend them together, I end up with yellow (R = 1.0, G = 1.0 [2.0 uncapped], B = 1.0). What kind of blending do I need if I want to make certain regions in the scene glow while still preserving their original colours?
  4. Guy Meh

    Keyboard focus for GUI

    Quote:Original post by Decrius I too have a tree (and even tree's within leave's) Wait. Wouldn't a leaf with a tree inside it just be a branch? :P This is the design I'm leaning towards: I'm going to have an Application, which will be polling for events as per my multimedia library and sending these events off to the widgets. So, this Application is the root of the widget tree. The Application would have a list of the topmost widgets (the first level of the tree). Mouse events are fairly easy to handle: for movement I can just send them off to all active widgets and let them deal with it, while mouse clicks involves a hit test. For keyboard events, the Application can have a pointer to the focused widget, and send keyboard events directly to it. If there's more than one widget that accepts keyboard input, the focus can be changed by clicking on the widget with the mouse (I'm avoiding Tab since I may want to use it for other things). Now I'm left with how to manage the focus. First there's determining if a widget accepts keyboard input in the first place, which is important when the GUI is first loaded and the relevant widget should have focus immediately. Giving all widgets an acceptsKeyboard boolean is probably ugly, but I'll probably have to give my widget class methods for handling keyboard events anyway to avoid downcasts when passing along events, so one more method wouldn't hurt. Then there's switching focus at runtime. A widget would have a grabKeyboardFocus method. For this to work, a widget would need a pointer to its Application, which means widgets need to know their parents. There's nothing wrong with that, but it makes things a bit harder to keep "clean".
  5. I'm designing a GUI system and I need to make a decision on how keyboard focus will work. My system will be a tree of widgets. The application/root widget will poll for events and pass the current event to its children. To keep things simple, I'm trying to avoid or reduce "focusing" as much as possible. This is fairly easy to do for mouse input, since the events can tell the position of the mouse and all widgets have a rectangle, but not so with keyboard input. If I am displaying a set of widgets that can respond to keyboard input (e.g. text boxes) how should my system give focus to one of them, and how should keyboard focus switch between the widgets?
  6. Quote:Original post by Zahlman Quote:Original post by Guy Meh This makes me wonder: for a game, would state be maintained by passing the old state to a function that returns a whole new state that represents the next frame? Yes. This can often be optimized behind the scenes so that it actually works the way it would in an imperative language (making a change to the existing data, instead of making a modified copy, rebinding to the copy and allowing the original to be GCd). That's certainly a relief. I suppose anyone may be initially scared off by the game state been apparently duplicated each frame. I imagine the state "duplication" could have other uses too. I'd expect recording replays would be easier, and the functional environment might even allow some kind of time travel worked in. :) Quote:Original post by Sneftel For more information, get to know monads in haskell, particularly the State monad. Ah geez, do I have to? :P It seems all the stuff I've read on monads either go right over my head or look like hacks to get imperative programming back into a functional program. I know monads are used for I/O, but surely swinging the state structures around inside a recursive function representing the main loop is enough. P.S. I suppose I'll insert a "choose a language for me" plead here. It has to at the very least work on Mac OS X since that's what I'm using. I'm leery of Haskell since it seems to use monads for everything but the most basic tasks. Erlang seems to be a good choice since it seems to be one of the few functional languages with extensive use outside academia (it's even used for Wings 3D) but I'm not sure how "purely" functional it is. Clean looks like another good choice since it's like Haskell but doesn't use monads. Obviously, since I'm thinking of games here, I want a language that has a library for graphics and other things games need (though I have to wonder what rendering graphics in a functional environment would be like).
  7. Just trying to get a handle on the idea of functional programming, especially in how it can be used in games. As I understand it, functional programming doesn't allow any kind of state. So, I can't pass a structure into a function and be able to modify the structure's data there. This makes designing for games tricky, since games are pretty much nothing but state. The only place where state can exist in a functional program is in function parameters (and, I guess, return values). This makes me wonder: for a game, would state be maintained by passing the old state to a function that returns a whole new state that represents the next frame? Lets use an example. Say I have a structure representing a ball with an X and a Y position. Each frame I want to update the ball's position. Say I do this by passing this ball to a moveBall function. In an imperative language, moveBall would modify the ball's X and Y values directly and could be declared void. If I understand functional programming correctly, moveBall would instead return an entirely new ball to "replace" the ball passed as a parameter, where the old ball was used to come up with the X and Y values the new ball needed. If I have a list of balls, I'd pass the list to a function that will generate a whole new list with wholly new balls that conceptually replace the old balls, instead of the function modifying the balls in-place. Am I understanding functional programming right?
  8. Guy Meh

    RPG hit points that aren't hits

    Quote:Original post by theOcelot Let me see if I've got this all right. Stamina is a measure of your ability to avoid attacks and such. Stamina is reduced (or put another way, you get tired) when an attack is dodged, instead of reducing hit-points or damage. Not really. Stamina can include damage, but also includes dodging/blocking. It's mostly evasion, actually. When I see a cinematic fight on TV (I'm going for "movie realism") I mostly see blocks and parries until that final blow that decides the winner. Really, Stamina is hit points with a name change and different assumptions. Quote:You could just allow them to be a very big deal ("Oh, crap! A magician!"), but balance their cost accordingly. I'm starting to lean towards this. From the perspective of your average medieval adventurer, a gang of axe-wielding goblins is one thing. But if an old man causes a wall of fire to close in on you, it'd be a pretty big deal. Quote:Original post by Edtharan IF you just rename Hit Points, they are sill hit points. I've already done the renaming, but I need to make other modifications so that it's not just renaming. Generally, I'm seeing a lot of support for the two-bar system for health. I suppose this model makes sense. Evasion and minor scratches may be rolled into the Stamina bar (not the same Stamina as my Stamina proposal). Real wounds may be rolled into the Health bar (or, use your favourite body-part/wound simulation). I suppose this grants the flexibility of most attacks affecting Stamina first, but more powerful attacks like magic and explosions affecting Health directly. Anyway, here's some ideas I've had. To recap, the gist of what I'm going for is that I want to use hit points, but I want to treat hit points as more than just a model of physical injury. So I need to determine what mechanics and what stats I need. A good way of approaching this is probably being more descriptive about what happens when character A attacks character B. First, suppose I use two physical stats: Strength and Agility. Strength controls your toughness and the force you may withstand and dish out. Agility is your speed, flexibility, and co-ordination. When someone attacks another, the defender may deal with the attack in four ways: dodge, block, parry, or simply get hit. Dodge The defender avoids the attack (or the attacker misses due to clumsiness). Compares the attacker's Agility to the defender's Agility. The weapon's reach may give the attacker a bonus; longer weapons are harder to escape from. Block The defender stops the attack (covers with shield, grab's attacker's weapon, etc.). Compares the attacker's Strength to the defender's Strength. The weapon's force or weight may give the attacker a bonus; heavier weapons like maces are harder to stop. This force may be tied to the attacker's Strength; weaker attackers may receive less benefit. Weapons or other equipment, especially shields, may give a bonus to the defender in blocking. Parry Instead of stopping the attack, the defender redirects the attack away from himself. I can see this both comparing the attacker's Strength to the defender's Strength and comparing the attacker's Agility to the defender's Agility. Agility is for placing or avoiding the parry, Strength is for holding or forcing through the parry. Some weapons may be easier to parry other weapons with, giving a bonus to the defender. Some weapons may also be hard to parry against, giving a bonus to the attacker. Hit This is where an attack represents physical contact between the defender and the attacker's weapon. Compares the attacker's Strength to the defender's Strength, like in blocking. I may possibly allow the attacker's and defender's Agility to be worked in as well, since Agility may help the attacker make a more precise attack while it may help the defender avoid the precision strike. Again, like in blocking, the weapon's force/weight may give the attacker a bonus. While this bonus may be affected by Strength, weapons may also have a precision bonus affected by Agility. This would also be where I'd factor the defender's armour in. The effectiveness of the different forms of defence depend on the attacker and defender; a fast character may dodge more often when against a slow character. Some defences may also grant certain modifiers; parrying may give a defence penalty to the attacker to represent the defender's coming counter-attack, since the defender would get to attack next turn. However, I'm unsure how to choose a defence for a given attack. I don't want the player to have to choose a defence every time he's attacked. The defence types also need to be balanced enough so that a character's defences against another character will not just be dodges because that is the Best Option right now. I suppose I could just pick a defence at random, but I would prefer some player control and (possibly semi-)predictability.
  9. Guy Meh

    RPG hit points that aren't hits

    I'm not sure I like the systems with two hit point bars, one meaning defence and the other meaning real health. If we assume damage means "this axe is slicing into your flesh," and consider the amount of "damage" that most weapons of war do in real combat situations, any attack to your "vitality" would drop it to pretty much zero. So you still effectively die after one hit without dodging, so there's no real point to having the vitality bar in addition to the stamina bar. The only place I see a use for the vitality bar is in handling unarmed attacks (punches won't really kill you right away, I guess) or handling large monsters (I'm sure Godzilla can take a few whacks with a halberd). I might just abstract those cases away into Stamina though. I do not intend to get rid of hit points. I do not intend on making combat more "lethal" than the combat of your typical commercial RPG. I just want to make the representation a little clearer. I could even do this solely through the animation. When you hit a monster in most RPGs, your attack passes through the monster and takes X damage. I can change it so that when you hit the monster, he blocks your attack or he jumps out of the way...actions represented by X damage. It's the same mechanic, but now it has a better presentation. Presentation isn't good enough for me though; I want the mechanics themselves (how Strength or Agility or Constitution are used if I use those stats, how damage is calculated, how armour works, etc.) to indicate that hit points (Stamina) are an abstraction of how long you can duck, parry, and do other evasive maneuvers. Some of the Stamina could represent your character being able to absorb a direct hit, but that would only truly apply to really strong/tough characters or characters with lots of armour. Stamina would be all dodging for weak but nimble characters, since that's technically all they have (where, if they're really nimble, they'd have as much Stamina as the tough characters, but should feel different gameplay-wise). P.S. Edtharan's "drain" as a new name for "damage" is interesting, but I'm not sure how well it sticks with me. This is completely arbitrary, but it just doesn't have the same ring to it. :P
  10. Hit points. Everyone likes to complain about them, but they're just too damn useful. People with one hit point acting as healthy as people with a million hit points sounds weird, but degrading your stats and performance as you take damage creates a positive feedback loop where you basically can't make a comeback as soon as you're hit once. Body part systems are compelling, but they don't completely solve the problem of the ridiculous number of hits you can take. Body parts take us from "get stabbed a million times and live" to "get stabbed in the chest/leg/whatever a million times and live." All of these systems ignore the fact that most weapons are designed to kill you will kill you in one or two hits. I think I've heard people suggest we keep hit points low and hope dodging takes care of it. But if we only use the standard percentage-chance-to-hit mechanic for dodging, then we might as well have "flip a coin; heads = you die." If you're still not convinced, read this article. The context: I'm trying to develop a turn-based cRPG with a single protagonist that can expect to fight lots of monsters. The combat style will be heroic fantasy: I do not want to simulate reality, I want to simulate our favourite action movies and cartoons. If stats are in the 5-15 range, my game should look like the Lord of the Rings movies. If stats are in the hundreds to thousands range, my game should look like Dragon Ball Z. I'm also against to-hit chances; all attacks will always hit. I actually thought of having attacks do constant damage and getting rid of other random elements; my system would be "diceless." I hoped this would encourage tactical play and discourage players from reloading their save a million times until they get a good roll. Plus, I figure the lack of dice worked out well for Chess and Go. Hit points are your general ability to survive combat and not your measure of physical injury or lack thereof. When a goblin swings his sword for X damage at you, that X damage is how hard it was for you to avoid getting truly hit. The damage may have been a scratch, or it may have been you dodging, blocking, or parrying. Lots of people have said on these forums that this was what hit points were meant to represent in original Dungeons and Dragons. My aim is to make this representation more obvious. To start, I guess I'll rename hit points to Stamina, though that's been done before. Anyway, Stamina would be a percentage; character statistics and equipment would increase/decrease damage percentages done for an attack. Damage is something I can't come up with a better name for. I also want to get rid of healing items (lost Stamina doesn't really represent injuries to heal). Instead, Stamina would regenerate in such a way that you'd have enough Stamina to handle a handful of monsters and it would be full in time for the next fight. The only things that would be problematic, if I strictly stick with the "most attacks are evaded" metaphor, are magic and area-of-effect attacks. If a character is caught in a fireball, how do I explain the allegedly non-fatal damage he took? Anyway, I've tweaked the Stamina bar itself. Now I want to design the character and equipment stats, as well as the general combat mechanics, to better reflect what Stamina means. I want just enough character stats to describe a variety of characters that are equal but play differently enough to justify multiple playthroughs (this is the extent of my game's "role playing"). I also want to balance this system for characters that don't use weapons or armour for the benefit of players who want to play a martial artist or a barbarian with nothing but an axe and a loincloth (not to mention all the wild beasts you'll meet in the countryside and dungeons). Unfortunately, I'm sort of drawing a blank. I get the feeling that the stats in most RPGs assume each attack is actually connecting, and I want to get away from that. That makes this design daunting though, since I can't just copy and past the stats of my favourite existing RPG.
  11. Guy Meh

    Multiple AIs with one Lua state

    Quote:Original post by Sneftel Dude, did you even read the link I posted? That was exactly what I advised you to do. *feels embarrassed*
  12. Guy Meh

    Multiple AIs with one Lua state

    I found Kambiz's solution interesting. So, for each script, I'd enclose all of the functions in a table, and the table name is different for each function. This solves the problem with function names colliding, and is especially good for objects that don't need their own state. I was hoping to avoid putting any Lua AI state inside C++ since I wanted my AI's to have as few assumptions as possible so that I could experiment with any AI I wanted. Don't worry about how the AIs detect their environment; I pass in all required information when I need to. ddn3, I noticed that your main program is another Lua script. How different should I expect it to look in C++? Also, is there any way to replicate some of the repeated code in the scripts like the header in C++ (like, say, when the script file is loaded) so that there's less work to do in the script files themselves?
  13. Guy Meh

    Multiple AIs with one Lua state

    Quote:Original post by ddn3 Just declare all functions and variables of the script local so it doesn't write into the global table overwritting each others implementation, unless that is what u want ( ie a shared global data or function between all the instances of the script ). This was sort of what I was trying to get at. NPCs with the same AI script share the functions but keep their own instances of the local variables. I suppose, to make it easier, any persistent local variables an AI would use would instead be stored in a single table instead of be scattered around the script file, though that doesn't solve the function name clashing between multiple AI scripts. Quote:Again alot of convoluted steps just so you can write scripts which use exact same named functions ? Is this a concession to the designers who don't want to or know about namespace and OOP ? Technically, yes. My scripts in general are basically implementations of C++ methods except that (a) I don't want to have to recompile and (b) I want to program in a higher level language. I'm just scared by all the solutions offered so far because they look like a lot of boilerplate code, and I wanted my scripts to be fairly minimal. Besides, I figured much of the work done in these scripts would be procedural in nature anyway (all of my OOP is in the C++ side). Quote:EDIT: ofcoruse u can put it all in C++/C Lua has a complete C api which duplicates every single facet of the normal Lua syntax, but why would u want to do that when u can dispatch any global Lua function from C/C++ with ease? So that I'd be able to put less code in my scripts. If my scripts need code to manage the scripts, I feel I might as well code my entire game in Lua. Again, if Lua is not designed for the kind of scripting I'm trying to fit it in, is there another language that follows my way of thinking better? </rant> In an attempt to prove that I've learned something from this thread; if this is what my original script looked like: local variable1 = foo ... local variableN = baz # Functions called by NPC objects in C++ function nextAction(arg1, ... , argN) # Could these be local? ... return actionCode end function currentState(arg1, ... , argN) ... return stateCode end ... # Functions only this script uses local function blarg(arg1, ... , argN) ... end ... Then I have to rewrite the script like this? AI { variable0 = foo, ... variableN = baz, # Functions called by NPC objects in C++ nextAction = function(arg1, ... , argN) ... return stateCode end, # Since this is a table, does a comma go here? currentState = function(arg1, ... , argN) ... return stateCode end, ... # Functions only this script uses blarg = function(arg1, ... , argN) ... end, ... } Here, is AI treated as a function that returns a table (in C++)? And I think I missed how to handle different NPCs that use the same script (with different values for their "local variables").
  14. Guy Meh

    Multiple AIs with one Lua state

    So...if I have a script like this: ---- # ai.lua # May or may not have local variables up here (which could be declared # local but might not be because I'm lazy) # And remember: more than one NPC can use this script, so the state # variables declared here would have different values for each NPC. function nextAction() # Do cool stuff ... return stuff end function getState() # More stuff ... return stateCode end # Not called in C++, so I might want to declare it local. function helperFunc(moreStuff) ... end ---- The suggestions here have generally been to perform extra processing in the script files (this is what I called "jumbling things up"). In addition to the actual AI code, these scripts would contain processing code to differentiate each script/chunk in the Lua interpreter. Code that would probably be the same across scripts besides maybe a few name changes. Is there no way to put this processing inside the C++ half?
  15. Guy Meh

    Multiple AIs with one Lua state

    I'm starting to wonder if Lua is even appropriate for the kind of scripting I want to accomplish here. Like the creator of the thread Sneftel linked to, I sort of want my scripts to be something that any object can just run; e.g. an NPC's think() method is runAIScript("myScript.lua"). I wanted to be a bit more elaborate by having these scripts store functions the objects could choose from, but it's the same spirit as far as I can tell. But with Lua's global name space it seems I either have to use multiple Lua states, jumble my scripts up with tables and stuff, or maybe just give up and write my entire game in Lua. I chose Lua because it was popular, fairly minimal, and could also be used for data definition. However, is there perhaps another scripting language that would be a better fit for this structure.
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!