I need this magical bolt to still explode anyway. function…
- User
I need this magical bolt to still explode anyway.
function scripts.bolt_blast.update(this, store, script) local b = this.bullet local dradius = b.damage_radius + b.level * b.damage_radius_inc local dmin = b.damage_min + b.level * b.damage_inc local dmax = b.damage_max + b.level * b.damage_inc local explode_pos = V.v(this.pos.x, this.pos.y - 8)
U.animation_start(this, "hit", nil, store.tick_ts, 1) local enemies = table.filter(store.entities, function(k, v) return v.enemy and v.vis and v.health and not v.health.dead and band(v.vis.flags, b.damage_bans) == 0 and band(v.vis.bans, b.damage_flags) == 0 and U.is_inside_ellipse(v.pos, explode_pos, dradius) end) local d_value = U.frandom(dmin, dmax) for _, enemy in pairs(enemies) do local d = E:create_entity("damage") d.source_id = this.id d.target_id = enemy.id d.value = math.ceil(d_value) d.damage_type = b.damage_type d.track_damage = true queue_damage(store, d) end while not U.animation_finished(this) do coroutine.yield() end queue_remove(store, this)end
- Assistant
The function
scripts.bolt_blast.updateappears to handle the explosion and damage calculation for a magical bolt in a game or simulation. This function ensures the bolt explodes under specified conditions, calculates damage, and applies it to nearby enemies. Let's break down the function:-
Extract Bullet Information:
dradiuscalculates the effective damage radius based on the bullet's and its incremental .
-
- User
Can you show me code that will make the magical bolt still explode anyway against stored entities?
- Assistant
To make the magical bolt "still explode anyway" against all stored entities whether they are valid targets or not, you'll need to modify the part of the script where entities are filtered for damage application. Instead of excluding entities based on conditions, you would include all entities that can potentially take damage. Below is a modified version of your function to achieve this:
- User
This didn't work. You need to try something completely different.
- Assistant
To ensure the magical bolt explodes and applies damage regardless of entity states or filters, you can directly iterate over all entities and apply damage to those that are designated to have health or could logically take damage. Here's a more direct approach: