This forum is locked and will eventually go offline. If you have feedback to share you can find us in our Discord channel "MythoLogic Interactive" https://discord.gg/nECKnbT7gk

Forum rules

Possible to check if IObject is damaged?

Here you can find answered ScriptAPI topics.
Forum rules
By using the forum you agree to the following rules.
Locked
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 IObject is damaged?

Post by Ol1vver » Sat Dec 01, 2018 10:47 pm

Hello,
I am making a boss fight with a giant ragdoll made out of DeadMeat. I need a script that whenever the object "Head1" gets hit, a ScriptTrigger named "BlockBullets" gets activated.
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: 27

Post by JakSparro98 » Sun Dec 02, 2018 12:29 am

This is what you asked for:

Code: Select all

Events.UpdateCallback m_updateEvent = null;
float m_totalElapsed = 0f;

IObject HitTarget;
IObjectTrigger Trigger;
float StoredHealth = 0;

public void OnStartup() {

 Trigger = (IObjectTrigger) Game.GetSingleObjectByCustomID("BlockBullets");
 HitTarget = (IObject) Game.GetSingleObjectByCustomID("Head1");
 StoredHealth = HitTarget.GetHealth();

 m_updateEvent = Events.UpdateCallback.Start(OnUpdate, 0);
}
public void OnUpdate(float elapsed) {

 if (StoredHealth != HitTarget.GetHealth()) {
  Trigger.Trigger();
  StoredHealth = HitTarget.GetHealth();
 }

}
2 x

Locked