Jump to content
Sign in to follow this  
bluevein

Point, score system

Recommended Posts

Hi,

I have opened a few CTF missions and Hold but cant find what I'm looking for.

Does any one know how to make a point system for destroying an object.

E.g.

I destroy a bridge and my team gets 10 points.

I kill an enemy soldier my team gets 1 point.

So by the end of all objectives the team with the most points win.

I need it for all 3 teams east, west and Independent.

Could any one point me in the right direction or even point me towards a mission I can dissect.

Many thanks

Share this post


Link to post
Share on other sites

In my limited experience, there are a couple of ways of doing a scoring system. Both involve using public variables to track the scores but use different methods of changing the scores: trigger or event handlers (or a combination of the two). I’ll try to give some simple examples of both (all of this code is untested to it may contain some errors) EDIT: this is a v 1.08 method, the new public variable event hander in 1.09 might improve the methods.

Before dealing with the scoring methods, you have to establish the public variables needed to record the scores. If you need separate scores for three sides, then create three separate public variables

init.sqf

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">scoreWest = 0; publicVariable "scoreWest";

scoreEast = 0; publicVariable "scoreEast";

scoreInd = 0; publicVariable "scoreInd";

In order to be fully MP and JIP compatible, I recommend only recording scores on the server. This way your scores will always be consistent. One way to do this is to have a script for each ‘score' that does all the math:

scoreWest.sqf

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">if !(isServer) exitwith{}; // If not the server the script will exit.

_scoreChange = _this select 0; // _scoreChange is the value to add/subtract as passed the the script by whatever executed it.

scoreWest = scoreWest + scoreChange; // Change the score.

publicVariable "scoreWest"; // Broadcast the new score value.

You will also need to make similar scripts for the other sides utilizing the different variables.

Now, for the actual scoring.

For the first example, let’s use your “destroy a bridge†objective. The easiest way to acomplish this would most likely be a trigger (assuming you have a specific bridge in mind as an objective). There is a good thread at OFPEC that discusses how to do this at length (make sure you read to the end): Obj Complete when bridge destroyed

In the On Act. field of the trigger, execute the appropriate's side's script and pass the amount you want to add to (or subtract from) the score:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">nul = [10] execVM "scoreWest.sqf";

The above line executes the scoreWest.sqf script and passes the value of 10 to add to the current value.

Let's try "kill an enemy soldier" for the second example. We could also do this with triggers (using alive in the condition line) but depending on the number of units in your mission, this could mean a lot of different triggers. Using a killed event handler is probably better.

In this init line of the units you want to be eligible for scoring (say east units), add code like this:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">this addEventHandler ["killed", {nul = [1] execVM "scoreWest.sqf"}];

EDIT: I have to check locality issues with Event Handlers, it may be required to run the score script on all clients and only use the server for the final comparison.

This line also executed the scoring script and passes the value of 1 to add to the current value.

You would have to change the script that is executed for west units (and Independent). Also note, this method will also score points for the other team when the unit dies by friendly fire or accident. It is only recording that the unit has been killed, not how. You can get more discriminating and only make sure that points are awarded when killed by an enemy. I can expand on that if you like but I am trying to keep it simple for now.

Then for your final requirement of the team with the most points wins when all objectives are complete, when you end the mission compare the values of the different scores (probably a trigger for each side would be easiest)

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">Cond: (scoreWest > scoreEast) AND (scoreWest > scoreInd)

etc, etc.

I hope this enough to get you started!

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  

×