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,462
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.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top