Dear forum users! In compliance with the new European GDPR regulations, we'd just like to inform you that if you have an account, your email address is stored in our database. We do not share your information with third parties, and your email address and password are encrypted for security reasons.

New to the forum? Say hello in this topic! Also make sure to read the rules.

Possible to check if two objects were destroyed?

Here you can find answered ScriptAPI topics.
Forum rules
By using the forum you agree to the following rules.
Post Reply
User avatar
Ol1vver
Superfighter
Superfighter
Posts: 69
Joined: Mon Nov 19, 2018 4:55 pm
SFD Account: olv
SFD Alias: olv
Started SFD: PreAlpha 1.6.4
Gender:

Possible to check if two objects were destroyed?

Post by Ol1vver » Sun Dec 02, 2018 2:13 pm

Hello,
Is it possible to make something that checks if 2+ IObjects were destroyed?

Example:
I have a map where in order to unlock a door you need to destroy an object with Object ID "Unlocker1", and destroy anything with Object Id "Unlocker2". If you destroy these two objects, a trigger named "ObjDestroyed" activates. Is that possible?
0 x

User avatar
JakSparro98
Superfighter
Superfighter
Posts: 530
Joined: Fri Jul 15, 2016 7:56 pm
Started SFD: PreAlpha 1.0.5
Location: Rome, Italy
Gender:
Age: 25

Post by JakSparro98 » Sun Dec 02, 2018 3:17 pm

There are more than one object named "Unlocker2" right? it's an undefined number, it can every number, isn't it?
0 x

User avatar
Ol1vver
Superfighter
Superfighter
Posts: 69
Joined: Mon Nov 19, 2018 4:55 pm
SFD Account: olv
SFD Alias: olv
Started SFD: PreAlpha 1.6.4
Gender:

Post by Ol1vver » Sun Dec 02, 2018 3:38 pm

JakSparro98 wrote:
Sun Dec 02, 2018 3:17 pm
There are more than one object named "Unlocker2" right? it's an undefined number, it can every number, isn't it?
Didn't understand the question, but what I was trying to say is:

In order to unlock a door, you need to destroy two objects

ScriptTrigger: DoorUnlock
Object 1: ThisWire
Object 2: PCThing

(in case if you didn't understand)

Or:

In order to unlock a door, you need to destroy two objects or one object

ScriptTrigger: DoorUnlock
Object 1: ThisWire
Object 2: PCThing

Or destroy:

Object 3: SecretActivator
0 x

User avatar
JakSparro98
Superfighter
Superfighter
Posts: 530
Joined: Fri Jul 15, 2016 7:56 pm
Started SFD: PreAlpha 1.0.5
Location: Rome, Italy
Gender:
Age: 25

Post by JakSparro98 » Sun Dec 02, 2018 6:53 pm

Yes, but I was asking if you need more than one object with custom ID "Unlocker", for instance, you need to destroy 4-5 objects or more (you can define the number and what kind of objects simply on the fly)

Also I want to ask, if this mechanic needs to be repeated (more than one door to unlock)
0 x

User avatar
Ol1vver
Superfighter
Superfighter
Posts: 69
Joined: Mon Nov 19, 2018 4:55 pm
SFD Account: olv
SFD Alias: olv
Started SFD: PreAlpha 1.6.4
Gender:

Post by Ol1vver » Mon Dec 03, 2018 10:32 am

JakSparro98 wrote:
Sun Dec 02, 2018 6:53 pm
Yes, but I was asking if you need more than one object with custom ID "Unlocker", for instance, you need to destroy 4-5 objects or more (you can define the number and what kind of objects simply on the fly)

Also I want to ask, if this mechanic needs to be repeated (more than one door to unlock)
I don't understand the question.
What you are trying to say is, there are 4-5 objects with one ID - "Unlocker"?

That is not necessary. They can have different IDs.

The problem I am experiencing is that OnDestroyedTrigger (or whatever it is) is triggered when one of the objects marked gets destroyed. What I want to get is: I want to do something that is triggered when all of the marked objects are destroyed (something like that, or use IDs)
0 x

User avatar
JakSparro98
Superfighter
Superfighter
Posts: 530
Joined: Fri Jul 15, 2016 7:56 pm
Started SFD: PreAlpha 1.0.5
Location: Rome, Italy
Gender:
Age: 25

Post by JakSparro98 » Tue Dec 04, 2018 10:31 pm

I was asking if you needed multiple object named "Unlocker" because you can use any quantity you want and all with the same customID, only when all the entities are destroyed the trigger will be activated, you could freely change the number of objects without code changes, but since you don't have needs I will limit myself to process what you asked at the initial post.

Here's to you:

Code: Select all

IObject Unlocker1;
IObject Unlocker2;
IObjectTrigger ObjDestroyed;
Events.UpdateCallback m_updateEvent = null;

public void OnStartup() {
 Unlocker1 = Game.GetSingleObjectByCustomID("Unlocker1");
 Unlocker2 = Game.GetSingleObjectByCustomID("Unlocker2");
 ObjDestroyed = Game.GetSingleObjectByCustomID("ObjDestroyed") as IObjectTrigger;
 Game.GetSingleObjectByCustomID("Unlocker1");
 m_updateEvent = Events.UpdateCallback.Start(OnUpdate, 0);
}

public void OnUpdate(float elapsed) {
 if (Unlocker1.IsRemoved && Unlocker2.IsRemoved) {
  ObjDestroyed.Trigger();
  m_updateEvent.Stop();
 }
}
1 x

Post Reply