31.07.2012, 09:20
ok, let me think out loudly a bit.. not a solution:
-car health goes from 1000 (or more if scripted) down to 0.0, the car burns at 250.0 HP (hard to move on if no /fix is there), i assume your player(s) will leave the car now.
-therefore, the color should be RED already when the car reached 250.0 HP, this...
-...difference is 750.0 HP for the "range" of colors. it can be changed later anyways
-health-250.0 will result in the range of 0 to 750..
-divided by 750, the range is normalized, you are working with health values from 0.0 (0/750) upto 1.0 (750/750), its very easy now, to...
-decide for a "resolution" for the color changes, ima do a quick color table:
7 colors (red>yellow>green)
11 (red>yellow>green)
or a neater transition (red and green channel changing, this way the brightest yellow will be smoother):
oh, what a coincidence, its using EXACTLY 25 colors:
750/25= 30 HP per color, so lets modify the divisor 750 by the 30 (undo the normalizing):
or without the "dark red" color, which looks ugly anyways://aswell your player WILL die aswell when the vehicle goes 0.0 and explodes)
and finally,
-car health goes from 1000 (or more if scripted) down to 0.0, the car burns at 250.0 HP (hard to move on if no /fix is there), i assume your player(s) will leave the car now.
-therefore, the color should be RED already when the car reached 250.0 HP, this...
-...difference is 750.0 HP for the "range" of colors. it can be changed later anyways
-health-250.0 will result in the range of 0 to 750..
-divided by 750, the range is normalized, you are working with health values from 0.0 (0/750) upto 1.0 (750/750), its very easy now, to...
-decide for a "resolution" for the color changes, ima do a quick color table:
7 colors (red>yellow>green)
Код:
0xff0000, 0xff5500, 0xffaa00, 0xffff00, 0xaaff00, 0x55ff00, 0x00ff00,
Код:
0xff0000, 0xff3300, 0xff6600, 0xff9900, 0xffcc00, 0xffff00, 0xccff00, 0x99ff00, 0x66ff00, 0x33ff00, 0x00ff00,
Код:
new ColorBar[25]}{ 0xff0000,//pure red for wither 250.0 ot 0.0 HP (depends on divisor 25 or 40 later) 0xff1100, 0xff2200, 0xff3300, 0xff4400, 0xff5500, 0xff6600, 0xff7700, 0xff8800, 0xff9900, 0xeeaa00, 0xddbb00, 0xcccc00, 0xbbdd00, 0xaaee00, 0x99ff00, 0x88ff00, 0x77ff00, 0x66ff00, 0x55ff00, 0x44ff00, 0x33ff00, 0x22ff00, 0x11ff00, 0x00ff00 }
750/25= 30 HP per color, so lets modify the divisor 750 by the 30 (undo the normalizing):
pawn Код:
(VehicleHP-250)/30=a cell 0 to 24 //my stupid idea to assume the vehicle is "undriveable @ 250 HP)
pawn Код:
VehicleHP/40=cell 0 to 24
pawn Код:
new HealthBarResolution=40; //1000/40=25, the sizeof the color array
VehHP=floatround(GetVehicleHealth(blabla)/HealthBarResolution,floatround_floor);
SetBarColor(playerid,ColorBar[VehHP]);