-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathbasic-ability.txt
More file actions
68 lines (57 loc) · 1.59 KB
/
Copy pathbasic-ability.txt
File metadata and controls
68 lines (57 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<<silently>> /% StoryNexus BasicAbilities %/
<<set $broadScale to 60>>
<<set $narrowScale to 10>>
<<script>>
var get = State.getVar || Wikifier.getValue
var set = State.setVar || Wikifier.setValue
window.BasicAbility = function(type, skill) {
if(this instanceof BasicAbility) {
this.type = type
this.skill = skill || 0
this.chance = BasicAbility.chance[type]
} else return new BasicAbility(type, skill)
}
BasicAbility.prototype.ranges = [
'almost impossible', 10,
'high-risk', 30,
'tough', 40,
'very chancy', 50,
'chancy', 60,
'modest', 70,
'very modest', 80,
'low-risk', 90,
'straightforward'
]
BasicAbility.prototype.changes = {
'almost impossible': [-4, 6],
'high-risk': [-3, 5],
'tough': [-2, 4],
'very chancy': [-1, 3],
'chancy': [-1, 3],
'modest': [-1, 2],
'very modest': [-1, 2],
'low-risk': [-1, 2],
'straightforward': [-1, 1]
}
BasicAbility.chance = {
broad: function(difficulty) {
var percent = this.skill / difficulty * get('$broadScale')
return Math.max(1, Math.min(99, percent))
},
narrow: function(difficulty) {
var percent = (this.skill - difficulty) * get('$narrowScale')
return Math.max(10, Math.min(99, percent + 50))
}
}
BasicAbility.prototype.difficulty = function(difficulty) {
return QBN.range(this.chance(difficulty), this.ranges)
}
BasicAbility.prototype.check = function(difficulty) {
var percent = this.chance(difficulty)
var success = State.random() * 100 < percent
var range = QBN.range(percent, this.ranges)
this.skill += this.changes[range][success|0]
return success
}
<</script>>
<</silently>>