Skip to content

Commit

Permalink
PR: Player can define extra vehicles in custom chapter json (#362)
Browse files Browse the repository at this point in the history
<!--- PR title format should be `commit type: Title` -->
<!--- Commit types can be found at
https://github.com/pvdlg/conventional-commit-types?tab=readme-ov-file#commit-types
-->
<!--- You can add `@sourcery-ai` into the title, so that the bot
auto-generates a title -->
## Description of changes
<!--- Leverage the list functionality, if you have many changes -->
- implements the `extra_vehicles` attribute from chapter jsons which
works on init now. All extra vehicles are added to the 10th company so
they show up on the homeworld at the beginning of the game
## Reasons for changes
<!--- Leverage the list functionality, here as well -->
- implement unfinished feature
## Related links
<!--- Other PRs; Discord bug reports, messages, threads, etc.; outside
docs, etc.; -->
-
https://discord.com/channels/714022226810372107/714027491412410369/1323805664723734549

## Summary by Sourcery

New Features:
- Added support for the "extra_vehicles" attribute in chapter JSON files
to add vehicles to the 10th company during game initialization.
  • Loading branch information
VanWeapon authored Jan 1, 2025
1 parent a57c40d commit 6483f94
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 5 deletions.
8 changes: 4 additions & 4 deletions ChapterMaster.yyp
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"daemon7.png","CopyToMask":-1,"filePath":"datafiles/images/diplomacy",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"daemon8.png","CopyToMask":-1,"filePath":"datafiles/images/diplomacy",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"daemon9.png","CopyToMask":-1,"filePath":"datafiles/images/diplomacy",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"diplomacy_icons.png","CopyToMask":-1,"filePath":"datafiles/images/diplomacy",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"diplomacy10.png","CopyToMask":-1,"filePath":"datafiles/images/diplomacy",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"diplomacy11.png","CopyToMask":-1,"filePath":"datafiles/images/diplomacy",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"diplomacy12.png","CopyToMask":-1,"filePath":"datafiles/images/diplomacy",},
Expand All @@ -184,6 +183,7 @@
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"diplomacy6.png","CopyToMask":-1,"filePath":"datafiles/images/diplomacy",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"diplomacy7.png","CopyToMask":-1,"filePath":"datafiles/images/diplomacy",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"diplomacy8.png","CopyToMask":-1,"filePath":"datafiles/images/diplomacy",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"diplomacy_icons.png","CopyToMask":-1,"filePath":"datafiles/images/diplomacy",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"instructions.txt","CopyToMask":9223372036854775807,"filePath":"datafiles/images/diplomacy",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"symbol1.png","CopyToMask":-1,"filePath":"datafiles/images/diplomacy",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"symbol2.png","CopyToMask":-1,"filePath":"datafiles/images/diplomacy",},
Expand Down Expand Up @@ -396,10 +396,10 @@
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"eldar.json","CopyToMask":-1,"filePath":"datafiles/main/names",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"genestealercult.json","CopyToMask":-1,"filePath":"datafiles/main/names",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"hulk.json","CopyToMask":-1,"filePath":"datafiles/main/names",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"imperial_ship.json","CopyToMask":-1,"filePath":"datafiles/main/names",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"imperial.json","CopyToMask":-1,"filePath":"datafiles/main/names",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"ork_ship.json","CopyToMask":-1,"filePath":"datafiles/main/names",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"imperial_ship.json","CopyToMask":-1,"filePath":"datafiles/main/names",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"ork.json","CopyToMask":-1,"filePath":"datafiles/main/names",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"ork_ship.json","CopyToMask":-1,"filePath":"datafiles/main/names",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"sector.json","CopyToMask":-1,"filePath":"datafiles/main/names",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"space_marine.json","CopyToMask":-1,"filePath":"datafiles/main/names",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"star.json","CopyToMask":-1,"filePath":"datafiles/main/names",},
Expand Down Expand Up @@ -1443,6 +1443,6 @@
],
"templateType": null,
"TextureGroups": [
{"resourceType":"GMTextureGroup","resourceVersion":"1.3","name":"Default","autocrop":true,"border":2,"compressFormat":"bz2","directory":"","groupParent":null,"isScaled":false,"loadType":"default","mipsToGenerate":0,"targets":-1,},
{"resourceType":"GMTextureGroup","resourceVersion":"1.3","name":"Default","autocrop":true,"border":2,"compressFormat":"bz2","customOptions":"","directory":"","groupParent":null,"isScaled":false,"loadType":"default","mipsToGenerate":0,"targets":-1,},
],
}
1 change: 0 additions & 1 deletion datafiles/main/chapters/1.JSON
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@
"ninth": 0,
"tenth": 0
},
// * Not working yet
"extra_vehicles": {
"rhino": 0,
"whirlwind": 0,
Expand Down
3 changes: 3 additions & 0 deletions datafiles/main/chapters/template.JSON
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,9 @@
"ninth": 0,
"tenth": 0
},
/**
* All vehicles are added to the 10th company at the start of the game
*/
"extra_vehicles": {
"rhino": 0,
"whirlwind": 0,
Expand Down
69 changes: 69 additions & 0 deletions scripts/scr_initialize_custom/scr_initialize_custom.gml
Original file line number Diff line number Diff line change
Expand Up @@ -3202,6 +3202,75 @@ function scr_initialize_custom() {
scr_add_item(e_name, e_qty);
}
}
if(struct_exists(obj_creation, "extra_vehicles")){
var _slot = 1;
while(obj_ini.veh_role[10][_slot] != ""){ // try not to overwrite existing vehicles
_slot++;
if(_slot > 500){ // no crash pls
break;
}
}
if (_slot < 500){
if(struct_exists(obj_creation.extra_vehicles, "rhino")){
if(real(obj_creation.extra_vehicles.rhino) > 0){
repeat(real(obj_creation.extra_vehicles.rhino)){
add_veh_to_company("Rhino", 10, _slot, "Storm Bolter","HK Missile","","","Dozer Blades");
_slot++;
man_size += 10;
}
}
}
if(struct_exists(obj_creation.extra_vehicles, "whirlwind")){
if(real(obj_creation.extra_vehicles.whirlwind) > 0){
repeat(real(obj_creation.extra_vehicles.whirlwind)){
add_veh_to_company("Whirlwind", 10, _slot, "Whirlwind Missiles", "HK Missile", "","","");
_slot++;
man_size += 10;
}
}
}
if(struct_exists(obj_creation.extra_vehicles, "predator")){
if(real(obj_creation.extra_vehicles.predator) > 0){
repeat(real(obj_creation.extra_vehicles.predator)){
if (!floor(_slot % 2) == 1) {
add_veh_to_company("Predator", 10, _slot, "Twin Linked Lascannon Turret", "Lascannon Sponsons", "HK Missile", "","Searchlight");
}
if (floor(_slot % 2) == 1) {
add_veh_to_company("Predator", 10, _slot, "Autocannon Turret", "Heavy Bolter Sponsons", "Storm Bolter", "","Dozer Blades");
}
man_size += 10;
_slot++;
}
}
}
if(struct_exists(obj_creation.extra_vehicles, "land_raider")){
if(real(obj_creation.extra_vehicles.land_raider) > 0){
repeat(real(obj_creation.extra_vehicles.land_raider)){
if (floor(_slot % 4) == 1) || (floor(_slot % 4) == 2) {
add_veh_to_company("Land Raider", 10, _slot, "Twin Linked Heavy Bolter Mount", "Twin Linked Lascannon Sponsons", "HK Missile", "Heavy Armour", "Searchlight")
}
if (floor(_slot % 4) == 3) {
add_veh_to_company("Land Raider", 10, _slot, "Twin Linked Assault Cannon Mount", "Hurricane Bolter Sponsons", "Storm Bolter", "Heavy Armour", "Frag Assault Launchers")
}
if (floor(_slot % 4) == 0) {
add_veh_to_company("Land Raider", 10, _slot, "Twin Linked Assault Cannon Mount", "Flamestorm Cannon Sponsons", "Storm Bolter", "Heavy Armour", "Frag Assault Launchers")
}
_slot++;
man_size += 10;
}
}
}
if(struct_exists(obj_creation.extra_vehicles, "land_speeder")){
if(real(obj_creation.extra_vehicles.land_speeder) > 0){
repeat(real(obj_creation.extra_vehicles.land_speeder)){
add_veh_to_company("Land Speeder", 10, _slot, "Heavy Bolter", "", "","","");
_slot++;
man_size += 10;
}
}
}
}
}

if(scr_has_disadv("Sieged")){
scr_add_item("Narthecium", 4);
Expand Down

0 comments on commit 6483f94

Please sign in to comment.