Author Topic: modifying a projectile datablock in flight  (Read 729 times)

this came to me because i enjoy experimenting with torquescript to hopefully be proficient in blockland-related coding one day, especially with weapons.

is there absolutely any way that you can modify a projectile that's in flight already?
My main focus would be to hopefully check the projectile's lifetime (in ms) and do something like lower damage, muzzleVelocity, and gravity.
but i'm not entirely sure if that's possible.

I don't know if it works, but you could try making multiple datablocks and using the setDatablock method.

Never tried anything like that before.

Damage doesn't require this, you can just package Player::Damage (not sure of arguments).

I think you may be able to just modify the projectile's velocity at fire using setVelocity.

Gravity would be the only one I'd assume you would need to modify with separate datablocks.

see, what i was thinking was just directly editing the projectileDatablock's values after it's been fired similarly to how strato's more-than-200-velocity script works

can anything with a bullet's lifetime and how long it's been since it has been fired be detected in an if statement?

see, what i was thinking was just directly editing the projectileDatablock's values after it's been fired
do not do this ever

can anything with a bullet's lifetime and how long it's been since it has been fired be detected in an if statement?
you can probably do something like this with a schedule and setting a variable on fire (unless there's already something for fire time on projectiles by default)

not sure on that though, seems like a slightly strange way of doing it
« Last Edit: April 25, 2013, 05:18:20 PM by otto-san »


Why?
modifying the datablock after it's been created can be tricky and when it works it's probably not what you want (modifies it for everything using the datablock)

sometimes the changes will just not even apply

sometimes you might actually crash/disconnect players

and the point of datablocks is to be a kind of a framework for objects anyway.

oh sorry i think i explained it the wrong way
you know how projectile::damage is usually used for headshots/critical hits?

pretend i'm using the sport rifle from t+t2
it initially has 24 damage (know this by heart lol)
but with sportrifleprojectile::damage it does like 50 with a headshot
i was thinking that when the projectile is fired, in the same way that ::damage changes the amount of damage the bullet does, that after (example) 40ms the projectile's damage will be lowered to 20 with the same line of code and everything.
is this possible?

oh sorry i think i explained it the wrong way
you know how projectile::damage is usually used for headshots/critical hits?

pretend i'm using the sport rifle from t+t2
it initially has 24 damage (know this by heart lol)
but with sportrifleprojectile::damage it does like 50 with a headshot
i was thinking that when the projectile is fired, in the same way that ::damage changes the amount of damage the bullet does, that after (example) 40ms the projectile's damage will be lowered to 20 with the same line of code and everything.
is this possible?
oh yeah.

if projectiles don't record the time they're shot or the time they've been alive, you could just do that upon firing, and just take the passed time into some kind of equation to figure out the damage