Changing projectile fired from ranged entities

So I’ve been making an abundance of posts asking for help on various things, and I apologize for the spam of it, but I have another question I have been unable to figure out on my own. I have been trying to implement a new class, and implementation of it is fine so far, however I can’t seem to work out how to change projectile fired from the ranged class that I made. How can I do this? Thanks again in advance for any help.

at the moment this is hardcoded in \attack_ranged_action.lua - so not possible to change at the moment ^^ but it think they will later make the softcoded (for example the mage needs later an own projectile xD

1 Like

I had a feeling it was coded in there, would it not be possible to make my own copies of the luas that are used by that and that one specifically for my class?

nope at the moment not … you can only change it in there with an own projectile

So I figured it out after struggling for some time, I made some changes to the ranged combat lua and wrote in an override for my mod. Not ideal but basically I added the projectile to be linked to the weapon_data itself, so that the code for the projectile spawning calls the projectile based on the weapon. If anyone is interested specifically in how I coded it I can provide that as well. As seen below both the archer and my class are firing projectiles!

1 Like

Actually you can change the projectile’s speed from json, but it’s found in the weapon that’s firing it. For the arrow you’ll have to change the bow’s json file. Here’s a snippet of bow.json:

   "entity_data": {
      "stonehearth:combat:weapon_data": {
         "base_damage": 25,
         "base_ranged_damage": 25,
         "range": 30,
         "projectile_speed": 30

The Lua script that you modified uses those values to determine the speed, so just do a mixinto on this one instead of overriding Lua scripts. :slight_smile:

1 Like

Thank you Drotten, however I was looking at modifying the projectile fired based on which class you were using, not the speed. I made a work around by implementing another variable into the weapon class that identifies the projectile assigned , then simply called it in the lua:

function AttackRanged:_create_projectile(attacker, target, projectile_speed, projectile_type)
local projectile = radiant.entities.create_entity(projectile_type)
local projectile_component = projectile:add_component(‘stonehearth:projectile’)

local projectile_origin = self:_get_world_location(self._attacker_offset, attacker)
radiant.terrain.place_entity_at_exact_location(projectile, projectile_origin)

return projectile

1 Like

Ah! I misunderstood then what you were after, obviously. Then yeah, you’ll have to change the function to take that into account.

1 Like