- Moved the implementation for the Thing_Damage special into another function

so that I can create the ACS function Thing_Damage2. It's exactly the same as
  Thing_Damage, except the damage type is specified by name. When I did this,
  I noticed that it didn't do anything useful for a TID of 0, so I made it
  affect the activator in that case.
- Added a new SetActorState ACS function:
    int SetActorState (int tid, str statename, optional bool exact);
  If tid is 0, it affects the script activator, otherwise it affects all the
  matching actors. Statename is the name of the state you want to put the
  actor in. The final parameter, exact, specifies whether or not partial
  state name matches are accepted. If you don't specify it or set it to
  false, if you try to do something like:
    SetActorState (0, "Foo.Bar");
  And the actor has a Foo state but no Foo.Bar state, it will enter the Foo
  state. If you set exact to true:
    SetActorState (0, "Foo.Bar", true);
  Then the actor must have a Foo.Bar state, or it will not change state at
  all, even if it has a Foo state.
  The return value for this function is the number of actors that successfully
  changed state. Note that you should refrain from using this function to
  enter special states such as Death, or unpredictable results could occur.


SVN r505 (trunk)
This commit is contained in:
Randy Heit 2007-03-23 22:26:14 +00:00
commit 490742cf46
7 changed files with 131 additions and 32 deletions

View file

@ -375,6 +375,41 @@ nolead: mobj->angle = R_PointToAngle2 (mobj->x, mobj->y, targ->x, targ->y);
return rtn != 0;
}
int P_Thing_Damage (int tid, AActor *whofor0, int amount, FName type)
{
FActorIterator iterator (tid);
int count = 0;
AActor *actor;
actor = (tid == 0 ? whofor0 : iterator.Next());
while (actor)
{
AActor *next = tid == 0 ? NULL : iterator.Next ();
if (actor->flags & MF_SHOOTABLE)
{
if (amount > 0)
{
P_DamageMobj (actor, NULL, whofor0, amount, type);
}
else if (actor->health < actor->GetDefault()->health)
{
actor->health -= amount;
if (actor->health > actor->GetDefault()->health)
{
actor->health = actor->GetDefault()->health;
}
if (actor->player != NULL)
{
actor->player->health = actor->health;
}
}
count++;
}
actor = next;
}
return count;
}
CCMD (dumpspawnables)
{
int i;