Hard Light Productions Forums

Modding, Mission Design, and Coding => The FRED Workshop => Topic started by: psyhotik on October 10, 2010, 01:58:42 pm

Title: Traitor detection
Post by: psyhotik on October 10, 2010, 01:58:42 pm
Hello! I have a question: Is there a SEXP that would test if player betrays (fires on friendly units to the moment they turn hostile)? I was trying to use 'is-iff -->Hostile, Alpha 2' (Alpha 2 is immortal for dialog purposes) but it seems to have no effect... Any suggestions? :)
Title: Re: Traitor detection
Post by: General Battuta on October 10, 2010, 02:00:25 pm
Hello! I have a question: Is there a SEXP that would test if player betrays (fires on friendly units to the moment they turn hostile)? I was trying to use 'is-iff -->Hostile, Alpha 2' (Alpha 2 is immortal for dialog purposes) but it seems to have no effect... Any suggestions? :)

Use 'is-iff traitor', that should work better. And you need to use the player ship as the argument.
Title: Re: Traitor detection
Post by: psyhotik on October 10, 2010, 02:05:50 pm
Thank you very much :) I haven't noticed the 'Traitor' option. Another question: Is there a way to alter traitor debriefing via FRED or is this only possible by editing tbl?
Title: Re: Traitor detection
Post by: Mobius on October 10, 2010, 02:18:08 pm
As far as I know you need to edit the tbl.
Title: Re: Traitor detection
Post by: FUBAR-BDHR on October 10, 2010, 03:51:33 pm
You could try an event that switches the player back from traitor to hostile.  That may give you a normal debrief.  You could also set the mission to no traitor and do your own version. 
Title: Re: Traitor detection
Post by: karajorma on October 11, 2010, 05:17:31 am
Hello! I have a question: Is there a SEXP that would test if player betrays (fires on friendly units to the moment they turn hostile)? I was trying to use 'is-iff -->Hostile, Alpha 2' (Alpha 2 is immortal for dialog purposes) but it seems to have no effect... Any suggestions? :)

There's a reason why that's not working. Alpha 2 is still friendly. What happened is that Alpha 1's IFF was changed to Traitor! :p As Battuta states, if you had actually tested Alpha 1's IFF that would have worked. :D


You could try an event that switches the player back from traitor to hostile.  That may give you a normal debrief.  You could also set the mission to no traitor and do your own version. 

Either of those would work but personally I prefer to do the second one as it allows you to turn off the debrief but keep running the mission. Changing the player to hostile would screw up the IFF tests so you'd have to wait until the last seconds of the mission to do it.
Title: Re: Traitor detection
Post by: psyhotik on October 11, 2010, 08:24:30 am
Thanks for all suggestions :) I'll try the trick with changing player IFF to hostile. I just want the mission to force end (with my own debriefing if possible) when player opens fire on own units, so messing up IFF check for the rest of the mission  is not an issue in this case (at least I think so...) :)
Title: Re: Traitor detection
Post by: karajorma on October 11, 2010, 08:34:35 am
Even if that wasn't an issue I'd still have done it the other way. :p
Title: Re: Traitor detection
Post by: psyhotik on October 11, 2010, 08:42:35 am
But doesn't the 'no traitor' option mean that player can shoot at friendly units unpunished?
Title: Re: Traitor detection
Post by: karajorma on October 11, 2010, 10:18:52 am
Yep. Which is why you only turn it on using the SEXP after the player has actually turned traitor. The game automatically handles everything that way (for instance turning off rearming, command messages etc) but due to the No Traitor flag being set by the SEXP the game won't play the default "You are a traitor" Debriefing leaving you free to make up one of your own. :)
Title: Re: Traitor detection
Post by: psyhotik on October 11, 2010, 10:24:10 am
Nice one! Thanks. I'll try that :)
Title: Re: Traitor detection
Post by: ssmit132 on October 13, 2010, 01:59:29 am
Incidentally, how does the game determine when to change the player's IFF to Traitor (in normal circumstances)?
Title: Re: Traitor detection
Post by: karajorma on October 13, 2010, 02:18:32 am
Basically the game does a huge long calculation to work out what the threshold is for damage you can do to a friendly vessel and if you break it you get assumed to be a traitor.

To be honest, it doesn't do a very good job of it as there are ways to get away with all kinds of crap. I've even blown up friendly fighters and gotten away with it in the past. Having a test to see if you did 100% of the damage to a friendly ship might be an idea. :p
Title: Re: Traitor detection
Post by: FUBAR-BDHR on October 13, 2010, 02:22:25 am
If you don't have the ship targeted it doesn't seem to count.  Difficulty does seem to factor in.  Other then that it's kind of a toss up. 
Title: Re: Traitor detection
Post by: karajorma on October 13, 2010, 03:03:29 am
If you don't have the ship targeted it doesn't seem to count.  Difficulty does seem to factor in.  Other then that it's kind of a toss up. 

Code: [Select]
        //    Hit ship, but not targeting it, so it's not so heinous, maybe an accident.
        if (Ai_info[shipp_hitter->ai_index].target_objnum != OBJ_INDEX(objp_hit)) {
            damage /= 5.0f;
        }

Yes it definitely takes both of those into account.
Title: Re: Traitor detection
Post by: ssmit132 on October 13, 2010, 05:27:14 am
Having a test to see if you did 100% of the damage to a friendly ship might be an idea. :p
Then hopefully they don't get near any exploding Infyrnos. :P
Title: Re: Traitor detection
Post by: Mongoose on October 14, 2010, 04:47:51 pm
Code: [Select]
       //    Hit ship, but not targeting it, so it's not so heinous, maybe an accident.
        if (Ai_info[shipp_hitter->ai_index].target_objnum != OBJ_INDEX(objp_hit)) {
            damage /= 5.0f;
        }
An "accident."  Yes.  Of course.  :nervous:
Title: Re: Traitor detection
Post by: FUBAR-BDHR on October 14, 2010, 05:40:38 pm
Yea nothing like firing a pair of nukes with a friendly in between.  Big oops and you still don't go traitor. 
Title: Re: Traitor detection
Post by: Mobius on October 15, 2010, 01:45:28 pm
If you don't have the ship targeted it doesn't seem to count.  Difficulty does seem to factor in.  Other then that it's kind of a toss up. 

Code: [Select]
        //    Hit ship, but not targeting it, so it's not so heinous, maybe an accident.
        if (Ai_info[shipp_hitter->ai_index].target_objnum != OBJ_INDEX(objp_hit)) {
            damage /= 5.0f;
        }

Yes it definitely takes both of those into account.

Interesting, it's what I've always suspected. And it makes a lot of sense, too. :)
Title: Re: Traitor detection
Post by: psyhotik on November 18, 2010, 01:15:48 pm
Hello! It's me again. Sorry for bumping old thread but the issue is not yet resolved :\

The solution proposed by karajorma (setting alow-treason false after player turned to traitor) is not working. Game still gives default traitor debriefing. The second solution (changing player IFF to 'hostile' moments before force-ending mission)  seems to work fine BUT it gives an unexpected side effect - every time (traitor or not) the player is killed, the IFF checking event seems to activate and mission ends giving my custom traitor debriefing. Any ideas how this could be solved? :)

EDIT: Small change to clear things up.
Title: Re: Traitor detection
Post by: Scotty on November 18, 2010, 01:36:02 pm
Use a different event for the debrief check?
Title: Re: Traitor detection
Post by: psyhotik on November 18, 2010, 01:58:56 pm
Use a different event for the debrief check?

No, no, that's not the problem. The thing is that game seems to confuse the fact the player has been killed with the fact he turned traitor. To test it, make the following:

1. Create a mission with some friendly units (so you can become a traitor to test custom debrief) and some enemy units (so you can get killed and see what will happen)
2. Create the following events:

Traitor detection
-when
--if-iff
---traitor
---Alpha1
--do-nothing

chain to (with 1 delay or more):

Force end
-when
--true
--change-iff
---Hostile
---Alpha1
---end-mission

3.Create some traitor debrief with formula:

-is event-true-delay
--Traitor detection
--0

4. Play and:
  a) fire on friendly units and become a traitor - the mission will end and you will get the debrief (which is good)
  b) do not become a traitor and get yourself killed. Soon after you are killed, the mission will end (you won't get the quit/restart/quickstart choice) and you will get your traitor debriefing (which is not good)...

The number of different debriefings is not important. It seems that killing alpha1 triggers Traitor detection event true. Surprisingly when you end-mission in the same event as is-iff, the problem will not occur.
Title: Re: Traitor detection
Post by: Droid803 on November 18, 2010, 02:33:04 pm
add a "and not is-destroyed-delay" for alpha wan?
Title: Re: Traitor detection
Post by: psyhotik on November 18, 2010, 02:37:01 pm
Yup. This seems to work :) Thank you very much. It's good to have more experienced FREDers around ;)
Title: Re: Traitor detection
Post by: karajorma on November 18, 2010, 05:09:32 pm
You set allow-treason to true, not false.
Title: Re: Traitor detection
Post by: psyhotik on November 19, 2010, 03:03:29 am
You set allow-treason to true, not false.

I tried both settings. Both are giving default traitor debrief :\