I already made some changes to the 1.7.4.4 server package for random vehicle damage and posted them on the Tunngle thread for pwnoz0r's server package, but there are quite some changes to the database structure and spawn script since that version, so I decided to redo the random damage for the newest version.
I also post them here because this forum seems to be a little more active, so more people that might be looking for things like this could benefit from them.
While I was busy scripting I also decided to add in random inventory for items and a random skin per object if the object can have different skins. (like the blue/green/red skoda for example)
Random damage
The random damage works with an object_parts table that defines all parts for the vehicle objecttypes, with editable chances for completely repaired and completely broken chances for those parts.
When a vehicle is spawned, and the Hitpoints value for that spawn location is empty ( '[]' ) the script will generate random damage for all defined parts for that vehicle type. (0.25 is 25% chance)
Random inventory
The random inventory works with an object_items table that defines all items that can be spawned for a vehicle type (or ALL if they are applicable to all vehicle types) and a chance to spawn that item. The Min and Max items to spawn in a vehicle are editable in the pMain function and are default set to 2 and 5.
Random skin
Some vehicle have different skins/colors available, but are essentialy the same vehicle ofcourse. I made some changes in the spawn script that allow vehicles to spawn with a different skin instead of always the same skin on the same spot.
For the Skoda for example there are like 3 skins, same for the Ural (Blue, Yellow, and the V3S version) and so on.
The object_skins table contains all different skins for a classname (for now 1 of the skins is chosen as main skin in the classname column)
I did consider making the system spawn a random vehicle type and making the spawns type based (like spawn any random car, spawn aany random truck, spawn any random helicopter on locations) but that would require some structure changes I'd rather not do. The more I change the table structures, the harder it will be to make these changes still work after a new version/database changes from the server package.
Anyway, here are the scripts for my changes:
object_parts table
object_items table:
object_skins table
I also post them here because this forum seems to be a little more active, so more people that might be looking for things like this could benefit from them.
While I was busy scripting I also decided to add in random inventory for items and a random skin per object if the object can have different skins. (like the blue/green/red skoda for example)
Random damage
The random damage works with an object_parts table that defines all parts for the vehicle objecttypes, with editable chances for completely repaired and completely broken chances for those parts.
When a vehicle is spawned, and the Hitpoints value for that spawn location is empty ( '[]' ) the script will generate random damage for all defined parts for that vehicle type. (0.25 is 25% chance)
Random inventory
The random inventory works with an object_items table that defines all items that can be spawned for a vehicle type (or ALL if they are applicable to all vehicle types) and a chance to spawn that item. The Min and Max items to spawn in a vehicle are editable in the pMain function and are default set to 2 and 5.
Random skin
Some vehicle have different skins/colors available, but are essentialy the same vehicle ofcourse. I made some changes in the spawn script that allow vehicles to spawn with a different skin instead of always the same skin on the same spot.
For the Skoda for example there are like 3 skins, same for the Ural (Blue, Yellow, and the V3S version) and so on.
The object_skins table contains all different skins for a classname (for now 1 of the skins is chosen as main skin in the classname column)
I did consider making the system spawn a random vehicle type and making the spawns type based (like spawn any random car, spawn aany random truck, spawn any random helicopter on locations) but that would require some structure changes I'd rather not do. The more I change the table structures, the harder it will be to make these changes still work after a new version/database changes from the server package.
Anyway, here are the scripts for my changes:
object_parts table
Code:
/*Table structure for table `object_parts` */
DROP TABLE IF EXISTS `object_parts`;
CREATE TABLE `object_parts` (
`ObjectType` varchar(50) NOT NULL,
`PartName` varchar(50) NOT NULL,
`CompletelyBrokenChance` double(13,5) NOT NULL DEFAULT '0.00000',
`CompletelyRepairedChance` double(13,5) NOT NULL DEFAULT '0.00000',
PRIMARY KEY (`ObjectType`,`PartName`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
/*Data for the table `object_parts` */
insert into `object_parts`(`ObjectType`,`PartName`,`CompletelyBrokenChance`,`CompletelyRepairedChance`) values ('car','karoserie',0.25000,0.30000),('car','motor',0.25000,0.30000),('car','palivo',0.25000,0.30000),('car','wheel_1_1_steering',0.25000,0.45000),('car','wheel_1_2_steering',0.25000,0.45000),('car','wheel_2_1_steering',0.25000,0.45000),('car','wheel_2_2_steering',0.25000,0.45000),('helicopter','karoserie',0.25000,0.30000),('helicopter','motor',0.25000,0.30000),('helicopter','palivo',0.25000,0.30000),('helicopter','elektronika',0.33000,0.50000),('helicopter','mala vrtule',0.33000,0.50000),('helicopter','velka vrtule',0.33000,0.50000),('boat','motor',0.25000,0.30000),('bike','karoserie',0.25000,0.30000),('bike','wheel_1_damper',0.25000,0.45000),('bike','wheel_2_damper',0.25000,0.45000),('motorcycle','karoserie',0.25000,0.30000),('motorcycle','motor',0.25000,0.30000),('motorcycle','palivo',0.25000,0.30000),('motorcycle','Pravy predni tlumic',0.25000,0.45000),('motorcycle','Pravy zadni tlumic',0.25000,0.45000),('atv','karoserie',0.25000,0.30000),('atv','motor',0.25000,0.30000),('atv','palivo',0.25000,0.30000),('atv','wheel_1_1_steering',0.25000,0.45000),('atv','wheel_1_2_steering',0.25000,0.45000),('atv','wheel_2_1_steering',0.25000,0.45000),('atv','wheel_2_2_steering',0.25000,0.45000),('truck','karoserie',0.25000,0.30000),('truck','motor',0.25000,0.30000),('truck','palivo',0.25000,0.30000),('truck','wheel_1_1_steering',0.25000,0.45000),('truck','wheel_1_2_steering',0.25000,0.45000),('truck','wheel_2_1_steering',0.25000,0.45000),('truck','wheel_2_2_steering',0.25000,0.45000),('truck','wheel_3_1_steering',0.25000,0.45000),('truck','wheel_3_2_steering',0.25000,0.45000),('bus','karoserie',0.25000,0.30000),('bus','motor',0.25000,0.30000),('bus','palivo',0.25000,0.30000),('bus','wheel_1_1_steering',0.25000,0.45000),('bus','wheel_1_2_steering',0.25000,0.45000),('bus','wheel_2_1_steering',0.25000,0.45000),('bus','wheel_2_2_steering',0.25000,0.45000),('bus','wheel_3_1_steering',0.25000,0.45000),('bus','wheel_3_2_steering',0.25000,0.45000),('farmvehicle','karoserie',0.25000,0.30000),('farmvehicle','motor',0.25000,0.30000),('farmvehicle','palivo',0.25000,0.30000),('farmvehicle','wheel_1_1_steering',0.25000,0.45000),('farmvehicle','wheel_1_2_steering',0.25000,0.45000),('farmvehicle','wheel_2_1_steering',0.25000,0.45000),('farmvehicle','wheel_2_2_steering',0.25000,0.45000);
object_items table:
Code:
/*Table structure for table `object_items` */
DROP TABLE IF EXISTS `object_items`;
CREATE TABLE `object_items` (
`ObjectType` varchar(50) NOT NULL,
`Item` varchar(100) NOT NULL,
`Chance` float DEFAULT '0',
PRIMARY KEY (`ObjectType`,`Item`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*Data for the table `object_items` */
insert into `object_items`(`ObjectType`,`Item`,`Chance`) values ('ALL','Binocular',1.68),('ALL','FoodCanBakedBeans',8.91),('ALL','FoodCanFrankBeans',8.91),('ALL','FoodCanPasta',8.91),('ALL','FoodCanSardines',8.91),('ALL','ItemBandage',8.91),('ALL','ItemCompass',1.4),('ALL','ItemFlashlight',0.84),('ALL','ItemKnife',2.24),('ALL','ItemMap',4.2),('ALL','ItemMatchbox',1.68),('ALL','ItemPainkiller',5),('ALL','ItemSodaCoke',8.91),('ALL','ItemSodaEmpty',72.87),('ALL','ItemSodaMdew',0.28),('ALL','ItemSodaPepsi',8.91),('ALL','ItemWatch',4.2),('ALL','ItemWaterbottle',5),('ALL','ItemWaterbottleUnfilled',5),('ALL','TrashJackDaniels',22.87),('ALL','TrashTinCan',72.87),('car','ItemJerrycan',3.92),('car','PartEngine',0.98),('car','PartFueltank',1.96),('car','PartGeneric',3.92),('car','PartGlass',3.92),('car','PartWheel',4.9),('helicopter','30Rnd_556x45_StanagSD',0.99),('helicopter','30Rnd_9x19_MP5',1.98),('helicopter','30Rnd_9x19_MP5SD',0.99),('helicopter','ItemBloodbag',1.98),('helicopter','ItemFlashlightRed',1.91),('helicopter','ItemGPS',0.19),('helicopter','ItemMorphine',0.99),('helicopter','NVGoggles',0.96),('helicopter','Skin_Camo1_DZ',3.48),('helicopter','Skin_Sniper1_DZ',2.17),('offroad','',0),('offroad','20Rnd_762x51_DMR',3.96),('offroad','30Rnd_556x45_Stanag',3.96),('offroad','ItemHatchet',10.78),('offroad','ItemHeatPack',4.35),('offroad','ItemTent',0.98),('offroad','ItemToolbox',1.96),('offroad','Skin_Sniper1_DZ',2.17),('offroad','TrapBear',0.98);
object_skins table
Code:
/*Table structure for table `object_skins` */
DROP TABLE IF EXISTS `object_skins`;
CREATE TABLE `object_skins` (
`classname` varchar(50) NOT NULL,
`skin` varchar(50) NOT NULL,
PRIMARY KEY (`classname`,`skin`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*Data for the table `object_skins` */
insert into `object_skins`(`classname`,`skin`) values ('AH6X_DZ','AH6X_DZ'),('AN2_DZ','AN2_DZ'),('ATV_US_EP1','ATV_CZ_EP1'),('ATV_US_EP1','ATV_US_EP1'),('BAF_Offroad_W','BAF_Offroad_D'),('BAF_Offroad_W','BAF_Offroad_W'),('BAF_Offroad_W','LandRover_CZ_EP1'),('BAF_Offroad_W','LandRover_TK_CIV_EP1'),('car_hatchback','car_hatchback'),('car_sedan','car_sedan'),('Fishing_Boat','Fishing_Boat'),('hilux1_civil_3_open','datsun1_civil_1_open'),('hilux1_civil_3_open','datsun1_civil_3_open'),('hilux1_civil_3_open','hilux1_civil_1_open'),('hilux1_civil_3_open','hilux1_civil_3_open'),('hilux1_civil_3_open','hilux1_civil_3_open_EP1'),('Ikarus','Ikarus'),('Ikarus','Ikarus_TK_CIV_EP1'),('Lada1_TK_CIV_EP1','Lada1'),('Lada1_TK_CIV_EP1','Lada1_TK_CIV_EP1'),('Lada1_TK_CIV_EP1','Lada2'),('Mi17_DZ','Mi17_DZ'),('Old_bike_TK_CIV_EP1','Old_bike_TK_CIV_EP1'),('Old_bike_TK_CIV_EP1','Old_bike_TK_INS_EP1'),('S1203_TK_CIV_EP1','S1203_TK_CIV_EP1'),('Skoda','Skoda'),('Skoda','SkodaBlue'),('Skoda','SkodaGreen'),('Skoda','SkodaRed'),('SUV_TK_EP1','SUV_TK_EP1'),('tractor','tractor'),('TT650_TK_CIV_EP1','M1030'),('TT650_TK_CIV_EP1','Old_moto_TK_Civ_EP1'),('TT650_TK_CIV_EP1','TT650_INS'),('TT650_TK_CIV_EP1','TT650_TK_CIV_EP1'),('UAZ_Unarmed_TK_EP1','UAZ_Unarmed_TK_CIV_EP1'),('UAZ_Unarmed_TK_EP1','UAZ_Unarmed_TK_EP1'),('UH1H_DZ','UH1H_DZ'),('UralCivil','UralCivil'),('UralCivil','UralCivil2'),('UralCivil','V3S_Civ'),('Volha_1_TK_CIV_EP1','VolhaLimo_TK_CIV_EP1'),('Volha_1_TK_CIV_EP1','Volha_1_TK_CIV_EP1'),('Volha_1_TK_CIV_EP1','Volha_2_TK_CIV_EP1');