Jump to content

Re:Skills and Status Effects.


Recommended Posts

I don't know if this would be "best," but it would be pretty solid.

Perhaps make engine-side sim object SkillContainer and AbilityContainer classes, add SkillDataBlock and AbilityDataBlock classes to go with them, define all of the possible skills on SkillDataBlock and abilities on AbilityDataBlock, then use the SkillContainer and AbilityContainer object classes as script-side containers. You could then create script-side objects with appropriate datablocks assigned, then assign them to your AI units. Mind that you correctly implement your data packing/unpacking in your datablock object - check out other datablock classes for examples of implementation. Might want to start with engine/source/console/simdatablock.h (SimDataBlock) and engine/source/T3D player.h (PlayerData), checking out the implementations there for ideas and insight.

You'd do something like this script-side when creating objects:

datablock SkillData( HeavyGunnerSkillData )
   lightgunskill = 0;
   rocketskill = 2;
   medgunskill = 0;
   heavygunskill = 2;
   empskill = 1;
datablock AbilityData( HeavyGunnerAbilityData )
   airstrike = 1;
   callbackup = 1;
   moveboost = 0;
   healrate = 1.0;
   reflectdamage = 0.5;
// -------------------------------------
// to spawn - this must happen server-side (in the game sense, not engine/script sense).
function serverCmdspawnUnit(%client, %type, %source)
   %skill = 0;
   %ability = 0;
   if(%type $= "HeavyGunner")
      %skill = new SkillContainer(){ datablock="HeavyGunnerSkillData";};
      %ability = new AbilityContainer(){ datablock="HeavyGunnerAbilityData";};
   else if ( ... ) // blah blah, other types
      .... // other types' stuff
   if(%skill == 0 || %ability == 0)
      echo("Error - type was invalid or unable to create correct skill/ability data for client " @ %client);
   %aiPlayer = new AIPlayer() 
      position = %source.getPosition();
      datablock = "DefaultPlayerData"; // or whatever datablock you're using
   // add the container objects to the unit in dynamic fields.  
   %aiPlayer.Skills = %skill;
   %aiPlayer.Abilities = %ability;
   // then spawn the ai player with whatever else it needs
// ---------------------------
// to access the skills, you can make methods on the *Container objects to handle it, or you can just grab the datablock 
// off of it and look at it directly:
%skillDB = %aiPlayer.Skills.getDatablock();
%rocket = %skillDB.rocketskill; // in this case, should be 2.

Of course, all untested, just thinking on paper.

This is probably going to be light as far as lag and server load because datablocks are transferred from the server to the clients at mission load, then only changes would be sent - except that datablocks are effectively static (there are ways around it, but I'd leave it be) and aren't refreshed during a mission.

Link to comment
Share on other sites

  • 2 weeks later...

I did this simple script-only Spell-Casting system.. It was geared for 3rd person, but might give you an idea for RTS games:


(Updated code here: https://github.com/lukaspj/Spellcasting-system-T3D)

I also had a code-version but I don't remember where I put it..


Here is a code-version of my spellsystem: https://onedrive.live.com/redir?resid=22CCBF302883D3DA!11806&authkey=!AGKx_Jm5NFsTsFk&ithint=file%2czip

Also, some documentation for the code-version: https://onedrive.live.com/redir?resid=22CCBF302883D3DA!212726&authkey=!AHvvk8iWumEg5og&ithint=folder%2c

You'll probably want to just go with the something like the path that @rlranft suggested for a RTS, but my code might be useful if you want a more generic solution.

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.

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.

  • Create New...