The online racing simulator
LFSLapper ISP_OBH (OBject Hit) packet
After LFSLapper developers Krayy and Gai-Luron left LFS. I'm trying to add some LFS insim packets to LFSLapper.

Atm i'm busy with adding a packet that reports the collision between Car and (AutoX)opjects.
After some strugling with finding out what everything means. I have finally received some data from lapper when hitting an opject.

Be aware: i'm not a programmer, and i have 0% knowledge of C# programming.
So thank you google for helping me out LOL
Good for you!

'Opject hitted!' - not sure what language that is, but in English, would be 'Object hit!'

If you are thinking of taking LFSLapper on, then how about doing something about...

In the most recent test patches, I've been getting this..



It has to do with

Quote from Scawen :...I agree, it seems bad or sad to break programs that can continue to work. I don't want to act like a company such as Oculus.

I didn't want to add an option bit to allow "reduced text packets" or whatever. It seems a silly option. But I understand this problem may come up in future. Sometimes, including this time, it seems I could simply provide backward compatibility.

So how about a small, compatible, addition to the IS_ISI packet? I could change the Sp0 byte to KnownVersion. If it is 0 (as for existing programs) then LFS will assume that means version 6.

To get any of the new packets you will have to specify version 7 (which I'll set as INSIM_VERSION).

So that would mean the old programs should continue to work, for now. I can attempt to retain backward compatibility in future using that number, as long as it doesn't become a burden.

Would you be able to change the number to get rid of the message?
Attached images
Insim v6.png
Sry about that typo LOL. Was a littlebit late yesterday XD

Lapper is running on Version 4.
After i finish the "opject hit" packet. i go try to change the Insimversion in lapper.
Quote from Bass-Driver :...Be aware: i'm not a programmer, and i have 0% knowledge of C# programming...

Everything is learnable, ok, but couldn't you try to team up with some more experienced buddy?
Good luck anyway! Thumbs up
thank you,

Sure will do that.

I have managed to get data from all values inside the OBH packet.
But i'm not sure, if the data is correct.

Could someone take a look??
Attached images
DataFromOBHPacket.jpg
Your pakGetShort calls should be referencing the first byte, not the second byte. I'd also recommend using different variable names instead of just lower/upper case.
Small update:

Added a event in LFSLapper.LPR named:

Event OnObjectCollision($userName,$objectflag,$Time,$XPos,$YPos)
EndEvent

@PeterN

Thanks
Attached images
OBHTest.jpg
Great work.

My curiousity - what do these "$objectflag,$Time,$XPos,$YPos" tell you? And are they all needed?

$objectflag - 10 in your example - is this like a car, wall, cone, tyre, etc? Is there a list somewhere? Would it need some sort of array to look up to give the item rather than a non-descript number.

$Time - I assume milliseconds? If so, roughly 5 and a half seconds. From race or qualy start? Or is it how long the event lasted for? Or something else?

$XPos,$YPos - I suppose this may be useful for logging if you ever want to look back at something? But likely needs 3rd party software (I have seen some polygon thing on the forum that could probably do this [Russian named Dennis somebody with spongebob avatar springs to mind]).

Or possibly AutoX, although for most things, you would get penalty for hitting an 'object'.

Other things you've recorded ..

What's difference between ObjectContactSpeed and InstantSpeed?

X and Y Axis - ? And how do they differ from $XPos and $YPos? Or even heading and direction? Which is how I think of Axis working - sort of East/West for X and North/South for Y, although your results look more like co-ordinates on a map

Heading and Direction - ? Is one the way you were going and other the way you now face?

For some people, the answers to these questions might be self evident. Sorry, but its not to me. It's 40 years since I left school (and saw my 1st ever calculator!); maybe I need refresher on geometry, maths and algebra.

I'm just trying to think how it could be used in real life, such as;
Quote :Impact: That idiot <$nickname> hit a <$object> at <$speed>

or
Quote :Impact: <$nickname> got a time penalty for hitting <$object>

Might have been more useful if Scawen's Insim told you sector number rather than X and Y.
Well, about "$objectflag,$Time,$XPos,$YPos" .
is explained in the doc i,ve attached.

$userName // $Username
$objectflag // Flag of object
OBH_LAYOUT, //1 // an added object
OBH_CAN_MOVE, //2 // a movable object
OBH_WAS_MOVING, //4 // was moving before this hit
OBH_ON_SPOT //8 // object in original position
$Time //Time you hit the object (Race timer) in milliseconds
$XPos // Object X Coordinate
$YPos // Object Y Coordinate

$XPos,$YPos
If you want to know the coordinates of the object you hit.

The difference between ObjectContactSpeed and InstantSpeed:
The Speed should be the same, but i think there is a delay between the packets

Heading and Direction

Direction = Is in which way you face your car.
For example:
North = 0 degrees
West = 90 degrees
South = 180 degrees
East = 270 degrees

Heading:
When you go north and your car is going sideways.


There is a insim packet that isnt implemented in Lapper. That gives a 2 second penalty when hitting a object.

// If an autocross object is hit (2 second time penalty) this packet is sent :

struct IS_AXO // AutoX Object
{
byte Size; // 4
byte Type; // ISP_AXO
byte ReqI; // 0
byte PLID; // player's unique id
};

There is plenty of stuff todo. I hope i can release the OBject Hit for lapper next week or so.
Update: This evening i go add a objectlist.
So when you hit a object you will see which object you hit.

Example Sourcecode below:


objectHit = Objects(obh.Index);

private string Objects(int ObjectIndex)
{
string[] Object = new string[192];
Object[0] = "Scenery object";
Object[1] = "";
Object[2] = "";
Object[3] = "";
Object[4] = "Long Chalk Line"; Object[5] = "Short Chalk Line";
Object[6] = "Short Ahead Arrow";Object[7] = "Long Ahead Arrow";
Object[20] = "Red+White Cone";
Object[21] = "Red Cone";
Object[22] = "Striped Code";

return Object[ObjectIndex];
}

Event OnObjectCollision($userName,$ObjectFlag,$ObjectHitTime,$Object_X,$Object_Y,$TypeObject) # Player event
Globalmsg("".getplayervar($userName,"NickName")."^8 hit a ^3".$TypeObject." ^8at ".GetCurrentPlayerVar("ObjectContactSpeed")." km/h");
EndEvent

Attached images
OBHobjecthit.jpg
Is it possible to hit a chalk line or chalk arrow? Or a striped code? Smile

Do you have space for all the objects?

There are;

1 start lights
4 marshalls
15 cone types
8 tyre types (excluding colours - probably enough to know what type of tyre was hit)
22 markers (direction and distance)
22 objects (armco, banners, etc) - 18 if you take away ramps and speed bumps, which you are allowed to drive on without penalty, or back up to 20 because you can still hit the ramps
8 concrete types - 6 if you take away slab and ramp, which you are allowed on without penalty

That makes about 74 'objects'.
I have a whole list with objects. Which i have added now.

i'm also trying to implement a Ignoreobject Variable. So if you do $IgnoreObjects = "Cones"; It will ignore all the cones your hit.

You may test all the objects in my test server.

Edit: Add Ignorelist

This is the IgnoreList so far: ( Event will not be executed)
Its also possible to add several values: seperated by &

$IgnoreObjects = Small_Tires&Big_Tires

All // All objects will be ignored
Small_Tires // All small tires will be ignored
Big_Tires //All big tires will be ignored
Cones//All Cones(normal+pointers) will be ignored

Idea's for the ignorelist? let me know.
Should your IgnoreList not just be basically the same as your ObjectList?

Your grouping (tyres and cones) looks good though.

I'd think markers should also be a group - in real life, when a driver plows through markers, they don't get extra penalties - they're already penalised as they're usually crashing, or at minimum, off the racing line and trying hard not to crash.

As I sometimes use back of markers as walls, etc, still like the choice of ignoring or not.

Maybe the 50 and 80 speed signs and keep left and right signs? They tend to be used in pit area, so might be nice to have option to not penalise someone when they're not on race track.

For the drifters who use the back of their cars to knock down poles, maybe poles too, both individually per colour and ALL?
What about enable objects instead of ignoring them. So it ignores all the objects by default.

Example:
$HitObjects="cones+green_pole"; #Event executes when hitting all cones and the green pole.
Probably more sensible idea, although would still like option of enabling one specific type of object, or all grouped types of that object (e.g. 'green_pole', or 'all_poles').
Here's a LFSLapper Testversion:

Changelog:

-New InsimPacket:OBH ObjectHit (Collision detection between car and object)
[b]-New Events :[/b]

OnObjectCollision (Object hit detection)
OnAcceleration2( Second Acceleration progress)


[b]-New PlayerVars :[/b]

ObjectContactX, //X position of player (dont know if this is usefull X does the same
ObjectContactY, //Y position of player (dont know if this is usefull Y does the same)
ObjectContactSpeed, //Speed of player when hitting a object
ObjectContactHead, //Heading of player when hitting a object
ObjectContactDir, //Direction of player when hitting a object

AccelerationStartSpeed2, // Min value for the acceleration feature relative to user unit km or mph
AccelerationEndSpeed2, // Max value for the acceleration feature relative to user unit km or mph
AccelerationTime2, // Acceleration time achieved from start to end speed


How to enable Object Hit detection:

Between the "" you can add one of the object from the list.
Also you can combine several objects: "All_Tires+White_Post"

$DetectHitObject = "All_Objects";
"" = No Object detection
All_Objects //All Objects
All_Tires //Small+Big Tires
All_Cones //All Type of Cones incl Pointers
All_Markers //All Types of Markers
All_DistMarkers //Distance Markers
All_Post//All Posts (Green/Orange/Red/White)
Green_Post
Orange_Post
Red_Post
White_Post
All_Barriers // All Types of Barriers
Long_Barrier
Red_Barrier
White_Barrier
Bale
KeepSigns
SpeedSigns

Been playing around with your new Object Detection system.

Looking good - what my code (below) shows in game;



My code:
Spoiler - click to reveal############################
#Actions to do on Hit Object#
############################

$DetectHitObject = "All_Objects";
# "" // No Objects
# All_Objects //All Objects
# All_Tires //Small+Big Tires
# All_Cones //All Type of Cones incl Pointers
# All_Markers //All Types of Markers
# All_DistMarkers //Distance Markers
# All_Post//All Posts (Green/Orange/Red/White)
# Green_Post
# Orange_Post
# Red_Post
# White_Post
# All_Barriers // All Types of Barriers
# Long_Barrier
# Red_Barrier
# White_Barrier
# Bale
# KeepSigns
# SpeedSigns

# NOTE: You can combine objects, Example: "All_Tires+Red_Post+etc"

Event OnObjectCollision($userName,$ObjectFlag,$ObjectHitTime,$Object_X,$Object_Y,$TypeObject) # Player event
# Player Vars
# -----------
$UnitSpeed = GetCurrentPlayerVar("UnitSpeed"); # Shows if player using kph or mph
$OCX = GetCurrentPlayerVar("ObjectContactX"); # X position of player
$OCY = GetCurrentPlayerVar("ObjectContactY"); # Y position of player
$OCH = GetCurrentPlayerVar("ObjectContactHead"); # Heading of player when hitting a object
$OCD = GetCurrentPlayerVar("ObjectContactDir"); # Direction of player when hitting a object
$OCS = GetCurrentPlayerVar("ObjectContactSpeed"); # Speed of player when hitting a object

# Conversion of vars
# ------------------
$OCS_mph = round(($OCS*0.621371),1);
$OCS_mph1 = (GetCurrentPlayerVar("ObjectContactSpeed")*0.621371);
$OCS_mph2 = (GetCurrentPlayerVar("ObjectContactSpeed")/1.60934);

# show vars on screen
# -------------------
privMsg( "^3Unit Speed used by player is: ^2".$UnitSpeed);
privMsg( "^3X Position: ^2".$OCX);
privMsg( "^3Y Position: ^2".$OCY);
privMsg( "^3Heading: ^2".$OCH);
privMsg( "^3Direction: ^2".$OCD);
privMsg( "^3Speed: ^2".$OCS);
privMsg( "^3Speed: ^2".$OCS_mph." ^3mph");
privMsg( "^3Speed: ^2".$OCS_mph1." ^3mph - conversion by multiplication");
privMsg( "^3Speed: ^2".$OCS_mph2." ^3mph - conversion by division");

Globalmsg("".getplayervar($userName,"NickName")."^8 hit ^1".$TypeObject." ^8at ".GetCurrentPlayerVar("ObjectContactSpeed")." km/h");

Globalmsg("".getplayervar($userName,"NickName")."^8 hit ^1".$TypeObject." ^8at ".$OCS_mph." mph "); # converting to mph

Globalmsg("".getplayervar($userName,"NickName")."^8 hit ^1".$TypeObject." ^8at ".$OCS." ".GetCurrentPlayerVar("UnitSpeed"));

EndEvent


Ignore last screen message - just checking what speed was outputting along with my UnitSpeed.

Few things;

- Your code makes kmh the default speed var. Most of the English speaking parts of the world (UK/USA/Australasia, etc) use MPH. Maybe a short note to advise that GetCurrentPlayerVar("ObjectContactSpeed") outputs in kmh? Regardless of drivers settings.

- Keeping with old lapper convention, can you add descriptive header before your system, as in something like

############################
#Actions to do on Hit Object#
############################

So much text where you placed it, I thought it was part of the OnAcceleration Event.

- Maybe best to delete your ip error message log in the /log directory.

- The /defaultfiles directory not needed. Likely very confusing for newbies.

- I can confirm that your code works with new version of InSim - extract from MSS.log "Product:S3 Version:0.6K23 InSim Version:7".
Attached images
ObjectHitDetection.png
Thank you for testing.

-About the unitspeed: i havent add the code for displaying MPH. Will do in the next testversion:

-Good one about the Header

-I have download the latest version of LFSlapper, that folder is incl the Defaultfiles directory. Will get rid of it.

-I'm still running on 0.6K , but good to know that it is working.
I have also noticed that the OBH packet is changed ( Z coordinate is added).I gonna add that one aswell.

That means the Event vars will change,
Event will be something like this:
Event OnObjectCollision($userName,$ObjectFlag,$ObjectHitTime,$Object_X,$Object_Y,$Object_Z,$TypeObject) # Player event
EndEvent

I also will make a file inside the Docs folder with the strings for:
$DetectHitObject = "";

I shall also get rid of the next 2 PlayerVars(Because they are the same as X and Y)

#GetCurrentPlayerVar("ObjectContactX") //X position of player
#GetCurrentPlayerVar("ObjectContactY") //Y position of player

What about the list with the detecting object. Is it ok or do i have to add more?
Your list should include 'StartLight', 'Speed Hump', 'Big Ramp', 'Small Ramp', 'Short Railing', 'Medium Railing' and 'Long Railing', as these appear as the $TypeObject when you hit them. As do 'Concrete Slab', 'Concrete Ramp', 'Concrete Wall', 'Concrete Slab Wall', 'Concrete Pillar', 'Concrete Ramp Wall', 'Concrete Short Slab Wall' and 'Concrete Wedge'.

Maybe group 'Railings'?
Maybe group 'Concrete'?

You have # All_DistMarkers //Distance Markers
Does Distance Markers include Turn Markers (haven't tested)

Have noticed that if you hit any distance or turn markers, they are described by what you hit, e.g. '100m sign', 'Left Winding Turn marker', etc.

22 different markers - should they be included individually in your list? Going to be HUGE!

Is anyone likely to have message popping up on screen if you hit one type, but nothing if another? Smile

As i'm testing solo, no way for me to know, but what if you hit another car? Is a car another object type?
Just a thought...

I think you should start using LFSLapper6.015 to keep your stuff separate from previous versions. And maybe add letter after number to differentiate (eg LFSLapper6.015a)? LFSLapper6.014v16 is confusing and looks odd.

Maybe change number every time you add an Event? (Hopefully you'll keep going!)

Or does first number (currently 6) refer to Scawen's InSim version? In which case, maybe you should be using v7.01?

Even if large version number (LFSLapper6....) is not related to InSim version, maybe it should?

In which case, LFSLapper7.01(a, b, c....) for your OnAcceleration2 and Object Detection events, LFSLapper7.02 for a future additional Event (e.g. InSim Circles), LFSLapper7.03 (InSim Checkpoints).....?
There are about 192 places for objects ( not all of them are used,because they are spare for objects Swawen will add in the future) but its still a big list.

All_Distmarkers does not incl the Turn Markers.
Turn Markers are All_Markers

Hit a another car is a another Insim Packet , which is not implemented in LFSLapper. I might do this after i finished the Object Hit.

I add those 2 groups you descriped.


Edit: Version Numbers

Good thought about the version numbering of LFSLapper

Dont know if the First number stand for the Insim Version.
Lets say it is.

I change the lapper version to 7.01.

My thoughts about changing LapperVersion number.

-For every codechange they should change the number with +1.
-For each testversion they should add a letter 7.01a
Here's a new TestServer of LFSLapper.

Changes:

ObjectHit Event:

-Added ObjectGroups for OBject Hit detection.
All_Concrete
All_Railings
Banners
SpeedBumps

-Added Header Before Event in LFSLapper.LPR
-Added Z Coordinate
-Removed: 2 Player Vars:
GetCurrentPlayerVar("ObjectContactX") //X position of player
GetCurrentPlayerVar("ObjectContactY") //Y position of player

Misc:
- Add: Textfile in "Doc" Folder with objectstrings for OnObjectCollision event
- Removed: DefaultFiles Directory
- Change: LFSLapper version
Edit: silly me. Getting confused trying to work on so many copies of LFS.exe and Lapper versions all at once.

Copied my whole 'Actions to do on Hit Object' section from your original V6 to V7 test - I now have bruise on forehead for taking so long (and many code changes) to notice that '$TypeObject' became '$TypeOfObject' Frown

$ObjectType might be better?

What is the $ObjectFlag for? Hit quite a few different objects, and only seeing numbers 9, 10 and 11 - e.g. Speed Hump = 9, Scenery Object = 10, and Left Turn Marker = 11.

Attached images
Object Flags.png
$objectflag // Flag of object

OBH_LAYOUT, //1 // an added object
OBH_CAN_MOVE, //2 // a movable object
OBH_WAS_MOVING, //4 // was moving before this hit
OBH_ON_SPOT //8 // object in original position

Is it nessesary to have that Var? otherwise i delete it.

Edit: I have fixed the value of the $Object_X and $Object_Y.
It displays now a correct value, instead of a high unknown value.
Doing test where I hit same object twice in short period of time, I get



So the original flag is 11 (a movable added object in original [static] position), but next hit is 7, so that becomes a movable added object that was already moving before being hit (again).

Is that how it works?

If so, you've done all the work, so leave it in. Like all the other variables, they can be used or not at discretion of whoever's using that bit of code.

Maybe put a short addendum to your Objecthit.txt (just realised why you never called it plural of object - Objectshit.txt!) about OBH_LAYOUT, etc.
Attached images
Object Flags2.png
1

FGED GREDG RDFGDR GSFDG