Jump to content

Immortal PVP or PVE 1v1 mission - hits counter


cpt_milkeye
Go to solution Solved by Tom Kazansky,

Recommended Posts

I can't figure it out and maybe somebody can help - I have two planes (either 1 player one AI or both players), set for immortal and unlimited guns. I am trying to display hits, or count them - keep score - but it seems that once a hit happens, it doesn't count the second. It should be simple enough but it's beyond me. 

Thanks.

Link to comment
Share on other sites

  • Solution

@cpt_milkeye

LATE EDIT: the attached mission is not the correct mission bc of an upload mistake of mine. I added the correct one with my post on Friday 25th (v 05.04.05)

I've been using exactly what you described for a number of years.

There is only 1 thing the mission (not the script) adds: As soon as the "health" of a plane reaches zero, it gets vulnerable and you can kill it. For "unlimited" training just set the health to 1000 or more. I like to see a burning bandit at the end of the day, so I like this feature.

I did not create the hitcounter script. Just found in in the WWW 2017 and AFAIR I did not change more than variable names, if any. So I don't take credits for the script. I never shared it btw. until totaday. (end of disclaimer 😉 )

So here it is:

 

 

customEventHandler = {};

function customEventHandler:onEvent(event)
    if (world.event.S_EVENT_HIT == event.id) then
        local target = "unknown";
        if event.target:getCategory() == Object.Category.UNIT then
            if event.target:getPlayerName() then
                target = event.target:getPlayerName();
            elseif event.target:getName() then
                target = event.target:getName();
            end;            
        end;
           if (target == "Pilot Red" and trigger.misc.getUserFlag("1") >0) then
          local hits = trigger.misc.getUserFlag("1") -1;
          trigger.action.setUserFlag("1", hits);
       elseif (target == "ice" and trigger.misc.getUserFlag("2") >0) then
          local hits = trigger.misc.getUserFlag("2") -1;
          trigger.action.setUserFlag("2", hits);
       end;
    end;
end;
world.addEventHandler(customEventHandler);

 

Here is my mission where I added the output and other little things.

To adjust the "Health-Points" of the enemy plane and your own, simply edit the 2nd and 3rd trigger values in the ME.

I'm German, so they are called "F1 Gegner-Leben" (="Enemy-Lifes") and "F2 Player-Leben" ("Player-Lifes").

default is: F1 = 30, F2 =10

Because I do my weapons trainings 99% of the time on the Nevada Map (NTTR) I only have the mission for that map.  And I use the F/A-18C for both planes in this version of the miz. (see attachment)

EDIT: the names of the pilots/units are important for the script. So mine is "ice" and the enemy is called "Pilot Red".

EDIT2: I use the stable version of DCS 2.8.7.42718 which (today) is 1 version behind. Hope that doesn't matter.

 

 

ice 05.04.04 AA Training FA-18 vs. X (LUA-hit-counter works).miz


Edited by Tom Kazansky
  • Thanks 1
Link to comment
Share on other sites

miz file did have Blue player instead of ice. Once I changed that, it worked like a charm. And I think I understand the scripts. I modified mine to reset lives to start instead of turning immortal OFF. And added unlimited fuel and removed the missiles off my plane. 

But the next goal - and I don't know the difference yet - is to make it work on a dedicated server, including 1v1 PVP and 2v2 PVP and 2v PVE. or for that matter 3v3 as there are 6 in VFA-195 squad that are actively playing. 

Server is set to start with clients, but might need to start it paused. Also, name of multiplayer players might need to be changed (or the scripts to match our multiplayer names). Mission starts as "failed" so Blue group must be "dead" before blue player logs on ... 

  • Thanks 1
Link to comment
Share on other sites

1 hour ago, cpt_milkeye said:

miz file did have Blue player instead of ice. Once I changed that, it worked like a charm. And I think I understand the scripts. I modified mine to reset lives to start instead of turning immortal OFF. And added unlimited fuel and removed the missiles off my plane. 

But the next goal - and I don't know the difference yet - is to make it work on a dedicated server, including 1v1 PVP and 2v2 PVP and 2v PVE. or for that matter 3v3 as there are 6 in VFA-195 squad that are actively playing. 

Server is set to start with clients, but might need to start it paused. Also, name of multiplayer players might need to be changed (or the scripts to match our multiplayer names). Mission starts as "failed" so Blue group must be "dead" before blue player logs on ... 

Good to read.

Yeah, those AA missiles weren't meant to be there. A relic of a test, that I didn't remove before uploading.

I hope you get your server project running.

Link to comment
Share on other sites

After your reports about the names and the missiles I checked the version of my file again, and have to say, I klicked on the wrong line for uploading.

The correct mission is this one

 

P.S.:

1.) It makes sense to set fuel to unlimited for longer training flights with high "health points" at the start, as you mentioned. (With limited fuel I've learned about the afterburner usage of different planes.)

2.) What is odd: I tried my first uploaded mission (05.04.04...) again and although the pilots names were different from the script, the hit counter still worked correctly. Maybe someone with better knowledg of scripting could tell me why.

 

 

ice 05.04.05 AA Training FA-18 vs. X (LUA-hit-counter works).miz


Edited by Tom Kazansky
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...