[Plugin] [REL] Math Plugin
#37

Quote:
Originally Posted by Bakr
Посмотреть сообщение
Unfortunately, I'm not the greatest with math and can hardly understand how to properly use half of these functions. I was curious, as you PMed me awhile ago telling me you had a function that could do so, if one of these functions could be manipulated to allow correct vehicle offsets when placing objects on certain areas of the map like slopes. For example, if I wanted to place a trash bin on the side of a trash truck, while it's going uphill, using the default offsets wouldn't work.

Would you mind showing me a short example of how to make that work with one of these functions (of course if it's not already added that would be a possible suggestion)?

Thanks.
Ok, here's a small example:

pawn Код:
public OnPlayerKeyStateChange(PlayerID, NewKeys, OldKeys) {
   
    // pressing fire key
    if ((NewKeys & KEY_FIRE) && !(OldKeys & KEY_FIRE)) {
       
        if (IsPlayerInAnyVehicle(PlayerID)) {
           
            new vehtype;
            vehtype = GetVehicleModel(GetPlayerVehicleID(PlayerID));
           
            if (vehtype == 564) {// while in RC tiger
               
                new time;
                time = GetPVarInt(PlayerID, "LastTigerShot");
               
                if (time + 500 < TickCount()) {
                   
                    new Float:turretstart[3];
                    new Float:inp[3];
                   
                    inp[0] = 0.000; inp[1] = -1.2559; inp[2] = 0.3384;
                    MPProjectPointOnVehicle(GetPlayerVehicleID(PlayerID), inp[0], inp[1], inp[2], turretstart[0], turretstart[1], turretstart[2], 1);
                    CreateObject( 921, turretstart[0], turretstart[1], turretstart[2], 0.0, 0.0, 0.0);
                   
                    SetPVarInt(PlayerID, "LastTigerShot", TickCount()); // shot time
                }
            }
        }
    }
}
This is a bit modified code from what i use on partyserver.

When you hit fire key while inside a RC tiger, this will take the turret end point coordinates, and project them thru car's rotations to get exit coordinates in game world space, then create a small light object at those points.

An alternative would be, to extend the exit turret coordinates further, and create a explosion instead, this would make the RC tank able to fire / explode things properly.

Screenshot - notice that objects are placed correctly taking the rc tank's pitch / roll / yaw into account:



You can use this, and get trash van's specific coordinates to place trash cans behind it, it's easy to get coordinates on vehicles - place a car in my map editor at exact 0,0,0 coordinates with no rotation, then click on the vehicle and status bar will show you vehicle-based coordinates.
Reply


Messages In This Thread
[REL] Math Plugin - by JernejL - 20.07.2011, 18:08
Re: WIP Math Plugin - by Calgon - 20.07.2011, 18:11
Re: WIP Math Plugin - by JernejL - 20.07.2011, 18:15
Re: WIP Math Plugin - by Donya - 20.07.2011, 18:15
Re: WIP Math Plugin - by Calgon - 20.07.2011, 18:17
Respuesta: WIP Math Plugin - by clavador - 20.07.2011, 18:20
Re: Respuesta: WIP Math Plugin - by JernejL - 20.07.2011, 18:21
Re: WIP Math Plugin - by Kyosaur - 20.07.2011, 19:30
Re: WIP Math Plugin - by Omega-300 - 20.07.2011, 19:45
Re: WIP Math Plugin - by Gamer_Z - 20.07.2011, 20:33
Re: WIP Math Plugin - by Jay_ - 20.07.2011, 20:40
Re: WIP Math Plugin - by gamer931215 - 20.07.2011, 22:16
Re: WIP Math Plugin - by JernejL - 20.07.2011, 22:18
Re: WIP Math Plugin - by Mauzen - 20.07.2011, 22:33
Re: WIP Math Plugin - by JernejL - 20.07.2011, 22:52
Re: WIP Math Plugin - by linuxthefish - 20.07.2011, 23:17
Re: WIP Math Plugin - by Famalamalam - 20.07.2011, 23:50
Re: WIP Math Plugin - by JernejL - 20.07.2011, 23:54
Re: WIP Math Plugin - by Whitetiger - 21.07.2011, 00:29
Re: WIP Math Plugin - by linuxthefish - 21.07.2011, 00:38
Re: WIP Math Plugin - by Famalamalam - 21.07.2011, 00:41
Re: WIP Math Plugin - by JernejL - 21.07.2011, 00:54
Re: WIP Math Plugin - by JernejL - 21.07.2011, 11:05
Re: WIP Math Plugin - by Babul - 21.07.2011, 14:01
Re: WIP Math Plugin - by samiras - 21.07.2011, 14:58
Re: WIP Math Plugin - by JernejL - 21.07.2011, 16:42
Re: WIP Math Plugin - by steki. - 21.07.2011, 17:36
Re: WIP Math Plugin - by wups - 21.07.2011, 20:35
Re: WIP Math Plugin - by Incognito - 22.07.2011, 13:20
Re: WIP Math Plugin - by samiras - 24.07.2011, 17:55
Re: [REL] Math Plugin - by dr.pepper - 14.08.2011, 18:11
Re: [REL] Math Plugin - by Blacklite - 16.08.2011, 10:21
Re: [REL] Math Plugin - by cyber_punk - 17.08.2011, 21:27
Re: [REL] Math Plugin - by linuxthefish - 17.08.2011, 21:38
Re: [REL] Math Plugin - by Kar - 17.08.2011, 22:20
Re: [REL] Math Plugin - by Bakr - 19.08.2011, 03:25
Re: [REL] Math Plugin - by JernejL - 20.08.2011, 16:05
Re: [REL] Math Plugin - by Bakr - 21.08.2011, 01:36
Re: [REL] Math Plugin - by BeckzyBoi - 28.08.2011, 03:30
Re: [REL] Math Plugin - by [IL]HeHu - 29.08.2011, 14:17
Re: [REL] Math Plugin - by AndreT - 29.08.2011, 14:32
Re: [REL] Math Plugin - by Kar - 29.08.2011, 14:51
Re: [REL] Math Plugin - by JernejL - 29.08.2011, 18:27
Re: [REL] Math Plugin - by SourceCode - 15.11.2011, 14:17
Re: [REL] Math Plugin - by Niko_boy - 15.11.2011, 15:25
Re: [REL] Math Plugin - by leong124 - 17.11.2011, 08:45
Re: [REL] Math Plugin - by BeckzyBoi - 22.12.2011, 21:56
Re: [REL] Math Plugin - by leong124 - 23.12.2011, 04:07
Re: [REL] Math Plugin - by BeckzyBoi - 23.12.2011, 22:54
Re: [REL] Math Plugin - by leong124 - 24.12.2011, 16:54
Re: [REL] Math Plugin - by TheArcher - 03.01.2012, 23:30
Re: [REL] Math Plugin - by RyDeR` - 04.01.2012, 00:35
Re: [REL] Math Plugin - by DrTHE - 04.01.2012, 00:44
Re: [REL] Math Plugin - by TheArcher - 04.01.2012, 01:05
Re: [REL] Math Plugin - by zgintasz - 09.06.2012, 12:11
Re: [REL] Math Plugin - by cyber_punk - 04.10.2012, 19:55
Re: [REL] Math Plugin - by TheArcher - 01.02.2013, 18:14
Re: [REL] Math Plugin - by TheArcher - 02.02.2013, 10:25
Re: [REL] Math Plugin - by JernejL - 25.03.2015, 12:14

Forum Jump:


Users browsing this thread: 4 Guest(s)