Jump to content

Noob calling a function on papyrus


Recommended Posts

I am a complete noob with papyrus and I am encountering a problem with a script. I am doing something wrong somewhere and I can't find a solution to this problem, so I thought to ask here.

I am trying to make a dialogue-based sex (and other things) mod that exploits Sexlab Attraction to use the values of lust and attraction this mod calculates to start sexual and romantical relationships. I have now encountered a problem that doesn't let me "import" these factors into my own mod because every time I try to call these functions in my script, it returns always 0 (or "none" I guess).

I have tried different formulas and routes, and none have sorted the desired results.

 

What I did:

1 - I have made a mod depending on Sexlab Attraction.esm (and consequently on Sexlab and Sexlab Aroused, since Attraction depends on them)

2 - I have setup my quest and my dialogue branches until I got to this point worked just fine.

3 - Since I wanted the different topics and responses from the character  based on attraction and lust (values the Attraction mod calculates) the character feels toward the actor he's speaking to and vice-versa I set up four conditional properties akLikes, akLust, pLikes and pLust as:

int Property akLikes auto conditional ;the attraction the actor feels towards player

etc.

4 - Since these properties should change according to which character I'm speaking, I made the attraction script a property in my script (I also tried the "import" route) and set some functions to run whenever I start the topic with someone. Since lust and attraction are defined by the functions "GetActorAttraction" and "GetLust" that are defined as

Int Function GetLust(Actor akSource, Actor akTarget)

int Function GetActorAttraction(Actor akSource, Actor akTarget)

I defined mine as

Function SetAkLikes(actor akRef, actor PlayerRef)
int attraction_var = SLAttraction.GetActorAttraction(akRef, PlayerRef)
akLikes = attraction_var
endfunction

and called the in the dialogue string as

(GetOwningQuest() as SLPU_Pickup).SetAkLikes(akSpeaker, Game.GetPlayer())

Problem is:

The functions are always returning me 0.

I have also tried to use (in my function)

akLikes = SLAttraction.GetActorAttraction(akRef, PlayerRef)

and

akLikes.set(SLAttraction.GetActorAttraction(akRef, PlayerRef))

but in both these cases I got the "cannot call the member function GetActorAttraction/GetLust alone or on a type, must call it on a variable" error when compiling, so I get I do something wrong in importing the said function. I never got to understand what that error means: I googled, searched in the wikis and all, but I never understand how people got around that part. Also that "must call it on a variable" part is sort of taking me down a bit: does it mean it can be used only in logic checks (as Attraction used only to determine which string was meant to show when getting to the attraction/lust)? I can't use that value at all?

Please, help me understand what I'm doing wrong.

 

(PS: uhm, I think I may have posted in the wrong forum, as it's more general Skyrim "Techincal Support", I probably got the wrong tab, feel mfree to move the topic if that's the case)

Link to comment

SLAttraction is actually a defined property

SLAttractionMainScript Property SLAttraction auto

The script wouldn't compile otherwise because SLAttraction property wouldn't be defined, and it does.

The problem is that the function returns "none" or "0".

Link to comment

The function GetActorAttractiveness seems to return the FactionRank of the actor you pass as parameter for the faction called SLAttraction_Attraction.

GetFactionRank(), that is a native function, returns:

  • -2 if the Actor is not in the faction.
  • -1 if the Actor is in the faction, with a rank set to -1. By convention, this means they may eventually become a member of this faction.
  • A non-negative number equal to the actor's rank in the faction.

 

For the function you are using ( GetActorAttraction() ), you still get a number as result. 0 means that there is no attraction (but the calculation is possible), -2 means that the calculation is NOT possible.

 

If this function fails then the problem is on the other mod.

 

 

Explain me better what you wish to do, and I will try to help.

 

Right now I think you wish to set an int property (that is a conditional property) with the result of the attraction of the player versus an actor.

 

Link to comment

Wait, I GOT IT! I understood what the error was: it was a problem of loose/bsa pex... *facepalm*

I'll elaborate: since both attraction and aroused come with bsa, I had to unpack the script to use them, but having them loose while I test the game gives me CTD (dunno why), so I put and removed the scripts... since sometimes I forget to put them back BEFORE loading the CK, the properties directed at those scripts were erased when I saved the script... so the properties were undefined and I was SURE they were. *headdesk*

 

Thank you for your patience, and sorry, it was a really stupid error on my part.

 

(BTW: that was exactly what I did: the conditional int was used in the dialogue to check for success -if the actor finds you attrractive you can enter the "success" branch - or fail -if the actor doesn't like you, the conversation is over)

Link to comment

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...