HawkRose's Forum Posts

  • Thanks to both of you for your advice!

  • Thanks for your suggestions!

    It's difficult to tell from these screenshot and your project file is inaccessible. But I would change the way the whole thing is triggered.

    I've changed the accessibility on the file, if that helps.

    That "Else Trigger once" event probably won't work correctly because numberMagic is a local non-static variable, it gets reset at the end of every tick. (unless it's inside a function)

    That part of the code seems to be working alright. That is, it skips over the magic resolution step if no characters are using magic. It's when characters are actually using magic that I run into various problems. Do you think it's still likely that the non-static variable is causing problems? Any idea how?

    Be very careful with Trigger Once condition, it can cause all kinds of problems when used incorrectly.

    Yeah, I'm kind of fumbling in the dark, doing guesswork based on other projects I'm learning from. What is the correct way to use "Trigger Once"?

    Also instead of "waits" I suggest using Timer behavior - it gives you much better control, you can pause/cancel it, run different timers per each instance, and you can use "On timer" event to schedule the next action.

    This seems like a good suggestion. I will look into it.

  • As you mentioned in the post, this way of making it will get overblown when you add detail and many things happening at once with many instances. You need more control over the gameplay and since it's JRPG I would create a turn system in an array. For each action you can add the person's turn to a new row and then run each row in order and pop off the top row when it's done. This also provides visibility of what's happening. Within the row you can include things like the target UID, even the damage calculated so you can see it before it's acted out.

    I haven't used arrays much before. Can you give an example of how you might organize one in this case?

  • I'm trying to build a combat system for a JRPG. Please pardon the placeholder assets.

    There are multiple types of actions. First the player selects. Then the AI. Then, the actions are meant to resolve in a predetermined sequence. Actions of the same type resolve simultaneously.

    What I hoped to do was:

    1) Create a text box above the head of each character using "Magic", containing text that indicates the skill that character is using.

    2) Destroy that text box and its text.

    3) Spawn an effect animation object at the location of the character's target, using an instance variable that tracks the target's UID.

    4) Display the skill animation

    5) show hitstun, calculate damage, and do a bunch of other stuff that I haven't been able to implement yet.

    So it should looks something like this:

    media.giphy.com/media/v1.Y2lkPTc5MGI3NjExNjFub2k1dG0waHZ3Y29mamJlc3dmbDhwcThlbGdweWt3MGQzbGljbyZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw/dZIUKNJS52E5tqdTHP/giphy.gif

    Right now, the system is doing what I want it to do, however, this is how I've had to code it:

    It seems to me that the effect I've produced is illusory, in that it will go straight to hell as soon as there are multiple instances of enemy and/or player. And there will probably be a lot of clutter and nonsense in the meantime. However, this is the most workable solution I've been able to reach.

    Everything else I've tried seems to have been stymied by one or more of the following problems:

    1) I'm not sure how to deal with targeting, since both the acting character and its target will both be members of the character family.

    2) Asynchronous weirdness caused by the "Wait" actions.

    3) Weird scope problems, where some elements within the loop appear not to be accessible, even after these loops are completed.

    If anybody can help me understand these problems, or point to possible solutions, I would much appreciate it.

    drive.google.com/file/d/18kHmHn-rUvJiba-nGwPef4jUxKr3al8O/view

  • I would probably do something like this:

    Another aspect of the problem is that I have a hard time understanding which conditions and actions in Construct allow me to express logical structures like this. I've reviewed the documentation pretty extensively, but many of the explanations given seem to rely on prior knowledge of programming, which I don't really have.

    If you have suggestions about conditions that would allow the system to ask "is X pending", that would be a great boon to me.

  • Your code seems to be ok up till the phase where you do the attacks. But I can't place what's amiss at that point. As you stated you have a lot of variables for the state, and it's tricky to debug where the logic error is.

    A slightly different way to go about it could be to have a single state variable to organize the different steps. I guess this is called a state machine.

    Anyways here's an example made from the free version. Although that probably made the events a bit odd looking in spots to get it to fit.

    https://www.dropbox.com/scl/fi/ugfnxtiht6kijgrqtqyq3/rpgBattle.c3p?rlkey=2igmwxg0953vcbqrv4vmf0stl&dl=0

    Could be useful for ideas possibly.

    Wow, this seems like it will be super useful! Thanks for putting it together. I will be using it to study up!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • The biggest obstacle seems to be in telling the compiler that one phase has ended, and another ought to begin. The first phase runs fine, but I can't get it to move on to the second phase in a way that handles multiple contingencies (ie both player and AI select Fight OR player selects Fight and AI selects Block).

  • I am really stumped here, gang.

    I am working on a JRPG-style combat system.

    There are three types of Skills: Block, Fight, and Magic.

    What I would like to happen:

    Player selects a skill.

    Player selects a target.

    AI selects a skill.

    AI selects a target.

    (So far, so good. The program does things more-or-less correctly up to here)

    All Block Skills resolve: Skill name displays, animation plays, numbers adjust.

    (This is where things start to go wrong)

    All Fight Skills resolve, as above.

    All Magic Skills resolve, as above.

    Things I have tried:

    For these first few attempts, I set everything up as sub-events of a single function.

    -- At first, I just set a timer on events associated with resolving Fight skills. This worked, but if nobody selected any Block skills, then there were a couple seconds of dead air before the Fight stuff started happening. Not ideal.

    --I tried toggling a "blockDone" boolean once all the resolution steps for Block Skills were complete. This never worked. Couldn't even get Fight Skills to start resolving.

    -- I told my Fight skills to wait for the "blocksDone" signal. I attached the "blocksDone" signal to the end of the resolution events to Block Skills. This worked better. Fight Skills started processing immediately upon completion of Block Skills. However, if nobody selected any Block skills the Fight Skills would never start resolving, because no signal.

    My most recent attempt has involved:

    1) Calculating the number of skills of each type that have been selected.

    2) Toggling booleans when the number of skills of a given type is equal to zero, in order to skip unnecessary resolution steps.

    3) Running each type of Skill resolution as its own function.

    The results of this attempt have been more-or-less identical to my efforts to leverage Booleans when all of resolution was handled as a chain of sub-events for a single function. That is, Blocks do what they're supposed to. Fights never get off the ground.

    I believe the problem has to do with when the system asks for the status of my booleans, versus when the booleans toggle as part of event processing. However, after much howling and gnashing of teeth, I can't think of a way to restructure the events in order to achieve the objectives stated above. Plz help?

    drive.google.com/file/d/1jpfnlE5EW4MJcQ9Z8sx3hq23bihJoAgq/view

    Addendum: Is there a way to track the values of local variables in debug mode? I've just been using global variables, setting them equal to the local variables whenever the local values change, but this seems cumbersome.

    Also, sorry, I have no idea why the formatting on this post is so obnoxious.

  • Thanks for your response!

    Usually you loop through a given path in json to find what you're looking for. Then when it matches, you use that path to look up the rest of the keys you're interested in at that path.

    What might that look like in terms of conditions and actions in construct?

    The most efficient way to me is to organize it so that order doesn't matter. You can have all sorts of different json files, and they can all be loaded into memory/parsed at the start of the game, so that you have access to all the data given you know the path or key/attribute you're looking for. Just imagine if all the files were "included" into your project as one file.

    I don't think the order matters. I've been operating from the assumption that once I parse a new AJAX.LastData, the previous AJAX.LastData is no longer accessible. But maybe that's not correct?

    I normally don't have the game modify json files, only json that is loaded into memory. Considering all the files are loaded into memory and the file that they came from is not relevant, then they don't really need to talk to each other. If you need to write back to the json file, then write whatever is relevant.

    Gotcha. Thanks again!

  • Thanks for your reply!

    I suggest you get rid of the array and change your JSON to this:

    {

    "Skills": { "Punch": {"baseDamage":1 }, "Kick": {"baseDamage":2 } }

    Does your recommendation hold if each skill has multiple keys associated with it? Base damage, energy cost, etc.? If so, would you mind explaining what the purpose of an array is, if each element can hold multiple key:attribute pairs of different types?

    2. I have lots of separate JSON objects in my project and load data into them at the beginning of the game with multiple AJAX requests.

    So if I parse Ajax.LastData, it remains parsed?

    3. There are no built-in ways to sync data between different JSON objects, you will have to do this with code. For example, instead of directly changing damage value in JSON1, make a function "UpdateDamage", which will change it in both JSON1 and JSON2.

    Thanks again for your responses. I hope my mismanagement of terminology is understandable, and not too cringy!

  • Hi!

    I've been learning about implementing JSON in Construct 3. I've read the manual, and done a little study on the wider web, but a few things still aren't clear to me.

    1) If I have an array in JSON which is, in turn, comprised of multiple key:attribute pairs, is there a way to use a given attribute to call for attributes of other keys within the same element of the array? For example, let's my JSON describes the parameters for a bunch of skills that the player can use. It looks something like:

    {

    "Skills": [ { "Name":"Punch", "baseDamage":1 }, { "Name":"Kick", "baseDamage":2 } ]

    }

    How do I tell Construct that when the player selects the skill named "Punch", it should use 1 in subsequent damage calculations, vs. 2 when the Skill is named "Kick"?

    2)What is the most efficient way to incorporate data from different JSON files into the same project? For example, skill data (names, damage, etc.) vs. enemy data (HP, attacks, etc.). I've seen an example where, I think, someone shifted AJAX.LastData to an array object as part of setup, then used AJAX to request the second JSON file, and parsed that with the JSON object. But I'm not sure whether that's the best way, or if I'm even understanding that process correctly.

    3) Related to Question 2, is there a way to make multiple JSON files talk to each other? So if data pulled from one JSON fulfills certain conditions, data in another file is altered?

    Thanks in advance for any help. Let me know if I can supply more information to aid in your response(s).

  • A delayed thanks for your response!

  • Hi all,

    I imported a custom SpriteFont, but I have discovered that it doesn't recognize blank spaces. If I tell the SpriteFont object to set text to "Hello world", it displays only "Hello". I can insert spaces by setting the text to "Hello*world" (* is not supported by the SpriteFont), but the spaces are the size of a full character, so it looks really weird. Also,*I'd*prefer*not*to*type*all*of*my*text*like*this.

    My questions:

    1)How do I get the Sprite Font object to recognize blank space/transparency in the imported image as a "space"?

    2)Is there a way to reduce the size of the "space", such that there is not an enormous distance between multiple words in a given SpriteFont text?

    Thanks in advance for your help!

    Tagged:

  • Thanks for your replies, dop2000 and Laura_D. Given the complexity of the dialogue box, I'll try your JSON tutorials, Laura_D.

  • New C3 user here.

    I'm using bbenny93's https://www.construct.net/en/tutorials/dialogue-box-lazy-people-1177 to study XML, and to look at one way of implementing a dialogue system.

    I think I understand in general terms what bbenny93 is doing: creating a JSON dictionary, and setting the key values to XML attributes in order to call lines of dialogue, and whatever functions might be related to that dialogue (animations, audio, cursor object, etc.). However, I can't understand the expressions bbenny93 is using to go about this, or why certain steps are necessary.

    Some questions:

    1)Line 50: ProjectVariables sets the key "name" equal to Function.Param(0). Which function is this does this apply to? "dialogue"? "create box"? Does it matter that "create box" doesn't seem to have any parameters? What will the value of "name" be at this point in, say, the Demo layout?

    2) Line 50: System sets the "dialogue" parameter, "dialogue_box_project_prefix" to... what? What does the expression "&ProjectVariables.Get("name")&"']/@ mean?

    3)Line 78: What in the wide wide world of sports is a'going on here? RegexMatchCount and all that follows it look like Greek to me.

    I've read this XML introduction https://www.liquid-technologies.com/xpath-tutorial, this tutorial on XML Parsing https://www.construct.net/en/tutorials/xml-parsing-209 and this one on using XML for dialogue https://www.construct.net/en/tutorials/read-xml-game-talk-518. I've also recreated and played around with the event sheets for the C3 tutorials myself. The latter tutorial says, "I hope you already understand the use of &ReferencingAVariableLikeThis&, if not, look into the Text Box tutorials as they can provide insight." So far these directions have proven too nebulous to be helpful. I also tried the Expressions and XML sections of the manual, but they weren't much help.

    If anybody can help me to understand the above, or point me in the direction of resources that might provide more comprehensive explanations of the problems in question, I'd be very grateful.