Aller au contenu

Photo

Need to know whether an object is a trap placeable


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

#1
Rolenka

Rolenka
  • Members
  • 2 257 messages
I'm trying to make a mod that will autopause when a trap is detected. (this was in BG2, why not DAO?)

The chain is as follows: EVENT_TYPE_HEARTBEAT2, player_core.ncs, sys_traps_h.ncs, then a number of functions ultimately resulting in removing the transparency effect on the trap and setting to be interactive.

I could rather easily intercept the HEARTBEAT2 event and replace the entire chain, adding my pause script at the very end. But that would be... inelegant.

What I'd rather do is intercept EVENT_TYPE_SET_INTERACTIVE, see if the object is a trap, then pause if it is. 

How do I do that? Can I somehow identify an object as a placeable and a placeable as a trap? Can I somehow check to see if the resource of the placeable matches that of any of the traps, then run through the list? (example: genip_tripwire.utp)

Thanks very much...

#2
_L_o_B_o_

_L_o_B_o_
  • Members
  • 117 messages
Here is an idea. To identify an object as a trap you could check the PLC_TRAP_TYPE local variable on the object. Use GetLocalInt(). It returns 0 on error, what means the object is not a placeable or is a placeable but not a trap.

Only doubt is if PLC_TRAP_TYPE is defined for every trap object :huh:

Modifié par _L_o_B_o_, 25 juin 2010 - 09:03 .


#3
TimelordDC

TimelordDC
  • Members
  • 923 messages
You could try using GetPlaceableBaseType (don't know what it returns but it looks like it might be of help) or GetPlaceableStateCntTable and compare the returned state controller against the trap's state controller. Again, I don't know what string is returned (for the state controller) so you might have to do some experimentation to figure that out and compare that against the placeables.xls.

#4
Rolenka

Rolenka
  • Members
  • 2 257 messages
Interesting... Lobo's idea is straightforward enough. I may go with that first and hope it really is defined for every trap object. :blush:

For Timelord's idea, it looks like if I used GetPlaceableBaseType, according to placeables.xls the trap type is 7. The builder wiki doesn't say what it returns either, but it's got to be either the integer (7) or the string (trap).

I admit I've no idea what a state controller is, as I've never encountered that before. So bear with me.

GetPlaceableStateCntTable isn't in the builder wiki, but I'm assuming you just feed it the object and it returns the string for the state controller? If that's true, it looks like I'd compare it against "StateCnt_Trap_Trigger." Even then, I'm not sure about the proper syntax... if strTarget == "StateCnt_Trap_Trigger"? Seems too simple.

Thanks again, you've each given me some things to try.

Modifié par Rolenka, 26 juin 2010 - 04:12 .


#5
TimelordDC

TimelordDC
  • Members
  • 923 messages
GetPlaceableBaseType returns an integer so you should check for that.



GetPlaceableStatCntTable returns a string. You can just use PrintToLog to output the string returned for a known trap placeable (or any other placeable for that matter) to the log file so you can analyze the returned string for the format and go from there - it could very well be StateCnt_Trap_Trigger, you never know :)

FYI - State Controllers determine what actions can be performed on a particular placeable type and are defined in the placeables.xls file.



I am pretty sure the state controller constants are defined in some header file so you can also try finding them there.