Raycasting in GameMaker Studio 2 to implement hitscan weapons?

I’m working on a 2D top-down shooter game in GameMaker Studio 2, featuring different weapons and obstacles all around the levels.

Since I don’t need a high degree of simulation, I’m implementing simple physics for character movement and interaction (e.g. weapons, bullets, doors…) myself via GML rather than using the dedicated physics library.

Currently, shooting works as follows:

  • The player presses the Left Mouse Button.
  • A bullet object spawns, according to the current weapon.
  • The bullet starts moving towards the mouse position at a given velocity.

Right now, the gameplay works quite well. However, I wanted to create different weapons with unique features, including different bullet speeds. And here’s my problem.

I tried to increase bullet velocity values, but they started behaving strangely: When shooting against objects, hits occur slightly before visual contact. Sometimes, bullets ‘warp’ beyond small objects or corners as if a collision hasn’t been detected at all.

There are two schematics, one for the general case:

Desired vs current behaviour 1

And one for the collision with thin objects:

Desired vs current behaviour 2

I think this is due to my code checking for collisions for given positions rather than sweeping along the expected motion trajectory. And, this doesn’t work well with laser weapons and sniper rifles, since players expect them to be precise when shooting.

My initial implementation was the following:

Create Event:

b_damage = 25; b_velocity = 100; b_direction = point_direction(x, y, mouse_x, mouse_y); 

Step Event:

var _xvel = lengthdir_x(b_velocity, b_direction); var _yvel = lengthdir_y(b_velocity, b_direction);  var _coll = instance_place(x + _xvel, y + _yvel, obj_CollisionParent);  if ( _coll == noone ) {     // No collision occurred, bullet can travel     x += _xvel;     y += _yvel; } else {     // Destroy bullet (shows sparks)     instance_destroy();     // Deal damage if an enemy was hit     if ( _coll.object_index == obj_Enemy )     {         scr_DealDamage(_coll, b_damage);     } } 

I then tried to increase precision by subdividing the collision check into smaller steps:

Step Event:

var _xvel = lengthdir_x(b_velocity, b_direction); var _yvel = lengthdir_y(b_velocity, b_direction);  var _coll; var _steps = 10;  for (var i = 0; i < _steps; i++) {     _coll = instance_place(x + _xvel/_steps, y + _yvel/_steps, obj_CollisionParent);      if ( _coll == noone )     {         // No collision occurred, bullet can travel for 1/_steps distance         x += _xvel / _steps;         y += _yvel / _steps;     }     else     {         // Destroy bullet (shows sparks)         instance_destroy();         // Deal damage if an enemy was hit         if ( _coll.object_index == obj_Enemy )         {             scr_DealDamage(_coll, b_damage);         }     } } 

Now, collision is more precise, yet it’s far from perfect. I still cannot use high velocity values without increasing the number of _steps. Also, 100 collision checks per step for dozens of bullets seem too much for my CPU. I would like to improve this aspect of my game.

I would like to use a raycast-like function, similar to Unity’s Physics.Raycast. I need to find the final impact position with a low computational effort so that I can make bullets travel instantly, draw impact particles at the right position, and show realistic bullet trails.

Are there any rules pertaining to using extremely heavy weapons, either standard or improvised?

I haven’t found any rules related to this subject. Nothing about weight changing the damage of any weapon was seen anywhere, and neither was there anything on the improvised weapon.

Have anyone seen house rules that modified the damage of standard weapons that happen to be extremely heavy by design? Like instead of using a Warhammer weighing 2lbs someone wants to use one that is 20lbs.

Using everyday items that are not included in the official list of weapons are generally counted as attacking with an improvised weapon, like a chair or a wine bottle. But the problem is, what if the improvised weapon in question is so ridiculously heavy that it no longer makes logical sense for it to only inflict 1d4 damage?

Consider The Bag of Holding, which will always be 15lbs. (For reference, a battleax is weighed at 8lbs and heavy crossbow weighs 18lbs) Even if the texture of the bag in question is soft leather, when you swing that bag to hit someone or someone, the weight and momentum itself should be plenty enough to crush things.

PS: Not that I would want to swing that thing around! Damaging the bag could be disastrous.

Swinging around a sack with a rock is definitely an improvised weapon with 1d4 damage. But if someone swings a regular sack filled with a lot of rocks (or with tons of loot and gold),filled the bag with more than 50lbs worth of stuff and swung it around? Or 100lbs? (Assuming the sack doesn’t rip or fall apart before the smashing hit connects).

Speaking of which, would using a gigantic heavy table that is capable of seating twenty people as an improvised weapon during the bar fight in the tavern really only do 1d4 damage?

Does Deadly Agility work with light thrown weapons?

Does Deadly Agility work with light thrown weapons?

Deadly Agility (Combat)

Prerequisite(s): Weapon Finesse

Benefit(s): You may add your Dexterity modifier in place of your Strength modifier when wielding a light weapon or a weapon that gains the benefits of the Weapon Finesse feat (such as the rapier) when determining additional damage inflicted upon a successful attack.

When wielding a weapon in your off-hand, Deadly Agility will add the same fraction of Dexterity as you normally would for Strength.

I’m just asking as RAW "add your Dexterity modifier in place of your Strength modifier when wielding a light weapon or a weapon that gains the benefits of the Weapon Finesse feat" since there are weapon the are light that can be thrown (daggers, shuriken, darts, etc.).

What are the rules for the size of weapons?

According to Items and Sizes Small and Medium creatures seem to be able to use Small and Medium weapons interchangeably without any penalty, and they can use Large weapons but they gain the Clumsy 1 condition.

The Bulk rules in this chapter are for Small and Medium creatures, as the items are made for creatures of those sizes.

In most cases, Small or Medium creatures can wield a Large weapon, though it’s unwieldy, giving them the clumsy 1 condition, and the larger size is canceled by the difficulty of swinging the weapon, so it grants no special benefit.

Items of Different Sizes also specifies:

Creatures of sizes other than Small or Medium need items appropriate to their size.

I’ve got several questions related to inappropriately sized weapons:

  • What happens if a Large creature tries to use a Medium weapon?
  • What happens if a Small/Medium creature tries to use a Tiny weapon?
  • What happens if a Small/Medium creature tries to use a Huge or bigger weapon?

And all other possible permutations of these questions.

Then, there is no mention about damage at all, is it the same for all sizes? It seems absurd that a Tiny hammer does the same damage as a Gargantuan hammer.

Are there any Feats for / ways to use spears it that reflect it’s dominance over shorter melee weapons

Spear are wildly effective weapons, in small-ish Combat Groups. In particular, when used defensively, they can keep melee attackers at bay with no ability to retaliate relatively easily. You would, for example be able to hold a 5ft-wide bridge against a mass of opponents pretty easily if they weren’t willing to rush you and sacrifice themselves.

I was disappointed to find that in DnD 5e, they really aren’t very effective or interesting weapons. They don’t even have Reach.

I’m planning to come up with some ideas for a homebrew additions to them, and propose them on here, but before I do, are there any existing official ways to make a spear behave like this?

Do black puddings corrode slashing weapons

Black puddings are immune to slashing damage, and the Corrosive Form trait states:

… Any nonmagical weapon made of metal or wood that hits the pudding corrodes. After dealing damage, the weapon takes a permanent and cumulative-1 penalty to damage rolls. …

The bit that confuses me is "after dealing damage". If the pudding is immune to slashing damage, then slashing weapons will never deal damage, and thus should not take the -1 penalty. However, that seems to contradict the previous statement, that anything that hits will corrode.

Can weapons with Reach be used to attack “through” willing allies?

I’m picturing the Greek Phalanx formation, where soldiers were arranged in rows and the men in Row B or even Row C could attack the enemy by thrusting their spears between the soldiers in Row A.

Can you do that with a Reach weapon in DnD 5e? Attack an enemy even though there’s an ally (or even a row of allies) directly between you and them?

Should unarmed melee weapons like fists and claws have the *finesse* and *light* traits? [closed]

In DnD 5e you find under Melee Attacks:

Instead of using a weapon to make a melee weapon attack, you can use an unarmed strike: a punch, kick, head-butt, or similar forceful blow (none of which count as weapons). On a hit, an unarmed strike deals bludgeoning damage equal to 1 + your Strength modifier. You are proficient with your unarmed strikes.

Also Martial Arts for monks, and Claws for tabaxis and tortles deal with unarmed strikes.

All use Strength for the attack and damage roll, with the exception of the Martial Arts for monks, which accepts Dexterity too.

Should "unarmed strikes with these natural weapons" have the finesse and light traits, because wrestling and boxing are not only based on strength but also dexterity like wushu or bujutsu, and there is no reason to use two daggers but can’t do so with claws or fists, feets etc.? The monk still has more damage and would gain two-weapon fighting with its body. So it would not unbalance in game, but give the tabaxi and tortle non-throwable natural daggers.

Should a high elf wizard use weapons instead of cantrips?

As a new DM I’m running my first adventure for my kids (LMoP). My daughter took the high elf wizard and she was wondering whether she should use weapons instead of her cantrips when she runs out of spell slots.

Indeed, high elf being proficient with weapons, she could use a bow who does 1d8+2, adding also the modifier to the attack roll, or a sword instead of shocking grasp for example… When cantrips don’t get any modifiers.

Not really sure what to answer her. Thanks ahead!

Are enemy weapons and armour up for grabs as loot?

I am running the Starter Set Adventure (Lost Mine of Phelvander), and the majority of enemies have weapons and armour. For example every goblin has a scimitar, a shortbow, and leather armour.

When the PCs defeat them, do they obtain these as items?

I ruled at the time that armour is rendered useless by the fight but weapons can be looted. (And then the first NPC shopkeeper they met swindled them horribly, so that worked out OK). But I would prefer to know what the rules have to say on the subject, and I can’t seem to find an answer.