[Half-Life AMXX] / jedigrab.sma Repository:
ViewVC logotype

Annotation of /jedigrab.sma

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (view) (download)

1 : ian 1 /* AMX Mod script.
2 :     *
3 :     * Jedi Force Grab
4 :     * by SpaceDude
5 :     * email: eayumns@nottingham.ac.uk
6 :     * MSN: eayumns@nottingham.ac.uk
7 :     * ICQ: 1615758
8 :     * IRC: Quakenet, nickname: "SpaceDude"
9 :     *
10 :     * Description:
11 :     *
12 :     * Another plugin for those admins who like to abuse their players and have a little fun.
13 :     * With this plugin you can literally pick players up, drag them around in the air and then
14 :     * depending on your mood either slam them into the ground or let them go free.
15 :     *
16 :     *
17 :     * Server Side Cvars:
18 :     *
19 :     * sv_grabforce - sets the amount of force used when grabbing players, default is 8
20 :     *
21 :     * sv_choketime - sets how long to choke players, default is 8
22 :     *
23 :     * sv_throwforce - sets the power used when throwing players, default is 1500
24 :     *
25 :     * sv_glowred - sets red amount for glow
26 :     *
27 :     * sv_glowgreen - sets green amount for glow
28 :     *
29 :     * sv_glowblue - sets blue amount for glow
30 :     *
31 :     * Client Side Commands:
32 :     *
33 :     * +grab - bind a key to +grab like this: bind <key> +grab, once you have done that
34 :     * hold the key down and look at someone. Once you see their ID pop-up on
35 :     * the screen you will be able to drag them around, just look in the direction
36 :     * you want them to go and they will be dragged there. requires level ADMIN_SLAY.
37 :     *
38 :     * grab_toggle - works in the same way as +grab except it is a toggle press once to grab
39 :     * press a second time to release.
40 :     *
41 :     * +pull/+push - pulls or pushes the grabee towards/away from you as you hold the button.
42 :     * Atm its speed is set at 35, feel free to change it below.
43 :     *
44 :     * choke - chokes the grabee for 8 seconds (it damages the grabee with 3 hp per second)
45 :     *
46 :     * throw - throws the grabee
47 :     * Atm its power is set at 1500, feel free to change it below.
48 :     *
49 :     *
50 :     * Revision History:
51 :     * v1.6.2 (by KCE)- Added Disable/Enable cvar (amx_jedigrab 1|0 Enabled\Disable)
52 :     * Added cvar, sv_choketime, sets how long to choke person
53 :     *
54 :     * v1.6.1 (by KCE) - Fixed bug where if graber disconnected while grabbing someone, the grabee was not released
55 :     *
56 :     * v1.6 (by KCE) - Fixed glowing and added cvars to customize it
57 :     * - Made buildings glow also
58 :     * - Changed cmd names
59 :     *
60 :     * v1.5 (by KCE) - Ported back to AMX X 1.0
61 :     * Added cvar sv_throwforce to adjust throwing power ingame
62 :     *
63 :     * v1.4 (by KRoTaL) - Converted to AMX 0.9.9, added jedichoke command from the Star Wars Mod *plugin by Gev
64 :     * - Added throw command
65 :     *
66 :     * v1.3 (by BOB_SLAYER) - Added +push and +pull commands
67 :     *
68 :     * v1.2 (by kosmo111) - Added ability to grab entities
69 :     *
70 :     * v1.1
71 :     * - Added a grab_toggle as an alternative to +grab
72 :     * - Added notify messages
73 :     * - Made it possible to grab people while dead (works best in Free View mode)
74 :     *
75 :     * v1.0 - Initial Release
76 :     */
77 :    
78 :     #include <amxmodx>
79 :     #include <amxmisc>
80 :     #include <fun>
81 :     #include <engine>
82 :    
83 :     new grabbed[33]
84 :     new grablength[33]
85 :     new bool:grabmodeon[33]
86 :     new velocity_multiplier
87 :     new Throw_force
88 :    
89 :     #define JEDI ADMIN_LEVEL_A
90 :    
91 :     stock is_player(id)
92 :     {
93 :     for(new i = 1 ;i <= get_maxplayers() ;i++)
94 :     {
95 :     if (i == id)
96 :     {
97 :     return true
98 :     }
99 :     }
100 :    
101 :     return false
102 :     }
103 :    
104 :     public grabtask(parm[])
105 :     {
106 :     new id = parm[0]
107 :     new targetid, body
108 :     if (!grabbed[id])
109 :     {
110 :     get_user_aiming(id, targetid, body)
111 :     if (targetid)
112 :     {
113 :     set_grabbed(id, targetid)
114 :     }
115 :     }
116 :     if (grabbed[id])
117 :     {
118 :     new origin[3], look[3], direction[3], moveto[3], Float:grabbedorigin[3], Float:velocity[3], length
119 :     get_user_origin(id, origin, 1)
120 :     get_user_origin(id, look, 3)
121 :     entity_get_vector(grabbed[id], EV_VEC_origin, grabbedorigin)
122 :    
123 :    
124 :     direction[0]=look[0]-origin[0]
125 :     direction[1]=look[1]-origin[1]
126 :     direction[2]=look[2]-origin[2]
127 :     length = get_distance(look,origin)
128 :     if (!length) length=1 // avoid division by 0
129 :    
130 :     moveto[0]=origin[0]+direction[0]*grablength[id]/length
131 :     moveto[1]=origin[1]+direction[1]*grablength[id]/length
132 :     moveto[2]=origin[2]+direction[2]*grablength[id]/length
133 :    
134 :     velocity[0]=(moveto[0]-grabbedorigin[0])*velocity_multiplier
135 :     velocity[1]=(moveto[1]-grabbedorigin[1])*velocity_multiplier
136 :     velocity[2]=(moveto[2]-grabbedorigin[2])*velocity_multiplier
137 :    
138 :     entity_set_vector(grabbed[id], EV_VEC_velocity, velocity)
139 :     }
140 :     }
141 :    
142 :     //Toggles grab.
143 :     public grab_toggle(id)
144 :     {
145 :     if (get_cvar_num("amx_jedigrab"))
146 :     {
147 :     if (grabmodeon[id])
148 :     release(id)
149 :     else
150 :     grab(id)
151 :     }
152 :     else
153 :     {
154 :     client_print(id,print_chat,"[AMX] Jedi Grab has been disabled")
155 :     }
156 :     return PLUGIN_CONTINUE
157 :     }
158 :    
159 :     //Actually does the grabbing.
160 :     public grab(id)
161 :     {
162 :     if (!(get_user_flags(id)&JEDI))
163 :     {
164 :     console_print(id,"[AMX] You have no access to that command")
165 :     return PLUGIN_CONTINUE
166 :     }
167 :     if (get_cvar_num("amx_jedigrab"))
168 :     {
169 :     if (!grabmodeon[id])
170 :     {
171 :     new targetid, body
172 :     new parm[1]
173 :     parm[0] = id
174 :     velocity_multiplier = get_cvar_num("sv_grabforce")
175 :     grabmodeon[id]=true
176 :     set_task(0.1, "grabtask", 100+id, parm, 1, "b")
177 :     get_user_aiming(id, targetid, body)
178 :     if (targetid)
179 :     {
180 :     if (get_cvar_num("amx_jedigrab_playersonly"))
181 :     {
182 :     if (is_player(targetid))
183 :     set_grabbed(id, targetid)
184 :     else
185 :     client_print(id,print_chat,"[AMX] You can only grab players")
186 :     }
187 :     else
188 :     {
189 :     set_grabbed(id, targetid)
190 :     }
191 :     }
192 :     else
193 :     {
194 :     client_print(id,print_chat,"[AMX] Searching for a target")
195 :     }
196 :     }
197 :     }
198 :     else
199 :     {
200 :     client_print(id,print_chat,"[AMX] Jedi Grab has been disabled")
201 :     }
202 :    
203 :     return PLUGIN_CONTINUE
204 :     }
205 :    
206 :     //Releases the grab.
207 :     public release(id)
208 :     {
209 :     if (!(get_user_flags(id)&JEDI))
210 :     {
211 :     console_print(id,"[AMX] You have no access to that command")
212 :     return PLUGIN_CONTINUE
213 :     }
214 :     if (grabmodeon[id])
215 :     {
216 :     grabmodeon[id]=false
217 :    
218 :     if (grabbed[id])
219 :     {
220 :     set_rendering(grabbed[id])
221 :     client_print(id,print_chat,"[AMX] You have released something!")
222 :     }
223 :     else
224 :     {
225 :     client_print(id,print_chat,"[AMX] No target found")
226 :     }
227 :     grabbed[id]=0
228 :     remove_task(100+id)
229 :     }
230 :     return PLUGIN_CONTINUE
231 :     }
232 :    
233 :     public throw(id)
234 :     {
235 :     if (!(get_user_flags(id)&JEDI))
236 :     {
237 :     console_print(id,"[AMX] You have no access to that command")
238 :     return PLUGIN_CONTINUE
239 :     }
240 :     if (grabbed[id])
241 :     {
242 :     Throw_force = get_cvar_num("sv_throwforce")
243 :     new Float:pVelocity[3]
244 :     VelocityByAim(id,Throw_force,pVelocity)
245 :     entity_set_vector(grabbed[id],EV_VEC_velocity,pVelocity)
246 :     client_print(id,print_chat,"[AMX] You have thrown something!")
247 :     grabbed[id]=0
248 :     grabmodeon[id]=false
249 :     set_rendering(grabbed[id])
250 :     remove_task(100+id)
251 :     }
252 :     return PLUGIN_CONTINUE
253 :     }
254 :    
255 :     //Allows you to spec grab.
256 :     public spec_event(id)
257 :     {
258 :     new targetid = read_data(2)
259 :    
260 :     if (targetid < 1 || targetid > 32)
261 :     return PLUGIN_CONTINUE
262 :    
263 :     if (grabmodeon[id] && !grabbed[id])
264 :     {
265 :     set_grabbed(id, targetid)
266 :     }
267 :     return PLUGIN_CONTINUE
268 :     }
269 :    
270 :     //Grabs onto someone
271 :     public set_grabbed(id, targetid)
272 :     {
273 :     new origin1[3], origin2[3], Float:forigin2[3]
274 :     get_user_origin(id, origin1)
275 :     entity_get_vector(targetid, EV_VEC_origin, forigin2)
276 :    
277 :     set_rendering(targetid,kRenderFxGlowShell,get_cvar_num("sv_glowred"),get_cvar_num("sv_glowgreen"),get_cvar_num("sv_glowblue"), kRenderNormal, 16)
278 :    
279 :     FVecIVec(forigin2, origin2)
280 :     grabbed[id]=targetid
281 :     grablength[id]=get_distance(origin1,origin2)
282 :     client_print(id,print_chat,"[AMX] You have grabbed something!")
283 :     }
284 :    
285 :     public disttask(parm[])
286 :     {
287 :     new id = parm[0]
288 :     if (grabbed[id])
289 :     {
290 :     if (parm[1] == 1)
291 :     {
292 :     grablength[id] -= 35
293 :     }
294 :     else if (parm[1] == 2)
295 :     {
296 :     grablength[id] += 35
297 :     }
298 :     }
299 :     }
300 :    
301 :     public startpull(id)
302 :     {
303 :     if (!(get_user_flags(id)&JEDI))
304 :     {
305 :     console_print(id,"[AMX] You have no access to that command")
306 :     return PLUGIN_CONTINUE
307 :     }
308 :     if (grabbed[id])
309 :     {
310 :     new parm[2]
311 :     parm[0] = id
312 :     parm[1] = 1
313 :     set_task(0.1, "disttask", 500+id, parm, 2, "b")
314 :     }
315 :     return PLUGIN_CONTINUE
316 :     }
317 :    
318 :     public startpush(id)
319 :     {
320 :     if (!(get_user_flags(id)&JEDI))
321 :     {
322 :     console_print(id,"[AMX] You have no access to that command")
323 :     return PLUGIN_CONTINUE
324 :     }
325 :     if (grabbed[id])
326 :     {
327 :     new parm[2]
328 :     parm[0] = id
329 :     parm[1] = 2
330 :     set_task(0.1, "disttask", 500+id, parm, 2, "b")
331 :     }
332 :     return PLUGIN_CONTINUE
333 :     }
334 :    
335 :     public stopdist(id)
336 :     {
337 :     if (!(get_user_flags(id)&JEDI))
338 :     {
339 :     console_print(id,"[AMX] You have no access to that command")
340 :     return PLUGIN_CONTINUE
341 :     }
342 :     if (grabbed[id])
343 :     {
344 :     remove_task(500+id)
345 :     }
346 :     return PLUGIN_CONTINUE
347 :     }
348 :    
349 :     public choke_func(id)
350 :     {
351 :     if (!(get_user_flags(id)&JEDI))
352 :     {
353 :     console_print(id,"[AMX] You have no access to that command")
354 :     return PLUGIN_CONTINUE
355 :     }
356 :     if (grabbed[id]>0 && grabbed[id]<33 && !task_exists(id+200))
357 :     {
358 :     new victim_name[33]
359 :     get_user_name(grabbed[id], victim_name, 32)
360 :     client_print(grabbed[id],print_chat,"*** You Are Being Choked By A Jedi !")
361 :     client_print(id,print_chat,"*** You Are Choking %s !", victim_name)
362 :     message_begin(MSG_ONE, get_user_msgid("ScreenShake") , {0,0,0}, grabbed[id])
363 :     write_short(1<<14)
364 :     write_short(1<<14)
365 :     write_short(1<<14)
366 :     message_end()
367 :     message_begin(MSG_ONE, get_user_msgid("ScreenFade") , {0,0,0}, grabbed[id])
368 :     write_short(1<<1) //total duration
369 :     write_short(1<<0) //time it stays one color
370 :     write_short(0<<1) //fade out, which means it goes away
371 :     write_byte(255) //red
372 :     write_byte(30) //green
373 :     write_byte(30) //blue
374 :     write_byte(180) //alpha, 255 means non-transparent
375 :     message_end()
376 :     new vec[3]
377 :     get_user_origin(grabbed[id],vec)
378 :     message_begin(MSG_ONE, get_user_msgid("Damage"), {0,0,0}, grabbed[id])
379 :     write_byte(30) // dmg_save
380 :     write_byte(30) // dmg_take
381 :     write_long(1<<0) // visibleDamageBits
382 :     write_coord(vec[0]) // damageOrigin.x
383 :     write_coord(vec[1]) // damageOrigin.y
384 :     write_coord(vec[2]) // damageOrigin.z
385 :     message_end()
386 :     new var[1],health
387 :     var[0]=id
388 :     set_task(1.0,"repeat_shake",id+200,var,1,"a",get_cvar_num("sv_choketime") )
389 :     emit_sound(grabbed[id],CHAN_BODY,"player/PL_PAIN2.WAV",1.0,ATTN_NORM,0, PITCH_NORM)
390 :     health=get_user_health(grabbed[id])
391 :     if(health>3)
392 :     set_user_health(grabbed[id],get_user_health(grabbed[id])-3)
393 :     }
394 :     return PLUGIN_CONTINUE
395 :     }
396 :    
397 :     public repeat_shake(var[])
398 :     {
399 :     new id=var[0]
400 :     if (grabbed[id]>0 && grabbed[id]<33)
401 :     {
402 :     message_begin(MSG_ONE, get_user_msgid("ScreenShake") , {0,0,0}, grabbed[id])
403 :     write_short(1<<14)
404 :     write_short(1<<14)
405 :     write_short(1<<14)
406 :     message_end()
407 :     message_begin(MSG_ONE, get_user_msgid("ScreenFade") , {0,0,0}, grabbed[id])
408 :     write_short(1<<1) //total duration
409 :     write_short(1<<0) //time it stays one color
410 :     write_short(0<<1) //fade out, which means it goes away
411 :     write_byte(255) //red
412 :     write_byte(30) //green
413 :     write_byte(30) //blue
414 :     write_byte(180) //alpha, 255 means non-transparent
415 :     message_end()
416 :     new vec[3]
417 :     get_user_origin(grabbed[id],vec)
418 :     message_begin(MSG_ONE, get_user_msgid("Damage"), {0,0,0}, grabbed[id])
419 :     write_byte(30) // dmg_save
420 :     write_byte(30) // dmg_take
421 :     write_long(1<<0) // visibleDamageBits
422 :     write_coord(vec[0]) // damageOrigin.x
423 :     write_coord(vec[1]) // damageOrigin.y
424 :     write_coord(vec[2]) // damageOrigin.z
425 :     message_end()
426 :     new health=get_user_health(grabbed[id])
427 :     if(health>3)
428 :     set_user_health(grabbed[id],get_user_health(grabbed[id])-3)
429 :     emit_sound(grabbed[id],CHAN_BODY,"player/PL_PAIN2.WAV",1.0,ATTN_NORM,0, PITCH_NORM)
430 :     }
431 :     else
432 :     {
433 :     if(task_exists(id+200))
434 :     remove_task(id+200)
435 :     }
436 :     return PLUGIN_CONTINUE
437 :     }
438 :    
439 :     //Forces them into your vision and grabs em.
440 :    
441 :     /*
442 :     *
443 :     * Right now still buggy as the grabee gets stuck into the wall or floor
444 :     *
445 :     */
446 :    
447 :     public force_grab(id){
448 :    
449 :     if (!(get_user_flags(id)&JEDI))
450 :     {
451 :     console_print(id,"[AMX] You have no access to that command")
452 :     return PLUGIN_CONTINUE
453 :     }
454 :     else
455 :     {
456 :     new arg[33], aimvec[3]
457 :     read_argv(1, arg, 32)
458 :    
459 :     new targetid = cmd_target(id, arg, 1)
460 :    
461 :     if (targetid < 1 || targetid > 32) return PLUGIN_CONTINUE
462 :    
463 :     get_user_origin(id,aimvec,3)
464 :     set_user_origin(targetid,aimvec)
465 :     grab(id)
466 :     // return PLUGIN_CONTINUE
467 :     }
468 :    
469 :     return PLUGIN_CONTINUE
470 :    
471 :     }
472 :    
473 :     public client_disconnect(id)
474 :     {
475 :    
476 :     if(grabbed[id] || grabmodeon[id])
477 :     {
478 :     release(id)
479 :     }
480 :    
481 :    
482 :     }
483 :    
484 :     public plugin_precache()
485 :     {
486 :     precache_sound("player/PL_PAIN2.WAV")
487 :     return PLUGIN_CONTINUE
488 :     }
489 :    
490 :     public plugin_init()
491 :     {
492 :     register_plugin("Jedi Force Grab","1.6.2","SpaceDude")
493 :     register_cvar("amx_jedigrab","1")
494 :     register_cvar("amx_jedigrab_playersonly","0")
495 :     register_cvar("sv_throwforce","1500")
496 :     register_cvar("sv_grabforce","8")
497 :     register_cvar("sv_choketime", "8")
498 :     register_cvar("sv_glowred","50")
499 :     register_cvar("sv_glowblue","0")
500 :     register_cvar("sv_glowgreen","0")
501 :     register_clcmd("grab_toggle","grab_toggle",JEDI,"press once to grab and again to release")
502 :     register_clcmd("+grab","grab",JEDI,"bind a key to +grab")
503 :     register_clcmd("-grab","release",JEDI)
504 :     register_clcmd("+pull","startpull",JEDI,"bind a key to +pull")
505 :     register_clcmd("-pull","stopdist",JEDI)
506 :     register_clcmd("+push","startpush",JEDI,"bind a key to +push")
507 :     register_clcmd("-push","stopdist",JEDI)
508 :     register_concmd("choke","choke_func",JEDI,"chokes the grabee")
509 :     register_concmd("throw","throw",JEDI,"throws the grabee")
510 :     register_event("StatusValue","spec_event","be","1=2")
511 :     }
512 :    

Contact
ViewVC Help
Powered by ViewVC 1.0.4