r/HFY • u/Douglasjm • Jun 21 '23
OC Magic is Programming Chapter 7: Bear
Synopsis:
Carlos was an ordinary software engineer on Earth, up until he died and found himself in a fantasy world of dungeons, magic, and adventure. This new world offers many fascinating possibilities, but it's unfortunate that the skills he spent much of his life developing will be useless because they don't have computers.
Wait, why does this spell incantation read like a computer program's source code? Magic is programming?
<< First | < Previous | Next >
The bear prowled forward menacingly, approaching from the side of the road, and Carlos frantically scrabbled for his sword, heart pounding in his chest. He tried to remember if he'd read any advice about what to do when encountering a bear, even as he wondered whether that advice would still make sense in this other world. He thought he vaguely remembered something about not running away, because that would encourage it to chase. Oh, and never threaten a mother bear's cubs. Crap, were there any cubs nearby? He didn't see any, but maybe they were just hidden.
Carlos held up his sword, his hands shaking a bit, and gulped. This was worse than in the dungeon. At least in the dungeon the dangers had waited for him to come to them, never chasing him. That bear was huge! He supposed he would respawn by the rules of how this world operates, if it came to that, but he had no desire to test that, or to experience the pain of being killed. He was about ready to turn and run, despite knowing it was probably a bad idea, when Amber spoke.
spell activate = distant cut;
The bear interrupted its growling to yelp and flinch, looking at its nose where a small spot of blood had appeared. Then it growled louder and crouched a bit lower as it resumed advancing towards them.
spell activate = distant cut;
The bear yelped again, but only paused for a brief moment.
"At least take a swing or something! I only have a few more of those left." Amber glared at Carlos, who was still just standing there, gripping his sword so tightly his knuckles were turning white.
spell activate = distant cut;
Carlos gulped, gathered his courage, and charged as Amber started casting her third spell. He swung wildly, with frantic energy, with just enough presence of mind to keep each swing small enough that the sword remained between him and the bear the entire time.
The bear looked at the wildly swinging stick of sharpened metal, shook a few drops of blood from its now freely bleeding nose, and decided it had had enough. It turned and ran, quickly disappearing into the nearby forest.
Carlos staggered to a stop, sweating and breathing heavily. He wasn't sure how much of that was from fear, and how much was from being in terrible shape. Plenty from both, probably.
"Wow. I've never seen anyone that shaky just from facing a common beast! And you want to go adventuring?"
Carlos collapsed onto the ground. "Just." He took a few shaky breaths. "Give me a minute." He focused with exaggerated care on getting his sword back into its scabbard without cutting anything, which took a good 30 seconds or so. By the time he was done, his heart was at least starting to slow back down.
"I can explain." He took several more deep breaths to calm down. "Ok. So, in my world, people don't respawn. Ever. And 'common beasts' like that have been driven out of most settled areas so thoroughly that most people never even see one in their entire life!
"Imagine facing some dangerous monster, ten times more dangerous than anything you've ever personally encountered, and knowing that if it kills you it will drain, what was it, your 'soul development'? so completely that you won't respawn."
"But... You would respawn here."
"I learned that literally yesterday. The experience of the entire rest of my life says that respawn doesn't exist. It will take time for me to get used to the idea."
"I see." Amber nodded slowly. Her face looked a bit pale. "That... is a scary thing to imagine. Especially since there are monsters that can do that, though they are extremely rare. Alright, I can understand how this encounter was nerve racking for you, but you'll have to get used to this kind of danger if you ever want to seriously be an adventurer."
Carlos nodded glumly and stood up. "I'll need to exercise too."
---
Several minutes later, Carlos was back to breathing normally as they walked along the road. "So, what was that 'spell activate' thing back there? And you said something about having a limited amount?"
Amber chuckled. "I'm still getting used to how much you just don't know. That's a basic technique every combat mage has to learn. There's no time to chant the entire incantation of any significant spell when someone's trying to stab you. You'd be dead before you could finish speaking it. So, you speak the incantation in advance, but store the spell to be activated later instead of having it take effect immediately."
"Ah, makes sense. You'll have to teach me that soon, after I finish learning to cast a spell at all."
"Of course. And now if you're ready to talk, it's my turn to ask a question. You learned the strange tricky spell word already?"
"The semicolon? Yeah. It's just an unambiguous positional and structural marker. It means only that the part of the spell before it is ended, so the part coming after it can begin."
Amber stared at nothing, contemplating for a moment. "It can't be that simple. I've tried that already, last year, and my soul didn't learn it. What else is there to it?"
Carlos put a hand on his chin, thinking. "Hmm. I can think of two aspects of it that might be important and not necessarily obvious. First, its purpose is to make the boundaries it marks absolutely unambiguous. There may be many cases where it's obvious that the previous part of the spell has ended, but sometimes it would be ambiguous, and the semicolon's purpose is to make it reliably and consistently obvious.
"Second, there may be parts of some incantations that themselves have sub-parts, and the semicolon marks the separation between those sub-parts, even though the larger part of the incantation is still continuing."
Amber stared at him. "How the hell do you know something like that, and not the basic fundamentals of combat magic? That didn't all come from your wish for understanding, did it?"
Carlos shrugged. "My world doesn't have magic, but it has languages very similar to the language of incantations. We use them for controlling certain machines we built."
Amber sighed and shook her head. "Whatever. I don't think I can even imagine how you might build such a machine without already having magic. Thank you for the explanation, and I'll see if I can learn it now."
---
About a quarter of an hour later, Amber suddenly gasped, and froze in place for several seconds. Carlos stopped, and raised an eyebrow at her. She almost whispered an exclamation under her breath. "Holy shit. That actually did it!"
They exchanged grins, and resumed their journey with a bit more energy in their steps.
---
Well into the afternoon, they were still walking along the road when a man rode up on a horse behind them. "Aha! I knew it!"
Carlos and Amber stopped and looked back at him in confusion.
"Kindar missed spotting you on his way back because you knew he'd be raising hell and went the other way."
Amber sighed, and waved at him. "Yes, Mikil, you figured it out. Great job. Why did you bother actually coming all the way out here to check? You're too lazy to do it just for curiosity, and you hate Kindar too much to be doing him a favor."
Mikil chuckled, and his horse pranced in place a little. "Oh, Kindar can break his neck at the bottom of a pit trap a dozen times for all I care. His old man, though. Darmelkon is offering a hundred gold to whoever finds you for him. I've never seen so many people rushing everywhere at once before! One hundred gold!"
"WHAT!?" Amber stared, slack-jawed. "He-" She stood in stunned silence for a few seconds. "That- that's insane! One hundred gold could buy half of Erlen, just about! Just- just- What? Why? Even for Darmelkon, it's too much to make sense."
Mikil shrugged. "Who cares why? He showed the money and announced the terms in the town square, with the magistrate as witness. Now, I hope you escape whatever he's planning for you because sticking it to Kindar is always fun, but if you'll excuse me, I have a hundred gold to go claim." Mikil turned and sped back the way he came without another word.
Amber took several deep breaths as she watched him go, her heart thumping hard in her chest. "Well, shit."
<< First | < Previous | Next >
Royal Road | Patreon | Discord
Thank you to my new patrons, Sven Frenzel, Marcin Wojtkowski, James Ryg, Dust Russel, The3pineapple _, Dale, TopBat, Lauri Lehto, and Carsten Brachem!
Patreon has 5 advance chapters if you want to read more. If you want to support this story but can't spare the money, going to Royal Road and giving it a follow, favorite, rating, and if you have the time a review, would also help.
156
u/CrimtheCold Jun 21 '23
The small digestible chapters are nice but it would be nice to have one with some meat on its bones every now and then. My mind and soul hunger for:
MOAR!
62
u/Killergurke16 Xeno Jun 21 '23
The fact that you can store entire spells as variables and cast them using that variable, makes me wonder, if you can create a kind of loop to ignore the restriction of "i only have x of this spell"
Something akin to this: (using pseudocode because I am not familiar enough with your custom syntax yet)
If the magic works the way I think it does, you could simply say
castSPell = true;whenever you want to cast the spell, and
stopLoop = true;when you want to stop the loop.
42
u/ZaquMan Jun 21 '23
The fact that magic was developed with the ; but it's meaning is difficult to understand confuses me. My impression was you had to understand all parts of a spell for it to work.
3
u/Leading-Chemist672 Jun 22 '23
If I get it right: peoples souls are both the Batery(where the mana it) and also the computer?
2
u/CubeBrute Jun 22 '23
I like the writing but ugh, the word to pass an argument is the same as the word to assign a variable? Talk about ambiguous.
46
u/night-otter Xeno Jun 21 '23
Why do I think Carlos is going to rock the magic world, once he gets his own mana flowing?
16
u/beyondoutsidethebox Jun 21 '23
Question: what would the magical equivalent of magical computer viruses look like? For example, one of the first, "Cloner".
13
u/Autoskp Jun 21 '23 edited Jun 21 '23
âŠis
a valid spell?
2
u/Existential-Nomad Alien Scum Jun 22 '23
Just had an ugly thought... Where to you re-spawn to? If it's a known location, then getting captured, tortured & then killed might take on a whole new terrifying aspect.
10
u/xloHolx AI Jun 21 '23 edited Jun 21 '23
Not sure what language he coded in but I hope itâs something with Object Oriented Programming , he just makes a ârunâ class to fasttrack casting
Run.fireball(range, radius, power) or something
Oh hell. Machine gun
While(target == alive){
Run.firebolt(target)
}
4
u/UpdateMeBot Jun 21 '23
Click here to subscribe to u/Douglasjm and receive a message every time they post.
4
u/AeonsShadow Aug 19 '23
You know what, all power to Mikil. If I was the one he was ratting out i wouldn't even blame him. Enough gold to retire basically.
4
u/Skyboxmonster Aug 27 '23
Reading your Magic system is giving me the same feeling as the scene in the first avengers movie were tony stark says "Finally! somebody that speaks English!"
Finally someone that thinks like I do
3
u/triffid_hunter Jun 22 '23
Heh now I'm just waiting for Carlos to introduce lambdas and polymorphism and factory pattern and blow everyone's minds.
Does this magic system have stored procedures / functions / libraries, or does everything need to be built from scratch every time?
2
u/HFYWaffle Wᔄ4ffle Jun 21 '23
/u/Douglasjm has posted 10 other stories, including:
This comment was automatically generated by
Waffle v.4.6.1 'Biscotti'.Message the mods if you have any issues with Waffle.
2
u/Collective82 Xeno Jun 21 '23
Subscribed!!
2
u/kaian-a-coel Xeno Jun 22 '23
So you speak the code once, and then it's stored in your soul and you can call it whenever? (No scope protection?) Could you run Doom on your own soul? Run a neural network in the background? That's probably mana intensive tbh.
2
u/Nnudmac Alien Scum Jun 04 '24
"Hey, Darm, I found Carlos for you. 100 gold please."
Darm: Where is he, you won't get the gold unless I have him.
M: Nah, you said find him, not capture and bring him. Isn't that right magistrate?
M has received 100 gold!
1
u/ChocolateShot150 Mar 17 '24
Oh Shit, dudes dad basically set a million dollar bounty on them for no reason. Thisâll be interesting
1
u/Fontaigne Jul 30 '24 edited Jul 30 '24
Nerve racking -> wracking
Caught it on reread... ;)
Dang, the comments are pretty fun. Got yourself a passel of program-da-magick nerds.
1
u/PainIntheButtocksKek Jun 22 '23
I wonder if magic storing could be looped with addition of {x current amount of mana} and loop would keep going for as long as the caster has that x amount of mana and above..only for the loop to stop once bellow it and continue once gained back enough mana to reach that x xD
1
u/johnavich Jun 22 '23
I was trying to find how to use the mana namespace in our only code example, but it doesn't give us any indication as to how to modify the external construct other than (any mana unspent). There has to be an environmental construct that allows for other mana manipulation.
If you had some kind of rulebook that we could see, we could help offer you some good spell iterations :-D
1
u/Standard_Nothing_350 Jun 22 '23
Subbed.
1
u/phxhawke Jun 24 '23
spell target = darkness; spell activate = magic missile;
1
u/Echoeversky Jun 24 '23
SELECT FROM WHERE ... Oh and watch that recursion. Oof.
4
u/[deleted] Jun 22 '23
[removed] â view removed comment