I’d recommend putting this in a subroutine. You can do it fairly easily like this. First, we need our stat to be changed, and a variable to control the announcement:
*temp empathy 50
*temp charisma 50
*temp announce_stat_changes true
Next we need our subroutine(s). (You can do it in one, and as an advance measure I’d recommend doing it as one, but I’ll show it as two to make it easier to follow.)
*label stat_raise
*params stat value
*set {stat} %+ value
*if announce_stat_changes
$!{stat} increased.
*return
*label stat_drop
*params stat value
*set {stat} %- value
*if announce_stat_changes
$!{stat} decreased.
*return
Then finally, rather than running *set
like usual to change our stats, we instead run:
*gosub stat_raise "empathy" 10
*gosub stat_drop "charisma" 10
So a few comments here. First, I presumed the use of fairmath, but you can obviously tweak and change to suit your needs.
The second comment is that you have to pay attention to how we used a {reference}
to change the real variable’s value, When we call the subroutine we pass it the variable name as a string, which is what lets us be able to both change the value of the variable, and display the name of the variable, but either using a {reference}
or not as required.
The third note is that, since we pass the subroutine the variable’s name as a string, it currently will display it as is, meaning a one word variable (empathy
) looks good: “Empathy Increased”, but a multiword variable name (jamie_relationship
) looks bad: “Jamie_relationship Increased”.
That all said, here’s the massive subroutine I use to do just this (note that it requires implicit_control_flow
).
Code Block
*label stat_bump
*comment Required variables: announce(false) [Can be changed in param_5] log(false) [Can be changed in param_6 only if not using logging]
*comment Best practices: Never use in a direct quote. Use at the end of sentences for short announcements, or at the end of paragraphs for long announcements or announcements of indeterminate length. Use appended to paragraphs, as it has its own paragraph breaks where necessary (i.e. it should not have a *line_break or paragraph break before it).
*params s x
*comment param_1 s:("variable"(numeric)) Stat: Input is either stat, or opposed pair (setup below)
*comment param_2 x:(numeric) Amount of change
*if x <= 0
*bug Stat change must be positive. Set parameter three to true to decrease stat.
*if param_count >= 3
*temp m param_3
*else
*temp m false
*comment param_3 m:(boolean) Minus: subtract rather than add. (optional: defaults to false)
*if param_count >= 4
*temp f param_4
*else
*temp f true
*comment param_4 f:(boolean) Fairmath: Use fairmath rather than plain addition/subtraction. (optional: defaults to true)
*if param_count >= 5
*temp a param_5
*else
*temp a announce
*comment param_5 a:(string|boolean) Announce: What announcement method to use (invalid = false). (optional: defaults to announce variable)
*comment Valid string parameters are "long" (aka "l"); "short" (aka "s"); "shortdesc" (aka "sd", true)
*if param_count >= 6
*temp l param_6
*else
*temp l log
*comment param_6 l:(false|string) Log: Stat is part of a log chain if not false. (optional: defaults to log(which should default to false))
*comment Valid string parameters are "open" (aka "o"); "body" (aka "b"); "close" (aka "c"); all other parameters are false
*temp r s
*temp o false
*comment r:report stat/variable; o:opposed(second of an opposed pair); y:amount of change
*if (m = "+") or (m = "%+")
*set m false
*if (m = "-") or (m = "%-")
*set m true
*if a = "l"
*set a "long"
*if a = "s"
*set a "short"
*if (a = true) or (a = "sd")
*set a "shortdesc"
*if (l = "o")
*set l "open"
*if l = "b"
*set l "body"
*if (l = "c")
*set l "close"
*if (l != "open") and ((l != "body") and (l != "close"))
*set l false
*comment fixes and aka above
*if s = "mature"
*set s "cute"
*if s = "honesty"
*set s "charm"
*if s = "retro"
*set s "modern"
*comment set opposed pairs above, where *if s = "non_variable"; then *set s "variable"
*if r != s
*set o true
*comment sets opposed_pair true if report stat is different from stat to be used above.
*if r = "julia_like"
*set r "Julia Like"
*if r = "julia_love"
*set r "Julia Love"
*if r = "isiah_like"
*set r "Isiah Like"
*if r = "isiah_love"
*set r "Isiah Love"
*if r = "sam_like"
*set r "Sam Like"
*if r = "sam_love"
*set r "Sam Love"
*if r = "julia_isiah"
*set r "Julia & Isiah"
*if r = "isiah_sam"
*set r "Isiah & Sam"
*if r = "sam_isiah"
*set r "Sam & Isiah"
*if r = "zoey_relationship"
*set r "Zoey Like"
*if r = "sophia_relationship"
*set r "Sophia Like"
*if r = "tristan_sophia_relationship"
*set r "Tristan & Sophia"
*if r = "vivian_relationship"
*set r "Vivian's Relationships"
*if r = "bonnie_relationship"
*set r "Bonnie Like"
*if r = "moonlight_development"
*set r "Moonlight Development"
*if r = "art_exhibit"
*set r "Art Exhibit"
*if r = "game_development"
*set r "Game Development"
*comment set display names above, where *if r = "variable_name"; then *set r "stat name"
*temp y {s}
*if not(f)
*if (o or m) and not(o and m)
*set {s} - x
*set y - {s}
*else
*set {s} + x
*set y ({s} - y)
*else
*if (o or m) and not(o and m)
*set {s} %- x
*set y - {s}
*else
*set {s} %+ x
*set y ({s} - y)
*if ((y > 5) and (a = "short")) and (l = false)
*comment "shortdesc" overrides "short" if amount of change is > 5, and not part of a log. Comment out the below line to turn off.
*set a "shortdesc"
*if (y = 0) and (a = "shortdesc")
*comment "short" overrides "shortdesc" if variable was not actually changed due to fairmath.
*set a "short"
*if a = "long"
*if (l = false) or (l = "open")
${""}
*elseif (l = "body") or (l = "close")
*line_break
*else
${""}
*if y = 0
[i]$!{r} is too @{m low|high} to @{m decrease|increase} further.[/i]
*else
[i]$!{r} @{m decreased|increased} by ${y} to @{o ${100-{s}}|${{s}}}.[/i]
*if (l = false) or (l = "close")
${""}
*else
${""}
*elseif a = "short"
*set r "$!{r}"
*if y = 0
*set r r&" too @{m low|high} to @{m decrease|increase}"
*label stat_bump_short_loop
*if y <= 0
*if (l = false) or (l = "open")
*set r "["&r
*if (l = false) or (l = "close")
*set r r&"]"
*if (l = "open") or (l = "body")
*set r r&","
[i]${r}[/i]
*goto stat_bump_short_loop_exit
*set r "@{m -|+}"&r
*set y - 1
*goto stat_bump_short_loop
*elseif a = "shortdesc"
*if (l = false) or (l = "open")
[i][@{m -|+}${y}
*else
@{m -|+}${y}
*if (l = "open") or (l = "body")
$!{r},
*else
$!{r}][/i]
*elseif a = false
*goto stat_bump_short_loop_exit
*else
*bug Invalid parameter: Announcement variable is ${a}. Acceptable values are "long", "short", or "shortdesc", or the booleans true or false.
*label stat_bump_short_loop_exit
*if l = "open"
*set log "body"
*if l = "close"
*set log false
*return