spawnprojectile in hit hook
6 replies



01.12.18 09:17:41 pm
hey
,
my problem is simple...
i want to add a stun effect for a snowball projectile which i spawned with spawnprojectile like this
...but it doesnt work
the attack2 hook works fine, but the hit hook cant find a hit of a snowball...
i tested it with a message "weapon hit found" but this message wasnt triggered.
my theory is that this projectile has another weapon id, but which?
thanks for answers

my problem is simple...
i want to add a stun effect for a snowball projectile which i spawned with spawnprojectile like this
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
2
3
4
5
6
7
8
9
10
11
12
13
14
15
function attack2hook(id, weapon)
if (weapon == 50) then
parse("spawnprojectile " .. id .. " 75 " .. player(id,"x") .. " " .. player(id,"y") .. " 500 " .. player(id, "rot"))
end
end
function hithook(id, weapon)
if (weapon == 75) then
parse("speedmod " .. id .. " " .. player(id, "speedmod") - 15)
msg("weapon hit found")
end
end
addhook("attack2", "attack2hook")
addhook("hit", "hithook")
if (weapon == 50) then
parse("spawnprojectile " .. id .. " 75 " .. player(id,"x") .. " " .. player(id,"y") .. " 500 " .. player(id, "rot"))
end
end
function hithook(id, weapon)
if (weapon == 75) then
parse("speedmod " .. id .. " " .. player(id, "speedmod") - 15)
msg("weapon hit found")
end
end
addhook("attack2", "attack2hook")
addhook("hit", "hithook")
...but it doesnt work
the attack2 hook works fine, but the hit hook cant find a hit of a snowball...
i tested it with a message "weapon hit found" but this message wasnt triggered.
my theory is that this projectile has another weapon id, but which?
thanks for answers

Place this in your hit hook:
Afterwords check your console for the given number.
print(weapon)
Afterwords check your console for the given number.
Is death truly a bad thing? If it is, then why do we all get to experience it? And... Why does it take so long? - What is the meaning of death?
Check the parameters for
hit. Try this:
What your parameters mean currently is that it will speed debuff the victim if the source player's ID is 75, which obviously cannot exist (one server can only fit 32 players tops).

Code:
function hithook(id,source,weapon)
What your parameters mean currently is that it will speed debuff the victim if the source player's ID is 75, which obviously cannot exist (one server can only fit 32 players tops).
edited 1×, last 28.05.20 03:23:13 am


@
Cure Pikachu: thanks. it works fine. its unusual that i must add parameters, which i dont need. c:
@
Bowlinghead: ive tried it, but the projectile hook hasnt got a victim parameter

@



@
Bowlinghead: ive tried it, but the projectile hook hasnt got a victim parameter 


Quote:
Parameters
id: id of player who shot
id: id of player who shot

Is death truly a bad thing? If it is, then why do we all get to experience it? And... Why does it take so long? - What is the meaning of death?
@
Carnivohra: It's not unusual. It provides all parameters and you can name them at your own convenience. Thus, the pc needs another way to figure out which parameter is which, cause you could technically name source id as "weapon" and weapon as "source", so it uses the order as a way to figure out which parameter is which. It's pretty nice, I'd hate having to write every param in a specific way.




