Unlimited party, improved damage formula, better healing system, comprehensive highlighting and more.
Cyrus
Posts: 20
Joined: Tue Nov 20, 2018 12:34 pm

Damage formula

Post by Cyrus » Tue Nov 20, 2018 12:47 pm

Hello Burn.

You have mentioned everywhere not to PM you, so I have to post this here.

First off, I really like and appreciate your damage formula. Work well done, and IMO best I've seen for the very reasons that you have mentioned, particularly that other formulas add unwanted elements which aren't categorically great, or may be preferential.

I wanted to ask permission to modify your damage formula mod for my personal use primarily ( and maybe public release if anyone else wants it).

I also need help as I just don't know enough and despite my effort to learn to do on my own, Ive been unsuccessful. So I'm also wondering if you'd be willing to help?

For example I want to use the X and Y variables from the ammo data in the damage formula, but I don't know how to call them (import them into memory for use).

Can you help me?

User avatar
Magus
Site Admin
Posts: 157
Joined: Mon Nov 21, 2016 9:13 am

Re: Damage formula

Post by Magus » Tue Nov 20, 2018 11:02 pm

Yes, I don't like explaining things repeatedly to different people. That's inefficient. So unless there's a reason why what you want to say should be private, no need to use private messaging.

The mod is available under CC BY-NC-SA 4.0, so as long as you honor it, you can do whatever you want, no need to ask for permission.

To get ammo X/Y multiplier, you need to use sfall's get_proto_data function, like it's used for getting DR mod. Offsets are here. Scripting reference also should help.
Please do not PM or email me about my mods and projects. Use forums. Also, see our talk channels.

Cyrus
Posts: 20
Joined: Tue Nov 20, 2018 12:34 pm

Re: Damage formula

Post by Cyrus » Thu Nov 22, 2018 9:18 am

Very well then. Thanks for the above. The references you mentioned are great, I didn't know about their existence. Not to say I understand them, I don't really for the most part, but thanks.

Your code is written in C++, correct?

I'm also wondering what do I need in order to edit and recompile it? I think I need an IDE and the damage mod file as well as the 4 "include" files. Am I correct?

Do I need anything else?

User avatar
Magus
Site Admin
Posts: 157
Joined: Mon Nov 21, 2016 9:13 am

Re: Damage formula

Post by Magus » Thu Nov 22, 2018 11:37 am

No, it's not C++, it's Star-Trek Scripting Language, or SSL. It does bear slight resemblance to C++ in that it also uses macro preprocessing.
Currently the best way to work with it is extended sfall script editor.
You're correct, the script plus the 4 files should be enough. But you'll probably want to download all headers anyway, they are in sfall modderspack.
Please do not PM or email me about my mods and projects. Use forums. Also, see our talk channels.

Cyrus
Posts: 20
Joined: Tue Nov 20, 2018 12:34 pm

Re: Damage formula

Post by Cyrus » Fri Nov 23, 2018 11:41 pm

Thanks for that burn.

Where can I learn the SSL syntax and documentation? Is there such a source?

I have found this page, https://falloutmods.fandom.com/wiki/Fal ... _(de_dood). But that's not complete.

I've also read some comments about some documentation being included in the "mapper". I don't know anything about that. Is that true?

Main question is, where can I find the documentation for this language so I can learn. I want to have a clear idea of how local and global variables work and how to declare them, so I don't [email protected]^k up. I have some familiarity with C++, but its been a long time and I've forgotten. I see a lot of similarities, but also differences. I need to know the basics solidly so I don't make mistakes.


Thank you.

User avatar
Magus
Site Admin
Posts: 157
Joined: Mon Nov 21, 2016 9:13 am

Re: Damage formula

Post by Magus » Sat Nov 24, 2018 4:44 am

What I linked is primary documentation. There's isn't really much to learn, syntax-wise. There are macros, procedures, loops, a few types of values, and that's basically it. Sfall adds more functions, and arrays, you can read about those.

There are some gotchas here and there, but the language itself is simplistic. I'm pretty sure that damage mod and other FO2tweaks scripts are easy to read. If you don't understand something in them even after doing due research, ask and I'll (try to) explain.

More importantly, if you want to start scripting, you've got to start scripting. You can stare at others' code for months, that won't lead to anything. Set a simple goal like displaying "Hello, Cyrus" upon loading the game. That can be done in 30 seconds and covers 50% of the syntax that you need to know.

Edit: and you don't need global variables (meaning vanilla GVARs or set_sfall_global) for a damage mod. Also, variables are scoped, so a variable declared inside a "begin" block is only seen inside that block. If you want a variable to be visible anywhere in the script, you just declare it outside any procedure.

Edit2: there's plenty of scripts in FO2tweaks repo to study, but if you need more examples, check sfall one. There are several (example) mods as well.
Please do not PM or email me about my mods and projects. Use forums. Also, see our talk channels.

Cyrus
Posts: 20
Joined: Tue Nov 20, 2018 12:34 pm

Re: Damage formula

Post by Cyrus » Sat Nov 24, 2018 9:37 am

If you want a variable to be visible anywhere in the script, you just declare it outside any procedure.
That ^ ...what I needed.

Well a few things I needed to know was
1. how to ensure certain operations are done in float,
2. how to make sure certain variables are saved as float,
3. how to convert a float variable to integer.

Also I have been thoroughly reading your code for the past few days, and I've got to say, man... great work. Truly thanks for doing this work. For the first time someone has written out the damage formula in modifiable code and written true to the original. You've saved me personally. As I read through your code I'm just very impressed. very well done man, a kudos to you, my personal gratitude.

There were some things I couldnt figure out though. I didn't wanna bother you with all my questions so I thought I'd try to learn from documentation first. A few things I was unclear about,

4. For example:

Code: Select all

35   variable begin
36     old_total := 0, new_total := 0;
37     ammo_pids;
38     mod_ammo_pids;
39     enabled;
40     dr_mod_list;
41     type_ammo;
42     ammo_damage;
43   end
You've declared these vars script wide (by global I meant script wide) but they have a begin and end , and in C these vars would terminate once they hit "end" within this block. So your saying this is not so, that clarifies things. So if I want to make new vars to stay available for use by all procedures then I should declare them here?

Code: Select all

78     register_hook_proc(HOOK_COMBATDAMAGE, damage_handler)
5. Does the above code register the "damage_handler" procedure in this script to run whenever combat damage hook is encountered? because otherwise I dont see how this script would get called. Is this line the culprit?


6. At line 45 You are declaring all the procedures. At line 49 there is a "procedure inv_handler;" but there is no such procedure in the rest of the script. is this a mistake? secondly, there is a "procedure map_enter_p_proc begin" at line 100, but it hasnt been declared in the procedure declaration area. This is not a problem?

7.

Code: Select all

Line 136     cd := gcd(div, mult);
"gcd" seems like a procedure, but what does it do? where is it defined?


8. line 391

Code: Select all

  variable nd := 0, rd, ranged_bonus := 0, cm, dr_mod := 0, cd;
  variable begin
    dmg_type;
    cd_setting;
    i;
    ammo_mult;
    difficulty_mult;
    critical_mult;

    weapon_pid;
    dmg_min;
    dmg_max;
    ammo_pid;
  end
You have declared 1 set of variables in the first line, then you have declared a second set using begin and end. Why? what is the difference here?

9. The "ndebug" function that you use to monitor the process, where does it output to? the msg box? or debug file?


Hey thanks for the help.

User avatar
Magus
Site Admin
Posts: 157
Joined: Mon Nov 21, 2016 9:13 am

Re: Damage formula

Post by Magus » Sat Nov 24, 2018 12:21 pm

1. What operations? If it's numbers, just use "2.0" instead of "2". For variables, I do "1.0 * x...".

2. Variables are what they are assigned. They don't change by themselves. Note that script vars get all reset on game load. If you need them to persist, use sfall global vars.

3. There are floor2 and round functions, see sfall docs.

4.

Code: Select all

variable old_total := 0;
variable new_total := 0;

Code: Select all

variable old_total := 0, new_total := 0;

Code: Select all

variable begin
  old_total := 0;
  new_total := 0;
end

These are all equivalent notations. If declared outside procedures, vars are available anywhere in the script. (But they have to be declared before the procedures that use them, so you want to keep them at the top).

5. Correct. Read up on the hookscripts in the sfall doc I linked above.

6. inv_handler is some leftover. It doesn't hurt.
Procedures don't necessarily need to be declared, but the script is parsed top-down, and if you use a procedure before it's been defined, compiler will spit an error. In case of long scripts or some circular logic, it's easier to declare them at the top.
*_p_proc procedures are special cases, they are native to engine and get executed at specific times. See another doc.
map_enter_p_proc is executed when entering a map (which reloads proto stats from disc).

7. https://github.com/BGforgeNet/fo2tweaks ... aks.h#L133

8. No difference. Just ease of maintenance and code evolution over time. When it's 1 or 2 vars, doesn't matter how to declare them, but when it's 20, things can get messy. I'd recommend to employ source control early.

9. ndebug ("named debug") is just a wrapper around debug_msg, prepending it with script name, so I know from which script the message came. Again, when you have dozens of them, things can get confusing.
Where it outputs the messages, depends on how you configure sfall.


Don't be afraid to try things, compiler will show where you're wrong.
Please do not PM or email me about my mods and projects. Use forums. Also, see our talk channels.

Cyrus
Posts: 20
Joined: Tue Nov 20, 2018 12:34 pm

Re: Damage formula

Post by Cyrus » Sat Nov 24, 2018 2:24 pm

Thanks for that.

I have noticed something which I think is an error in code, but because I'm not settled in this language I'm can't be very sure.

Inside "procedure get_total_damage", line 234, you have called the procedure "get_dr_dt(attacker, target, dmg_type, dr_mod, flags)", while calculating for a single bullet.
The variable "flags" is declared a few lines before on line 230, and is not initialized. So it seems like you are passing a null variable to procedure "get_dr_dt".
Looking at "procedure get_dr_dt" at line 305, the equivalent variable inside get_dr_dt is called "target_flags", which variable "flags" is being passed onto.
The variable "target_flags" is then not mentioned again until line 327.... "if is_bypassing_armor(target_flags) then begin ..." where "target_flags" is being checked for critical flags. But its null. It doesn't seem to me like it has been populated yet.

Looking back inside of "procedure get_total_damage", at line 246, you have called "procedure get_dr_dt" again, but this time to calculate for multiple bullets.
This time the variable "flags" is being initialized on the previous line, at 245. >>>> "flags := critical_type[1];"




So...., I think...., I think!........ if I'm not mistaken......, dare I say.... Its a coding mistake. A line like "flags := critical_type[1];" should probably be added just before you call get_dr_dt on line 234. Right now it seems single shots if they are armor penetrating the penetrate is not being applied.

Please check for yourself, because its possible that you are doing something else that I'm not aware of. And If I'm mistaken... please still be my friend!



Oh also, at line 47 you have declared the "get_dr_dt" procedure:
line 47: procedure get_dr_dt(variable attacker, variable target, variable target_flags, variable dmg_type, variable dr_mod);

But its variable order is different from when you have declared it at the actual procedure section.
line 305: procedure get_dr_dt(variable attacker, variable target, variable dmg_type, variable dr_mod, variable target_flags)


Is this a problem?

User avatar
Magus
Site Admin
Posts: 157
Joined: Mon Nov 21, 2016 9:13 am

Re: Damage formula

Post by Magus » Sat Nov 24, 2018 2:40 pm

Yes the first one is an oversight, thanks.
As for the second, I think the compiler just counts the vars in declaration, so it doesn't really matter. But I'll update it to match the definition all the same.
Please do not PM or email me about my mods and projects. Use forums. Also, see our talk channels.

Post Reply