• Home
  • Index
  • Search
  • Download
  • Server Rules
  • House Roleplay Laws
  • Player Utilities
  • Player Help
  • Forum Utilities
  • Returning Player?
  • Toggle Sidebar
Interactive Nav-Map
Tutorials
New Wiki
ID reference
Restart reference
Players Online
Player Activity
Faction Activity
Player Base Status
Discord Help Channel
DarkStat
Server public configs
POB Administration
Missing Powerplant
Stuck in Connecticut
Account Banned
Lost Ship/Account
POB Restoration
Disconnected
Member List
Forum Stats
Show Team
View New Posts
View Today's Posts
Calendar
Help
Archive Mode




Hi there Guest,  
Existing user?   Sign in    Create account
Login
Username:
Password: Lost Password?
 
  Discovery Gaming Community The Community Flood
« Previous 1 … 112 113 114 115 116 … 386 Next »
C# for all to disaprove of

Server Time (24h)

Players Online

Active Events - Scoreboard

Latest activity

C# for all to disaprove of
Offline Inferno
08-02-2016, 12:12 AM, (This post was last modified: 08-25-2016, 02:51 PM by Inferno.)
#1
[LN]
Posts: 949
Threads: 97
Joined: Apr 2016

So, I have this damage code for a small game I was working on awhile ago(it won't bear fruit, so I just tinker with the codes now) and I recently got a problem with it.

If(PlayerGetAttack){
If(ArmorThickness > ProjPen){
ImpDmg = (ProjImpDmg/ShieldStr);
PenDmg = (ProjPenDmg/(ShieldStr*4));
SlashDmg = (ProjSlashDmg/(ShieldStr*6)) ;
PlayerHP = OldPlayerHP - (ImpDmg+PenDmg+SlashDmg);
ArmorHP = OldArmorHP - ((ImpDmg+PenDmg+SlashDmg)/2);
OldPlayerHP = PlayerHP;
OldArmorHP = ArmorHP;
}
//What you saw above this comment is if the projectile is not powerful enough to penetrate the armor, the player will take very limited damage, as the armor took it up for him. Below is the codes for if the projectile goes THROUGH the armor.
If(ArmorThickness < ProjPen){
ImpDmg = (ProjImpDmg/ShieldStr);
PenDmg = (ProjPenDmg/(ShieldStr/3));
SlashDmg = (ProjSlashDmg/(ShieldStr/2)) ;
PlayerHP = OldPlayerHP - (ImpDmg+PenDmg+SlashDmg);
ArmorHP = OldArmorHP - ((ImpDmg+PenDmg+SlashDmg)*3);
OldPlayerHP = PlayerHP;
OldArmorHP = ArmorHP;
}
}

/*I recently added a new form of protection, shielding as we all know it. It takes up all damage, and Shields v1.0 took Impact damage the most, while Shields v2.0 introduced the shield types Positron, Gravaton, and Molecular, the latter being the closest to the original shield concept. Shields v2.0 also introduced three new damage types, Thermal against Molecular, Magnetic against Positron, and a third damage type I never gave a name to for Gravaton. Only problem is that instead of having six damage types, I now have 15 damage types and the majority of them do masses of damage to their respective shield. I seem to have lost the Shields v2.0 code, pity.

Anyway, take a look at the simple code overhead, and judge it for yourself. */


EDIT A:A request from one of my friends have yeilded a slightly different code, focused on small % reductions and a flat dmg reduction, meaning if you have '10' armor and you take 25 damage, the armor takes up ten of the 25 and then a percentage of the remaining 15, and you take the rest. ArmorHP may or may not be a factor in this matter.

If(PlayerGetAttack){
DMG = (AttackDMG/ArmorDMG) - ArmorSTR; //a single number, or we multiply it by a percentage, should he resuest otherwise. ArmorDMG will represent % reduction and ArmorSTR will represent flat reduction.
PlayerHP = OldPlayerHP - DMG;
OldPlayerHP = PlayerHP;
}


Now, without the complex Pen/Slash/Imp damages, we get a smaller code overall. It isnt as pleasing to code in, due to the lack of complexity(somehow I feel that the more conplex the code the more fun it is. Strange right?)
Reply  
Offline Sturmwind
08-02-2016, 06:55 AM,
#2
Member
Posts: 2,099
Threads: 148
Joined: Aug 2009

pc load letter
Reply  
Offline Sorrontis
08-02-2016, 03:59 PM,
#3
Member
Posts: 234
Threads: 28
Joined: Jun 2016

I'm still learning C#. it's a slow process.

Good bye my friends. Good luck in space. Fly safe.
Reply  
Offline Inferno
08-25-2016, 02:58 PM,
#4
[LN]
Posts: 949
Threads: 97
Joined: Apr 2016

if(bump){
if(ThreadView){
Read = True;
Understand = 1(RAND);
if(Understand > 1){
Understand = 1;
}
else
{
Understood = 0;
If(Understood = 0){
Draw.(255, 255, 255, "What?!");
}}}}

I'm sorry. What I meant to say is that I bump this thread.
Reply  
Offline Thyrzul
08-26-2016, 12:37 AM,
#5
The Council
Posts: 4,684
Threads: 115
Joined: Sep 2011

What?!

[Image: OFPpYpb.png][Image: N1Zf8K4.png][Image: LnLbhul.png]
Reply  
Offline Arioch
08-26-2016, 01:44 AM,
#6
Retired Zoner Overlord
Posts: 1,938
Threads: 219
Joined: May 2011

What?!

[Image: drrobe.gif]
Reply  
Offline Thyrzul
08-26-2016, 01:46 AM,
#7
The Council
Posts: 4,684
Threads: 115
Joined: Sep 2011

Finn, you did it wrong, it says white.

[Image: OFPpYpb.png][Image: N1Zf8K4.png][Image: LnLbhul.png]
Reply  
Offline Remnant
08-26-2016, 02:04 AM,
#8
Member
Posts: 2,206
Threads: 248
Joined: Apr 2012

I'm curious as to how you're doing this in some sort of static sense. (Though I guess it's not full code anyways, so you don't have any way of calling each unique ship)

I reccomend not doing everything all at once like that. Calculate the damage in a different function, and set certain values based on what the function yields. That way you'll be able to handle more types of damage types, rather than just saying 'if you are hit, take damage'

Code:
float doDamage(String type, float amount, float currentHP){

//If the damage type is..
if(type == <INSERT TYPE>){

//Do your damage calculation
<Blahblahblah>
//Return the modified damage based on if the type conflicted or not. Was it critical? Was it not?
return currentHP - damage;
}

//Do another damage type
else if(type == <ANOTHER TYPE>){

//Do the same thing as above, and return the damage

}

So then, you can just do..

Code:
if(PlayerGetAttack){

SetPlayerHP = processDamage(type, amount, currentHP);

}
So really you just need a way to feed in what type of damage you were just hit with, and how much whenever your 'GetAttack' boolean triggers.

Or.. something.

Edit: Better yet, instead of feeding it a string for the damage type, create a struct for each of the types. Or some other method of holding subvalues such as modifiers.
Edit Edit: C#? The Unity Engine i'm assuming? I like Unity. I've done some creation with that engine for fun.
Reply  
Offline Inferno
08-26-2016, 05:28 AM, (This post was last modified: 08-26-2016, 04:30 PM by Inferno. Edit Reason: Edit A )
#9
[LN]
Posts: 949
Threads: 97
Joined: Apr 2016

(08-26-2016, 02:04 AM)King Boo Wrote: Edit Edit: C#? The Unity Engine i'm assuming? I like Unity. I've done some creation with that engine for fun.
The Unity Engine indeed. I started code in Visual Studio and went to Unity, so I may be merging alot of concepts without real attention(I haven't been able to send these strips of code through a compiler in two years)

(08-26-2016, 02:04 AM)King Boo Wrote: That way you'll be able to handle more types of damage types, rather than just saying 'if you are hit, take damage'
I would assume you are referring to the first example. That fragment is about as flawed as I can get it before it stops resembling code. The original 1.0 version of it is lost somewhere within my laptop(which no longer functions.)
As for the second, shorter example of code, it was designed for an example of a project my friend wants me to develop. He specified one damage type, so that the players of the game would not have to make complex decisions regarding weapons and armor.

As for doing it all together...I'll work on phrasing it another way. I haven't really been working on my code in a long time(thanks, higher education) and that felt the easiest way was as such.

(08-26-2016, 02:04 AM)King Boo Wrote: (Though I guess it's not full code anyways, so you don't have any way of calling each unique ship)
I was thinking of linking the variables to JavaScript that would be attached/unique to every weapon/ship that had their own stats. I am unsure what I am typing now. I blame...the Zoners.
*Inferno retreats to his corner and slams the dolphin door shut. The door accepts PayPal, but not MasterCard. Taco.
Edit A: Alright, I reread the if DamageType code block you provided, Boo, and I can understand why you are confused.
The damage types represented above are like the damage concept in Warframe, not Discovery. Instead of one weapon type per weapon, most weapons have differences on certain values of all three, but they all have the same three values. For example, if a shrapnel shotgun was fired, it would be high amounts of slash damage for the shards, and medium penetration values, and very low Impact, as if they didn't cut or punctured the target, they just... bounce off.

Right now I am looking into alternate code phrasing. I will one day get a full script to this thread, with floats, booleans and even variable values. 90% chance it will be Unity-based scripting..
Reply  
Offline Corile
08-26-2016, 12:03 PM,
#10
C::iemka pl
Posts: 3,248
Threads: 267
Joined: Apr 2014

curly braces
semicolons

(puke)




Reflections on the Revolution in Gallia
Custodi // High City of Heraklion // The Cult of Archangels
Log Filter // Post Creator // Manhattan
  Reply  


  • View a Printable Version
  • Subscribe to this thread


Users browsing this thread:
1 Guest(s)



Powered By MyBB, © 2002-2025 MyBB Group. Theme © 2014 iAndrew & DiscoveryGC
  • Contact Us
  •  Lite mode
Linear Mode
Threaded Mode