Code: Show/Hide /** called when a tracked player is killed */
typedef void (*KilledFunc)(Player *p, Player *killer, void *clos); /** user module must set new x and y coords for this players position. */ typedef void (*RespawnFunc)(Player *p, void *clos); /** called when a tile in a tracked region takes damage. x and y are the tile * damage is the amount of damage taken, freq is the owner of the weapon, * wtype is the type of the weapon that did the damage, see packets/ppk.h for * weapon types. */ typedef void (*TileDamageFunc)(Arena *arena, int x, int y, int damage, int freq, int wtype, void *clos); /** the interface id for damage */ #define I_DAMAGE "damage-2" /** the damage interface struct */ typedef struct Idamage { INTERFACE_HEAD_DECL /** pos will get modified if this player is effected by a weapon, * killfunc will get called when this player dies. currently * killfunc is optional but respawnfunc is required. */ void (*AddFake)(Player *p, struct C2SPosition *pos, KilledFunc killfunc, RespawnFunc respawnfunc, void *clos); void (*RemoveFake)(Player *p); /** call this when the fake player enters a safe zone or fires a weapon */ void (*FakePosition)(Player *p, struct C2SPosition *pos, int len); void (*AddRegion)(Arena *arena, Region *rgn, TileDamageFunc tilefunc, void *clos); void (*RemoveRegion)(Arena *arena, Region *rgn); } Idamage; |
Quote: |
this module is closed source due to the amount of effort I put into it. |
Smong wrote: |
Update
Added arena setting: Damage:IgnoreTeamDamage (default: 0). Added support for some of the special tiles. |
Bak wrote: |
How did you get the source? |
Code: Show/Hide offset2 = shipradius * 0.7; if (shipradius == 14) // special case, probably for VIE compatability offset1 = offset2; else offset1 = offset2 + 1; sin(i * PI / 20) // double barrel 1(left one with rot = 0) barrel1->x += round(offset1 * ( sin(((pos->rotation + 30) % 40) * PI / 20) )); barrel1->y -= round(offset1 * ( sin(pos->rotation) * PI / 20 )); // double barrel 2 (right one with rot = 0) barrel2->x -= round(offset2 * ( sin(((pos->rotation + 30) % 40) * PI / 20) )); barrel2->y += round(offset2 * ( sin(pos->rotation) * PI / 20 )); |
Code: Show/Hide #include <stdio.h> #include <stdlib.h> #include <stdbool.h> #include "asss.h" #include "damage.h" static Imodman *mm; static Iarenaman *aman; static Iplayerdata *pd; static Idamage *damage; static Ilogman *lm; static int arenaKey = -1; static int playerKey = -1; struct ArenaData { }; #define PlayerData PlayerData_ struct PlayerData { Arena *arena; }; static struct ArenaData* GetArenaData(Arena *arena) { struct ArenaData *adata = P_ARENA_DATA(arena, arenaKey); return adata; } static struct PlayerData* GetPlayerData(Player *p) { struct PlayerData *pdata = PPDATA(p, playerKey); if (p->arena && p->arena != pdata->arena) { pdata->arena = p->arena; //... } return pdata; } static void newWeaponCB(Arena *arena, DamageWeapon *wpn) { lm->LogP(L_INFO, "damagetest", wpn->p, "Added a weapon (%p) at %d, %d", wpn, wpn->x / 1000, wpn->y / 1000); } static void removeWeaponCB(Arena *arena, DamageWeapon *wpn, u8 removereason) { const char *reason; switch (removereason) { case DAMAGE_REMOVEWPN_HIT: reason = "Hit a tile"; break; case DAMAGE_REMOVEWPN_HITPLAYER: reason = "Hit a player"; break; case DAMAGE_REMOVEWPN_OTHERBARRELHIT: reason = "Other barrel hit a player"; break; case DAMAGE_REMOVEWPN_SHIPFREQCHANGE: reason = "Firer changed ship / freq"; break; case DAMAGE_REMOVEWPN_LEAVEARENA: reason = "Firer left the arena"; break; case DAMAGE_REMOVEWPN_EXPIRED: reason = "Weapon expired"; break; case DAMAGE_REMOVEWPN_SAFEZONE: reason = "Firer entered a safe zone"; break; default: reason = "UNKNOWN"; break; } lm->LogP(L_INFO, "damagetest", wpn->p, "Removed a weapon(%p) at %d, %d. Because: %s", wpn, wpn->x / 1000, wpn->y / 1000, reason); } static void weaponsUpdatedCB(Arena *arena, ticks_t now) { static DamageWeapon* lastFound = NULL; DamageWeapon *wpn; Link *link; damage->WeaponLock(arena); FOR_EACH_DAMAGEWEAPON(wpn, arena) { if (wpn->wpn.type == W_THOR) { if (wpn != lastFound) { lm->LogA(L_INFO, "damagetest", arena, "Found a thor while looping over all the current weapons! (only displayed once)"); lastFound = wpn; } break; } } damage->WeaponUnlock(arena); } EXPORT const char info_template[] = "DamageTest"; static void ReleaseInterfaces() { mm->ReleaseInterface(aman ); mm->ReleaseInterface(pd ); mm->ReleaseInterface(damage ); mm->ReleaseInterface(lm ); } EXPORT int MM_damagetest(int action, Imodman *mm_, Arena *arena) { if (action == MM_LOAD) { mm = mm_; aman = mm->GetInterface(I_ARENAMAN , ALLARENAS); pd = mm->GetInterface(I_PLAYERDATA , ALLARENAS); damage = mm->GetInterface(I_DAMAGE , ALLARENAS); lm = mm->GetInterface(I_LOGMAN , ALLARENAS); if (!aman || !pd || !damage || !lm) { ReleaseInterfaces(); printf("<damagetest> Missing interfaces"); return MM_FAIL; } arenaKey = aman->AllocateArenaData(sizeof(struct ArenaData)); playerKey = pd->AllocatePlayerData(sizeof(struct PlayerData)); if (arenaKey == -1 || playerKey == -1) // check if we ran out of memory { if (arenaKey != -1) // free data if it was allocated aman->FreeArenaData(arenaKey); if (playerKey != -1) // free data if it was allocated pd->FreePlayerData (playerKey); ReleaseInterfaces(); return MM_FAIL; } return MM_OK; } else if (action == MM_UNLOAD) { aman->FreeArenaData(arenaKey); pd->FreePlayerData(playerKey); ReleaseInterfaces(); return MM_OK; } else if (action == MM_ATTACH) { damage->AddWeaponCallback(arena, newWeaponCB, removeWeaponCB, weaponsUpdatedCB); return MM_OK; } else if (action == MM_DETACH) { damage->RemoveWeaponCallback(arena, newWeaponCB, removeWeaponCB, weaponsUpdatedCB); return MM_OK; } return MM_FAIL; } |
Cheese wrote: |
does this calculate ship radius from settings, or is it hardcoded to the default 14px?
also, why does it load normally from modules.conf, but crashes almost immediately after loading successfully using ?insmod? and it doesnt seem to take damage from bursts, why is that? couldnt you just look at the number of shrap, then use circle-math to get their direction, then use the bounce bullet math? |