Weird thing happening when casting a spell

I have a script that fires on the OnDamage of a placeable. When that object is damaged by something magical, I’m using this function here: GetDamageDealtByType(DAMAGE_TYPE_MAGICAL) >0 a bunch of stuff is supposed to happen. If I use the PC casting a spell that damages the placeable, everything is fine. If I however, use one of the companions to cast a spell, everything works EXCEPT one thing. I do a thing like this: SendMessageToPC(oPC,"You destroy the object."); This message doesn’t show up if I use one of the companions damaging the object by a spell. How can this be? Every other thing that’s supposed to happen beside this does happen.

Edit: Does the game sense that I used the PC to damage the placeable object and only send the message if I use the PC?..But why in that case?

What is the oPC defined as? If it’s GetFirstPC(), change it to GetFirstPC(FALSE)

1 Like

Ah, yes. That’s correct. Thanks, I’ll try that then.

So, if you send the message to the PC, and your not controlling him at the moment, the message won’t get through? Didn’t think that was the way it worked…

In a single player game, GetFirstPC() or GetFirstPC(TRUE) is always the main character regardless of who you are currently controlling. Whereas, GetFirstPC(FALSE) is the party member you are currently controlling.

1 Like

Yes, I get that part, travus, but I still thought that in the chat-window, or what it’s called, a message to the player always got through here, regardless of who you’re controlling at the moment,but maybe that’s not how it works with the SendMessageToPC(oPC,“bla bla”) function. Is the chat-window somehow connected to if you control the PC or a companion then since you can’t see the message if you’re controlling a companion and using the oPC = GetFirstPC()?

I couldn’t tell you the engineering behind it. But I’m guessing it’s like that because there is a multiplayer component behind the scenes, where messages sent to the main PC would only be seen by the player who started the campaign, for whatever reason.

1 Like

Ah, ok. Yes, that would make sense.

Thanks for helping out, travus!

1 Like