Raised This Month: $ Target: $400
 0% 

Setting Angles and Origins.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Drak
Veteran Member
Join Date: Jul 2005
Old 02-04-2007 , 04:14   Setting Angles and Origins.
Reply With Quote #1

I'm trying to rotate the entities all around a selected player.

Code:
public npc_rotate(ent,player) {     new Float:entorigin[3],i,Float:playerorigin[3]     pev(ent,pev_origin,entorigin)     pev(player,pev_origin,playerorigin)     origin[0] += 30     origin[1] += 10     origin[2] += 0     for(i=0;i<3;i++) {         playerorigin[i] += origin[i]         set_pev(ent,pev_origin,playerorigin)         //console_print(0,"[POWER NPC] For called")     }     fm_drop_to_floor(ent)         return PLUGIN_HANDLED }
The ents directly line up to a right angle of the player. Now, what I want todo is to somehow set the angles of each ent, so it completes a circle.

Here's what I have.
[IMG]http://img267.**************/img267/3995/whatun1.jpg[/IMG]
The ents line up.

Here's what I'm trying to achieve.
[IMG]http://img47.**************/img47/5585/360wq0.jpg[/IMG]
(The images probably weren't needed, but I wanted to make sure I made sense)

I would assume this would have todo alot with the ents angles. But how to get them at the right angel, I have no idea. Anyone know anything that might be able to get them correctly angled?
Drak is offline
Send a message via MSN to Drak
jim_yang
Veteran Member
Join Date: Aug 2006
Old 02-04-2007 , 06:03   Re: Setting Angles and Origins.
Reply With Quote #2

are you sure your code works? i see you just set the origin of the same ent three times.
__________________
Project : CSDM all in one - 99%
<team balancer#no round end#entity remover#quake sounds#fake full#maps management menu#players punishment menu#no team flash#colored flashbang#grenade trails#HE effect#spawn protection#weapon arena#weapon upgrade#auto join#no weapon drop#one name>
jim_yang is offline
Drak
Veteran Member
Join Date: Jul 2005
Old 02-04-2007 , 17:28   Re: Setting Angles and Origins.
Reply With Quote #3

Quote:
Originally Posted by jim_yang View Post
are you sure your code works? i see you just set the origin of the same ent three times.
I should of shown part of the full code:
Code:
#include <amxmodx> #include <amxmisc> #include <engine> #include <fakemeta> new g_origin[3] new const validents[4][256] = {     "monster_zombie",     "monster_scientist",     "monster_barney",     "monster_sentry" } public plugin_init() {     register_plugin("Circle Test","1.0","")     register_concmd("amx_circle","find_ent2") } public find_ent2(id) {         new random_player = random_num(1,get_playersnum()) //Apprently this always doesn't return true player indexs     if(is_user_connected(random_player) && is_user_alive(random_player))     {         new Float:origin[3],classname[32],ent,i         pev(random_player,pev_origin,origin)         while((ent = engfunc(EngFunc_FindEntityInSphere,ent,origin,10000.0)) != 0 ) {             for(i=0;i<sizeof(validents);i++) {                 pev(ent, pev_classname, classname, 31)                 if(equali(classname,"monster_sentry")) {                     npc_rotate(ent,random_player)                     break;                 }             }         }     }     return PLUGIN_HANDLED }                     public npc_rotate(ent,player) {         new Float:entorigin[3],Float:playerorigin[3],i     pev(ent,pev_origin,entorigin)     pev(player,pev_origin,playerorigin)     g_origin[0] += 30     g_origin[1] += 10     g_origin[2] += 0     for(i=0;i<3;i++) {         playerorigin[i] += g_origin[i]         set_pev(ent,pev_origin,playerorigin)         console_print(0,"[POWER NPC] For called")     }     return PLUGIN_HANDLED }
But yes, tested it and works fine.

@lunarwolfx
There's a total of six monsters (Sentrys) around the player, it's always the same amount, and always in the same place. It's simply suppose to place itself around the player, and spin around the player untill his/her death.
Drak is offline
Send a message via MSN to Drak
lunarwolfx
Member
Join Date: Feb 2005
Old 02-04-2007 , 14:05   Re: Setting Angles and Origins.
Reply With Quote #4

well, you might want to explain the radius of the circle, and then how many ents you want to circle around the player.

Does it need to follow the player?

and does it need be circling the player?
lunarwolfx is offline
lunarwolfx
Member
Join Date: Feb 2005
Old 02-04-2007 , 18:44   Re: Setting Angles and Origins.
Reply With Quote #5

okay you say it stays in the same place, yet you say it spins around the player until the players death. So are the monsters stuck in the same place they're spawned, or do they follow and circle the player?

If it's the latter option, then it's not as simple to do, but I'll try to do the math and figure it out, but what's the radius you want the circle to be?
lunarwolfx is offline
Drak
Veteran Member
Join Date: Jul 2005
Old 02-04-2007 , 18:54   Re: Setting Angles and Origins.
Reply With Quote #6

Quote:
Originally Posted by lunarwolfx View Post
okay you say it stays in the same place, yet you say it spins around the player until the players death. So are the monsters stuck in the same place they're spawned, or do they follow and circle the player?

If it's the latter option, then it's not as simple to do, but I'll try to do the math and figure it out, but what's the radius you want the circle to be?
They are a stationary monster, they spawn in the same place, and don't move. (It's a HL1 monster, not a made AMXX entity)
But I would like to have them rotate around the player after they join around in a circle.
Also, the radius of the circle is 1000 HL1 Units (I have no idea what units HL1 measures in)

Last edited by Drak; 02-04-2007 at 18:57.
Drak is offline
Send a message via MSN to Drak
lunarwolfx
Member
Join Date: Feb 2005
Old 02-04-2007 , 19:24   Re: Setting Angles and Origins.
Reply With Quote #7

Well that totally complicates things even more.

If that's the case, you'll have to hook FM_Think, and flag when the sentries need to form a circle, and work the math to have them rotate around the player. If you're going to have them walking to form the circle, then I would suggest you take a look at p3tsins civilian npc plugin for references.
lunarwolfx is offline
Drak
Veteran Member
Join Date: Jul 2005
Old 02-04-2007 , 19:32   Re: Setting Angles and Origins.
Reply With Quote #8

Quote:
Originally Posted by lunarwolfx View Post
Well that totally complicates things even more.

If that's the case, you'll have to hook FM_Think, and flag when the sentries need to form a circle, and work the math to have them rotate around the player. If you're going to have them walking to form the circle, then I would suggest you take a look at p3tsins civilian npc plugin for references.
They don't need to walk, even know they can't ;) (http://www.thewall.de/content/media/...ies/sentry.png)
And the rotating around the player was just a little extra, wasn't really needed. Mainly I was just trying to figure out how to make there origin shifting off on an angle.
Drak is offline
Send a message via MSN to Drak
lunarwolfx
Member
Join Date: Feb 2005
Old 02-04-2007 , 20:31   Re: Setting Angles and Origins.
Reply With Quote #9

well I'm still not sure what you're trying to do, but if you want the sentries to form a circle around the player, then this might help

Basically focus on npc_circle.

Code:
#include <amxmodx> #include <fakemeta> public plugin_init() {     register_plugin("test","0", "noone")         register_clcmd("say /some_entity", "test");     } public test(id) {         some_entity(id,6);     } public some_entity(id,numofents) {         for(new i = 1; i <= numofents; i++) {                 new Float:radius = 50.0, Float:angle = float(i * 360/numofents);                                     new ent = engfunc(EngFunc_CreateNamedEntity,engfunc(EngFunc_AllocString, "info_target"));                                         npc_circle(id,ent,radius,angle);             engfunc(EngFunc_SetModel,ent,"models/player.mdl");     }         } public npc_circle(id,ent,Float:radius, Float:angle) {         new Float:offset[3],Float:origin[3];         offset[0] = radius * floatcos(angle,degrees);     offset[1] = radius * floatsin(angle,degrees);         get_offset_origin(id,offset,origin);         set_pev(ent,pev_origin,origin);         return 1; } //This is taken from chr_engine.inc, which I highly recommend people to use stock get_offset_origin(ent,const Float:offset[3],Float:origin[3]) {     if(!pev_valid(ent))         return 0;         new Float:angle[3]     pev(ent,pev_origin,origin)     pev(ent,pev_angles,angle)         origin[0] += floatcos(angle[1],degrees) * offset[0]     origin[1] += floatsin(angle[1],degrees) * offset[0]         origin[2] += floatsin(angle[0],degrees) * offset[0]     origin[0] += floatcos(angle[0],degrees) * offset[0]         origin[1] += floatcos(angle[1],degrees) * offset[1]     origin[0] -= floatsin(angle[1],degrees) * offset[1]         origin[2] += floatsin(angle[2],degrees) * offset[1]     origin[1] += floatcos(angle[2],degrees) * offset[1]         origin[2] += floatcos(angle[2],degrees) * offset[2]     origin[1] -= floatsin(angle[2],degrees) * offset[2]         origin[2] += floatcos(angle[0],degrees) * offset[2]     origin[0] -= floatsin(angle[0],degrees) * offset[2]         origin[0] -= offset[0]     origin[1] -= offset[1]     origin[2] -= offset[2]         return 1; }

I tried it ingame, and it seems to work.
lunarwolfx is offline
Drak
Veteran Member
Join Date: Jul 2005
Old 02-04-2007 , 21:32   Re: Setting Angles and Origins.
Reply With Quote #10

That's exactly it! Thank you much.
Drak is offline
Send a message via MSN to Drak
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 00:37.


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