The forum has been set to read-only mode. For community discussion and questions, head over to our Discord: https://discord.taleoftwowastelands.com

Help detecting Perk Rank Via Script

General mod discussion and requests.
mr01
Posts: 21
Joined: Sat Nov 23, 2013 8:29 pm

Not a possible solution, I am

Post by mr01 » Wed Dec 04, 2013 10:43 pm

Not a possible solution, I am afraid (that was also what I tried to do last night). RemovePerk will remove all ranks of the perks in one go. When that happens there isn't a way that the AddPerk function to tell the difference between rank 2 and rank 3 of the perk. The trouble comes down to rank 2 and 3 since since addperk function will return a 3 in both instances.


Since my mod is about fixing pulse explosions to actually scale, I may just ending up throwing my hands in the air and set the global variable to max if the player has even 1 rank of demolition expert (as if the player has all 3 ranks of demolition expert) with a one time run quest on start. My thinking is that if the player has one or two ranks of demolition expert, they are most likely going to eventually invest and get more ranks of demolition expert, in which case the perk will reset the global variable appropriately. For those who already have 3 ranks, they are good to go, since the quest will automatically set it to max for the first time. Since this mod will only affect Pulse grenade weapons, I don't think I have to worry about the player gaming the system for unearned damage since the damage boost only applies to pulse grenades (regular,40mm, and 25mm) as well as only affecting robots and power armors. It is funny, making the mod isn't the hard part...it is circumventing flaws in the game engine that refuses to tell me the answer to a simple question of how many ranks does the player have of one perk.


Hmm...it gets me thinking that perhaps TTW should straight up alter all perks that have ranks, to set a global variable with each rank added in case in the future the team members or other modders might want to write a script that needs to check the ranks. This is to avoid the problem that I run into now and serves as a good precaution in the future in case for whatever reason someone needs to know the ranks for a script.



User avatar
Puppettron
Gary
Posts: 1715
Joined: Sat Nov 23, 2013 10:47 pm

i know this is a month old

Post by Puppettron » Sat Jan 04, 2014 7:00 am

(edit:  missed a line in OP that invalidated my response)


perms:  either a full fireworks display spelling out "Puppettron Made This" anytime a user accesses my content in-game, or just give me credit somewhere.

User avatar
Puppettron
Gary
Posts: 1715
Joined: Sat Nov 23, 2013 10:47 pm

ok, i think i've got an idea.

Post by Puppettron » Sun Jan 05, 2014 12:19 am

ok, i think i've got an idea.  i know, you've probably moved on, but try this:




start with if player.hasperk demo.  if they do, add a rank of demo and then check to see which spell they now have, if they have rank 2 spell, then remove and add 1 rank.  if rank 3, then remove and add 2.  otherwise remove and add 3.  


 


perms:  either a full fireworks display spelling out "Puppettron Made This" anytime a user accesses my content in-game, or just give me credit somewhere.

mr01
Posts: 21
Joined: Sat Nov 23, 2013 8:29 pm

@Puppettron

Post by mr01 » Sun Jan 05, 2014 7:45 pm

@Puppettron  


Nah, that won't work. 


If the player has 1 rank, then the AddPerk will return a value of 2, which can then be used to remove and then add back 1 rank of the perk. The problem is discerning rank 2 from rank 3. If the player has rank 2, the AddPerk will return a value of 3 and if the player has rank 3, then AddPerk can't add anymore ranks of the perk; therefore, it will still return rank 3. Using your suggestion, players with rank 3 would lose a single rank of the perk, because the script would think that it is rank 2. It is because of this that it it is not possible to discern the difference between rank 2 and rank 3.  



User avatar
Puppettron
Gary
Posts: 1715
Joined: Sat Nov 23, 2013 10:47 pm

right, but if the spell is

Post by Puppettron » Mon Jan 06, 2014 3:07 am

right, but if the spell is activated on acquisition of the perk, does failing to add a perk at rank 3 activate the rank 3 version?


perms:  either a full fireworks display spelling out "Puppettron Made This" anytime a user accesses my content in-game, or just give me credit somewhere.

mr01
Posts: 21
Joined: Sat Nov 23, 2013 8:29 pm

Puppettron wrote:

Post by mr01 » Wed Jan 15, 2014 1:03 am

[quote=Puppettron]


right, but if the spell is activated on acquisition of the perk, does failing to add a perk at rank 3 activate the rank 3 version?


[/quote]


@Puppettron


I finally have some free time to test out your suggestion of testing whether the AddPerk function re-activates the perk's effect at max rank or it does nothing and merely return the value of the perk's rank. To my surprise, the AddPerk function does nothing when the player already has max rank of a perk and merely returns that value, which is good news. This means that it is possible to discern the difference between Rank 2 and Rank 3.


To test it out, I made a dummy perk with no effect and gave my player character all 3 ranks of it. After a quick save and edit, I changed the perk's effect to modify a global value by +1 with every rank addition. After using the AddPerk function on the already maxed out perk, the global value remained at zero, which means that the rank 3 perk effect did not re-activate.


If my original perk rank was 2, then the AddPerk function would add another rank, return a value of 3 to the script, and activates the Rank 3 effect; thereby, causing the global value to change by + 1. However, since the perk was already maxed out at rank 3, the only thing the AddPerk function did was return a value of 3 to the script and the global value remained at zero. This is great news because it is possible to discern the difference between Rank 2 and Rank 3 with a script.


Congratulation Puppettron, you solved the riddle of how to determine Perk ranks via script. For that you have my thanks.



Gribbleshnibit8
Posts: 481
Joined: Sun Nov 04, 2012 2:06 am

I would like to suggest that

Post by Gribbleshnibit8 » Wed Jan 15, 2014 2:17 am

I would like to suggest that you need to add this information to the GECK wiki. Make sure to cite your reasons and testing on the talk page, but this is information that does not need to be kept only here, or forgotten :) That's some pretty good determination to find this out.



User avatar
Puppettron
Gary
Posts: 1715
Joined: Sat Nov 23, 2013 10:47 pm

i thought as much, but had no

Post by Puppettron » Thu Jan 23, 2014 2:42 am

i thought as much, but had no idea how to test it.  so, thank you also for doing all that work so that we can all benefit :D


perms:  either a full fireworks display spelling out "Puppettron Made This" anytime a user accesses my content in-game, or just give me credit somewhere.

Post Reply