AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Setting Angles and Origins. (https://forums.alliedmods.net/showthread.php?t=50806)

Drak 02-04-2007 04:14

Setting Angles and Origins.
 
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?

jim_yang 02-04-2007 06:03

Re: Setting Angles and Origins.
 
are you sure your code works? i see you just set the origin of the same ent three times.

lunarwolfx 02-04-2007 14:05

Re: Setting Angles and Origins.
 
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?

Drak 02-04-2007 17:28

Re: Setting Angles and Origins.
 
Quote:

Originally Posted by jim_yang (Post 435216)
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.

lunarwolfx 02-04-2007 18:44

Re: Setting Angles and Origins.
 
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?

Drak 02-04-2007 18:54

Re: Setting Angles and Origins.
 
Quote:

Originally Posted by lunarwolfx (Post 435429)
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)

lunarwolfx 02-04-2007 19:24

Re: Setting Angles and Origins.
 
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.

Drak 02-04-2007 19:32

Re: Setting Angles and Origins.
 
Quote:

Originally Posted by lunarwolfx (Post 435441)
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.

lunarwolfx 02-04-2007 20:31

Re: Setting Angles and Origins.
 
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.

Drak 02-04-2007 21:32

Re: Setting Angles and Origins.
 
That's exactly it! Thank you much.


All times are GMT -4. The time now is 00:38.

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