Jump to content
Sign in to follow this  
owmyeye

AI players NOT deducting tickets but human players are. Help

Recommended Posts

I've been pulling my hair out trying to make a 'simple' sector control scenario.

All I want the scenario to do is:

1) Spawn at their respective team base (done)

2) Lose tickets when the enemy controls the sector (done- although the bleed ticket module doesn't effect the rate at all, which is stuck on 3 per 5 seconds)

3) Win/Lose when a team runs out of tickets (done)

3) Have a ticket limit I determine (done)

4) Team loses tickets when a member dies - that doesn't work properly . I can make human players deduct a ticket for dieing but not AI players. I've tested playing as both teams and both work for a human player but not for AI. Since i'm making the scenario for myself to play alone with AI that's unacceptable.

Have I done something wrong? Or do I have to add another code somewhere to make a team lose tickets for AI deaths??

Edited by owmyeye

Share this post


Link to post
Share on other sites
Provide code piece that handles ticket deduction and how it is setup

I'm simply using a basic setup of the sector control game mode with it's associated modules. I have a Respawn Ticket module in which I have set the total amount of tickets each team has. I have not done any coding other than creating description.ext file which contains:

respawnTemplates[] = {"Tickets"};

respawn = BASE;

respawndelay = 6;

aikills = 1;

Just to clarify again in other words (just in case it helps), the sector control bit works properly with a ticket level I have defined which bleeds off when the sector is controlled. It also correctly removes a ticket if I am killed. However, what doesn't work is if the AI gets shot, no ticket is removed.

Share this post


Link to post
Share on other sites

By default, the ticket system works only for players. You'll have to call BIS_fnc_respawnTickets every time an AI unit dies:

_unit addEventHandler ["killed",{[_this select 0,-1,true] call bis_fnc_respawnTickets;}];

Edited by Moricky

Share this post


Link to post
Share on other sites
By default, the ticket system works only for players. You'll have to call BIS_fnc_respawnTickets every time an AI unit dies:

_unit addEventHandler ["killed",{[_this select 0,-1,true] call bis_fnc_respawnTickets;}];

Thanks for that. Where do I add that code though? The init file? Description? Each unit's initialisation?

Share this post


Link to post
Share on other sites

To each unit's init (replace _unit by this in that case). If you're creating some units on the fly, you have to call it on them as well.

Share this post


Link to post
Share on other sites
To each unit's init (replace _unit by this in that case). If you're creating some units on the fly, you have to call it on them as well.

Thanks man that code works :)... for extra credit though, is there an easy work-around to the problem that human players now take 2x tickets per death? (since they already took 1 before and now take another 1 from the command added to their init)

Share this post


Link to post
Share on other sites
Thanks man that code works :)... for extra credit though, is there an easy work-around to the problem that human players now take 2x tickets per death? (since they already took 1 before and now take another 1 from the command added to their init)

Do the same code in the init of the unit :P

or put in the init.sqf that code but replace _unit with player.

also i'm talking about Moricky's code

Share this post


Link to post
Share on other sites
Do the same code in the init of the unit :P

I don't get what you mean, although, maybe you don't get what kind of setup i'm making.

The scenario is being made so there are 2 teams with 8 playable units on each. That means that any one of them could be the human player in the game, but all the rest will be AI. I've done it this way not so much because I think I will be having other humans join the game, but because each other units have a different load-out. Even if I were to do a class selection menu on respawn, make all the AI unplayable, and delete the code from the playable's init- i'd still need 1 player on each team. That would mean there would be 1 AI getting around that doesn't deduct. So it would be a choice between double points against me or the AI team getting a freebie... much of a muchness, as the silly saying goes. Furthermore, I don't think unplayable AI units respawn?

So what I was asking for is that is there some kind of "if AI and not human" kind of condition that can be added to the code above which deducts the tickets.

Share this post


Link to post
Share on other sites
I don't get what you mean, although, maybe you don't get what kind of setup i'm making.

The scenario is being made so there are 2 teams with 8 playable units on each. That means that any one of them could be the human player in the game, but all the rest will be AI. I've done it this way not so much because I think I will be having other humans join the game, but because each other units have a different load-out. Even if I were to do a class selection menu on respawn, make all the AI unplayable, and delete the code from the playable's init- i'd still need 1 player on each team. That would mean there would be 1 AI getting around that doesn't deduct. So it would be a choice between double points against me or the AI team getting a freebie... much of a muchness, as the silly saying goes. Furthermore, I don't think unplayable AI units respawn?

So what I was asking for is that is there some kind of "if AI and not human" kind of condition that can be added to the code above which deducts the tickets.

if (!isPlayer this) then { Moricky's code };

Share this post


Link to post
Share on other sites
if (!isPlayer this) then { Moricky's code };

Ah thank you both very much!:yay:

Share this post


Link to post
Share on other sites

I'm very interested in using this code to bleed tickets for AI in some of my offline missions I'm setting up, but is there an easier way than putting that code into every single units init field? Like a global variable for every unit placed in the editor at the start? I'd be curious about how to put this code into AI spawners to get spawned AI to bleed tickets too. I've only recently started playing around with the tickets function so I'm not familiar with the coding for it :P

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×