Jump to content

Multiplay Race Script


BB.

Recommended Posts

This script can multi-play the course which the user created.

 

The flow of a race

"FreeRun" -> "Qualify" -> "Starting Grid" -> "Final"

 

attachment.php?attachmentid=92643&stc=1&d=1388938422

 

DOWNLOAD SCRIPT FILE

http://www.en.wiki.eagle.ru/attachment.php?attachmentid=92655&stc=1&d=1388939082

 

DOWNLOAD 4 COURSE

http://www.en.wiki.eagle.ru/attachment.php?attachmentid=92656&stc=1&d=1388939082

Stage-1 : F-15x10

Stage-2 : MiG-29x10

Stage-3 : UH-1x10

Stage-4 : P-51x12 (Time Attack Ver)

 

 

*User create course

1. MIST load

 

attachment.php?attachmentid=92646&stc=1&d=1388938670

 

 

2. This script load

 

attachment.php?attachmentid=92649&stc=1&d=1388938869

 

 

3. If there is a fanfare file, it will load sound file.

(DefaultFlagNumber8. When you change a flag number, please change the line:760 of lua file. )

 

attachment.php?attachmentid=92648&stc=1&d=1388938670

 

 

4. Course guide (static objects) create

Left side is made into the name

"LeftSide #001" ... "LeftSide #002" ... "LeftSide #999"(Maximum number)

Right side is made into the name

"RightSide #001" ... "RightSide #002" ... "RightSide #999"(Maximum number)

Note : LeftSide #Number = RightSide #Number

 

attachment.php?attachmentid=92650&stc=1&d=1388938869

 

 

5. Grid Zone create

TriggerZone Name "Grid1" ... "Grid2" ... "Grid99"(Maximum number)

Please create a smoke zone near a grid zone. Zone name "GridSmoke1" ... "GridSmoke99"(Maximum number)

Note : Grid number = GridSmoke number

 

attachment.php?attachmentid=92651&stc=1&d=1388938869

 

 

6. RaceZone create

This trigger zone should cover the whole course.

Record time will be erased if a player comes out of this zone.

 

attachment.php?attachmentid=92652&stc=1&d=1388938966

 

 

7. Client Plane or Heli create

Grid number = Client AirPlane

 

attachment.php?attachmentid=92653&stc=1&d=1388938966

 

 

8. UserSetting Edit

 

attachment.php?attachmentid=92654&stc=1&d=1388938966

 

PoleNumber = 67  --Please fill in the placed number of "Course guide".  Example "LeftSide #067" and "RightSide #067"
MaxPlayer = 10  --Please fill in the placed number of Grid & Client AirPlane.

--Checkpoint Pole Number
CheckPoint = {}
CheckPoint[1] = 13 
CheckPoint[2] = 32
CheckPoint[3] = 53

FreeRunTime = 600  --(sec)
QualifyTime = 600  --(sec)

PenaltyVolume = 2  --Course Out Penalty
PrematureStartPenalty = 15  --(sec)
maxalt = 3000  --meter    The maximum altitude. It will be "course out" if it becomes higher than this. 
LapNumber = 3  --Final Race LapNumber

smokecolor = "Orange"  --Grid Smoke Color   (Green , Red , White , Orange , Blue)

FanfareWaitTime = 11  --(sec)   Fanfare sound play time
PrematureStartSpeed = 1  --Premature start check speed

Known problem

When it respawn after the pilot ejected, a script stops.

If "Russia Infantry Soldier Rus" is specified as a course guide, will be nil error. (bug?)

If four or more players participate, it cannot fly with server PC. (Very high load)

 

 

I am a programming beginner.

Since I think that there are many problems and improving points, please point out a correction part.

 

Thank you.

p001.thumb.jpg.d9d892f752582413ed5bea58ffcab437.jpg

p002.jpg.3fa536f09d4e7001a45583b772307cb9.jpg

p003.thumb.jpg.bff35919ba09573cbfe5c01824059fe5.jpg

c001.PNG.17daced1ba3f37023e9f0e0debc0029f.PNG

c003.PNG.69f63a3665ebafd14622882989fa09eb.PNG

c002.PNG.5e690428b7d87f1cd157bb863a535810.PNG

c004.PNG.eed446206fef1777275b0c9656f6215b.PNG

c005.PNG.17fca884610fdf932c21749756c1a237.PNG

c006.thumb.PNG.1cdc1c12a7b934db0912a7a28be05e46.PNG

c007.PNG.42c307b31bb0eb86439b70740fd67e5b.PNG

c008.PNG.78581da46ffb34aee3d45f5290d0be67.PNG

MP_RaceScript_v1.0.zip

BigBird AirRace CousePack.zip

konnichiwa

Link to comment
Share on other sites

This is great coding for Air Racing. Couple things I would like to see implemented. Some way to trigger the start as opposed to it starting right at mission load. Along those lines, allowing it to reset and be raced again without having to reload the mission. The courses BB has created are a lot of fun and the code works really well. I will be looking to modifying my courses to use the code as well if we can work in the above issues.

 

Great job!

Link to comment
Share on other sites

Multiplay RaceScript_v1.04b (TestVersion)

http://www.en.wiki.eagle.ru/attachment.php?attachmentid=92893&stc=1&d=1389455251

 

 

Change log

A fanfare flag number can be specified by UserSetting.

The race re-starting (reset) function was added. Race will be reset if the flag 10 is set ON.

(Default Flag10. When you change a flag number, please change the line 19 of UserSetting. ).

 

Example: RaceReset

attachment.php?attachmentid=92894&stc=1&d=1389455276

 

 

I am creating the script which saves a course record now.

It will take some time before it is complete.

 

Thanks

MP_RaceScript_v1.04b.zip

e001.PNG.49239cdeeabc3c92a1bb75c55a9cc1fc.PNG

konnichiwa

Link to comment
Share on other sites

  • 3 weeks later...

BB we (JoeKurr and me) are also working on the script now.

 

Here are some changes we are trying to test this week

 

*Missed Gate- have to turn around to complete a lap.

*Lighter server load

*After leaving the triggerzone (flying away crashing or exit) The player fastest time will be deleted after 60sec

This last mentioned must make sure your time stays if you crash or rejoin But you'll have to choose the same jet/heli.

*easy to maintain and adjust

Link to comment
Share on other sites

As Liger Zero said I took the liberty to do a rewrite of your script in order to make it easier to maintain and add functionality.

 

At the moment I have the triggerzone part working:

- Every second, the script checks if there are new units inside the trigger zone and adds them to the players list

- Every 10 seconds, the script checks if units have left the trigger zone, and removes them from the players list.

 

The remove timer can be set to a higher value at a later time, to enable crashed pilots to get a new aircraft and not lose their time.

 

The script also doesn't stop after eject / rejoin.

 

_zoneName = "RaceZone"
_updateText = true
_players = {}

-- Initialize the script
-- This function gets called only once, at the beginning of the mission
function Init()
mist.scheduleFunction(RaceTimer, nil, timer.getTime(), 0.01)
mist.scheduleFunction(NewPlayerTimer, nil, timer.getTime(), 1)
mist.scheduleFunction(RemovePlayerTimer, nil, timer.getTime(), 10)
end

-- The main timer, this is where the checks will be done,
-- for now it only shows the players inside the trigger zone
function RaceTimer()
local text = string.format("Elapsed time: %d seconds", timer.getTime())
if #_players > 0 then
	text = string.format("%s\n%d players found", text, #_players)
	for playerIndex, player in ipairs(_players) do
		text = string.format("%s\n%d. %s", text, playerIndex, player.Name)
	end
else
	text = string.format("%s\nNo players found", text)
end
logString(text)
_updateText = false
end

-- Check for new players inside the trigger zone, and add them to the list
-- This function gets called once every second.
function NewPlayerTimer()
local allUnits = mist.makeUnitTable( { '[all][plane][helicopter]' } )
local unitsInZone = mist.getUnitsInZones(allUnits, { _zoneName } )

for unitIndex, unit in ipairs(unitsInZone) do
	playerExists = false
	for playerIndex, player in ipairs(_players) do
		local unitName = ""
		if unit:getPlayerName() then
			unitName = unit:getPlayerName()
		else
			unitName = unit:getName()
		end
		if player.Name == unitName then
			playerExists = true
			break
		end
	end
	if not playerExists then
		table.insert(_players, newPlayer(unit))
		_updateText = true
	end
end
end

-- Check for players who have left the trigger zone, and remove them from the list.
-- This function gets called once every 10 seconds, interval will be higher when script is done
function RemovePlayerTimer()
local allUnits = mist.makeUnitTable( { '[all][plane][helicopter]' } )
local unitsInZone = mist.getUnitsInZones(allUnits, { _zoneName } )
local playerExists = false

for playerIndex, player in ipairs(_players) do
	playerExists = false
	for unitIndex, unit in ipairs(unitsInZone) do
		local unitName = ""
		if unit:getPlayerName() then
			unitName = unit:getPlayerName()
		else
			unitName = unit:getName()
		end
		if player.Name == unitName then
			playerExists = true
			break
		end
	end
	if not playerExists then
		table.remove(_players, playerIndex)
		_updateText = true
	end
end
end

-- Create a new player and populate statistics for the new player
-- Gets called from NewPlayerTimer
function newPlayer(playerUnit)
local unitName = playerUnit:getName()
local playerName = ""
if playerUnit:getPlayerName() then
	playerName = playerUnit:getPlayerName()
else
	playerName = unitName
end

local player = {
	Name = playerName,
	Unit = Unit.getByName(unitName),
	UnitName = unitName,
	Location = {}
}
return player
end

function logString(message)
trigger.action.outText(message, 10)
end

-- Initialize the script and start the timers
Init()

 

I'll see if I can add the actual race code shortly.

  • Like 1
Dutch Flanker Display Team | LLTM 2010 Tiger Spirit Award
Link to comment
Share on other sites

  • 1 year later...

i just got NTTR and i'm totally psych'ed about making a Vegas air race. i need to study all these script, figure out what's going on. i'm sure i'll have a lot of questions.

My kit: i7-4790K@4GHz / 8GB - GTX 980ti + rift CV1 - X52 pro - Multi Keyboard Remapper - 2DOF motion sim (in development)

Link to comment
Share on other sites

  • 1 year later...

Hello BB, thanks for your nice job.

 

As you said, the load is too important for 4 and more player, I just try your first script. I'll try your version 1.04b, but I'm afraid the load problem keep alive.

 

Did you try to incorporate the script optimization from Joe Kurr in your script? I don't know how to use his optimization.

 

Thanks again

Link to comment
Share on other sites

  • Recently Browsing   0 members

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