Here I will post some scripts I use to fine-tune the game experience to my liking
4. Critical hits. Code for simple critical hits. Might still be a bit finicky. I use this because I play with with a very low damageRange.
I've been playing around with the critical hit code, combining it to the "turn red for one frame" code and a message to show critical hits.
extraStrings:
- type: en-US
strings:
STR_CRITICAL_HIT_MESSAGE: "Critical hit!"
extended:
tags:
BattleUnit:
CRITICAL_STATE: int
LAST_HIT_FRAME: int
RuleItem:
CRIT_CHANCE: int
CRIT_DAMAGE: int
scripts:
# Future Script for luck
#
# Script for Criticals
damageUnit:
- offset: -1 # critical hits (balancing for lower damageRange)
code: |
var ptr RuleItem item_rule;
var int weapon_chance;
var int unit_chance;
var int chance;
var int crit_factor; # 100 = 100% additional damage of original power
var int crit_damage;
var int temp;
weapon_item.getRuleItem item_rule;
unit.getTag unit_chance Tag.CRITICAL_STATE;
item_rule.getTag weapon_chance Tag.CRIT_CHANCE;
item_rule.getTag crit_factor Tag.CRIT_DAMAGE;
add unit_chance weapon_chance;
if eq unit_chance 0;
set unit_chance 5; # base chance of 5% for everybody
end;
if eq crit_factor 0;
set crit_factor 100; # 100% additional damage as baseline for everybody on crit
end;
battle_game.randomChance unit_chance; # will set unit_chance to 1 on success
if gt unit_chance 0;
set crit_damage orig_power;
muldiv crit_damage crit_factor 100;
add to_health crit_damage;
# Flash RED when crit hit
# NEED TO BUILD IN A CHECK TO SEE IF ITS WEAPON DAMAGE FFS
battle_game.flashMessage "STR_CRITICAL_HIT_MESSAGE";
battle_game.getAnimFrame temp;
unit.setTag Tag.LAST_HIT_FRAME temp;
debug_log "CRITICAL HIT:" crit_damage;
end;
return;
recolorUnitSprite:
- offset: 10
code: |
var int temp;
unit.getTag temp Tag.LAST_HIT_FRAME;
if neq temp 0;
sub temp anim_frame;
if gt temp -3; #only 3 frames after hit have changed color
set_color new_pixel 2; #red color
end;
end;
return new_pixel;
I need to figure out
1) How to connect it to shoot script, since I'd love to have it as 5% for snap shots, 1% for auto shots and 10% for aimed shots.
a) Also I need it to stop declaring critical hits for smoke
2) How to change the code so that it leaves off a damage roll and just gives the base damage number (100%) and then reduces armor effectiveness to 0.25
But I haven't been playing with it all that much yet. Too busy streaming.
Thanks for posting this up.