AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Help with some phy emulation (https://forums.alliedmods.net/showthread.php?t=156452)

Nightfall1 05-06-2011 16:18

Help with some phy emulation
 
PHP Code:

new const classes[][] = { "weaponbox""item_thighpack""weapon_shield""grenade"}
 
public 
plugin_init()
{
 for (new 
xsizeof classesx++)
  
RegisterHam(Ham_Touchclasses[x], "touch_test")
}
 
public 
touch_test(enttouched)
{
 new 
owner pev(entpev_owner)
 if (!
pev_valid(ent)) return HAM_IGNORED
 
if ((touched != owner) && (touched <= 33 && touched != 0))
 {
  
set_pev(entpev_ownertouched)
  if(
pev(entpev_flags) & FL_ONGROUND)
  {
   
set_pev(entpev_owner0)
   return 
HAM_IGNORED
  
}
 
  static 
Float:oent[3], Float:otou[3], Float:oaim[3], velnew
  pev
(entpev_originoent)
  
pev(entpev_originotou)
  
fm_get_aim_origin(entoaim)
  if(
oaim[1] == otou[1] && oaim[2] == otou[2])
   
velnew random_num(-150, -50)
  else
   
velnew random_num(50150)
 
  
pev(entpev_velocityset_peventpev_velocityvel_by_aimownervelnew ) ))
 }
}
 
stock Float:vel_by_aimidspeed )
{
 new 
Float:v1[3], Float:vBlah[3]
 
pevidpev_anglev1 )
 
engfuncEngFunc_AngleVectorsv1v1vBlahvBlah )
 
 
v1[0] *= speed
 v1
[1] *= speed
 v1
[2] *= speed
 
 
return v1
}
 
// ported from AMXX's core get_user_origin(..., 3) (suggested by Greenberet)
stock fm_get_aim_origin(indexFloat:origin[3]) {
 new 
Float:start[3], Float:view_ofs[3];
 
pev(indexpev_originstart);
 
pev(indexpev_view_ofsview_ofs);
 
xs_vec_add(startview_ofsstart);
 
 new 
Float:dest[3];
 
pev(indexpev_v_angledest);
 
engfunc(EngFunc_MakeVectorsdest);
 
global_get(glb_v_forwarddest);
 
xs_vec_mul_scalar(dest9999.0dest);
 
xs_vec_add(startdestdest);
 
 
engfunc(EngFunc_TraceLinestartdest0index0);
 
get_tr2(0TR_vecEndPosorigin);
 
 return 
1;


Explication: drop weapon will reflect/return from him to look down \/

http://i.imgur.com/PwdLc.jpg


.gif at attackment

http://highcs.ro/bogdyutzu/thebogdyhitgifr.gif

http://highcs.ro/bogdyutzu/thebogdyhitgif.gif

who I can do to look more realistic because my velocity by aim is not quite well

SonicSonedit 05-06-2011 16:55

Re: Help with some phy emulation
 
Why do you create custom entity in the first place? My CSO weapons work fine by using regular weaponbox entities.

Nightfall1 05-07-2011 03:43

Re: Help with some phy emulation
 
please ignore the skin is regular weaponbox entities, i want to reflect a weapon from body but i don't want to use vel_by_aim because is not a good choise

SonicSonedit 05-07-2011 11:07

Re: Help with some phy emulation
 
Nightfall1
You don't like regular weaponboxes behavior? What exactly do you want to change?

P.S.
Can you change the images to clickable preview please?

Nightfall1 05-07-2011 12:04

Re: Help with some phy emulation
 
OK !!! Simple reflect weapon from playerbody / weapon rebounds / the weapon is repulsive / weapon is reflected / touches playerid turns back
but I Don't Want to Turn FROM MY AIM, I change a litel byte code see up after I edit

SonicSonedit 05-07-2011 13:14

Re: Help with some phy emulation
 
Nightfall1
Quote:

weapon from playerbody / weapon rebounds / the weapon is repulsive / weapon is reflected / touches playerid turns back
You don't need to calculate anyone's aim. Use weapon velocity to calcalute reflection angle and then use this angle to set aiment.

Nightfall1 05-07-2011 14:48

Re: Help with some phy emulation
 
Quote:

Originally Posted by SonicSonedit (Post 1465102)
Nightfall1
You don't need to calculate anyone's aim. Use weapon velocity to calcalute reflection angle and then use this angle to set aiment.

NO but I want this
http://cdn3.droidmill.com/media/mark...three_icon.png
__.\/.__


PHP Code:

if (touched != owner && touched <= 33 && touched != )
 {
  
set_pev(entpev_ownertouched)
 
  static 
Float:velnew[3]
  
pev(entpev_velocityvelnew)
  
xs_vec_mul_scalar(velnew, -0.4velnew)
 
  
set_pev(entpev_velocityvelnew)
 } 

and I need to protect if 2 player touch the weapon wath is not on ground because is can't reflect and it drop slow
something like if(is_2_player_touched) return HAM_IGNORED

SonicSonedit 05-07-2011 15:10

Re: Help with some phy emulation
 
It's hard to understand you.
To check if player is on gorund, check
PHP Code:

if (pev(idpev_flags)&FL_ONGROUND


Nightfall1 05-07-2011 15:21

Re: Help with some phy emulation
 
don't try to understand from my try from code, I don't need to check if is on ground I need to check if is 2 of player touch the classes if is true the plugin will stop if is false will continue what is down
sorry because I don't speak very fluent(good) english
the point is if 2 player is touch the weapon that is in classes the plugin will not execute what is below(will return HAM_IGNORED)
simple or I need to write a book of you?


All times are GMT -4. The time now is 04:30.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.