Raised This Month: $ Target: $400
 0% 

Creating env_beam problem


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
hlstriker
Green Gaben
Join Date: Mar 2006
Location: OH-IO!
Old 07-27-2009 , 16:27   Creating env_beam problem
Reply With Quote #1

I'm trying to create an env_beam just like you would when making one in hammer editor. Using 3 ents - the start point, end point, and beam ent.

I've tried so many different things using both fakemeta and engine to get this working.

If you run the following code you will see it makes both end points and the beam sprite, but the beam sprite doesn't connect to the points (note: I made the end points a sprite just so I could see them).

PHP Code:
#include <amxmodx>
#include <fakemeta>

#define PLUGIN    "Create env_beam"
#define VERSION    "1.0"
#define AUTHOR    "hlstriker"

#define BEAM_SPRITE "sprites/laserbeam.spr"

public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR);
    
register_clcmd("say /beam""CreateBeamEnts");
}

public 
plugin_precache()
{
    
precache_model(BEAM_SPRITE);
}

public 
CreateBeamEnts(iClient)
{
    
CreateEntStart(iClient);
    
CreateEntEnd(iClient);
    
set_task(0.5"CreateBeam"iClient);
}

CreateEntStart(iClient)
{
    new 
Float:flOrigin[3];
    
GetFrontOrigin(iClient50flOrigin);
    
    new 
iEnt engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"info_target"));
    
set_keyvalue(iEnt"targetname""startbeam");
    
dllfunc(DLLFunc_SpawniEnt);
    
dllfunc(DLLFunc_ThinkiEnt);
    
set_pev(iEntpev_solidSOLID_BBOX);
    
//set_pev(iEnt, pev_targetname, "startbeam");
    
engfunc(EngFunc_SetOriginiEntflOrigin);
    
engfunc(EngFunc_SetModeliEntBEAM_SPRITE);
    
engfunc(EngFunc_SetSizeiEntFloat:{-4.0, -4.00.0}, Float:{4.04.08.0});
    
    
client_print(0print_chat"START: [%f] - [%f] - [%f]"flOrigin[0], flOrigin[1], flOrigin[2]);
}

CreateEntEnd(iClient)
{
    new 
Float:flOrigin[3];
    
GetFrontOrigin(iClient300flOrigin);
    
    new 
iEnt engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"info_target"));
    
set_keyvalue(iEnt"targetname""endbeam");
    
dllfunc(DLLFunc_SpawniEnt);
    
dllfunc(DLLFunc_ThinkiEnt);
    
set_pev(iEntpev_solidSOLID_BBOX);
    
//set_pev(iEnt, pev_targetname, "endbeam");
    
engfunc(EngFunc_SetOriginiEntflOrigin);
    
engfunc(EngFunc_SetModeliEntBEAM_SPRITE);
    
engfunc(EngFunc_SetSizeiEntFloat:{-4.0, -4.00.0}, Float:{4.04.08.0});
    
    
client_print(0print_chat"END: [%f] - [%f] - [%f]"flOrigin[0], flOrigin[1], flOrigin[2]);
}

public 
CreateBeam(iClient)
{
    new 
Float:flOrigin[3];
    
GetFrontOrigin(iClient150flOrigin);
    
    new 
iEnt engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"env_beam"));
    
set_keyvalue(iEnt"Radius""256");
    
set_keyvalue(iEnt"StrikeTime""10");
    
set_keyvalue(iEnt"TextureScroll""100");
    
set_keyvalue(iEnt"texture"BEAM_SPRITE);
    
set_keyvalue(iEnt"BoltWidth""8");
    
set_keyvalue(iEnt"rendermode""5");
    
set_keyvalue(iEnt"rendercolor""255 0 0");
    
set_keyvalue(iEnt"renderamt""125");
    
set_keyvalue(iEnt"LightningEnd""endbeam");
    
set_keyvalue(iEnt"LightningStart""startbeam");
    
set_keyvalue(iEnt"spawnflags""1");
    
//set_keyvalue(iEnt, "classname", "env_beam");
    
dllfunc(DLLFunc_SpawniEnt);
    
dllfunc(DLLFunc_ThinkiEnt);
    
set_pev(iEntpev_solidSOLID_BBOX);
    
engfunc(EngFunc_SetOriginiEntflOrigin);
    
engfunc(EngFunc_SetModeliEntBEAM_SPRITE);
    
engfunc(EngFunc_SetSizeiEntFloat:{-4.0, -4.00.0}, Float:{4.04.08.0});
    
    
client_print(0print_chat"BEAM: [%f] - [%f] - [%f]"flOrigin[0], flOrigin[1], flOrigin[2]);
}

stock GetFrontOrigin(iEntiDistanceFloat:flReturnOrigin[3])
{
    static 
Float:flOrigin[3], Float:flAngles[3];
    
pev(iEntpev_originflOrigin);
    
pev(iEntpev_v_angleflAngles);
    
flAngles[0] = 0.0;
    
    
angle_vector(flAnglesANGLEVECTOR_FORWARDflReturnOrigin);
    
flReturnOrigin[0] = flOrigin[0] + flReturnOrigin[0] * iDistance;
    
flReturnOrigin[1] = flOrigin[1] + flReturnOrigin[1] * iDistance;
    
flReturnOrigin[2] = flOrigin[2];
}

stock set_keyvalue(iEntszKey[], szValue[])
{
    new 
szClassname[32];
    
pev(iEntpev_classnameszClassnamesizeof(szClassname)-1);
    
set_kvd(0KV_ClassNameszClassname);
    
set_kvd(0KV_KeyNameszKey);
    
set_kvd(0KV_ValueszValue);
    
set_kvd(0KV_fHandled0);
    
    
dllfunc(DLLFunc_KeyValueiEnt0);

Here is a screen shot of what that produces:
[img]http://img190.**************/img190/7384/beamk.jpg[/img]

Here is what I want it to produce:
[img]http://img212.**************/img212/2069/goodbeam.jpg[/img]

Anyone have any ideas how to make this?
hlstriker is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 07-27-2009 , 16:38   Re: Creating env_beam problem
Reply With Quote #2

This could help you : http://svn.alliedmods.net/viewvc.cgi...p&root=amxmodx
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 07-27-2009 , 16:45   Re: Creating env_beam problem
Reply With Quote #3

Let me search few minutes, I have what you want somewhere in my computer.
__________________
Arkshine is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 07-27-2009 , 17:38   Re: Creating env_beam problem
Reply With Quote #4

Here. You just need, FX_BeamPoints() and UTIL_RelinkBeam(). Life is infinite, it means you need to execute just one time the code. To remove the beam, just kill the beam. Since you will probably check if someone passes the beam, I would suggest to add a check if the beam (entity) is still then the redraw it, because on specific situations the beam could be removed. Btw, "beam" is not the same as "env_beam". "beam" is more a simplified version of env_beam but allowing to use different type of beam : Point -> Point, Point -> Entity, Entity -> Entity, Point -> Direction and there are no spawn flags. "env_beam" seems to be only between entity name, with more options and spawn flags. In your case you should use "beam". If you want to use "env_beam" and the provided options, you would need to create 2 entities like "info_target", setting the right origin and targetname.
Attached Files
File Type: sma Get Plugin or Get Source (test_beam.sma - 800 views - 3.5 KB)
__________________

Last edited by Arkshine; 07-27-2009 at 18:08.
Arkshine is offline
hlstriker
Green Gaben
Join Date: Mar 2006
Location: OH-IO!
Old 07-27-2009 , 18:14   Re: Creating env_beam problem
Reply With Quote #5

Alright thanks a lot both Arkshine and Connor

I never knew entity "beam" even existed, maybe I should look around the hl1 source more ;)
hlstriker is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 18:24.


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