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?
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.
New to the forum? Say hello in this topic! Also make sure to read the rules.
Possible to check if two objects were destroyed?
Forum rules
By using the forum you agree to the following rules.
By using the forum you agree to the following rules.
- JakSparro98
- Superfighter
- Posts: 530
- Joined: Fri Jul 15, 2016 7:56 pm
- Started SFD: PreAlpha 1.0.5
- Location: Rome, Italy
- Gender:
- Age: 25
There are more than one object named "Unlocker2" right? it's an undefined number, it can every number, isn't it?
0 x
- Ol1vver
- Superfighter
- Posts: 69
- Joined: Mon Nov 19, 2018 4:55 pm
- SFD Account: olv
- SFD Alias: olv
- Started SFD: PreAlpha 1.6.4
- Gender:
Didn't understand the question, but what I was trying to say is:JakSparro98 wrote: ↑Sun Dec 02, 2018 3:17 pmThere are more than one object named "Unlocker2" right? it's an undefined number, it can every number, isn't it?
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
- JakSparro98
- Superfighter
- Posts: 530
- Joined: Fri Jul 15, 2016 7:56 pm
- Started SFD: PreAlpha 1.0.5
- Location: Rome, Italy
- Gender:
- Age: 25
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)
Also I want to ask, if this mechanic needs to be repeated (more than one door to unlock)
0 x
- Ol1vver
- Superfighter
- Posts: 69
- Joined: Mon Nov 19, 2018 4:55 pm
- SFD Account: olv
- SFD Alias: olv
- Started SFD: PreAlpha 1.6.4
- Gender:
I don't understand the question.JakSparro98 wrote: ↑Sun Dec 02, 2018 6:53 pmYes, 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)
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
- JakSparro98
- Superfighter
- Posts: 530
- Joined: Fri Jul 15, 2016 7:56 pm
- Started SFD: PreAlpha 1.0.5
- Location: Rome, Italy
- Gender:
- Age: 25
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:
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