English Molotov without explosion request

4 replies
Goto Page
To the start Previous 1 Next To the start
Up
Anybody is able to reproduce this script?

https://youtu.be/s_KCXLD__GU

I tried this but it still instakill if you have less health than the damage of explosion.

Code:
1
2
3
4
5
6
7
8
9
addhook("hit","_hit")
function _hit(id,source,weapon,hpdmg,apdmg)
local hp = player(id,"health")
     if weapon == 73 then
          if hpdmg > 4 then              
               timer(0,"parse","sethealth "..id.." "..hp)
          end
     end
end
CS2DBR Community - http://cs2dbr.tk
25.07.20 06:41:59 pm
Up
Masea
Super User
Offline Off
What happens in that script is basically removing the original projectile whenever a player attacks with it (cs2d lua hook attack). Afterwards, you are just creating your own custom projectile and do anything with it.
Create your UI easy and fast: UI Framework | Go deeper into the darkness and test your bravery: file cs2d Outlast II Modification (28)
25.07.20 11:23:45 pm
Up
Here is the full script plus smoke extinguish flames.

Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
local smoke_effects = {}
local molotov_effects = {}
local pl_effects = {}
local effecttimer = 7000
local effectrad = 4
local effectamm = 40

local function effect(name,x,y,radius,amount)
     parse("effect \""..name.."\" "..x.." "..y.." "..radius.." "..amount)
end

addhook("hit","_hit")
function _hit(id,source,weapon,hpdmg,apdmg)
     if weapon == 73 then
          if hpdmg > 4 then   
               local hp = player(id,"health")           
               timer(0,"parse","sethealth "..id.." "..hp)
          end
     end
end

addhook("ms100", "molotov_ms100")
function molotov_ms100()
     for k, v in pairs(molotov_effects) do
          if v.timer > 0 then
               effect("fire", v.x, v.y, effectrad, effectamm)
               molotov_effects[k].timer = molotov_effects[k].timer - 100
          else
               molotov_effects[k] = nil
          end
          if molotov_effects[k] then 
               for s, t in pairs(smoke_effects) do
                    if (math.sqrt(((t.x-v.x)^2 +t.y-v.y)^2)<100) then
                         molotov_effects[k] = nil
                    end
               end
          end
     end     
     for _, id in pairs (player(0,"tableliving")) do
          for k, v in pairs(molotov_effects) do
               local dist = math.sqrt(((player(id,"x")-v.x)^2) + ((player(id,"y")-v.y)^2))
               if dist <= effectrad * 16 then   
                    if player(id, "health")-1 == 0 then
                         parse("customkill "..v.pl.." 'MolotovCocktail,gfx/weapons/molotovcocktail_k.bmp' "..id)
                    else
                         parse("sethealth "..id.." "..player(id,"health")-4)
                         parse('sv_soundpos "player/hit'..math.random(1,3)..'.wav" '..player(id,"x")..' '..player(id,"y")) 
                    end
               end
          end
     end
end

addhook("always", "molotov_always") 
function molotov_always()
     for _,p in pairs(projectilelist(0,0)) do
          if projectile(p.id,p.player,"type") == 73 or projectile(p.id,p.player,"type") == 54 then
               local x, y, pl = projectile(p.id,p.player,"x"), projectile(p.id,p.player,"y"), p.player
               if projectile(p.id,p.player, "flydist") < 7 then
                    parse("freeprojectile "..p.id.." "..p.player)
                    effect("fire", x, y, effectrad, effectamm)
                    parse("explosion ".. x .." ".. y .." 48 0 "..p.player.."")
                    parse('sv_soundpos "materials/glass'..math.random(1,3)..'.wav" '..x..' '..y)
                    molotov_effects[#molotov_effects+1] = {timer = effecttimer, x = x, y = y, pl = pl}
               end
          end
     end
end

addhook("projectile_impact", "smokegas_impact") 
function smokegas_impact(id, w, x, y, m, projid)
     if w == 53 then
          smoke_effects[#smoke_effects+1] = {timer = effecttimer,x = x, y = y, pl = pl}
     end
end

addhook("leave", "effect_leave") 
function effect_leave(id)
     for k, v in pairs(molotov_effects) do
          if v.pl == id then
               molotov_effects[k] = nil
          end
     end     
     for k, v in pairs(smoke_effects) do
          if v.pl == id then
               smoke_effects[k] = nil
          end
     end
end

addhook("startround", "effect_startround") 
function effect_startround()
     for k, v in pairs(molotov_effects) do
          molotov_effects[k] = nil
     end
     for k, v in pairs(smoke_effects) do
          smoke_effects[k] = nil
     end
end


credits: pokerfce
fixed by: mrc (me )
edited 10×, last 27.07.20 04:15:42 pm
CS2DBR Community - http://cs2dbr.tk
27.07.20 10:13:41 am
Up
Gaios
Security Supporter
Offline Off
You should never use cs2d lua hook always
27.07.20 10:58:35 am
Up
The Dark Shadow
User
Offline Off
You better do some optimizations.
To the start Previous 1 Next To the start