I press the Analyze option, and sure enough, the same programming window appears like before, but this time it isn’t blank. There is something written and it really does look like a programming language, just one that I don’t recognize:
[Yellow] Fireball:
import Magic_Class.Projectile;
import Magic_Class.Effect;
import User;
public class Fireball extends ManaActivity {
@Override
protected void onActivation() {
boolean active = true;
while(active) {
if (User.Brain.Thought_detection == "Shoot") {
private Projectile fireball = new Projectile;
// fireball initiation
fireball.shape = "SPHERE";
fireball.volume = 0.06; // in m³
fireball.velocity = 100; // in m/s = Kinetic energy
fireball.acceleration = 0; // in m/s²
fireball.power = 600; // in KiloJoule = Potential energy
fireball.element = "FIRE";
fireball.starting_point = User.limbs.hand.palm;
fireball.trajectory = "Y = V0y*t - 1/2*g*t²";
// shoot the actual fireball
fireball.launch();
private boolean fired = true;
long start = System.currentTimeMillis();
long end = start + 5*1000;
while(fired && System.currentTimeMillis() < end){
if(CollisionDetected(fireball)){
fired = false;
ApplyBurnEffect(fireball);
}
}
fireball.detonate(); //unleashes explosive force of the fireball
}
if (User.Brain.Thought_detection == "Deactivate") {
active = false;
}
}
};
// Modifier 1: Collision detection
public boolean CollisionDetected(Projectile fireball){
if(fireball.velocity == 0){ //fireball stops when it hits anything
return true;
}
else{
return false;
}
};
// Modifier 2: Burn effect
public void ApplyBurnEffect(projectile fireball){
private Effect burn = new Effect;
// Effect initiation
burn.shape = "SPHERE";
burn.effective_radius = 0.065; // in m³
burn.targetPrimary = "ORGANISMS";
burn.targetSecondary = "SURFACES";
burn.center_point = fireball.center_point;
burn.duration = 6; // in seconds
// Start the effect
burn.apply();
};
};
Okay, this is a lot to take in at once… I can’t quite make sense of it yet, but it doesn’t look overly complicated either. For now, I’ll just write it all down on a piece of paper.
This confirms it, I’m the one with a special power… Why though?
Is it because I woke up in the middle of the abduction? Wait… did I talk to the aliens before I fell back asleep? What did I say to them… “Aaawh, fuck!”
Goddam! It feels like my head is about to explode… It seems like every time I try to think about the abduction, I get a severe headache…
Maybe I’ll get some answers from the government after I become a high ranking Machia…
I put the code I copied in my backpack and head back to Lance and Fudo after ejecting his fireball-cartridge.
“Okay Lance I’m finished.”
I sit down next to him and secretly hand him the cartridge behind our backs.
“Did you really make his assignment for him Reo? Not fair!”
“Y-Yeah Fudo, he didn’t understand any of it, it was just a lot faster this way. Looks like you’re not the only muscle-brain here Ha-Ha- AUWTCH”
I feel Lance pinching me in the back. Fudo looks confused, well, not like that’s unusual or anything.
“Don’t worry Fudo, I think a mosquito just stung me or something…”
After some more joking around and playing with Sakura, I finally head back to my dorm.
…
“Honey I’m home~ !”
“Shut up! I’m trying to concentrate!”
Alas, such beaty is truly wasted on a rude girl like her.
I study the code some more in my bedroom before going to sleep. I discovered that the main code uses 2 different modifiers, one modifier to burn the target on contact with the fireball and another modifier to detect that contact…
I need to quickly come up with a magic I could program on my yellow cartridge based on the fireball-code, I only have 2 days left until the dual… Let’s just go to sleep for now though.
…
I wake up late for my first couple of classes, looks like Sara already left. I thought about it some more in my sleep and decided I needed a cheap yet powerful magic that’s faster than a regular fireball, since my opponent will likely also use a fireball cartridge… It’s a very common cartridge after all…
Let’s go to Mr. Ito’s class, maybe he’ll give me some ideas?
…
“Alright class now that even our wood [I] student ‘Van Dijk’ graces us with his presence, can anyone tell me the number one factor that determines a Machia’s strength?”
Lance raises his hand:
“It’s mana sir, without mana a Machia is nothing…”
“Great answer Lance, without mana a Machia can’t execute any top-level magic. However, a lot of people also overlook the magics themselves. The cartridges in the market today are mostly of the common and uncommon rarity- *SIGH* Yes Reo?“
I raised my hand after hearing ‘common and uncommon rarity’.
“What is this rarity you speak off? Aren’t cartridges divided based on color?”
*SIGH* “You don’t even know something as simple as this? Fuck my job man… Right, very good question Reo. Cartridges of the same color are further categorized based on rarity, an arbitrary measure of the amount of revealed cartridges with a particular magic, it goes from common – uncommon – rare – legendary to unique. Unique basically being the only one of its kind.”
Fuck, I guess all my programmed cartridges are going to be unique then, hope that doesn’t attract too much attention…
“Eeuurr thanks, Mister Ito…”
“No problem. Now, like I was saying, you won’t become a powerful Machia with just uncommon and common cartridges, these are predictable and usually less powerful then rare or legendary ones. That’s why I think money is also vital for becoming a powerful Machia, whether it’s buying unrevealed cartridges directly from the market-place or buying access to a guild-owned dungeon, you’ll need money on your way to the top, a lot of it.”
After his speech, Mister Ito rambled on about what factors determine the kinds of magic you can discover from unrevealed cartridges. It basically boiled down to your affinity, your talent and your luck. He didn’t really explain what talent meant though and I was too late to ask him about it.
In the end he didn’t really give me any ideas for a magic I could program.
I should at least be able to fire my magic twice, even if I only have a mana-pool of 100. It should be powerful enough to rival fireball, and it should be a lot faster…
I got it!
Okay, I don’t mean to nitpick, but as a coder, I must talk about your code. I’m assuming that there are a ton of event listeners to handle damage and the burn effect, but the collision detection is a bit off. What happens if it hits something and knocks it back, allowing it to keep going forward? That wouldn’t count as a collision in your code.
What is onActivation overriding? Fireball doesn’t seem to extend anything.
Since your methods aren’t static, what is creating the instance of Fireball and calling the activation method?
How does mana fit into the code? I figured it would be a parameter, but is it a private method in the spell superclass, something like calculateMana()?
That’s all I’ve got at the moment, but this all looks pretty good.
True the collision isn't perfect and it might not lose enough velocity in some circumstances for it to activate (although it barely has any mass to push around objects since it's basicly pure energy), that's why the loop also depends on a timer that'll make it explode after a while. The damage is also pyhsics based and relates to the potential energy the fireball starts with and is released upon detonation.
You're right about the extending, i forgot to extend from a main magic super class of some sort (will fix it).
I derived 'onActiviation' from the 'onCreate' of a java script for android studio, in this context it basicly means that it'll activate or be called when the user subconsciously wants to use the particular fireball magic (kind of like opening an app).
And yes, mana is handled behind the scenes by that magic super class. I didn't want it to be incorporated into the code itself since it could get very complicated and time consuming for me, especially with the cartridges that have a lot of modifiers later on in the story.
Thanks a lot for the feedback tho, you're probably better at coding than me, so would appreciate tips in the future too ;)
@Niku20 One of the reasons I was thinking about mana was because if you are writing your own spells, you would really want to know how much mana they cost. If you knew the mana calculation formula, you could even give an input for the amount of mana you want to spend and get the correct spell values for it. This especially relates to him, as he has a limited mana-pool, and would want to make every point count.
@TrussiaLink Yeah, Mana-cost of spells will be eleborated upon in the coming chapters when he starts writing his own spell :)
@Niku20 So based on the code he can only have one fireball in existence at a time? Would be interesting if he could find a way to make that async. Also I hope the editor has some debugging options so he can explore the language some by trying to echo out variables and what not without having to burn through cartridges.
Edit: also if he can add
while((fired && System.currentTimeMillis() < end) || User.Brain.Thought_detection == "Explode")
so he can have it explode early if he misses.
@ShadeByTheSea I just want the explosion function on an infinite loop.
@Niku20 Also, this guy supposedly worked as a coder for a company. This code is so ridiculously simplistic that even me, a person who only does coding when absolutely necessary and relies almost entirely on Unities built in systems. can instantly understand it, and can easily rewrite the entire code to do pretty much anything since it's been based on java and it's calls are all done to external banks that handle everything externally, this code literally just says to call from existing functions elsewhere that are clear as day and I don't even need to see those external sources to figure out exactly what they all do.
So a guy who actually works as a coder. Would look at this and say "too simple" and instantly make a nuke.
Also you made a coding error. quite a few actually.
You have.
fireball.acceleration = 0; // in m/s²
as your defined variable for movement. But you also have
fireball.velocity = 100; // in m/s = Kinetic energy
Which is dumb. You only need one of these two things. And in fact any seasoned coder will tell you to never directly use acceleration and velocity at the same time. Also neither of these calls or defines any sort of direction.
fireball.trajectory = "Y = V0y*t - 1/2*g*t²";
This also doesn't suffice as Y is a single coordinate but you'd need at least 3 without explicitly using Quaternions. You literally only gave it 1 single axis of coordination and even a physics major specialized in researching 5th dimensions and above can tell you that no, you can't get around needing to define the 3 axis just because "But it's like magic" NO this code is clearly extremely simplistic and requires everything our normal code requires. there is no reason for it to not require you to at least define more than 1 single axis for trajectories.
Unless for some reason beyond any belief these aliens defined A call to a Quaternion elsewhere as "Y"
@crystalkalem Yeah you're right, the code is pretty simple, this is because I wanted casual viewers or beginner-coders to also follow along and somewhat understand the mechanics behind the programming-language (plus i didn't want to spend to long on writing imaginary code, hence the many libraries).
The code is also based on java (written for android studio specifically).
And finally, the code is quite simple to understand for our MC coder here, he can easily tweak parameters and whatnot to make a 'nuke', however, debugging his magic-code is an absolute nightmare since the system doesn't tell him where the error lies, he doesn't know the function calls or libraries (or even the syntax) and he has to keep in mind the mana-consumption of his magic. These things make writing magic-code quite 'complex' for our MC.
[EDIT] Yeah, acceleration probably wasn't really necessary, as for the trajectory, this was my reasoning: knowing that the starting point is the palm of the hand, the axis coming out from the hand would be Y, to the right of the hand would be X and going up would be Z. This would be handled and interpreted by the libraries to define the direction and how far the fireball can travel in order to avoid a complex code section about following the movements/direction of the palm or a section about the standard values of the other two axes.
Hope this cleared a few things up, your criticism is valid though, the code isn't amizingly written or complex. I just wanted to give some background information. :)
@Niku20 Using coding as a medium to exploit magic has been done before, and it’s mostly been at this level of depth. You made a good choice in sticking to readable code that normal readers can figure out.
@Niku20 Soooo... what you're saying is... the alians defined the quaternion call address simply as. Y... I mean... they are alian.
@crystalkalem I'm sure this is just the human readable code language, the java for magic. The aliens might instead write in the magic c++ code, or real elite aliens write in magic machine code.