Here's what I've got so far:
void main() {
object hero = getHero();
object[] party_members = GetPartyList(hero);
int num_members = GetArraySize(party_members);
int i;
int traps_found = FALSE;
for (i = 0; i < num_members; i++){
traps_found = traps_found || CheckForTraps(party_members[i], 20.0f);
}
if (traps_found) {
ToggleGamePause(TRUE);
DisplayFloatyMessage(GetMainControlled(),"Trap Detected!",FLOATY_MESSAGE,0xff0000,3.0f);
}
}
int CheckForTraps(object oCreature, float fRadius) {
location loc = GetLocation(oCreature);
object[] traps = GetObjectsInShape(PLACEABLE_ACTION_TRIGGER_TRAP, SHAPE_SPHERE, loc, fRadius);
int num_traps = GetArraySize(traps);
int trap_detected = FALSE;
if (num_traps > 0) {
//traps found!
//set all detected and pause the game
int i;
for (i = 0; i < num_traps; i++){
if (GetPlaceableState(traps[i]) == 1) {
SetTrapDetected(traps[i], TRUE);
trap_detected = TRUE;
}
}
}
return trap_detected;
}
From what I can tell, it looks like this would have to be called from the console.
What I'm thinking may be a decent alternative is a sustained mode script. it is easy enough to add new abilities. e.g. a zero cost sustainable which executes the above every time the ability script is called. Obviously this would be MUCH easier if we could see the script code for DA2 and actually understand how it handles these things. I'm guessing that sustainables call their script with at least three states: ON_CAST, ON_END, and ON_HEARTBEAT.
Alternatively, it could be a mage spell that detects traps in a very large area but only when cast. I'll let you know how the process goes, of course
Modifié par Signo Vir, 18 août 2011 - 07:18 .