Aller au contenu

Photo

[REQUEST] Improvement to Trap Detection


  • Veuillez vous connecter pour répondre
19 réponses à ce sujet

#1
Copyright Theft

Copyright Theft
  • Members
  • 197 messages
Whenever I play a non-rogue character I always seem to find my companions warning me of a trap RIGHT AS I STEP ON IT.

Is anyone able to make a mod that causes the traps to be detected from a greater distance? Anything between 50-100% further away would be great.

Alternatively, can anyone make the game pause when a trap is detected? This may give me the 0.5 seconds extra warning before my legs fly off. Image IPB

#2
Signo Vir

Signo Vir
  • Members
  • 91 messages
There is a SetTrapDetected() function and GetObjectsInShape() function that lets you filter the type of object you are looking for. I suppose it would be possible to create script to listen for the heartbeat event and look for traps within a certain radius of the player or followers. If a trap is found, call the SetTrapDetected(trapObject, TRUE), and ToggleGamePause(TRUE);

And I agree, the default distance is so near that you have to lead with your rogue.

#3
Copyright Theft

Copyright Theft
  • Members
  • 197 messages
I'm not gonna lie, I have no idea how to do any of that XD

Maybe I should put in a PM to one of the regular contributors, hmm...

#4
Signo Vir

Signo Vir
  • Members
  • 91 messages
I haven't done any scripting for DA2 yet, but certainly have for other games. I'm going to give it a try today and see if I can get it working. The only part I don't know how to do script-wise is getting an array of followers and only applying the function to the rogues in the party.

That assumes that I can make the toolset compile the new scripts at all.

Assuming this works, I might make a mage spell that does the same thing (maybe a larger area) and/or disarms the traps (spell upgrade?)

Modifié par Signo Vir, 18 août 2011 - 01:19 .


#5
mesmerizedish

mesmerizedish
  • Members
  • 7 776 messages
The toolset will compile the scripts just fine.

We've had a lot of trouble with event listeners, however. I'm not sure what the deal is there (I just say "Make this happen," and hoorayforicecream gives me a script naked).

#6
Signo Vir

Signo Vir
  • Members
  • 91 messages
script.ldf contains the constants for event types as well so that might help.

The other functions seem to be the same as DA:O. GetCurrentEvent(), GetEventType(event), GetEventInteger(event, index), etc.

#7
hoorayforicecream

hoorayforicecream
  • Members
  • 3 420 messages
The biggest issue we've come across is trying to actually field events. As near as I can understand it, events need to be broadcast to specific scripts for the scripts to actually be able to listen to them. Since we don't have the DA2 source, we can't exactly go in and change it to say 'broadcast this event to script X' since we don't know where it does that. I've tried having my own scripts send events to each other, but that doesn't quite work either. There's something significantly diferrent about how the event system works in DA2, and none of the devs have shed any light. If you can get event listeners to work, I'd be very interested in hearing how.

#8
Signo Vir

Signo Vir
  • Members
  • 91 messages
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 .


#9
Signo Vir

Signo Vir
  • Members
  • 91 messages
scratch that... I can't even get it to compile:

E: 15:13:19 - traps_detection_ring.nss - traps_detection_ring.nss(2): Parsing variable list

EDIT:

This compiles: 
void main() {
    event ev = GetCurrentEvent();
}


This does not:
void main() {
    object oHero = getHero();
}

Modifié par Signo Vir, 18 août 2011 - 07:28 .


#10
hoorayforicecream

hoorayforicecream
  • Members
  • 3 420 messages
it's case sensitive. getHero() is undefined, GetHero() is not.

#11
Signo Vir

Signo Vir
  • Members
  • 91 messages
d'oh! *facepalm*

Thanks. I'm so used to camelCase for methods that it was just automatic.

It compiles now. Now I just need to figure out how to include it

#12
hoorayforicecream

hoorayforicecream
  • Members
  • 3 420 messages
Drop it in /Bioware/Dragon Age 2/packages/core/override, then runscript from the console to test. Attaching it to some other event or something is up to you.

#13
Copyright Theft

Copyright Theft
  • Members
  • 197 messages
Wow, that's a lot of work being done so far. I'll be really grateful if you can get something working Signo. Even if it's a mage spell with an area the size of firestorm it'd be an improvement.

#14
Signo Vir

Signo Vir
  • Members
  • 91 messages
well good news and bad news.

I added floaty text lines to know if it was working... and calling the script does indeed work. the bad news is that it doesn't find the trap right in front of my character. The problem is:

object[] traps = GetObjectsInShape(PLACEABLE_ACTION_TRIGGER_TRAP, SHAPE_SPHERE, loc, fRadius);

is returning an empty array.

I'm guessing that PLACEABLE_ACTION_TRIGGER_TRAP isn't the right thing to look for.

When I ask for _all_ objects in the area, I get 110 objects.
When I use a radius of 20m and object type OBJECT_TYPE_TRIGGER, I get 7 objects.
reducing it to 5m and combining filters OBJECT_TYPE_TRIGGER + OBJECT_TYPE_PLACEABLE I get 3. but using SetTrapDetected does nothing to them, it seems.

#15
Copyright Theft

Copyright Theft
  • Members
  • 197 messages
Perhaps PLACEABLE_ACTION_TRIGGER_TRAP relates to the deactivation levers for the big traps, or even the big traps themselves?

May sound silly, but what if you tried making the script activate (i.e trigger) the trap. That may at least help with finding what you need to refer to (if you can get the script to set off the trap it may be a good point to continue from).

Modifié par Copyright Theft, 19 août 2011 - 04:32 .


#16
Signo Vir

Signo Vir
  • Members
  • 91 messages
That's actually not a bad idea. Maybe a mage spell that doesn't find traps, but rather disables them? XP for each trap disabled? There are functions toset the state of a placeable, and statecnt_trap.gda defines the states for traps. Sadly, the states are only Armed, Triggered, and TriggerOnRelease. Similarly there are states for triggers: Active and Inactive. So there might be a way to either disable or trigger the traps. I'll give it a try later.

#17
Copyright Theft

Copyright Theft
  • Members
  • 197 messages
OK, so in effect it'll work like the AoE unlock spell someone did for Origins, I can certainly live with that (walk into a room, cast to clear, continue).

Would prefer if we could get it working more like a tweak to the normal detection, but hey.

#18
Signo Vir

Signo Vir
  • Members
  • 91 messages
I would prefer that as well. By order of preference:

1) Simple detection range change
2) new script to detect traps at greater range (essentially replacing built-in script)
3) new skill/spell to do above detection
4) new skill/spell to disarm traps

The detection range doesn't seem to be in the GDA files, so #1 is out. There isn't any way at the moment to make user scripts get notified by events so #2 is also out. #3 has run into serious roadblocks.... so we're left with #4. I didn't have time yesterday but should be able to give it a go today.

#19
Copyright Theft

Copyright Theft
  • Members
  • 197 messages
Exactly the same as my preference order Signo, let me know how it goes!

As a side note, do we know how the game converts cunning to trap detection. If there's a separate 'trap detection' stat what happens if we boost it to say 255? Just thinking that if the trap detect/disarm skill affects detection range it may be another way to sort it.

#20
Copyright Theft

Copyright Theft
  • Members
  • 197 messages
Noooo, Signor Vir where'd you go? You seemed to be making really good progress!