English spawnprojectile in hit hook

6 replies
Goto Page
To the start Previous 1 Next To the start
01.12.18 09:17:41 pm
Up
Carnivohra
User
Offline Off
hey us,

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
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")


...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
01.12.18 09:59:43 pm
Up
Goo
User
Offline Off
Place this in your hit hook:

print(weapon)


Afterwords check your console for the given number.
02.12.18 02:17:56 am
Up
Bowlinghead
User
Offline Off
I think you gotta replace the hit hook with the cs2d lua hook projectile hook
Share time limited free games here
02.12.18 09:27:57 am
Up
Cure Pikachu
User
Offline Off
Check the parameters for cs2d lua hook hit. Try this:
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 doesn't exist.
IMG:https://i.imgur.com/uUrye71.png
IMG:https://i.imgur.com/xpsyQRX.png
02.12.18 11:54:03 am
Up
Carnivohra
User
Offline Off
@user Cure Pikachu: thanks. it works fine. its unusual that i must add parameters, which i dont need. c:

@user Bowlinghead: ive tried it, but the projectile hook hasnt got a victim parameter
02.12.18 01:10:53 pm
Up
Goo
User
Offline Off
user Carnivohra has written:
@user Bowlinghead: ive tried it, but the projectile hook hasnt got a victim parameter


Quote:
Parameters
id: id of player who shot

02.12.18 03:01:48 pm
Up
Rainoth
Moderator
Offline Off
@user 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.
To the start Previous 1 Next To the start