Implementation Combat System

Shine

New Member
Contributor
Module Name: CombatSystem
Status: Usable but in progress(more features will be added regularly)
Scope: extra content
Summery: The module can be used to introduce various weapons, traps as well puzzle rooms for a variety of other content based modules.
Repository: https://github.com/Terasology/CombatSystem

Do check out its wiki if you wish to understand the structure of code.
However, if you wish to use its features for your content than use this forum as your guide.

The things that have been implemented so far:
  1. Weapons
  2. Traps
  3. Trap rooms
1. Weapons
The weapons are basically items that could give damage to other entities that have a health component. Since the weapons are items they are always held by a character whether npc or human.
To use the weapons in combat system just treat them as you would any other item.
Also, the right mouse button click is responsible for attacking through a particular weapon.

For debugging purposes: use command give itemName in the console of the game and replace itemName with the name of the weapon.

For content purposes: there may be various ways to give item in game. Either by crafting it, walking over a pickup entity of the item, through chests or through gifts from npc's or other player. My point being treat the weapons as you would any other item to make them available in-game.

Now the important part, a list of names of all the weapons prefabs in one place.

Weapons name list:
  • bow: launches arrows that are in its inventory
  • spearItem: launches the spear that is currently held in hand
  • staff: shoots fireballs
  • sword: deals random melee damage with a chance of crit.
  • waraxe: deals more damage than sword and has more range but also more cooldown time.
  • bouceArrowItem: bounce arrow that bounces off the targets.
  • explodeArrowItem: explode arrow that explodes on contact with target.
  • stickArrowItem: stick arrow that pierces and sticks to the target.
Note: Only the items that have ArrowItem in there names can be slotted into the bow inventory. You might be wondering what is bow inventory. Whenever you select bow in inventory i.e. it becomes the handheld item. Than a new inventory slot appears to the right and slightly apart the existing 10. That is the bow inventory slot. You can move the arrow items from player inventory to bow inventory by pressing i after selecting bow.
The arrow items in the characters hand won't do anything unless fitted into a bow.

2. Traps
Traps are weapons that can be placed in the world either by a player, npc or world initialization. Therefore, traps are to be considered as blocks just like weapons are considered as items.
The right mouse button click will place the traps as is the case with blocks. To activate/deactivate a trap, use E keyboard key. Initially, the traps are in activated state as soon as they are placed in the world. Moreover, a visual range of the trap is visible to the person who placed and activated the traps but the range is invisible to other players. Also the owner of the trap(the character who placed the trap) is an exception for that particular trap and the trap won't get triggered due to the owner.

Traps are needed to sense nearby entities within range and react accordingly. This led to the development of another module called Sensors which is responsible for introducing various methods for sensing nearby entities. If you are interested in something like that than do check that module out.

For debugging purposes: use command give itemName in the console of the game and replace itemName with the name of the trap.

For content purposes: treat the traps as blocks.

Traps name list:
  • explodeMineTrap: explodes if a foreign entity comes within range of the trap.
  • fireBallMineTrap: shoots fireballs in the direction of entity that is within range of this trap. It won't shoot at entities that are behind other entities or blocks but still within range.
3. Trap Rooms
Trap rooms make use of StructureTemplates module. There are a few trap rooms already available in this module for use but i will also explain how you can make use of some special blocks provided in this module to include in your own structure template. Please be noted that i won't tell you how to create structures through StructureTemplate module, please use other references for that like the README.md of StructureTemplates module.

To spawn a structure through console, follow these steps:
  1. Type give toolbox in console
  2. Select toolbox item and right click on a block to activate it.
  3. Expand the drop down list named Structures.
  4. Select any structure listed in the list (preferably those that are in CombatSystem module to use predefined ones) and click Get Item button.
  5. A page like item will appear in your inventory. Select that item.
  6. Point to a block near you, preferably on ground, to see the outline of structure.
  7. Right click to place the structure. Also, do not click twice as that will spawn 2 structures. Best strategy is to Right click to spawn structure and immediately select another item. If the structure is really large than it may take some time to spawn. Done :)
Note : I don't know how to have the structures spawned during initialization of game. Haven't required it yet. If you need that than you may either look through the StructureTemplates module for the appropriate Event to spawn structure and use that or look through this post :
http://forum.terasology.org/threads/structure-templates.1550/

List of structures available in this module:
  • puzzleRoom: A room with several corridors with various traps, obstacles and locked doors in between. The next corrider can only be accessed if the previous corridor is cleared.
List of blocks available in this module:
Here's a list of special blocks that can be used in these trap rooms or anywhere else for more fun.
  • combatTNT: An indestructible block that explodes if an exploding projectile hits it. It also causes a chain reaction that explodes any other combatTNT block if it is among all 26 blocks(6 blocks directly attached to faces and the other 20 blocks placed diagonal to given block) surrounding the exploding block.
  • destroySwitch: A block with some health that opens door if it gets destroyed. You may place it behind some obstacle so that it can only be destroyed by a specific set of weapons like bounce arrow.
  • stickSwitch: An indestructible block that opens door only when an entity sticks to it. Please note that sticking here means the piercing functionality introduced in combat system and not the one used by torch to stick to a block. So, the switch works only when stick arrow or spear or something that uses stick functionality sticks on the switch.
  • lockedDoor: An indestructible block that is used as door which is opened whenever the switch is activated.
All these blocks are used in puzzleRoom structure if you wish to see there implementation.

Also note that the lockedDoor blocks and the switch blocks are to be linked to each other to specify which switch opens which door. This is achieved in case of structures through the introduction of a new Component that links the preferred door to its switch whenever the structure is spawned.
StructuresHandlingSystem.java in package
org.terasology.combatSystem.world in this module
makes use of that component if you wish to see how that is achieved.
That bit may come in handy if you wish to create your own structures and also use the doors and switches.
 
Last edited:
Top