Pulstar's Recent Forum Activity

  • Hi, I am doing an inventory system myself currently, displayed as a grid (it works so far) and also did some stuff related to it in the past.

    1) The example in the tutorial has a function for that "AddToInv". From what I understand you pass the ID of the item as parameter 0 when you call the function "AddToInv". Look into the capx of the tutorial for the function call action in event 6.

    2) If you are using the exact same functions as the tutorial you can't just change to the height to 6 to have a 6 by 6 grid as the example uses row 1 on the Y axis to store the number of items of a given ID.

    There are basically two approaches here, both are valid and possible to use, but I believe the first one is a lot easier to manage (and I used it myself):

    A) Always use the X axis to store items and the Y elements for each X axis element as the items properties. So have an array of 36 width with whatever height you need (I do not know what information besides item name you need to store in the array).

    Advantages:

    • very easy to add remove new items from the array, as you can just pop and push, and use "array.width-1" to retrieve the index of the last added (empty) x element, and don't need to do custom functions for it.
    • counting empty space or number of items is easy (equal to array.width).

    Disadvantage:

    • requires a bit of tinkering to have it display as an item grid. Basically you need to map a one dimensional X index to a row/column combination. Not hard, but it is some extra work. But not much as your inventory slots will need a row and column position anyway, regardless if you go with a 2D array or a 3D array.

    B) Do a 3 dimensional array, with x and y being grid position and z-axis elements being item data. IMO this is a lot better for maps or other grid-based structures where you need to check relative position, calculate distance, angle or do any kind of shapes. Personally I use a 3D array for a tilemap.

    Advantages:

    • easier to map to a grid

    Disadvantages:

    • counting empty slots or finding an empty slot is more difficult.
    • you can't just add a new item by pushing a new X level element easily. Well you can, but you are basically creating new slots at the same time. So to use the array effectively, you would need to have logic to find if you have empty slots, where there is an empty slot and if no empty slots are available to push a new array element.
  • In your situation I figure spawn might be more convenient.

    I would remove the containers, otherwise you will end up with creating too many detectors and badguys. Bah, I am not sure if this would not create a feedback loop if you forget to remove the containers. Badguy spawns detector via event, detector spawns rest of container on event creating new badguy, badguy spawns new detector via event etc.

  • Yeah, I read that was the case. So, should I give each badguy a variable, put the detectors in each badguy's container, assign a variable to all the detectors and badguys, and pick each of them and give them the nearest UID?

    Or should I just duplicate code?

    Do something like below.

    On family "badguy" created

    For each "badguy"

    create/spawn detector

    set variable "detector.parent" to "badguy.UID"

    Then if the detector colides with whatever it is to collide with do:

    On detector collides with whatever

    for each detector

    pick badguy by uid [detector.parent]

    do events for badguy

    Should work IIRC. Let me know if it does not, I will be using a similar method to link inventories to NPCs and Loot Containers in my current project.

    Also family.uid=object.uid, you can also use that to check if a family member is a particular object type IIRC.

  • You could turn it off with a first subevent in the event block for the object, do whatever picking/collision condition in the next sub-event and re-enable the solid behaviour in the 3rd sub-event. If done within the same event block this should have no impact on other events.

    I used a similar solution for a tilemap with multiple z-levels when I needed to do fog-of-war. Seemed to work.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Please provide a new download link/URL, it doesn't appear to work.

    However there is one reason why it could be saving just one block, you need to do the saving action for each block objects, so a for each loop needs to be used. This is usually the case when an action is done just for one object correctly in an event, and what you are describing basically requires the use of a for each loop.

  • I assume the tiles are made of sprite objects and you are not using a tilemap.

    If you need to use for each, first set all the limiting conditions and to for each as the last condition. For each is slow so it is best to limit the instances it checks. With so many isometric tile objects you want to avoid doing for each unless necessary.

    Also why are you checking it every tick? What is the purpose of it? Is there not some particular triggering action that mandates a check which could trigger a function?

  • > Don't move the tilemap - scroll the viewpoint using 'System> Scroll to' events.

    >

    I better explain myself better. My tilemap map has its own layer.

    7-etc.

    6-etc.

    5-skills

    4-Map

    3-UI

    2-game layer

    1-background1

    0-background2

    Can you "scroll to" using only a layer? I imagined that would only move the viewport and i need to move the tilemap within the map layer only

    Set parralax to 0,0 on the layers not containing objects that have locations on the map (so any UIs, minimap/worldmap windows etc.), that way the layers will not scroll when any scroll commands are issued.

    For finding the portal coords you will have a bigger challenge, depends how many portals you have per map. Personally I am doing a random map generator myself at the moment and I store all tilemap data within an array that uses Z-levels to store different info about a tile (such as bitwise sum for autotile, passability, fog of war visibility/discovered status etc.). So if you also use a similar method you could iterate through the map array until you find the right portal tile and upon finding it fire the whole scroll2portal function.

    The easier way would be to not have the portal as a tile but as a sprite object drawn/created on top of an empty tile. That way you could use regular picking via events which would make the whole thing easier. I use a similar solution for some objects myself, most notable doors as they are animated and need additional data such as open/closed state and will later use it for loot boxes.

  • In theory yes (never bothered to do it myself but the functionality is in place). You will need to retrieve the correct answer from somewhere and store it in a string, but I assume you will be loading new questions via events anyway so you will be doing it then. Once you have text variable [answer] stored do the following on text changed in textbox.

    event

    condition

    User finishes entering answer and confirms (clicks a confirm button or presses enter or something, don;t use the textbox changed text condition as it triggers every time when you type inside it)

    no actions

    sub-event -1

    condition

    textbox compare text to text stored in [answer]

    action

    call function "correct"

    sub-event -2

    condition

    else (system conditons)

    action

    call function "wrong"

  • Hi, I think I know what you want to do.

    First you need to make sure nothing else is setting the scrolling (not sure if you use scrolling to the player or if you have free scrolling in your project).

    Easiest way to do it is with some trigonometry, but you also need to store the scroll to points, either create two global variables called scroll2x and scroll2y or add those as instance variables to the player, maybe even create an object that is invisible called camera and have it store all kinds of variables related to scrolling mode. The reason why the latter might be more useful is that you can use the object as a storage for all kinds of boolean variables (like IsScrolling2Portal).

    Regardless, here is an example, because it was faster to make this than explains:

    https://www.dropbox.com/s/m9f65q4mn5yv0 ... .capx?dl=1

    It took me longer than expected to make this, mostly because I forgot the proper order of parameters for distance and angle functions. Mornings are not my best time of the day.

    I cheated a bit as I set scroll2x and scroll2y in the same event when picking the random location of the portal tile instead of searching for it in the tile map. Normally you will need to obtain it otherwise somehow, assuming your maps are not randomly generated that should be fairly easy to do.

  • Please see my answer in the below topic, there is also a capx showing how to do it there:

  • You do not have permission to view this post

  • Hi SpyDaniel, there are multiple ways to do this, some very complex (but also flexible, great for turnbased strategy or RPG gameplay with lots of stats defining units or characters). But the basic structure would be:

    [construct 2 expressions are in brackets]

    Conditions:

    On event trigger (attack animation end or frame X of animation, or on a function triggered by the attack):

    Pick the player object (not needed if there is just one)

    Actions:

    add to variable - [choose(0,0,0,1)]

    ^ choose picks a random choice out of the defined possibilities, in this case 3 zeroes and 1 one value. So you have 25% odds of 1 getting added to the variable.

    If you want more complex logic (but easier to maintain and also change while the game is running thus more dynamic), you could do for example an event block as below with the same initial triggers but two sub-event blocks:

    Conditions - same as above.

    Subevent 1 conditions - nothing (leave it empty, this is needed only so that the number can be checked by the conditions in the second subevent)

    Subevent 1 local variable - number type [Roll = 0]

    subevent 1 actions - set variable Roll to [random(0,100)]

    end subevent 1 block

    subevent 2 conditions - if Roll < 25

    subevent 2 actions - add to variable [1]

    End subevent 2 block

    ^The above is probably the best structure if you want to have flexibility. Basically Roll can be set in any way you wish, you can use a random number within a range, add another variable to it (static player bonus to mining or a multiplication bonus like [Roll*player.miningefficiency] object variable). You can set up a custom function for dice rolling to determine the roll value setting Roll etc.

    Also in subevent 2 conditions you can test to see if roll is below another variable, for example if Roll<player.miningskill (mining skill being a variable that increases with better gear or experience). That would effectively translate to increasing player odds of adding to the mystical variable (like mining experience? Or maybe loot?).

Pulstar's avatar

Pulstar

Member since 10 Jan, 2016

None one is following Pulstar yet!

Trophy Case

  • 9-Year Club
  • Email Verified

Progress

10/44
How to earn trophies