|
Server Help Community forums for Subgame, ASSS, and bots
|
Author |
Message |
Guest
Offline
|
Posted: Sat Oct 15, 2011 6:19 am Post subject: Vehicle module by Bak- Questions |
|
|
|
|
This is the perfect module for the project I am using, but not so perfect in the fact it doesn't work properly.
Wondering if anyone has used it, and had it working.
Issues:
1) Fixed the ship change from being coded on 1.4.4 to compile on 1.5.
2) Errors with the ?in function when you are not near a vehicle in crashes
- Its a problem in the attach funtion
- Commented out the attach function and it works
3) When you enter a vehicle, then go back to where it was when you go in, you can get into it again and then there are 2 vehicles. You can do this once, the second time you try it doesn't work. |
|
Back to top |
|
|
Guest
Offline
|
Posted: Wed Oct 26, 2011 8:35 pm Post subject: |
|
|
|
|
Here is where the code fails if anyone can see anything obvious, I don't do much work with C.
local BOOL tryAttach(Player *p, tdvector *tdv)
{
int x;
BOOL rv = FALSE;
printf("[v] looking up players in proximity to %s. %d found\n",p->name,tdv->count);
for (x = 0; x < tdv->count;++x)
{
Player* mounted = findPlayerWithName(tdv->data[x].name);
if (mounted)
{
printf("[v] checking %s\n",mounted->name);
int deltaX = p->position.x - mounted->position.x;
int deltaY = p->position.y - mounted->position.y;
int radius = getRadius(p->arena->cfg, tdv->data[x].ship) + 16; // plus one tile lee-way
if (deltaX * deltaX + deltaY * deltaY < radius * radius)
{ // this is our turret!!!
if (tdv->data[x].state == STATE_OCCUPIED)
{
if (strchr(tdv->data[x].disallowAttachShips,'1' + p->p_ship) != 0)
{
chat->SendMessage(p,"%ss are not allowed to attach to that vehicle.", shipNames[p->p_ship]);
}
else if (getNumAttached(mounted) >= tdv->data[x].maxTurrets)
{
chat->SendMessage(p,"There are too many turrets attached to %s.",mounted->name);
}
else
{
if (p->p_freq != mounted->p_freq && tdv->data[x].disallowEnemyAttach)
chat->SendMessage(p,"Enemies are not allowed to attach to that vehicle.", shipNames[p->p_ship]);
else
{
forceAttach(p, mounted);
rv = TRUE;
break;
}
}
}
}
}
}
return rv;
} |
and here is forceAttach where it may or may not also be a problem.
local void forceAttach(Player *p, Player* mounted)
{
int pid2 = mounted->pid;
/* only send it if state has changed */
if (p->p_attached != pid2)
{
struct SimplePacket pkt = { S2C_TURRET, p->pid, pid2 };
net->SendToArena(p->arena, NULL, (byte*)&pkt, 5, NET_RELIABLE);
p->p_attached = pid2;
DO_CBS(CB_ATTACH, p->arena, AttachFunc, (p, mounted));
}
}
local Player* findPlayerWithName(const char* name)
{
Player* rv, *p;
Link* link;
pd->Lock();
FOR_EACH_PLAYER(p)
{
if (strcmp(p->name, name) == 0)
{
rv = p;
break;
}
}
pd->Unlock();
return rv;
} |
|
|
Back to top |
|
|
|
|
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
|
Software by php BB © php BB Group Server Load: 666 page(s) served in previous 5 minutes.
|