Server Help Forum Index Server Help
Community forums for Subgame, ASSS, and bots
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   StatisticsStatistics   RegisterRegister 
 ProfileProfile   Login to check your private messagesLogin to check your private messages   LoginLogin (SSL) 

Server Help | ASSS Wiki (0) | Shanky.com
Misc ASSS Questions
Goto page Previous  1, 2, 3, 4, 5, 6, 7, 8, 9, 10  Next
 
Post new topic   Reply to topic Printable version
 View previous topic  per-arena commands? Post :: Post ASSS Zone crashed after 120 days of be...  View next topic  
Author Message
Arnk Kilo Dylie
Seasoned Helper


Age:36
Gender:Gender:Male
Joined: Jul 14 2006
Posts: 108
Offline

PostPosted: Sat Jul 10, 2010 3:28 am    Post subject: Reply to topic Reply with quote

When you call EndFaked you should no longer be keeping the pointer anywhere.
Back to top
View users profile Send private message Add User to Ignore List Visit posters website
JoWie
Server Help Squatter


Gender:Gender:Male
Joined: Feb 25 2004
Posts: 215
Offline

PostPosted: Sat Jul 10, 2010 7:11 am    Post subject: Reply to topic Reply with quote

CB_NEWPLAYER is right after a player gets allocated and right before the freeing
Back to top
View users profile Send private message Add User to Ignore List
Cheese
Wow Cheese is so helpful!


Joined: Mar 18 2007
Posts: 1017
Offline

PostPosted: Sat Jul 10, 2010 4:32 pm    Post subject: Reply to topic Reply with quote

JoWie wrote:
CB_NEWPLAYER is right after a player gets allocated and right before the freeing


i should have looked in player.h first right? lol -_-
thanks


Arnk Kilo Dylie wrote:
When you call EndFaked you should no longer be keeping the pointer anywhere.


but what if its not me calling it? :P
_________________
SSC Distension Owner
SSCU Trench Wars Developer
Back to top
View users profile Send private message Add User to Ignore List Visit posters website AIM Address
JoWie
Server Help Squatter


Gender:Gender:Male
Joined: Feb 25 2004
Posts: 215
Offline

PostPosted: Mon Jul 12, 2010 7:16 pm    Post subject: Reply to topic Reply with quote

Personally, I almost always watch for CB_NEWPLAYER when creating or dealing with fake players. It feels less error prone and I like playing with ?killfake
Back to top
View users profile Send private message Add User to Ignore List
Cheese
Wow Cheese is so helpful!


Joined: Mar 18 2007
Posts: 1017
Offline

PostPosted: Sun Jan 02, 2011 2:06 am    Post subject: Reply to topic Reply with quote

so im trying to move a fake player
it has a speed and thrust, which if i recall is pixels per 10s.
however, when placed in the middle of a square it currently moves to a corner as fast as it moves to a side.

Code: Show/Hide

//dt=change in time
//tp=target pos
//md=fake pos
               while(dt)
               {
                  dt--;
                  int dx=tp->position.x - md->pos.x;
                  int dy=tp->position.y - md->pos.y;
                  
                  md->pos.xspeed+=(dx > md->thr) ? md->thr : dx;
                  md->pos.yspeed+=(dy > md->thr) ? md->thr : dy;
                  
                  if(md->pos.xspeed > md->spd) md->pos.xspeed=md->spd;
                  if(md->pos.xspeed < -md->spd) md->pos.xspeed=-md->spd;
                  if(md->pos.yspeed > md->spd) md->pos.yspeed=md->spd;
                  if(md->pos.yspeed < -md->spd) md->pos.yspeed=-md->spd;
                  
                  md->pos.x+=md->pos.xspeed;
                  md->pos.y+=md->pos.yspeed;
               }


i am pretty bad at math, and i think i might be needing sin and cos somewhere, because the speed/time locus should be a circle and not a square



edit:

im thinking its something close to this: -oldcode-

edit2:

but now i think i might have it:

Code: Show/Hide

                  if(dx == 0) dx++;
                  double dir=atan(dy/dx);
                  md->pos.xspeed+=md->thr*sin(dir);
                  md->pos.yspeed-=md->thr*cos(dir);
                  
                  int spd=sqrt(pow(md->pos.xspeed,2)+pow(md->pos.yspeed,2));
                  if(spd > md->spd)
                  {
                     int excess=spd-md->spd;
                     md->pos.xspeed-=excess*sin(dir);
                     md->pos.yspeed+=excess*cos(dir);
                  }


edit3:

but now it only moves up vertically :(
i think somethings wrong with atan?
Back to top
View users profile Send private message Add User to Ignore List Visit posters website AIM Address
Dr Brain
Flip-flopping like a wind surfer


Age:38
Gender:Gender:Male
Joined: Dec 01 2002
Posts: 3502
Location: Hyperspace
Offline

PostPosted: Sun Jan 02, 2011 8:05 am    Post subject: Reply to topic Reply with quote

That looks like an infinite loop. That can't be a good thing.

EDIT: look at atan2 if you're having trouble with atan.
_________________
Hyperspace Owner

Smong> so long as 99% deaths feel lame it will always be hyperspace to me
Back to top
View users profile Send private message Add User to Ignore List AIM Address Yahoo Messenger MSN Messenger
Cheese
Wow Cheese is so helpful!


Joined: Mar 18 2007
Posts: 1017
Offline

PostPosted: Sun Jan 02, 2011 11:08 am    Post subject: Reply to topic Reply with quote

having dir=atan(dy/dx); or dir=atan2(dy,dx); both produce the same strange result where the bot circles me at an odd radius, so its probably very close to being correct

i know this is the last line i need to fix but i am terrible at math and have no idea how to fix it


Last edited by Cheese on Sun Jan 02, 2011 11:42 am, edited 1 time in total
Back to top
View users profile Send private message Add User to Ignore List Visit posters website AIM Address
Dr Brain
Flip-flopping like a wind surfer


Age:38
Gender:Gender:Male
Joined: Dec 01 2002
Posts: 3502
Location: Hyperspace
Offline

PostPosted: Sun Jan 02, 2011 11:32 am    Post subject: Reply to topic Reply with quote

I'm rather unclear on what you're trying to accomplish.
Back to top
View users profile Send private message Add User to Ignore List AIM Address Yahoo Messenger MSN Messenger
Cheese
Wow Cheese is so helpful!


Joined: Mar 18 2007
Posts: 1017
Offline

PostPosted: Sun Jan 02, 2011 11:45 am    Post subject: Reply to topic Reply with quote

theres a fake player, and a target.
goal: fake player moves to target

so far:
Code: Show/Hide

      dt=TICK_DIFF(now,md->lastmove);
...
               while(dt)
               {
                  dt--;
                  int dx=tp->position.x - md->pos.x;
                  int dy=tp->position.y - md->pos.y;
                  
                  if(dx == 0) dx++;
                  double dir=atan(dy/dx); //<-----------------
                  md->pos.xspeed+=md->thr*sin(dir);
                  md->pos.yspeed-=md->thr*cos(dir);
                  
                  int spd=sqrt(pow(md->pos.xspeed,2)+pow(md->pos.yspeed,2));
                  if(spd > md->spd)
                  {
                     int excess=spd-md->spd;
                     md->pos.xspeed-=excess*sin(dir);
                     md->pos.yspeed+=excess*cos(dir);
                  }
                  
                  md->pos.x+=md->pos.xspeed;
                  md->pos.y+=md->pos.yspeed;
               }



with this, it is moving, but in strange ways

heres some detailed technical diagrams






pic.png - 3.87 KB
File downloaded or viewed 87 time(s)

trig.png - 7.25 KB
File downloaded or viewed 231 time(s)
Back to top
View users profile Send private message Add User to Ignore List Visit posters website AIM Address
Samapico
No, these DO NOT look like penises, ok?


Joined: May 08 2003
Posts: 1252
Offline

PostPosted: Sun Jan 02, 2011 12:54 pm    Post subject: Reply to topic Reply with quote

1) atan2 will work no matter in which quadrant the angle is (or if you prefer, no matter what's the sign of x and y)... i.e. if x is negative and y is positive, the angle output will be from pi/2 to pi. atan always returns an angle between -pi/2 and pi/2.
So you want to use atan2.

2)md->pos.xspeed+=md->thr*sin(dir);
md->pos.yspeed-=md->thr*cos(dir);

cos applies to x, and sin applies to y

3) just an optimization, but:
sqrt(pow(md->pos.xspeed,2)+pow(md->pos.yspeed,2))
should be
sqrt(md->pos.xspeed*md->pos.xspeed + md->pos.yspeed*md->pos.yspeed)
it's much more efficient

4) You can calculate the max speed in both x and y , instead of removing excess speed...
maxspeedx = <max ship speed> * cos(dir)
maxspeedy = <max ship speed> * sin(dir)

however... if the ship is going left, maxspeedx will be NEGATIVE, so you would need to check the absolute value to compare, probably...
_________________
(Insert a bunch of dead links here)
Back to top
View users profile Send private message Add User to Ignore List
Cheese
Wow Cheese is so helpful!


Joined: Mar 18 2007
Posts: 1017
Offline

PostPosted: Sun Jan 09, 2011 2:35 am    Post subject: Reply to topic Reply with quote

so now im trying to construct a system of bitwise flags

problem is i have no idea what im doing
this is what ive got so far:
Code: Show/Hide

#define STATE_A 1
#define STATE_B 2
#define STATE_C 4
#define STATE_D 8
int oldstate=0;
setflags(int newflags, BOOL value) //falue is true to add flags, false to remove
{
   if(!value) newflags=!newflags;
   if(!oldstate & state) oldstate+=state;
}


any ideas where i could look in the asss source to find a better idea?
Back to top
View users profile Send private message Add User to Ignore List Visit posters website AIM Address
Samapico
No, these DO NOT look like penises, ok?


Joined: May 08 2003
Posts: 1252
Offline

PostPosted: Sun Jan 09, 2011 3:39 am    Post subject: Reply to topic Reply with quote

hmmm

Code: Show/Hide

setflag(int oldflag, int newflag)
{
oldstate |= newflag;  //this is equivalent to: oldstate = oldsate|newflag;
}

clearflag(int oldflag, int newflag)
{
oldstate = oldstate & (~newflag);
}


i.e.

setflag(oldstate, STATE_A);
clearflag(oldstate, STATE_B);



OR


following the structure you have in your example:

Code: Show/Hide

setflags(int newflags, BOOL value) //falue is true to add flags, false to remove
{
   if(value)
          oldstate |= newflags; //or 'oldstate = (oldstate | newflags);'
   else
          oldstate = (oldstate & (~newflags));
}



And I suggest you define your flags in a typedef enum


Last edited by Samapico on Sun Jan 09, 2011 11:59 am, edited 1 time in total
Back to top
View users profile Send private message Add User to Ignore List
Dr Brain
Flip-flopping like a wind surfer


Age:38
Gender:Gender:Male
Joined: Dec 01 2002
Posts: 3502
Location: Hyperspace
Offline

PostPosted: Sun Jan 09, 2011 8:43 am    Post subject: Reply to topic Reply with quote

The "!" is a logical not, you want the "~" for bitwise not.

Set:
val |= flags;

Clear:
val &= ~flags;

I do this all the time for my work in embedded controllers. It's much more common to make two inline functions for set and clear than to make one function taking an option.
Back to top
View users profile Send private message Add User to Ignore List AIM Address Yahoo Messenger MSN Messenger
Samapico
No, these DO NOT look like penises, ok?


Joined: May 08 2003
Posts: 1252
Offline

PostPosted: Sun Jan 09, 2011 12:00 pm    Post subject: Reply to topic Reply with quote

Dr Brain wrote:
The "!" is a logical not, you want the "~" for bitwise not.
Oops, you're right... edited post to avoid confusion.
Back to top
View users profile Send private message Add User to Ignore List
Cheese
Wow Cheese is so helpful!


Joined: Mar 18 2007
Posts: 1017
Offline

PostPosted: Sun Jan 09, 2011 2:27 pm    Post subject: Reply to topic Reply with quote

yay i was getting close :D


also, it looks like it will be able to do sending it a combination of flags added together?
or should they be &'d together?


Samapico wrote:
And I suggest you define your flags in a typedef enum


why?
Back to top
View users profile Send private message Add User to Ignore List Visit posters website AIM Address
Dr Brain
Flip-flopping like a wind surfer


Age:38
Gender:Gender:Male
Joined: Dec 01 2002
Posts: 3502
Location: Hyperspace
Offline

PostPosted: Sun Jan 09, 2011 3:11 pm    Post subject: Reply to topic Reply with quote

Don't use + or &. You want |.

As far as I'm aware, an enum has no advantages over a define for flags and masks.


Last edited by Dr Brain on Sun Jan 09, 2011 3:13 pm, edited 1 time in total
Back to top
View users profile Send private message Add User to Ignore List AIM Address Yahoo Messenger MSN Messenger
Samapico
No, these DO NOT look like penises, ok?


Joined: May 08 2003
Posts: 1252
Offline

PostPosted: Sun Jan 09, 2011 3:11 pm    Post subject: Reply to topic Reply with quote

Well it depends on how you use them I guess, but you could have functions that take a 'somethingFlag' as an argument, or variables of type 'somethingFlag', which is more explicit than 'int'. Much like using BOOL is clearer than using ints, even though they're the same thing.


And you can set multiple flags at once if you call like: set(flag1 | flag2)
Or clear multiple flags the same way: clear(flag1 | flag2)
Back to top
View users profile Send private message Add User to Ignore List
Cheese
Wow Cheese is so helpful!


Joined: Mar 18 2007
Posts: 1017
Offline

PostPosted: Sun Jan 09, 2011 3:28 pm    Post subject: Reply to topic Reply with quote

and this agrees with sama:

http://www.cprogramming.com/tutorial/enum.html
Back to top
View users profile Send private message Add User to Ignore List Visit posters website AIM Address
Dr Brain
Flip-flopping like a wind surfer


Age:38
Gender:Gender:Male
Joined: Dec 01 2002
Posts: 3502
Location: Hyperspace
Offline

PostPosted: Sun Jan 09, 2011 7:16 pm    Post subject: Reply to topic Reply with quote

You'll note that it says it doesn't help in C.

It doesn't hurt you, but like I said, there's no advantage.
Back to top
View users profile Send private message Add User to Ignore List AIM Address Yahoo Messenger MSN Messenger
Cheese
Wow Cheese is so helpful!


Joined: Mar 18 2007
Posts: 1017
Offline

PostPosted: Sun Jan 09, 2011 7:17 pm    Post subject: Reply to topic Reply with quote

meh i guess its just good practice anyways :<
Back to top
View users profile Send private message Add User to Ignore List Visit posters website AIM Address
Arnk Kilo Dylie
Seasoned Helper


Age:36
Gender:Gender:Male
Joined: Jul 14 2006
Posts: 108
Offline

PostPosted: Tue Jan 11, 2011 2:01 pm    Post subject: Reply to topic Reply with quote

Using enums in function declarations instead of ints tends to make certain python integration things more headachy ;)

Of course that never stopped me.
Back to top
View users profile Send private message Add User to Ignore List Visit posters website
Cheese
Wow Cheese is so helpful!


Joined: Mar 18 2007
Posts: 1017
Offline

PostPosted: Fri Jan 14, 2011 3:22 am    Post subject: Reply to topic Reply with quote

what might cause this?





scrn.png - 169.01 KB
File downloaded or viewed 167 time(s)
Back to top
View users profile Send private message Add User to Ignore List Visit posters website AIM Address
Dr Brain
Flip-flopping like a wind surfer


Age:38
Gender:Gender:Male
Joined: Dec 01 2002
Posts: 3502
Location: Hyperspace
Offline

PostPosted: Fri Jan 14, 2011 7:01 am    Post subject: Reply to topic Reply with quote

Posting all of your topics in a single thread.

Did you try recovering the database?
Back to top
View users profile Send private message Add User to Ignore List AIM Address Yahoo Messenger MSN Messenger
Cheese
Wow Cheese is so helpful!


Joined: Mar 18 2007
Posts: 1017
Offline

PostPosted: Fri Jan 14, 2011 9:10 pm    Post subject: Reply to topic Reply with quote

how would i do that

it seems i am forced to do this, because now the module wont load
and i dont want to disable persist


been poking at this dbtool.exe
not seeing anything
Back to top
View users profile Send private message Add User to Ignore List Visit posters website AIM Address
Samapico
No, these DO NOT look like penises, ok?


Joined: May 08 2003
Posts: 1252
Offline

PostPosted: Sat Jan 15, 2011 12:21 am    Post subject: Reply to topic Reply with quote

That green/black theme suggests you know how to get things done.



And if you don't, hack in from a public telephone.
Back to top
View users profile Send private message Add User to Ignore List
Display posts from previous:   
Post new topic   Reply to topic    Server Help Forum Index -> ASSS Questions All times are GMT - 5 Hours
Goto page Previous  1, 2, 3, 4, 5, 6, 7, 8, 9, 10  Next
Page 6 of 10

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum
View online users | View Statistics | View Ignored List


Software by php BB © php BB Group
Server Load: 675 page(s) served in previous 5 minutes.

phpBB Created this page in 0.508269 seconds : 52 queries executed (89.7%): GZIP compression disabled