Why is your target p.arena and not just p?
xsp0rtsfanx - Sun Apr 15, 2007 8:03 pm
Post subject:
i figured it out.. and if its not p.arena i get an error. Now i have another question. I have placeball in my code.. and when i use one command to start the game i warp the players and then the ball is placed. the error i get is "TypeError: arg is not a 'balldata' "
tcsoccerman - Sun Apr 15, 2007 8:07 pm
Post subject:
one of the arguements is not part of balldata, which i'm guessing means there is not the right number of arguements, or not the right variable/arguement
xsp0rtsfanx - Sun Apr 15, 2007 8:17 pm
Post subject:
balls.PlaceBall(arena, 512, 512) |
thats the code. I had it at p.arena and removed arena. neither worked.
BDwinsAlt - Sun Apr 15, 2007 11:22 pm
Post subject:
Does this help?
def c_centerball(cmd, params, p, targ):
bd = balldata()
bd.state = BALL_ONMAP
bd.x = bd.y = 8200
bd.xspeed = bd.yspeed = 0
bd.carrier = None
bd.time = current_ticks()
ball.PlaceBall(p.arena, 0, bd)
chat.SendMessage(p, "Ball centered.")
|
xsp0rtsfanx - Sun Apr 15, 2007 11:28 pm
Post subject:
so use that for where i wanna put it? like if i have it put to 3 different spots i just run back to that same definition to get there? also i'm getting door errors on one command.. it says cfg is not a valid thing. its cfg.SetInt(stuff in here) and cfg = get_interface(I_CONFIG) up top right..?
i dont wanna make it a command.. i want to place the ball after a certain team scores a point to a certain location and another when the other scores
Animate Dreams - Mon Apr 16, 2007 1:53 am
Post subject:
If you're still trying to warp entire frequencies, let me show you how I do it in C:
pd->Lock(); // Lock, necessary when cycling through players
FOR_EACH_PLAYER_P(tempPlayer, zData, playerKey) // Cycles through each player, I use this to set playerdata and warp.
{
zData->died = FALSE;
if (tempPlayer->p_freq == 0) // If human...
{
t.u.p = tempPlayer;
game->WarpTo (&t, eData->humanSpawnX, eData->humanSpawnY); // Warp to human spawn.
}
else if (tempPlayer->p_freq == 1) // Repeat for Zombies.
{
t.u.p = tempPlayer;
game->WarpTo (&t, eData->zombieSpawnX, eData->zombieSpawnY);
}
}
pd->Unlock(); // End cycle and lock |
You don't have to use FOR_EACH_PLAYER_P, though, since you're not using playerdata, FOR_EACH_PLAYER will be fine. Basically, the idea is to cycle through all the players, check their freq, and warp them accordingly. I thought there would be a better way to do it, but this is the best I could come up with(well, D1 actually sent me this code).
But also, the first parameter in WarpTo is a Target, which is why you can use an arena, I guess, but that's going to warp the whole arena. The critical part of the code I showed you was "t.u.p = tempPlayer". You just use whatever player you pass into FOR_EACH_PLAYER, and put it into t.u.p. I never actually even figured out what t.u.p was, but it works for me. This shouldn't be too hard to convert to python. Hope this helps.
Smong - Mon Apr 16, 2007 4:55 am
Post subject:
Python is a little different when it comes to using Target. To warp an entire freq you can do:
game.WarpTo((arena, freq), x, y) |
It's only worth using a loop to warp freqs if you're also doing other things inside the loop like setting player data.
If you didn't manage to adapt BD's code you can paste this function into your code to easily move a ball.
# xy are in tiles
# bid is ball id (0-7, depends how many balls are in the arena)
def move_ball(arena, bid, x, y):
bd = balldata()
bd.state = BALL_ONMAP
bd.x = x * 16
bd.y = y * 16
bd.xspeed = bd.yspeed= 0
bd.carrier = None
bd.freq = -1
bd.time = current_ticks()
balls.PlaceBall(arena, bid, bd) |
Make sure you are using enough parameters in your SetInt call.
BDwinsAlt - Mon Apr 16, 2007 7:33 pm
Post subject:
All you have to do is modify the x and y location of the ball. Use an if statement to see where it needs to go.