-
-
Save nelix/d05fe0e0d274f748ffd7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Helpers { | |
currentHP(db) { return db.PlayerInfo.CurrHP } | |
noCurrentHPGain(db) { return db.PlayerInfo.CurrentHPGain == 0.0 } | |
radiation(db) { return db.PlayerInfo.TotalDamages[5].Value } | |
aidItems(db) { return db.Inventory['48'] } | |
radiationMoreThan(rads) { | |
return db => { | |
this.radiation(db) > rads; | |
}; | |
} | |
healthDownBy(percent) { | |
return db => { | |
let {MaxHP, CurrHP} = db.PlayerInfo; | |
return (MaxHP - CurrHP) > (MaxHP * (percent / 100)) | |
} | |
} | |
findAid(text) { | |
return db => { | |
let item = this.findItemByText( | |
this.aidItems(db), | |
text | |
) | |
if(item) | |
return this.useItem(db, item) | |
}; | |
} | |
findItemByText(inventory, text) { | |
for(var item of inventory) | |
if(item.text == text) | |
return inv[i] | |
} | |
whenNotBusy(db) { | |
let { | |
IsDataUnavailable, | |
IsInAnimation, | |
IsInVats, | |
IsInVatsPlayback, | |
IsLoading, | |
IsMenuOpen, | |
IsPipboyNotEquipped, | |
IsPlayerDead, | |
IsPlayerInDialogue, | |
IsPlayerMovementLocked, | |
IsPlayerPipboyLocked | |
} = db.Status; | |
return !( | |
IsDataUnavailable || | |
IsInAnimation || | |
IsInVats || | |
IsInVatsPlayback || | |
IsLoading || | |
IsMenuOpen || | |
IsPipboyNotEquipped || | |
IsPlayerDead || | |
IsPlayerInDialogue || | |
IsPlayerMovementLocked || | |
IsPlayerPipboyLocked | |
); | |
} | |
useItem(db, item) { | |
return [ | |
'UseItem', | |
item.HandleID, | |
0, | |
db.Inventory.Version | |
]; | |
} | |
runCommandOn(subject) { | |
return (command) => { | |
if(command) | |
subject.onNext(command) | |
} | |
} | |
} | |
export default const helpers = new Helpers(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment