- Updated scripting branch to latest version in trunk.

SVN r4337 (scripting)
This commit is contained in:
Randy Heit 2013-06-07 03:31:30 +00:00
commit 459ad5abff
282 changed files with 15968 additions and 3535 deletions

View file

@ -62,10 +62,11 @@
static FRandom pr_obituary ("Obituary");
static FRandom pr_botrespawn ("BotRespawn");
static FRandom pr_killmobj ("ActorDie");
static FRandom pr_damagemobj ("ActorTakeDamage");
FRandom pr_damagemobj ("ActorTakeDamage");
static FRandom pr_lightning ("LightningDamage");
static FRandom pr_poison ("PoisonDamage");
static FRandom pr_switcher ("SwitchTarget");
static FRandom pr_kickbackdir ("KickbackDir");
CVAR (Bool, cl_showsprees, true, CVAR_ARCHIVE)
CVAR (Bool, cl_showmultikills, true, CVAR_ARCHIVE)
@ -191,7 +192,7 @@ void ClientObituary (AActor *self, AActor *inflictor, AActor *attacker, int dmgf
if (self->player == NULL || self->player->mo != self || !show_obituaries)
return;
gender = self->player->userinfo.gender;
gender = self->player->userinfo.GetGender();
// Treat voodoo dolls as unknown deaths
if (inflictor && inflictor->player && inflictor->player->mo != inflictor)
@ -269,7 +270,7 @@ void ClientObituary (AActor *self, AActor *inflictor, AActor *attacker, int dmgf
attacker->player->fragcount -= 2;
attacker->player->frags[attacker->player - players]++;
self = attacker;
gender = self->player->userinfo.gender;
gender = self->player->userinfo.GetGender();
mysnprintf (gendermessage, countof(gendermessage), "OB_FRIENDLY%c", '1' + (pr_obituary() & 3));
message = GStrings(gendermessage);
}
@ -316,7 +317,7 @@ void ClientObituary (AActor *self, AActor *inflictor, AActor *attacker, int dmgf
}
SexMessage (message, gendermessage, gender,
self->player->userinfo.netname, attacker->player->userinfo.netname);
self->player->userinfo.GetName(), attacker->player->userinfo.GetName());
Printf (PRINT_MEDIUM, "%s\n", gendermessage);
}
@ -342,7 +343,7 @@ void AActor::Die (AActor *source, AActor *inflictor, int dmgflags)
int realgibhealth = realthis->GetGibHealth();
if (realthis->health >= realgibhealth)
{
realthis->health = realgibhealth -1; // if morphed was gibbed, so must original be (where allowed)
realthis->health = realgibhealth -1; // if morphed was gibbed, so must original be (where allowed)l
}
}
realthis->Die(source, inflictor, dmgflags);
@ -451,8 +452,8 @@ void AActor::Die (AActor *source, AActor *inflictor, int dmgflags)
if (deathmatch && player->spreecount >= 5 && cl_showsprees)
{
SexMessage (GStrings("SPREEKILLSELF"), buff,
player->userinfo.gender, player->userinfo.netname,
player->userinfo.netname);
player->userinfo.GetGender(), player->userinfo.GetName(),
player->userinfo.GetName());
StatusBar->AttachMessage (new DHUDMessageFadeOut (SmallFont, buff,
1.5f, 0.2f, 0, 0, CR_WHITE, 3.f, 0.5f), MAKE_ID('K','S','P','R'));
}
@ -499,8 +500,8 @@ void AActor::Die (AActor *source, AActor *inflictor, int dmgflags)
{
if (!AnnounceSpreeLoss (this))
{
SexMessage (GStrings("SPREEOVER"), buff, player->userinfo.gender,
player->userinfo.netname, source->player->userinfo.netname);
SexMessage (GStrings("SPREEOVER"), buff, player->userinfo.GetGender(),
player->userinfo.GetName(), source->player->userinfo.GetName());
StatusBar->AttachMessage (new DHUDMessageFadeOut (SmallFont, buff,
1.5f, 0.2f, 0, 0, CR_WHITE, 3.f, 0.5f), MAKE_ID('K','S','P','R'));
}
@ -509,8 +510,8 @@ void AActor::Die (AActor *source, AActor *inflictor, int dmgflags)
{
if (!AnnounceSpree (source))
{
SexMessage (spreemsg, buff, player->userinfo.gender,
player->userinfo.netname, source->player->userinfo.netname);
SexMessage (spreemsg, buff, player->userinfo.GetGender(),
player->userinfo.GetName(), source->player->userinfo.GetName());
StatusBar->AttachMessage (new DHUDMessageFadeOut (SmallFont, buff,
1.5f, 0.2f, 0, 0, CR_WHITE, 3.f, 0.5f), MAKE_ID('K','S','P','R'));
}
@ -559,8 +560,8 @@ void AActor::Die (AActor *source, AActor *inflictor, int dmgflags)
if (!AnnounceMultikill (source))
{
SexMessage (multimsg, buff, player->userinfo.gender,
player->userinfo.netname, source->player->userinfo.netname);
SexMessage (multimsg, buff, player->userinfo.GetGender(),
player->userinfo.GetName(), source->player->userinfo.GetName());
StatusBar->AttachMessage (new DHUDMessageFadeOut (SmallFont, buff,
1.5f, 0.8f, 0, 0, CR_RED, 3.f, 0.5f), MAKE_ID('M','K','I','L'));
}
@ -883,7 +884,9 @@ static inline bool MustForcePain(AActor *target, AActor *inflictor)
}
void P_DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage, FName mod, int flags)
// Returns the amount of damage actually inflicted upon the target, or -1 if
// the damage was cancelled.
int P_DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage, FName mod, int flags)
{
unsigned ang;
player_t *player = NULL;
@ -896,7 +899,7 @@ void P_DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage
if (target == NULL || !((target->flags & MF_SHOOTABLE) || (target->flags6 & MF6_VULNERABLE)))
{ // Shouldn't happen
return;
return -1;
}
// Spectral targets only take damage from spectral projectiles.
@ -904,14 +907,14 @@ void P_DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage
{
if (inflictor == NULL || !(inflictor->flags4 & MF4_SPECTRAL))
{
return;
return -1;
}
}
if (target->health <= 0)
{
if (inflictor && mod == NAME_Ice)
{
return;
return -1;
}
else if (target->flags & MF_ICECORPSE) // frozen
{
@ -919,7 +922,7 @@ void P_DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage
target->flags6 |= MF6_SHATTERING;
target->velx = target->vely = target->velz = 0;
}
return;
return -1;
}
if ((target->flags2 & MF2_INVULNERABLE) && damage < TELEFRAG_DAMAGE && !(flags & DMG_FORCED))
{ // actor is invulnerable
@ -927,7 +930,7 @@ void P_DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage
{
if (inflictor == NULL || !(inflictor->flags3 & MF3_FOILINVUL))
{
return;
return -1;
}
}
else
@ -935,7 +938,7 @@ void P_DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage
// Players are optionally excluded from getting thrust by damage.
if (static_cast<APlayerPawn *>(target)->PlayerFlags & PPF_NOTHRUSTWHENINVUL)
{
return;
return -1;
}
}
@ -963,7 +966,7 @@ void P_DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage
if (target->flags2 & MF2_DORMANT)
{
// Invulnerable, and won't wake up
return;
return -1;
}
player = target->player;
if (player && damage > 1 && damage < TELEFRAG_DAMAGE)
@ -979,19 +982,19 @@ void P_DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage
if (player != NULL)
{
if (!deathmatch && inflictor->FriendPlayer > 0)
return;
return -1;
}
else if (target->flags4 & MF4_SPECTRAL)
{
if (inflictor->FriendPlayer == 0 && !target->IsHostile(inflictor))
return;
return -1;
}
}
damage = inflictor->DoSpecialDamage (target, damage, mod);
if (damage == -1)
{
return;
return -1;
}
}
// Handle active damage modifiers (e.g. PowerDamage)
@ -1005,7 +1008,7 @@ void P_DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage
{
goto dopain;
}
return;
return -1;
}
}
// Handle passive damage modifiers (e.g. PowerProtection)
@ -1019,7 +1022,7 @@ void P_DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage
{
goto dopain;
}
return;
return -1;
}
}
@ -1036,7 +1039,7 @@ void P_DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage
{
goto dopain;
}
return;
return -1;
}
}
@ -1044,7 +1047,7 @@ void P_DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage
}
if (damage == -1)
{
return;
return -1;
}
// Push the target unless the source's weapon's kickback is 0.
// (i.e. Gauntlets/Chainsaw)
@ -1066,9 +1069,18 @@ void P_DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage
if (kickback)
{
AActor *origin = (source && (flags & DMG_INFLICTOR_IS_PUFF))? source : inflictor;
ang = R_PointToAngle2 (origin->x, origin->y,
target->x, target->y);
// If the origin and target are in exactly the same spot, choose a random direction.
// (Most likely cause is from telefragging somebody during spawning because they
// haven't moved from their spawn spot at all.)
if (origin->x == target->x && origin->y == target->y)
{
ang = pr_kickbackdir.GenRand32();
}
else
{
ang = R_PointToAngle2 (origin->x, origin->y, target->x, target->y);
}
// Calculate this as float to avoid overflows so that the
// clamping that had to be done here can be removed.
@ -1128,7 +1140,7 @@ void P_DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage
{ // Still allow telefragging :-(
damage = (int)((float)damage * level.teamdamage);
if (damage <= 0)
return;
return damage;
}
}
@ -1157,7 +1169,7 @@ void P_DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage
if (damage < TELEFRAG_DAMAGE && ((player->mo->flags2 & MF2_INVULNERABLE) ||
(player->cheats & CF_GODMODE)))
{ // player is invulnerable, so don't hurt him
return;
return -1;
}
if (!(flags & DMG_NO_ARMOR) && player->mo->Inventory != NULL)
@ -1168,12 +1180,12 @@ void P_DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage
if (damage <= 0)
{
// If MF6_FORCEPAIN is set, make the player enter the pain state.
if (!(target->flags5 & MF5_NOPAIN) && inflictor != NULL &&
(inflictor->flags6 & MF6_FORCEPAIN) && !(inflictor->flags5 & MF5_PAINLESS))
{
goto dopain;
}
return;
if (!(target->flags5 & MF5_NOPAIN) && inflictor != NULL &&
(inflictor->flags6 & MF6_FORCEPAIN) && !(inflictor->flags5 & MF5_PAINLESS))
{
goto dopain;
}
return damage;
}
}
@ -1232,7 +1244,7 @@ void P_DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage
damage = newdam;
if (damage <= 0)
{
return;
return damage;
}
}
@ -1291,7 +1303,7 @@ void P_DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage
}
}
target->Die (source, inflictor, flags);
return;
return damage;
}
woundstate = target->FindState(NAME_Wound, mod);
@ -1302,7 +1314,7 @@ void P_DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage
if (target->health <= woundhealth)
{
target->SetState (woundstate);
return;
return damage;
}
}
@ -1396,6 +1408,8 @@ dopain:
// killough 11/98: Don't attack a friend, unless hit by that friend.
if (justhit && (target->target == source || !target->target || !target->IsFriend(target->target)))
target->flags |= MF_JUSTHIT; // fight back!
return damage;
}
void P_PoisonMobj (AActor *target, AActor *inflictor, AActor *source, int damage, int duration, int period, FName type)
@ -1502,6 +1516,10 @@ bool AActor::OkayToSwitchTarget (AActor *other)
//
// P_PoisonPlayer - Sets up all data concerning poisoning
//
// poisoner is the object directly responsible for poisoning the player,
// such as a missile. source is the actor responsible for creating the
// poisoner.
//
//==========================================================================
bool P_PoisonPlayer (player_t *player, AActor *poisoner, AActor *source, int poison)
@ -1517,7 +1535,7 @@ bool P_PoisonPlayer (player_t *player, AActor *poisoner, AActor *source, int poi
if (poison > 0)
{
player->poisoncount += poison;
player->poisoner = poisoner;
player->poisoner = source;
if (poisoner == NULL)
{
player->poisontype = player->poisonpaintype = NAME_None;
@ -1547,6 +1565,10 @@ void P_PoisonDamage (player_t *player, AActor *source, int damage,
AActor *target;
AActor *inflictor;
if (player == NULL)
{
return;
}
target = player->mo;
inflictor = source;
if (target->health <= 0)
@ -1558,11 +1580,8 @@ void P_PoisonDamage (player_t *player, AActor *source, int damage,
{ // target is invulnerable
return;
}
if (player)
{
// Take half damage in trainer mode
damage = FixedMul(damage, G_SkillProperty(SKILLP_DamageFactor));
}
// Take half damage in trainer mode
damage = FixedMul(damage, G_SkillProperty(SKILLP_DamageFactor));
// Handle passive damage modifiers (e.g. PowerProtection)
if (target->Inventory != NULL)
{