Server Help

ASSS Questions - ?centerball (python)

BDwinsAlt - Tue Jul 25, 2006 12:50 pm
Post subject: ?centerball (python)
I've searched high and low. I played with this all day. I now would like to try some help. I have a full Dodgeball module done. Everything works perfectly. When you enter the arena the ball spawns in the correct spot and all. The only issue is, what if you want to play dodgeball again without recreating the arena? I want to be able to put the ball back to its orginal spawnx and spawny coords. How can I do this? This would be sending the ball back to 512 512 when someone types ?centerball in python.

Again everything else is functional and fine. I just need to be able to center the ball on command. Thanks.
xsp0rtsfanx - Tue Jul 25, 2006 12:59 pm
Post subject:
I think you'd use MoveBall or something like that.
BDwinsAlt - Tue Jul 25, 2006 2:01 pm
Post subject:
http://asss.yi.org/asss/files/userguide.html
That only works with flags (?moveflags)

Can someone help me please.
i88gerbils - Tue Jul 25, 2006 4:04 pm
Post subject:
I don't know much about the soccer code in asss, but I found this in balls.h:

Code: Show/Hide

        void (*PlaceBall)(Arena *arena, int bid, struct BallData *newpos);
        /* sets the parameters of the ball to those in the given BallData
         * struct */
        /* pyint: arena, int, balldata -> void */


It looks like that may work by looking at the code in balls.c.

There's also an EndGame function, but no StartGame though I've only taken 5 minutes to look into this.
BDwinsAlt - Tue Jul 25, 2006 4:56 pm
Post subject:
I saw that too :\
I have the arena and ballid set. Just the last bit that is troubling me. newpos...
i88gerbils - Tue Jul 25, 2006 6:26 pm
Post subject:
newpos is the variable name for the BallData struct. It looks like you can access that in python though ArenaBallData seems safer.

Code: Show/Hide

struct BallData
{
        /* pytype: struct, struct BallData, balldata */
        int state; /* the state of this ball */
        int x, y, xspeed, yspeed; /* the coordinates of the ball */
        Player *carrier; /* the player that is carrying or last touched the ball */
        int freq; /* freq of carrier */
        ticks_t time; /* the time that the ball was last fired (will be 0 for
                       * balls being held). for BALL_WAITING, this time is the
                       * time when the ball will be re-spawned. */
};

BDwinsAlt - Tue Jul 25, 2006 7:54 pm
Post subject:
Yea I tried that too. It will let me use ball.PlaceBall but not BallData or anything like that. I've tried this all day so yea. I've looked at all of that. Thanks though.

Edit: Fixed thanks to smong.
Smong - Wed Jul 26, 2006 7:41 pm
Post subject:
Here's the solution incase anyone else is looking for it.
Code: Show/Hide
from asss import *

balls = get_interface(I_BALLS)

def mm_attach(a):
   bd = balldata()
   bd.state = BALL_ONMAP
   bd.x = bd.y = 512 * 16
   bd.xspeed = bd.yspeed= 0
   bd.carrier = None
   bd.freq = -1
   bd.time = current_ticks()
   balls.PlaceBall(a, 0, bd)

def mm_detach(a):
   pass

All times are -5 GMT
View topic
Powered by phpBB 2.0 .0.11 © 2001 phpBB Group