Skip to content
Browse files

add a few more unscheduled checks

Fixes scripts attacking actors which aren't there (again).
  • Loading branch information...
1 parent 0dc2078 commit b5bc53de01b492a05e822cf34fde3f8ce17be60c @fizzet fizzet committed Jun 8, 2013
Showing with 12 additions and 2 deletions.
  1. +12 −2 gemrb/core/GameScript/Matching.cpp
View
14 gemrb/core/GameScript/Matching.cpp
@@ -598,12 +598,17 @@ Targets *ClosestEnemySummoned(Scriptable *origin, Targets *parameters, int ga_fl
}
actor = NULL;
+ ieDword gametime = core->GetGame()->GameTime;
while ( t ) {
Actor *tmp = (Actor *) (t->actor);
if (tmp->GetStat(IE_SEX) != SEX_SUMMON) {
t = parameters->GetNextTarget(m, ST_ACTOR);
continue;
}
+ if (!tmp->Schedule(gametime, true)) {
+ t = parameters->GetNextTarget(m, ST_ACTOR);
+ continue;
+ }
if (type) { //origin is PC
if (tmp->GetStat(IE_EA) <= EA_GOODCUTOFF) {
t = parameters->GetNextTarget(m, ST_ACTOR);
@@ -644,13 +649,18 @@ Targets *XthNearestEnemyOfType(Scriptable *origin, Targets *parameters, unsigned
return parameters;
}
+ ieDword gametime = core->GetGame()->GameTime;
while ( t ) {
if (t->actor->Type!=ST_ACTOR) {
t=parameters->RemoveTargetAt(m);
continue;
}
Actor *actor = (Actor *) (t->actor);
// IDS targeting already did object checks (unless we need to override Detect?)
+ if (!actor->Schedule(gametime, true)) {
+ t = parameters->RemoveTargetAt(m);
+ continue;
+ }
if (type) { //origin is PC
if (actor->GetStat(IE_EA) <= EA_EVILCUTOFF) {
t=parameters->RemoveTargetAt(m);
@@ -682,9 +692,9 @@ Targets *XthNearestEnemyOf(Targets *parameters, int count, int ga_flags)
}
Map *map = origin->GetCurrentArea();
int i = map->GetActorCount(true);
- Actor *ac;
+ ga_flags |= GA_NO_UNSCHEDULED;
while (i--) {
- ac=map->GetActor(i,true);
+ Actor *ac = map->GetActor(i,true);
if (ac == origin) continue;
int distance;
//int distance = Distance(ac, origin);

0 comments on commit b5bc53d

Please sign in to comment.
Something went wrong with that request. Please try again.