Added.
Example:
items:
- type: STR_LASGUN
compatibleAmmo: [STR_LASGUN_CLIP]
confAimed:
spendPerShot: 4 # 4x battery consumption for 2x power
name: STR_BIG_BOOM
confSnap:
name: STR_SMALL_BOOM
tags:
BPL_AIMED_2X_POWER: 1 # custom script
"onFiring" script is not easy, and not very well definable either.
I've added bullet consumption via ruleset; tested only on player-controlled units so far.
Help testing on AI would be appreciated.
The second part can be solved via standard "hitUnit" script.
Example:
# Battery Powered Lasgun script by Meridian
extended:
tags:
RuleItem:
BPL_AIMED_2X_POWER: int
scripts:
hitUnit:
- offset: 0.1
code: |
var int temp;
if eq battle_action battle_action_aimshoot;
weapon_item.getTag temp Tag.BPL_AIMED_2X_POWER;
if neq temp 0;
# debug_log "hitUnit: yo, double up!";
mul power 2;
end;
end;
return power part side;
Full sample mod is attached.
Please allow me to consider another question. What if I need to have a weapon that uses this type of battery munitions, but also confers a power bonus. At the same time, I would like to have a weapon that also uses the same type of battery munitions, but without power bonus. A use case may be a sniper rifle and a machine gun. How could I encode this distinction in the weapon definitions?
Would it work, if I simply encode the
powerBonus with a weapon itself, rather than munitions?
Also, is there a way to change completely the definition of a shot? Could I use the same battery for laser and warp or EMP cannons? How would it be best to approach this task? Should I encode the damage types with the weapon itself through
damageAlter? What should I indicate in the battery definition? Would it work if I set no
damageType and
power with battery, but would set those with a weapon?