Check if object has been activated after campaign map is loaded.

Solu9

You can change this now in User CP.
Reaction score
216
Bad title. I'll explain.

The player can interact with certain objects in each map in the campaign.
Since the player can jump back to maps already played I need to detect if these object have already been activated.

My initial thought was setting a boolean array in the map initialization in each map.
Each of these object is bound to a specific number in the array.
When an object is activated I check the array and set the corresponding number to "true"
This information I'll save in the game cache to carry from map to map.

The con with this method is that I have to set the array manually to each object, and there are like 1500 all in all...

So my question is. Is there an easier/better way to do this?
 

Accname

2D-Graphics enthusiast
Reaction score
1,463
Hard to say.
You could work on some kind of indexing system (like custom value or something) to make referencing the array positions easier.
Really depends on what you want to do with these dubious "objects".
 

Solu9

You can change this now in User CP.
Reaction score
216
The objects are just structures which, when interacted with, will change color or whatever to indicate they have been activated.
When activated they award the player with 1 Lumber. Used as ability points.
 

KaerfNomekop

Swim, fishies. Swim through the veil of steel.
Reaction score
613
Couldn't you just change the owner of the structure or something?
 

Solu9

You can change this now in User CP.
Reaction score
216
Couldn't you just change the owner of the structure or something?


I could also morph it into a naked woman.
The problem is I need to have the game remember which objects has been interacted with :)
 

DrEvil

FCRI Associate!
Reaction score
111
Are they all the same type of unit?
Can't you just loop and group over all the same type of units and add to the array?
 

Solu9

You can change this now in User CP.
Reaction score
216
Pffft.

And in the second map I do the same. And the third and so on. No need to put all of the towers from all the maps in the same array.
I'll just have a separate array in each map.

Ofc...
 

Solu9

You can change this now in User CP.
Reaction score
216
So what's stopping you from grouping all guard towers and setting the arrays from them?


Seemed like an easy solution. Too easy perhaps.

-I still need to carry the data between maps. It's not like there is 2 or 3 maps to jump between. More like 50-60.
-And how can I make sure it's the same objects that already has been activated, that are activated again.

Object A, B and D is activated in a map.
At some point I come back to this map and I need the exact same 3 objects to already be activated. Not A, B, C or B, C, D.

I can't use the same array for each map, because then the data from the just finished map is gone and all the objects in that map can be activated again.

Am I missing something obvious?
 

DrEvil

FCRI Associate!
Reaction score
111
I'm not quite sure how campaign map loading works.
Does each map have its own separate variables or do they share?

I think I got solutions for both answers! :D

Edit: The reason for gamecache is because variables aren't shared.... -_-

What happens when you switch maps, does everything get removed from a previous map?
Does it all spontaneously combust ?
What happens when you reload a map, what units are on the map?

Are variables kept from previous maps? (When reloaded)
Are they reset to defaults?

Can't you just have a trigger in the first map, that maps each unit to a specific index in an array and a boolean for activation.
Make sure that copying unknown variables creates new variables and just copy the trigger into each map?
 

Solu9

You can change this now in User CP.
Reaction score
216
I haven't actually implemented this yet. I wanted to ask here before I made some stupid ineffective system.

Although I have fizzled with the game cache before.
I had 2 maps. In each map there was a unit, and once killed the game switched to the other map.
I saved:
Life, Mana, Exp and it worked fine.
These were not stored in arrays though. I had a single variable for each unit's life, mana, exp.

All units stayed at their default locations when the map switched, no prob.
All units that was meant to be carried over did so. Got their Life, Mana and Exp set to the stored values

Can't you just have a trigger in the first map, that maps each unit to a specific index in an array and a boolean for activation.
Make sure that copying unknown variables creates new variables and just copy the trigger into each map?

Let me see if I understand exactly what you mean.

Unit array - Set in map initialization.
uTower [1] = Tower 0001
uTower [2] = Tower 0002
uTower [3] = Tower 0003
...
uTower [500] = Tower 0500

When a tower is activated set the corresponding boolean to true, and change color.

Boolean array:
booTower [1] = true
booTower [2] = false
booTower [3] = false
...
booTower [500] = false

This information is kept in the game cache.
When this map is loaded again I run this third trigger to check if a tower has already been activated.

From interger (A) 1 to 500
Loop:
If - booTower [integer A] = true
Then - Change color of uTower [integer A]
Else -
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top