|
1 | 1 | #!/usr/bin/env php
|
2 | 2 | <?php
|
3 | 3 | /* libdogma
|
4 |
| - * Copyright (C) 2012, 2013, 2014, 2015, 2016 Romain "Artefact2" Dalmaso <[email protected]> |
| 4 | + * Copyright (C) 2012, 2013, 2014, 2015, 2016, 2017 Romain "Artefact2" Dalmaso <[email protected]> |
5 | 5 | *
|
6 | 6 | * This program is free software: you can redistribute it and/or
|
7 | 7 | * modify it under the terms of the GNU Affero General Public License
|
@@ -422,6 +422,93 @@ function combine_expressions(&$json, array $expressionids) {
|
422 | 422 | return array_pop($expressionids);
|
423 | 423 | }
|
424 | 424 |
|
| 425 | +/* DEFASSOCIATION($assoc) */ |
| 426 | +function mkexpr_association(&$json, $assoc) { |
| 427 | + return query_or_insert_expression($json, [ |
| 428 | + 'operandID' => 21, |
| 429 | + 'expressionValue' => $assoc, |
| 430 | + ]); |
| 431 | +} |
| 432 | + |
| 433 | +/* DEFENVIDX($env) */ |
| 434 | +function mkexpr_envidx(&$json, $env) { |
| 435 | + return query_or_insert_expression($json, [ |
| 436 | + 'operandID' => 24, |
| 437 | + 'expressionValue' => $env, |
| 438 | + ]); |
| 439 | +} |
| 440 | + |
| 441 | +/* DEFATTRIBUTE($attr) */ |
| 442 | +function mkexpr_attribute(&$json, $attr) { |
| 443 | + return query_or_insert_expression($json, [ |
| 444 | + 'operandID' => 22, |
| 445 | + 'expressionAttributeID' => $attr, |
| 446 | + ]); |
| 447 | +} |
| 448 | + |
| 449 | +/* $env->$attr */ |
| 450 | +function mkexpr_att(&$json, $env, $attr) { |
| 451 | + return query_or_insert_expression($json, [ |
| 452 | + 'operandID' => 12, /* ATT */ |
| 453 | + 'arg1' => mkexpr_envidx($json, $env), |
| 454 | + 'arg2' => mkexpr_attribute($json, $attr), |
| 455 | + ]); |
| 456 | +} |
| 457 | + |
| 458 | +/* ($env->$attr).($assoc) */ |
| 459 | +function mkexpr_eff(&$json, $assoc, $env, $attr) { |
| 460 | + return query_or_insert_expression($json, [ |
| 461 | + 'operandID' => 31, |
| 462 | + 'arg1' => mkexpr_association($json, $assoc), |
| 463 | + 'arg2' => mkexpr_att($json, $env, $attr), |
| 464 | + ]); |
| 465 | +} |
| 466 | + |
| 467 | +/* (($destenv->$destattr).($assoc)).AddItemModifier($srcattr) */ |
| 468 | +function mkexpr_aim(&$json, $assoc, $destenv, $destattr, $srcattr, $customsrc = false) { |
| 469 | + return query_or_insert_expression($json, [ |
| 470 | + 'operandID' => 6, |
| 471 | + 'arg1' => mkexpr_eff($json, $assoc, $destenv, $destattr), |
| 472 | + 'arg2' => $customsrc ? $srcattr : mkexpr_attribute($json, $srcattr), |
| 473 | + ]); |
| 474 | +} |
| 475 | + |
| 476 | +/* Turns AIM into RIM, etc. Returns new exprID */ |
| 477 | +function flip_modifiers(&$json, $id) { |
| 478 | + static $mods = null; |
| 479 | + |
| 480 | + if($mods === null) { |
| 481 | + $mods = [ |
| 482 | + 2 => 54, /* GangGroupModifier */ |
| 483 | + 3 => 55, /* GangItemModifier */ |
| 484 | + 4 => 56, /* GangOwnerRequiredSkillModifier */ |
| 485 | + 5 => 57, /* GangRequiredSkillModifier */ |
| 486 | + 6 => 58, /* ItemModifier */ |
| 487 | + 7 => 59, /* LocationGroupModifier */ |
| 488 | + 8 => 60, /* LocationModifier */ |
| 489 | + 9 => 61, /* LocationRequiredSkillModifier */ |
| 490 | + 11 => 62, /* OwnerRequiredSkillModifier */ |
| 491 | + ]; |
| 492 | + foreach($mods as $a => $r) $mods[$r] = $a; |
| 493 | + } |
| 494 | + |
| 495 | + assert(isset($json['expressions'][$id])); |
| 496 | + $exp = $json['expressions'][$id]; |
| 497 | + |
| 498 | + if(isset($exp['arg1'])) { |
| 499 | + $exp['arg1'] = flip_modifiers($json, $exp['arg1']); |
| 500 | + } |
| 501 | + if(isset($exp['arg2'])) { |
| 502 | + $exp['arg2'] = flip_modifiers($json, $exp['arg2']); |
| 503 | + } |
| 504 | + |
| 505 | + if(isset($mods[$exp['operandID']])) { |
| 506 | + $exp['operandID'] = $mods[$exp['operandID']]; |
| 507 | + } |
| 508 | + |
| 509 | + return query_or_insert_expression($json, $exp); |
| 510 | +} |
| 511 | + |
425 | 512 | /* ---------------- */
|
426 | 513 |
|
427 | 514 | if($argc !== 2) {
|
@@ -732,10 +819,7 @@ foreach($json['effects'] as &$effect) {
|
732 | 819 |
|
733 | 820 | }
|
734 | 821 |
|
735 |
| - $association = query_or_insert_expression($json, [ |
736 |
| - 'operandID' => 21, /* DEFASSOCIATION */ |
737 |
| - 'expressionValue' => $assocstring, |
738 |
| - ]); |
| 822 | + $association = mkexpr_association($json, $assocstring); |
739 | 823 |
|
740 | 824 | $eff = query_or_insert_expression($json, [
|
741 | 825 | 'operandID' => 31, /* EFF */
|
@@ -766,54 +850,16 @@ foreach($json['effects'] as &$effect) {
|
766 | 850 |
|
767 | 851 | /* Expression for the AAR charge:
|
768 | 852 | * ((CurrentOther->armorDamageAmount).(PreMul)).AddItemModifier (CurrentOther->chargedArmorDamageMultiplier)
|
| 853 | + * Real dogma wouldn't accept this. |
769 | 854 | */
|
770 | 855 |
|
771 |
| -$source = query_or_insert_expression($json, [ |
772 |
| - 'operandID' => 31, /* EFF */ |
773 |
| - 'arg1' => query_or_insert_expression($json, [ |
774 |
| - 'operandID' => 21, /* DEFASSOCIATION */ |
775 |
| - 'expressionValue' => 'PreMul', |
776 |
| - ]), |
777 |
| - 'arg2' => query_or_insert_expression($json, [ |
778 |
| - 'operandID' => 12, /* ATT */ |
779 |
| - 'arg1' => query_or_insert_expression($json, [ |
780 |
| - 'operandID' => 24, /* DEFENVIDX */ |
781 |
| - 'expressionValue' => 'Other', |
782 |
| - ]), |
783 |
| - 'arg2' => query_or_insert_expression($json, [ |
784 |
| - 'operandID' => 22, /* DEFATTRIBUTE */ |
785 |
| - 'expressionAttributeID' => 84, /* armorDamageAmount */ |
786 |
| - ]), |
787 |
| - ]), |
788 |
| -]); |
789 |
| - |
790 |
| -$target = query_or_insert_expression($json, [ |
791 |
| - 'operandID' => 12, /* ATT */ |
792 |
| - 'arg1' => query_or_insert_expression($json, [ |
793 |
| - 'operandID' => 24, /* DEFENVIDX */ |
794 |
| - 'expressionValue' => 'Other', |
795 |
| - ]), |
796 |
| - 'arg2' => query_or_insert_expression($json, [ |
797 |
| - 'operandID' => 22, /* DEFATTRIBUTE */ |
798 |
| - 'expressionAttributeID' => 1886, /* chargedArmorDamageMultiplier */ |
799 |
| - ]), |
800 |
| -]); |
801 |
| - |
802 | 856 | /* Effect for the Nanite Repair Paste when used in an Ancillary Armor Repairer */
|
803 | 857 | $json['effects'][-10] = array(
|
804 | 858 | 'effectName' => 'internalAAREffect',
|
805 | 859 | 'effectID' => -10,
|
806 | 860 | 'effectCategory' => 0,
|
807 |
| - 'preExpression' => query_or_insert_expression($json, [ |
808 |
| - 'operandID' => 6, /* AIM */ |
809 |
| - 'arg1' => $source, |
810 |
| - 'arg2' => $target, |
811 |
| - ]), |
812 |
| - 'postExpression' => query_or_insert_expression($json, [ |
813 |
| - 'operandID' => 58, /* RIM */ |
814 |
| - 'arg1' => $source, |
815 |
| - 'arg2' => $target, |
816 |
| - ]), |
| 861 | + 'preExpression' => $id = mkexpr_aim($json, 'PreMul', 'Other', 84, mkexpr_att($json, 'Other', 1886), true), |
| 862 | + 'postExpression' => flip_modifiers($json, $id), |
817 | 863 | 'durationAttributeID' => null,
|
818 | 864 | 'trackingSpeedAttributeID' => null,
|
819 | 865 | 'dischargeAttributeID' => null,
|
@@ -906,6 +952,28 @@ $json['effects'][3380]['postExpression'] = combine_expressions($json, [
|
906 | 952 | $makeWDSGroupModifier(59 /* RLGM */, 46, 20, 1164), /* AB and MWD Max velocity */
|
907 | 953 | ]);
|
908 | 954 |
|
| 955 | +/* moduleBonusAfterburner: |
| 956 | + * ship mass += massAddition |
| 957 | + * speedFactor *= speedBoostFactor (thrust) |
| 958 | + * speedFactor /= ship mass |
| 959 | + * ship maxVelocity PostPercent speedFactor */ |
| 960 | +$json['effects'][6731]['preExpression'] = combine_expressions($json, [ |
| 961 | + mkexpr_aim($json, 'ModAdd', 'Ship', 4, 796), |
| 962 | + mkexpr_aim($json, 'PostMul', 'Self', 20, 567), |
| 963 | + mkexpr_aim($json, 'PostDiv', 'Self', 20, mkexpr_att($json, 'Ship', 4), true), |
| 964 | + mkexpr_aim($json, 'PostPercent', 'Ship', 37, 20), |
| 965 | +]); |
| 966 | +$json['effects'][6731]['postExpression'] = flip_modifiers($json, $json['effects'][6731]['preExpression']); |
| 967 | + |
| 968 | +/* moduleBonusMicrowarpdrive: |
| 969 | + * same as afterburner |
| 970 | + * ship signatureRadius PostPercent signatureRadiusBonus */ |
| 971 | +$json['effects'][6730]['preExpression'] = combine_expressions($json, [ |
| 972 | + $json['effects'][6731]['preExpression'], |
| 973 | + mkexpr_aim($json, 'PostPercent', 'Ship', 552, 554), |
| 974 | +]); |
| 975 | +$json['effects'][6730]['postExpression'] = flip_modifiers($json, $json['effects'][6730]['preExpression']); |
| 976 | + |
909 | 977 | /* skillEffect: bogus/unknown DEFASSOCIATION, skills are handled
|
910 | 978 | * correctly without it anyway */
|
911 | 979 | $json['effects'][132]['preExpression'] = -1;
|
|
0 commit comments