Jump to content

FEXNA (Currently In Private Beta)


BwdYeti
 Share

Recommended Posts

No maybe I was unclear. I didn't mean "are your skills callable functions?" I was asking if you have functions that make custom skills easier to write

Edit: @Crazycolorz5, yeah I remember Alex telling me the same thing about making your references const

Edited by Brendor
Link to comment
Share on other sites

  • Replies 1.2k
  • Created
  • Last Reply

Top Posters In This Topic

No seriously though, guys, if you keep modifying references inside of code blocks you're going to get funny, hard-to-track bugs. Think functionally guys, functionally. Especially if you're using a high level language that allows it (I haz excuses for how ugly modular battle is because it's all in assembly :P But given to chance to write it in a higher level language...)

Try something like, in pseduocode because I haven't memorized C# syntax or anything:

//inside some calculation object

protected int? get_stats_hit(Game_Unit? unit);

protected int? get_stats_avoid(Game_Unit? unit);

public int get_final_hit(const Game_Unit& attacker, const Game_Unit& target)

{

const int? w_hit = get_base_hit(attacker.get_equip());

const int? stats_hit = get_stats_hit(attacker);

const int? stats_avoid = get_stats_avoid(target);

const int? hit_skill_bonus = attacker.getSkills().Where((skill)=>skill.name.substring(0,3)=="HIT" && double.TryParse(/*blah blah what was here before*/)).Aggregate(0, (acc, skill) => acc+Convert.ToInt32(/*blah blah same*/)

if(attacker.has_skill("KNIFE"))

{

return *knife formula*

}

else

{

int[4] relevant_nums = {w_hit, stats_hit, -1*stats_avoid, hit_skill_bonus};

//return relevant_nums.Aggregate(0, (acc, ele) => acc+ele.GetValueOrDefault());

//Or, for a more moldular-battle-esque approach

if(has_hit_skill(attacker.get_equip()))

{

return attacker.get_equip.get_hit_skill()(relevant_nums.Aggregate(0, (acc, ele) => acc+ele.GetValueOrDefault()),attacker, defender);

}

else

{

return relevant_nums.Aggregate(0, (acc, ele) => acc+ele.GetValueOrDefault());

}

}

}

edit:(dang it forum way to mess up my tabulations.)

edit2: made the skill handling code cleaner

Edited by Crazycolorz5
Link to comment
Share on other sites

(edit: I didn't know the int? thing either but guessing from what Tryhard said I just assume it's the C# equivalent of Scala's Option[int].)

I think in Java you can use Integer for null while int cannot. Or at least I can remember it like that.

I'm assuming Brendor means something like this, but I might be wrong. Java actually doesn't have structs, though it is pretty one of the red-haired step children of C# like C++ as Crazycolorz said.

Edited by Tryhard
Link to comment
Share on other sites

@Tryhard, I looked it up and it's basically the same as Scala's Option[int]. The idea is, it can contain either an int type or a null type. It differs slightly from Java's implementation in that they really are separate types and you need to check its type or ask it to get its value with a default.

Link to comment
Share on other sites

int32 is a 32-bit integer obv

TryParse, as written in this code, checks to make sure the substring after HIT is a valid number (since "HIT 20" is a valid skill name and increases hit by 20, but "HIT foo" is not). So basically what that part does is go through a for loop on the skills and anything with "HIT X" is checked to see if X is a valid double, and if so it's added to the int n. Presumably n modifies actor_hit later in some way but that's not in the screenshot.

The second calling of substring is a bit odd since it implies the last 3 characters in the string aren't important? Might just be how the skills are named, but it might just be substring working differently than what I'm used to with other languages.A quick google check says my suspicion that it works differently are right. substring(int X, int Y) in C# looks to start at the Xth character in the string, then go Y more characters deep, so that call would basically just make a string chopping off the first 3 characters.

edit: ninja'd hard

Edited by Paperblade
Link to comment
Share on other sites

@Brendor

return attacker.get_equip.get_hit_skill()(relevant_nums.Aggregate(0, (acc, ele) => acc+ele.GetValueOrDefault()),attacker, defender);

The idea behind this line, which is expandable to not just the equipped weapon, is that you can just make your skills ultimately be a function that has a prototype that looks like this:

int hit_bonus_skill(Game_Unit attacker, Game_Unit defender);

and this can be part of a skill struct and/or defined anonymously(yay!). I mean, I don't see any way to make it easier than that. The thing is, the way FEXNA is, it's easier to go in and directly re-modify the battle routines to check for a certain skill, allowing you to change it in a lot of different areas (as opposed to making just a bonus-hit skill). I actually talk a bit about this in the Renaissance Panel which Arch needs to edit/upload still.

Edited by Crazycolorz5
Link to comment
Share on other sites

Huh. I feel moderately better about myself after how much of that snippet I could grok.

It's a bitch to set up but once you get it it's really convenient as far as going back and making revisions

Crom laughs at your four winds. Or Crazycolorz laughs at your shortcuts, as the case seems to be.

*pokes head in* I know C++ and Java, and C# is their red-headed step child soooo, I can say i'm at least slightly proficient in it.

Oh yeah I did make this one thing in C# a long time ago but that sucked and I didn't know Java then.

A for-each loop is a staple in functional programming; imagine it as a higher order function that takes in a void function(element) and a list[elements] and performs that function on each list. Though technically in this case it's mutable so you'd want to use reduce/fold as analogy but agghhhhh I'm wscratching this out because it was poorly planned
The for each in list loop performs the actions with each taking the value of every element in the list once. So what that bit of code does it that it looks at every skill the actor has in his data and sees if it starts with "HIT", and if so, adds the parsed amount of hit to add to n, which I assume is an ongoing count for hit.

Also comeon guys, don't you know to pass in constant references to your functions!? What happened to code robustness and immutability? You're going to get funny bugs that are hard to trace this way. :\. You make sad programmer sad :(.

(edit: I didn't know the int? thing either but guessing from what Tryhard said I just assume it's the C# equivalent of Scala's Option[int].)

Given what you've shared of your background, if some university hasn't offered you an astounding amount of money to study there, I am going to be profoundly disappointed in the competence of higher education (moreso than I normally am.)

Edited by Siuloir
Link to comment
Share on other sites

Holy. Shit.

Someone else who's read Stranger in a Strange Land.

I didn't realize that it was unusual to have read Heinlein? He's pretty much one of the seminal science fiction authors.

Maybe it's a generation bracket thing.

I don't get your meaning

Conan the Barbarian (the film, not the much more amazing pulp stories and novellas by Robert E. Howard) reference.
Maybe this generation gap thing is more apparent than i thought...
Edited by Siuloir
Link to comment
Share on other sites

It's not just a generation gap, people don't read books anymore, and his was a cult classic novel for a reason. I literally don't know anybody else who's read it.

But wow uh, way offtopic.

To be honest I have no idea what you're talking about with regards to what Brendor just quoted.

Edit: Hey let's put stuff back on topic a little.

fce12d0359.png

Edited by Klok's Juicy Tits
Link to comment
Share on other sites

In what I've been discussing with Yeti, maybe they're be written like this

int skillCheckForHitBonus(Game_Actor a)
{
//code
}


//...
    delegate int hitFunction(Game_Actor a);
    hit_function = shillCheckForHitBonus
    BattleMonads[Hit].bindBonus(hit_function);
Edited by Crazycolorz5
Link to comment
Share on other sites

Most new shit the player might add to classes/units is coded as a skill. It's quite genius actually.

To be fair, you haven't been posting particularly complex snippets of code.

Link to comment
Share on other sites

To be fair, you haven't been posting particularly complex snippets of code.

That's the point, really. Many modifications to formulae, like statuses, are handled as skills because 90% of the time the entire effect of a skill can exist as 5 lines of code, and it's easy to see what the existing skills do or to edit them.

And if I move to a functional programming system like Crazycolorz is suggesting it's close to a 1:1 conversion in terms of moving pieces around.

So do you guys need C# help or not?

Not at the moment, no. If nothing else than because I'm focusing on FE7x's next release for NCFC right now. Check back in November, I think the the few months after that some real progress will be made.
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...