Request: Damage DLL/SO

For collaboration on developing the mod capabilities of VS; request new features, report bugs, or suggest improvements

Moderator: Mod Contributor

chuck_starchaser
Elite
Elite
Posts: 8014
Joined: Fri Sep 05, 2003 4:03 am
Location: Montreal
Contact:

Request: Damage DLL/SO

Post by chuck_starchaser »

I seem to be hearing rumors that weapon types and damage models are hard-coded into the engine.
If so, this B... A... D.... BAD!

Vegastrike's weapons and damage models are vast departures from WC's, and not what PU needs.

Case in point:

Apparently, in Vegastrike, phase weapons come first, and are able to bypass normal shields; then come phase shields, to try and stop phase weapons...

In WC, phase shields come first (are older than phase weapons). They differ from normal shields in that normal shields are less effective against kinetic weapons and fast-flying missiles, which explode after flying past the shields; so phase shields are like normal shields PLUS they can stop fast-flying missiles and kinetic weapons; and are stronger against beams, to boot. Phase weapons, in WC, come later, historically, and they differ from normal beams in that they can wear down phase shields faster. In WC, phase weapons do NOT "bypass" shields like they do in Vegastrike.
Furthermore, phase shields in WC are not effective at stopping slow-moving objects. That's the whole reason why, in WC, torpedoes fly slowly: to be able to fly through phase shields, explode on contact, and so deliver damage directly to armor and hull.

Plus, for PU we need to define a distinct category: Steltec damage, that relates to Steltek shields and guns.

If it's true that Vegastrike's weapon categories and damage models are hard-coded, and if it would be too hard to translate them to Python, could the relevant code at least be moved to a DLL/SO, so that we're not forced to fork the engine?
TIA.
jackS
Minister of Information
Minister of Information
Posts: 1895
Joined: Fri Jan 31, 2003 9:40 pm
Location: The land of tenure (and diaper changes)

Post by jackS »

First, an aside -- VS doesn't have phase shields :). There's only one type of shield, one type of armor, and one type of hull. All differentiation is specified in the weapon definition.

I can confirm that damage types are currently hardcoded.
I can also confirm that there has been a long-standing discussion among the devs re: how this isn't a long-term solution, and wouldn't it be nice if we had a more abstracted damage model.
However, the conclusion was that it wasn't something we were going to monkey with until after 0.5.0.
Moving to python is questionable from a performance perspective.
When we have the chance, we will, post-0.5.0, implement a more abstract damage model. Insight from mod groups such as PU as to what features such an abstract model will want to take into account would be welcome. Note, however, that not all proposed or desired features will necessarily make it in (e.g. I doubt that there'll be any special-casing for speed differentiation, like that you've described for the phase shields).
bgaskey
Elite Venturer
Elite Venturer
Posts: 718
Joined: Wed Mar 07, 2007 9:05 pm
Location: Rimward of Eden

Post by bgaskey »

instead of moving to python, better would be having another file that defines damage types and armor types and the interactions between each type (as safemode suggested in this thread: http://vegastrike.sourceforge.net/forum ... hp?t=10474) 8)
chuck_starchaser
Elite
Elite
Posts: 8014
Joined: Fri Sep 05, 2003 4:03 am
Location: Montreal
Contact:

Post by chuck_starchaser »

Well, a game engine won't sell much by putting ANY restrictions whatsoever on damage models. It's just pure luck the Vegastrike and WC have a lot of things in common. But in the future you might have modders interested in using the vegastrike engine for some space RPG they might need to define "ice damage" and "fire damage" and have scrolls that cast shield piercing spells. Or some other modders might be considering making a Starcraft Remake around the VS engine, and they would need to differentiate between piercing and explosive damage.
There should be no assumption about ships having armor and shields. A highly realistic mod might dispense with the idea of shields altogether, and instead use multi-layered armor.
Damage types should be definable from the data side, rather than be hard-coded. Then, and here comes the biggie... What do we do with units.csv if every type of armor, shield and weapon needs damage quantities for 7 types of damage, for a given mod?
It would seem to me that damage data for weapons and defenses need to be treated separately from units.
Hell. What does "unit" mean?
If a type of shape of gun, having a particular mesh, is a "unit", then the damage it does depends on what type of munition you load on it. We shouldn't assume that a given gun shape can only fire one type of shot.
klauss
Elite
Elite
Posts: 7243
Joined: Mon Apr 18, 2005 2:40 pm
Location: LS87, Buenos Aires, República Argentina

Post by klauss »

Hey, people!

I remember VS had python AI. Right?
With some work it could be made python physics as well, phython damage model and stuff.

I know the problem with python AI was speed. But... there's something out there called "pyrex" - I've been using it a lot at work, and it really is very cool. It would make python-looking objects that are implemented in C/C++!

So, python AI/physics/damage/whatever could be made efficient that way.

Just an idea.

Pyrex is a python-like language that compiles to python extension modules. It's really cool. So for modders it would look very similar to python, except that it needs compiling (and produces a dll/so).

I bet python damage models would work nicely like this.
Oíd mortales, el grito sagrado...
Call me "Menes, lord of Cats"
Wing Commander Universe
safemode
Developer
Developer
Posts: 2150
Joined: Mon Apr 23, 2007 1:17 am
Location: Pennsylvania
Contact:

Post by safemode »

the only problem is that you need developers. Developers dont like learning languages that they aren't using in common practice. So you'll move a lot of functionality from something that is popular and common like C++ to pyrex, and then when the 1 or 2 programmers who actually know the language leave the project, we'll be screwed, or at the very least, extremely inconvenienced.

similarity in a language only goes so far. To the effect of the most dangerous amount of knowledge is a little. That is to say, knowing a little of how to code in python via C++ proficiency, is likely is yield horrible python, regardless if it actually by miracle works. Same would be true for pyrex.

I'm just saying, the lack in popularity really hurts the project, just like python despite being the right thing for the job, has less eyes (that actually know what they're doing) on it than the C++ code, pyrex would have magnitudes less.
Ed Sweetman endorses this message.
safemode
Developer
Developer
Posts: 2150
Joined: Mon Apr 23, 2007 1:17 am
Location: Pennsylvania
Contact:

Post by safemode »

Getting C++ runtime loadable modules to work in linux is incredibly easy. In windows, it shouldn't be much harder. The api to set it up shouldn't be all that complex either. I dont see why C++ modules to do this job should be unthinkable. MODs, while consisting of mostly python changes, should be perfectly capable if they find it necessary, to do some C++ work and edit a template C++ module to do their dirty work. No need to distribute their own version of the VS binary, they just need to distribute the modules they will use and VS will search and load them at runtime.

I dont see the problem with that.
Ed Sweetman endorses this message.
chuck_starchaser
Elite
Elite
Posts: 8014
Joined: Fri Sep 05, 2003 4:03 am
Location: Montreal
Contact:

Post by chuck_starchaser »

That's all I was asking for, btw. If the existing damage model could be encapsulated into a dll, then I could compile a dll to suit PU's needs.
safemode
Developer
Developer
Posts: 2150
Joined: Mon Apr 23, 2007 1:17 am
Location: Pennsylvania
Contact:

Post by safemode »

i think post 0.5 we'll see VS heading towards modularization in this manner. dlopen for the unix guys, LoadLibrary for windows. The idea being, we want to open up VS to configurability in the more exciting areas, like economics and ai and other stuff, but taking the python hit isn't acceptable.


I think it should be made clear though, I dont consider VS to be a general game engine, it's a game engine for games that are fairly similar to it's core style, but there are some things that are never going to be configurable, because it's not meant to be all encompassing. I think the line will be drawn on a Pain factor, if it's too much of a pain to make it configurable, it wont be.
Ed Sweetman endorses this message.
javier
Bounty Hunter
Bounty Hunter
Posts: 137
Joined: Tue Jan 31, 2006 12:46 am

Post by javier »

Funny thing.
This Eastern I have been toying with the source code and just implemented an idea that could work.

My initial testing has been successful, so I'm posting a diff to try, if you want.

How does it works:
- Add a new column in units.csv, called Shield_Mask, ranging from 0 to 255. Value 0 is the default, so there's no need to change anything if you don't want to modify current working mode.
- Add a new attribute to the damage tag in weapons.xml called Mask, ranging from 0 to 255. Default is 1.

At the begin of Unit::ApplyLocalDamage, the following code has been inserted:

Code: Select all

       // Apply damage mask
       if (((0xFF^shield.mask) & mask) == 0) {
               amt=0;
               phasedamage=0;
       }
The effect is that a shield can be defined to be impenetrable or not to weapons on a one per one basis, depending on the masks. The prototypes of Unit::ApplyDamage and Unit::ApplyLocalDamage has been modified to append an additional mask parameter, defaulted to 0xFF. That way, damages due to collisions will be computed as before, except if shield mask are set to 0xFF (God mode :twisted:).

Some examples:
- The default case
Shield mask: 00000000 xored to 11111111
Weapon mask: 00000001
Damage is delivered as usual.

- A capital shield against a standard weapon
Shield mask: 11111101 (253 or -2) xored to 00000010
Weapon mask: 00000001
No damage is delivered. You have an effective Phase Shield

- The Borg shield: 01111111 only can be damaged by Anti Borg Weapon, 10000000. As it is, this weapon deliver no damage to any other shield. If you don't intend that, change its mask to 11111111 or something like this.


I think this change is very simple, works by default and offers a lot of possibilities to mods. Only thing to take into account, right now I only have modified beam and bolt weapons, not missiles. If I get positive feedback, I will go for it.
You do not have the required permissions to view the files attached to this post.
safemode
Developer
Developer
Posts: 2150
Joined: Mon Apr 23, 2007 1:17 am
Location: Pennsylvania
Contact:

Post by safemode »

phase damage is like a chip in the idea of modularizing something like the damage model. Another chip would have been putting tunables in the hull and shields like I suggested in that thread. The thing is, to make more people happy, we have to keep putting more and more conditionals and tunables in. This gets slow and ugly fast. It's much more cleaner and simpler to just say "Here is a the default damage model, you can customize it as you want" and let people goto town. Their changes likely wont be hugely drastic, but it will allow us to minimize conditionals and tunables that have to be taken into account, simpliftying the calculations.


edit: i think eventually we'll see the phase idea incorporated into mainline VS. (after 0.5) Though, when it comes to borgs, their shield adapt, so it would be cool to make the borg shield code randomly change their mask after a given number of hits, then the anti-borg weapon would "detect" the mask by asking the borg shield what the mask happens to be, and the rate it would do that would be dependent on the quality of the borg weapon or damage state of the ship. etc.
Ed Sweetman endorses this message.
klauss
Elite
Elite
Posts: 7243
Joined: Mon Apr 18, 2005 2:40 pm
Location: LS87, Buenos Aires, República Argentina

Post by klauss »

You need a lot of refactoring in order to get modularizable damage and interaction models. You'll have to expose a flexible way of accessing unit stats, and a reliable and reversible way of "damaging" components (sets of stats modifiers?). It's not as easy as separating the code into a dll.

You also need flexible ways of interaction between units. Maybe not only firing weapons damages them - maybe hitting them too. Maybe getting close to some objects as well (stars), or going through certain others too fast (planetary rings). You certainly need a lot of homework into designing an interface in which the "modules" will be plugged into the engine.

But, it's an interesting and useful task. And... dare I say... fun?
Oíd mortales, el grito sagrado...
Call me "Menes, lord of Cats"
Wing Commander Universe
safemode
Developer
Developer
Posts: 2150
Joined: Mon Apr 23, 2007 1:17 am
Location: Pennsylvania
Contact:

Post by safemode »

well, that will go along with refactoring Unit, which is slated for the near future.
Ed Sweetman endorses this message.
javier
Bounty Hunter
Bounty Hunter
Posts: 137
Joined: Tue Jan 31, 2006 12:46 am

Post by javier »

I have completed my patch to implement the mask to weapons and shields.
The mask is now an integer, offering 32 bits to play with. It should be handy if anybody intends to design something like a changing mask.

How to use it:
- In weapons.xml, an attribute mask can be added to the damage tag. It defaults to 0x0001 if not declared.
- In units.csv a new column, Shield_Mask, should be created. Default value is 0x0000. If declared for a certain shield, its value will be carried to the units when upgrading.
- A XOR is applied to the shield mask and 0xFFFF. Before applying damage, a bitwise AND with that value and the weapon mask is made. If the result is 0, both normal and phase damages are set to 0.

I've modified the base computer output on units and shields to print the mask value.
My next step should be creating a pair of member functions to read and set dynamically the mask value of an unit and make them callable from python.

@safemode: If you remember the weapons model discussion, yours included a value you called shield efficiency. This is already included, but called Shield Leak, although the expression is exactly the opposite.

@chuck: This patch, if accepted, should allow the PU designers to implement real phase shields and its weapon counterparts, and also to solve the incompatibility between the drone and the previous existence of phase damage weapons and missiles.

As a side note, its worth noting that a unit with a shield mask of -1 (0xFFFF), its effectively invulnerable to any weapon. That is something that could be convenient in determined scenarios, i.e. a base whose existence must be granted.
You do not have the required permissions to view the files attached to this post.
chuck_starchaser
Elite
Elite
Posts: 8014
Joined: Fri Sep 05, 2003 4:03 am
Location: Montreal
Contact:

Post by chuck_starchaser »

That sound wonderful, Javier; I'd like to give it a try in PU, and if it works I'll cast my vote with the vs devs.
Any chance I could get a windows executable from you. I got no compiler.
javier
Bounty Hunter
Bounty Hunter
Posts: 137
Joined: Tue Jan 31, 2006 12:46 am

Post by javier »

Sorry, I only have windows on my walls, not my computers :wink:

I've tried the patch with the PU data set and it seems to be something weird. Give me a couple days to fix it.
With the VS data set, instead, it seems to work. Only one thing, I forgot to initialize weapons if mask is not set. I'll post a patch soon, but it could be tried as it is declaring masks explicitly.

[EDIT]
Another problem I found is that save doesn't carry the ship's Shield_Mask to serialized.xml. I'll try to fix it too.
javier
Bounty Hunter
Bounty Hunter
Posts: 137
Joined: Tue Jan 31, 2006 12:46 am

Post by javier »

Just tested the code from this patch. Seems to work well.

Changes from last version are:
- Fixed data saved into serialized.xml
- Print "Shield Mask" info in Unit and Shields
- Mask of weapons w/o an explicit attribute are initialized to 0x0001
- Modify the python callable function ApplyDamage to include a mask parameter.

I've tested it with both VS and PU data sets.

To the PU people, I recommend these settings to begin:
- Real phase shield: mask=1 (Paradigm and Kamekh shouldn't have it)
- Steltek drone shield: mask=3
- Proton Torpedo: mask=2.
- Boosted steltek gun: mask=3

There should not be the need of making the drone shields recharge at such an insane rate, because now the only weapon that could damage it is the boosted steltek, as in the original. Neither the gun need to do phase damage.

Let me know if you find something wrong.
You do not have the required permissions to view the files attached to this post.
chuck_starchaser
Elite
Elite
Posts: 8014
Joined: Fri Sep 05, 2003 4:03 am
Location: Montreal
Contact:

Post by chuck_starchaser »

Thanks. I can't compile, but sent Wolphin a message; hopefully he'll be able to apply it. Not sure if he can make an exe, tho; he's on unix too.
javier
Bounty Hunter
Bounty Hunter
Posts: 137
Joined: Tue Jan 31, 2006 12:46 am

Post by javier »

Here is a new version of the patch. Includes the following changes:
  • Fixed: When passing damage to another unit, mask was left out.
  • Reserve high order bit of the mask to damages not made by weapons. A shield with this bit on will not suffer damage from collisions. Previously, a mask of 0xFFFF was required.
  • Add two new attributes to the weapon "Damage" tag: EfficiencyOnShields and EfficiencyOnArmor. Both floats, they are multipliers to the base damage when applied to the corresponding element. By default, they take a value of 1, so if not used, everything will keep working as it is now.
Should apply cleanly against latest svn. If somebody want to test it, please let me know if you find any problems.
You do not have the required permissions to view the files attached to this post.
chuck_starchaser
Elite
Elite
Posts: 8014
Joined: Fri Sep 05, 2003 4:03 am
Location: Montreal
Contact:

Post by chuck_starchaser »

Sounds great! Unfortunately, I'm compiler-less; and Wolphin is taking a vacation from PU to catch up with schoolwork, so it will probably be a couple of weeks before we can test it. Sounds absolutely wonderful, though.
safemode
Developer
Developer
Posts: 2150
Joined: Mon Apr 23, 2007 1:17 am
Location: Pennsylvania
Contact:

Post by safemode »

before we would start making use of this I think it's important to document what the masks actually refer to when it comes to the units (weapons,etc) that they cover.

Meaning, I think we should assign ranges a name and put certain weapons in that range, and make certain ships shields / hulls part of those ranges.

All of that needs to be detailed and mapped out or we'll have a mess of trying to figure out which ship should have what mask to "balance" correctly with this damage system.

Basically what i'd like to see is something like a table, where we have Mask (what weapons are covered in that mask) and then what Shields are covered in that mask, and hulls and then what ships can get those shields and hulls.

That way it's easy to see how the balance of things are and where any additional units can fit in, what mask they should have and what weapons will affect them.

I think that is integral to the additional features of the patch. Because while, yes, we can make it work just like how things work now, I would think the point of the patch isn't to emulate how things are now, but get VS to use a more realistic damage model provided by the patch.

The ranges shouldn't be arbituary entirely, they should reflect like weapons, and weaknesses to those weapons that have some connection to reality (sci fi).

All matter based weapons would be under a mask seperate from energy weapons.

Inside those masks, you would group types of weapons.

Hulls and shields would have masks, with most just looking at the larger groups, for effectiveness. Some special ships may have very specific masks, and thus only specific weapons can be used effectively.


I take it, the patch can handle that. Or are you organizing along a different mode that has nothing to do with the physics (real or not) of the weapons/shields/hulls.
Ed Sweetman endorses this message.
javier
Bounty Hunter
Bounty Hunter
Posts: 137
Joined: Tue Jan 31, 2006 12:46 am

Post by javier »

Well, I should have added a label saying HANDLE WITH CARE. :wink:

I'm with you on that a careless use, specially of masks, can derive on a big mess. But the kind of tables you're talking of should be one of the first steps on any mod concept definition, patch or not patch included, and should also be included on the internal documentation of any mod.

One thing I've been careful with, is that after applying the patch, the actual data set kept working exactly the same way than before. If there is some different behavior, then it's a bug. So, in that way, the patch creates a superset of the current model.
safemode
Developer
Developer
Posts: 2150
Joined: Mon Apr 23, 2007 1:17 am
Location: Pennsylvania
Contact:

Post by safemode »

well obviously, VS has no such table because this type of damage model didn't exist until now. So a table has to be created.

Right now it's not very important, as the campaign and thus, strategy aspect of VS doesn't exist yet. But it will become very necessary as an actual plot and campaign and functionally different faction ai's develop as we work towards 1.0.
Ed Sweetman endorses this message.
javier
Bounty Hunter
Bounty Hunter
Posts: 137
Joined: Tue Jan 31, 2006 12:46 am

Post by javier »

Agree absolutely. As of now, I see the patch the most useful on the PU mod, where there is a back story already established, and also there is a special unit, the drone, that should be only able to be killed by an special weapon.

One thing I left out, but should include, is a couple functions to dynamically read and set masks, both on weapons and shields. Surely, the VegaTrek people will appreciate this (Sing with me: We are the Borg, we are the children...). :D
safemode
Developer
Developer
Posts: 2150
Joined: Mon Apr 23, 2007 1:17 am
Location: Pennsylvania
Contact:

Post by safemode »

reading dynamically the mask of a shield (frequency in star trek terms) should be a function of the sensors. So basically the sensors should randomly retrieve the mask from the target whenever the sensor code is processed. The chance for it to do so, is dependent on the level of sensor. Now the target has a randomized value to change the mask, and it does so based on the level of shields and type (if it's even capable of changing).

So, you should be able to "guess" shield frequencies of phase changing shields fairly well while the Borg first encounter you, then they can get more advanced and change their frequency more often. Meaning, you have to get your kill shots in early, or you may be SOL.

etc etc.

I can see such a technology used in VS. Capital ship torpedoes. They could read the mask of a capital ship's shields and pass right through them, subsequent shots may not be so lucky, as the capital ship could change the mask after they were hit. The next torpedo would have to read the shields, and it might not have time to before impact. strategy then would be to get close enough to not give torpedoes time to get your shield frequency. Leaving conventional weapons as the only choice.

that would all depend on the ship and torpedo used.

It also makes for some cool campaign offshoots, traitors could give important codes away to pirates or such and devestate a military plan. etc. You could buy such codes to attack a ship that cant change it's shield frequency. etc
Ed Sweetman endorses this message.
Post Reply