violgamba Posted April 24, 2024 (edited) I have a pretty basic logic that I'm struggling to implement in either ZScript or ACS. I've sunk about 6 solid hours of searching through forums, existing mods, and the wiki. Here's what I'd like to do: 1) get the player's current target 2) check whether the target's class extends from a particular superclass 3) If it IS an instance of the superclass, pull 2 fields from it which are defined in that superclass. In ACS, I can accomplish step 1 (sort of) with SetActivatorToTarget(playerTid). But step 2 seems out of reach, and for step 3, I've only found GetActorProperty, which helps with generic properties like "health", but not custom ones. Meanwhile, in ZScript, the "is" keyword makes step 2 simple, and an answer to step 3 seems likely, but I can't find anything to help with step 1. I feel like I've exhausted my research options for this. If anyone can provide some insight, I'd be very grateful. Edited April 24, 2024 by violgamba 0 Quote Share this post Link to post
jaeden Posted April 24, 2024 In ZScript: 1) You can use AimTarget or AimLineAttack to get what the player is aiming at (or manually do a hitscan check through LineTrace). 2)3) You can use "is" keyword, but if you want to pull fields from a class, it is better to cast a pointer to the superclass and check if the casted pointer is valid. Assuming "pl" is pointer to the player, "Superclass" is class name of the superclass, this code should access fields if the aiming target is extended from the superclass (or is the superclass itself): Actor tgt = pl.AimTarget(); let casted = Superclass(tgt); if (casted) { casted.field1 = ... int result = casted.field2; } (untested) 1 Quote Share this post Link to post
violgamba Posted April 24, 2024 (edited) It works! Amazing. Thank you so much. Edited April 24, 2024 by violgamba 0 Quote Share this post Link to post
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.