OpenXcom Forum

Modding => Work In Progress => Topic started by: The Reaver of Darkness on August 06, 2016, 08:18:04 am

Title: How do I make psionics require same-turn discovery?
Post by: The Reaver of Darkness on August 06, 2016, 08:18:04 am
I know there's already a default mod that forces psionics to only be used when the user has line of sight to the target. But in default settings X-Com soldiers can only use psionics on aliens whom any of your units have seen in the same turn, however the aliens have no such restriction and can use psionics on your units when none of the aliens can see your units. I want to make it so that the aliens have to have any unit see your soldier that turn in order for them to use psionics on that soldier. The one using the psionics doesn't need to see them, but at least one of the aliens does. That's what I want.



Also I want to put in the TFTD default of ranged psionics into UFO Defense, such that psionic attacks are weakened with range.
Title: Re: How do I make psionics require same-turn discovery?
Post by: Solarius Scorch on August 06, 2016, 12:47:53 pm
It's a tough problem.

Once an X-Com alien spots you, it knows exactly where you are for a period of several turns, as per Intelligence stat. It can't shoot you if it doesn't see you, but it can still psi you up.

So the only way to prevent them from remembering where you are is to minimize their Intelligence, which will also make them very stupid.
Title: Re: How do I make psionics require same-turn discovery?
Post by: The Reaver of Darkness on August 06, 2016, 09:39:55 pm
What if all of the aliens on the map shared the knowledge of your troops' location, but only for one turn?

If their intelligence attribute was reduced, it wouldn't make them stupid. They're already stupid. AFAIK the only thing it affects is their "memory" which is really cheating on their part anyway.
Title: Re: How do I make psionics require same-turn discovery?
Post by: ivandogovich on August 06, 2016, 10:18:45 pm
What if all of the aliens on the map shared the knowledge of your troops' location, but only for one turn?

That is exactly what happens.  When one of your troops is spotted, they all know where it is and will continue to track it mentally.  The Intelligence score is how fast they lose track of you.
Title: Re: How do I make psionics require same-turn discovery?
Post by: The Reaver of Darkness on August 07, 2016, 12:48:36 am
That is exactly what happens.  When one of your troops is spotted, they all know where it is and will continue to track it mentally.  The Intelligence score is how fast they lose track of you.
That doesn't appear to be how it works. I just tested with a sectoid leader. All other aliens on the map were eliminated and the sectoid leader can use psionic attacks on units it cannot see and has never seen. Even after many turns, it is still able to use these attacks. I reduced its intelligence from 7 to 1 and then stuck it in a room and had my soldiers all evacuate the area. It didn't see a single soldier of mine for eight turns, yet was still able to mind control my soldiers every turn.
Title: Re: How do I make psionics require same-turn discovery?
Post by: ivandogovich on August 07, 2016, 12:53:12 am
That doesn't appear to be how it works. I just tested with a sectoid leader. All other aliens on the map were eliminated and the sectoid leader can use psionic attacks on units it cannot see and has never seen. Even after many turns, it is still able to use these attacks. I reduced its intelligence from 7 to 1 and then stuck it in a room and had my soldiers all evacuate the area. It didn't see a single soldier of mine for eight turns, yet was still able to mind control my soldiers every turn.
When it mind controls a soldier, it sees them and any in their view too. 
Warboy might be your best resource as to how the actual code works.
Title: Re: How do I make psionics require same-turn discovery?
Post by: The Reaver of Darkness on August 07, 2016, 01:28:31 am
When it mind controls a soldier, it sees them and any in their view too. 
It seems to gain vision of my whole squad when it sees any one of them. I can hide the two psi-weak soldiers from the rest, I can control the alien and have it face a wall for multiple turns, and it'll still be able to mind control the psiweak soldiers even though it hasn't seen any of my soldiers in a long time, and the psiweak ones are on the other side of the map.
Title: Re: How do I make psionics require same-turn discovery?
Post by: Starving Poet on August 07, 2016, 02:05:16 am
That doesn't appear to be how it works. I just tested with a sectoid leader. All other aliens on the map were eliminated and the sectoid leader can use psionic attacks on units it cannot see and has never seen. Even after many turns, it is still able to use these attacks. I reduced its intelligence from 7 to 1 and then stuck it in a room and had my soldiers all evacuate the area. It didn't see a single soldier of mine for eight turns, yet was still able to mind control my soldiers every turn.

After turn 20 or less than 3 aliens left - they get full knowledge of your troops location.
Title: Re: How do I make psionics require same-turn discovery?
Post by: The Reaver of Darkness on August 07, 2016, 03:53:02 am
After turn 20 or less than 3 aliens left - they get full knowledge of your troops location.
Ah, that explains it.

I was running a second test using lots of smoke to prevent my soldiers from being seen, and it seemed to be working but then they began attacking one of my soldiers that they couldn't see. It probably happened on or after turn 20.

So how do I change that? I want to make it so they never get vision of my squad, at least the ones that can perform psionic attacks anyway.
Title: Re: How do I make psionics require same-turn discovery?
Post by: Starving Poet on August 07, 2016, 05:22:38 am
You'd need to modify the executable.  It shouldn't be too difficult to add some sort of ruleset that disallows targeting based on a specific 'turnssincespotted' variable.

As far as the turn 20 / 2 alien rule - I don't know how that works internally - whether it changes the turnssincespotted to 0 or something else.  I guess that would be easy enough to check - if you have a save from past turn 20, just do a search to see what that value is. 

Title: Re: How do I make psionics require same-turn discovery?
Post by: The Reaver of Darkness on August 07, 2016, 09:21:28 am
I have such a save file but I have no idea how to look up the value. You're saying something about looking at the executable code?
Title: Re: How do I make psionics require same-turn discovery?
Post by: bladum on August 07, 2016, 03:49:23 pm
why not make it work like that:

Alien will remember any soldier he spots in his field off view for N turns where N = intelligence, other aliens are not aware of these soldiers
Alien will make other aliens remember any soldier he spots in his field of view for K turns where K = group intelligence (new alien stat)
Alien will pass his memory of soldiers to any other alien that is with his field of view for M turns, where M = telepathy (new alien stat, optional, very complex to implement but could be helpfull to create chain of memory strategy for aliens, so xcom can pass grenades and aliens could pass positions of xcom soldiers that way)

So IQ =  5 and Group IQ = 1, means that alien will remember spotted soldier for 5 turns + he will make other aliens remember them for additional 1 turn

Using this engine we could implement standard behavior from X-COM but also bring much more for mods.

Tom
Title: Re: How do I make psionics require same-turn discovery?
Post by: Starving Poet on August 07, 2016, 05:35:28 pm
I have such a save file but I have no idea how to look up the value. You're saying something about looking at the executable code?

I just opened it up in a text editor and searched for turnsSinceSpotted.  As I expected, all of your units have a TSS of 0 - which makes since from a programming standpoint.
Title: Re: How do I make psionics require same-turn discovery?
Post by: The Reaver of Darkness on August 08, 2016, 03:57:53 am
Well that's useful information, but it doesn't tell me how to fix it. I need some way to make the game stop setting that value to 0, and let it climb up as normal regardless of how few aliens there are or how many turns have passed.
Title: Re: How do I make psionics require same-turn discovery?
Post by: Starving Poet on August 08, 2016, 04:18:48 am
This is just a guess - but try modifying aliendeployments and adding a cheatTurn:255 to, say, an escort mission - based off of this: https://github.com/SupSuper/OpenXcom/blob/361467e4c3cd10ae40ed1b503a1c1e86e328b370/src/Mod/AlienDeployment.cpp#L116

it looks like a settable option.  If that works it might remove the timer, but not the two alien rule.
Title: Re: How do I make psionics require same-turn discovery?
Post by: The Reaver of Darkness on August 08, 2016, 08:47:29 pm
I'm more concerned with the two alien rule.

I wish I could access the ruleset reference. Ever since UFOPaedia went down, I've been getting stuck making my mods.
Title: Re: How do I make psionics require same-turn discovery?
Post by: R1dO on August 09, 2016, 01:10:09 am
Not the most polished version ... but at least it is pretty up to date:

https://webcache.googleusercontent.com/search?q=cache:b6mpK1tbzf4J:https://ufopaedia.org/index.php/Ruleset_Reference_Nightly_(OpenXcom)
Title: Re: How do I make psionics require same-turn discovery?
Post by: Starving Poet on August 09, 2016, 07:48:20 am
Going through the code again and this makes it look like the 2 alien rule only applies if turn > cheatturn / 2.

https://github.com/SupSuper/OpenXcom/blob/8d51815ee0aeeeab0fb9764e1f7a389023f7219f/src/Savegame/SavedBattleGame.cpp#L857

So, if you try the cheatturn option in the ruleset set to 255, that might work for you.

/edit: I'm away from my testing computer right now - but quick test would be to add cheatTurn: 1 to the small scout in aliendeployments and do a quick battle in a lightning with an ethereal small scout mission and immediately end the turn.  If he PSI attacks you on his first turn; you'll know it works.
Title: Re: How do I make psionics require same-turn discovery?
Post by: The Reaver of Darkness on August 09, 2016, 10:30:50 am
do a quick battle in a lightning with an ethereal small scout mission
Small scout has a soldier, Ethereal Soldiers can't use psionics (which is weird because they have a psi skill attribute).
Title: Re: How do I make psionics require same-turn discovery?
Post by: Starving Poet on August 09, 2016, 02:51:37 pm
Yes they do - they're just not likely to because they have low stats. 
Title: Re: How do I make psionics require same-turn discovery?
Post by: Starving Poet on August 09, 2016, 08:13:38 pm
Alright - just tested this in the latest nightly:

adding cheatTurn: 255 to the small scout deployment gives you until turn 123 before the 2 alien cheat turn rule goes into effect.
Title: Re: How do I make psionics require same-turn discovery?
Post by: The Reaver of Darkness on August 09, 2016, 10:55:47 pm
Alright - just tested this in the latest nightly:

adding cheatTurn: 255 to the small scout deployment gives you until turn 123 before the 2 alien cheat turn rule goes into effect.
Where do I add it? I tried adding it to the medium scout and used the value 1 but they still waited until turn 20.
alienDeployments:
  - type: STR_MEDIUM_SCOUT
    cheatTurn: 1


Also when I set their intelligence to 0 it doesn't seem to work properly. They can use psi attacks on someone they saw last turn. They don't have to see the soldier in the same turn as they use psi attacks. This means once they have seen your squad, it's all over and you'll never be free of psi attacks until you kill the aliens doing it. And that's the entire problem I'm seeking to avoid.
Title: Re: How do I make psionics require same-turn discovery?
Post by: Starving Poet on August 09, 2016, 10:59:46 pm
This works for me - again using the latest nightly.  It didn't work with OXCE when I tried that executable.
Code: [Select]
- type: STR_MEDIUM_SCOUT
    data:
      - alienRank: 5
        lowQty: 2
        highQty: 4
        dQty: 2
        percentageOutsideUfo: 60
        itemSets:
          -
            - STR_PLASMA_PISTOL
            - STR_PLASMA_PISTOL_CLIP
            - STR_PLASMA_PISTOL_CLIP
          -
            - STR_PLASMA_RIFLE
            - STR_PLASMA_RIFLE_CLIP
            - STR_PLASMA_RIFLE_CLIP
          -
            - STR_HEAVY_PLASMA
            - STR_HEAVY_PLASMA_CLIP
            - STR_ALIEN_GRENADE
      - alienRank: 4
        lowQty: 1
        highQty: 2
        dQty: 1
        percentageOutsideUfo: 20
        itemSets:
          -
            - STR_PLASMA_PISTOL
            - STR_PLASMA_PISTOL_CLIP
            - STR_MIND_PROBE
          -
            - STR_PLASMA_RIFLE
            - STR_PLASMA_RIFLE_CLIP
          -
            - STR_HEAVY_PLASMA
            - STR_HEAVY_PLASMA_CLIP
    width: 40
    length: 40
    height: 4
    cheatTurn: 2
Title: Re: How do I make psionics require same-turn discovery?
Post by: The Reaver of Darkness on August 09, 2016, 11:28:54 pm
After some testing, I figured out it has to go on each individual alien rank.

alienDeployments:
  - type: STR_MEDIUM_SCOUT
      - alienRank: 5
        cheatTurn: 1
      - alienRank: 4
        cheatTurn: 1

It also doesn't work when the cheat turn is set to 0.


Setting intelligence to 0 does work. It seems to allow them to use psionics on soldiers they saw during their turn or in your turn before it. You can theoretically make your psiweak soldiers hide from either the aliens or your squad, or you can kill the psiweak soldiers, and that will make the psi attacks stop. It's almost what I want, but not quite. It's still a bit cheaty on their part.
Title: Re: How do I make psionics require same-turn discovery?
Post by: Starving Poet on August 09, 2016, 11:52:56 pm

It also doesn't work when the cheat turn is set to 0.

That makes sense in hindsight - you can't divide 0 / 2 after all.
Title: Re: How do I make psionics require same-turn discovery?
Post by: The Reaver of Darkness on August 10, 2016, 01:59:40 am
That makes sense in hindsight - you can't divide 0 / 2 after all.
It doesn't seem to be dividing it by 2. The default value as stated in the cached ruleset reference you linked is 20. When I set it to 2, they used psi attacks on the third turn. When I set it to 4, they used psi attacks on the 5th turn. I think perhaps it has a range of only 1-127. I didn't test it that many times, but it seemed to be taking the number of turns and adding one to it, not dividing it in half.
Title: Re: How do I make psionics require same-turn discovery?
Post by: Starving Poet on August 10, 2016, 02:36:03 am
Right, but the code for activating cheatMode is a single line checking for (turn > cheatTurn) OR (aliens <= 2 AND turn > cheatTurn / 2).

There is no code making sure cheatTurn is > 0 so when it hits that conditional it's probably just silently failing.
Title: Re: How do I make psionics require same-turn discovery?
Post by: Meridian on August 10, 2016, 09:32:15 am
That makes sense in hindsight - you can't divide 0 / 2 after all.

Why not? 0 / 2 = 0
Title: Re: How do I make psionics require same-turn discovery?
Post by: Starving Poet on August 10, 2016, 03:12:10 pm
And of course you can, no idea why I said that.  I think my toddler is eating my brain when I sleep.
Title: Re: How do I make psionics require same-turn discovery?
Post by: Solarius Scorch on August 10, 2016, 03:51:58 pm
And of course you can, no idea why I said that.  I think my toddler is eating my brain when I sleep.

I really didn't need this image in my head. :P
Title: Re: How do I make psionics require same-turn discovery?
Post by: new_civilian on August 31, 2016, 11:48:33 am
I experimented a bit with cheatturn set to 100 and intelligence of psi units set to 0 and got interesting results: It seems the AI still gets the ability to psi-attack you after turn 21 (or if the 2-unit rule triggers), but it will not know your position and/or use the cheat-attack mode.


Anyway: I really like the removal of the AI-cheating, it makes entering USOs/UFOs much more balanced, you now really have a chance to surprise the aliens, it feels like a totally new and better game.
Title: Re: How do I make psionics require same-turn discovery?
Post by: Meridian on August 31, 2016, 12:35:11 pm
Depends on how you play I guess.

In UFO, I never get beyond turn 20 (unless I willingly want to train reactions).
In TFTD, sometimes you get close to and over turn 20, especially in ship terror missions, but even then I am grateful for cheating, since it helps prevent bughunts (a little).
Title: Re: How do I make psionics require same-turn discovery?
Post by: new_civilian on September 01, 2016, 11:30:04 am
Yes, true, it does depend a lot on the way of playing. I try to keep my soldiers alive, even when they are mind-controlled, I try to not kill them, but stun them and take them home and sack them there.  :) I rpg XCom as far as possible...

That's why I hate the cheating AI a lot: You plan a careful and clever entry into the UFO, clear the whole outside and BAMM suddenly when you e.g. enter the UFO the aliens know EXACTLY and MAGICALLY where you are? Nope, no longer working for me, it defeats the whole point of being careful and placing your units tactically clever.

I can live with the PSI cheating, it gives you a reason to hurry without being a brute and stupid AI omni-knowledge cheat.
But that alien knowing exactly where my units hide and where to attack without me being able to counter that? No.
Title: Re: How do I make psionics require same-turn discovery?
Post by: Meridian on September 01, 2016, 12:07:51 pm
That's why I hate the cheating AI a lot: You plan a careful and clever entry into the UFO, clear the whole outside and BAMM suddenly when you e.g. enter the UFO the aliens know EXACTLY and MAGICALLY where you are? Nope, no longer working for me, it defeats the whole point of being careful and placing your units tactically clever.

You know, maybe they just have CCTV cameras... even 1-star hotels and lowest-of-the-lowest bars in the middle of nowhere have those nowadays, why wouldn't aliens have them ? :) Not really any magic in that.
Title: Re: How do I make psionics require same-turn discovery?
Post by: Arthanor on September 01, 2016, 06:15:49 pm
Good point Meridian!

Also, a good tactic is one that is recognized too late to be foiled. Given that the AI is quite basic and that it only knows your position without being able to guess what you will do after, it should be plenty doable to come up with tactics it can't handle.

Breaching ufos without losses is hard, yes, but it really should be. A good tactic might mean that you only lose a soldier every other time. If you can not lose soldiers every time, then something is wrong unless you're playing Piratez and raiding low tier ufos. It should not be doable in XCOM.
Title: Re: How do I make psionics require same-turn discovery?
Post by: new_civilian on September 02, 2016, 12:43:37 pm
You know, maybe they just have CCTV cameras... even 1-star hotels and lowest-of-the-lowest bars in the middle of nowhere have those nowadays, why wouldn't aliens have them ? :) Not really any magic in that.

Well, why don't they know then right from the start? They could have invisible nanobot-cameras floating in the skyranger... Also no magic in that.  ::)

Arthanor, I am not necessarily talking about vanilla XCom. What if you fight e.g. human vs. human in a 1950s Total Conversion?
It's not the AI cheat per se that bugs me, but the blunt way it is enforced no matter what.
Title: Re: How do I make psionics require same-turn discovery?
Post by: Arthanor on September 02, 2016, 06:56:32 pm
Well, whatever the AI does, I can't believe it's as brutal and ruthless as humans would be. I haven't tried to 1vs1 XCom game, but I am fairly certain that casualties abound on both sides even if your opponent doesn't know your units' positions like the AI does.

I think that in general, unless you are fighting an enemy that you thoroughly dominate, breaching enemy positions should come with casualties regularly enough. That should be true in normal XCom, or in human vs human operations.

All that being said, I agree with you that the transition between no cheat and cheat at a given time limit is contrived.
Title: Re: How do I make psionics require same-turn discovery?
Post by: new_civilian on September 11, 2016, 03:24:52 pm
After playing an entire campaign with this mod^AND the cheatturn removed I am absolutely content with the AI behaviour now. Finally there is a real tactical battle going on inside the USO/UFOs, you can surprise aliens and it feels much better to have a fair chance and no longer automatically loose the first  soldier entering the enemy craft and/or having to resort to exploits or overly time-consuming and unrealistic tactics. Realism meaning equal chances here.