Jump to content

Building a script to track interactions with beasts - works, but have an efficiency question


Recommended Posts

Hello,

 

So 3 questions

 

So below script in spoiler works (abridged for ease of reading), but as you can see it may be pretty inefficient. 

 

Spoiler

    Int NumActors = actorList.Length            
    If (ActorList[1] != Game.GetPlayer()) && controller.hasPlayer() == true
        ;Will fuck up if creature is not actor 1, or there are multiple creature types
        ;debug.notification("Actorlist is " + actorlist) ; this doesn't work
        String raceID = MiscUtil.GetActorRaceEditorID(ActorList[1])                                                                               
        String raceKey = sslCreatureAnimationSlots.GetRaceKeyByID(raceID)
        debug.notification("You learn more about " + racekey)
        Utility.Wait(1.0)
       
        
        PenetrationType(racekey)
        Utility.Wait(1.0)
        
        ;Increments Creature Count
        Int iawainc = GlobalCreature(racekey).GetValue() as Int
        iawainc += (NumActors - 1)
        GlobalCreature(racekey).SetValue(iawainc as Int)
        
        awaDamage(racekey).Cast (player, player) ; Apply creature +/- damage spell
        ;debug.notification("Creaturedamagebuff")
        ;Utility.Wait(1.0)
        
        ;awaAreaBuff.Cast (player, player)
    endif

endfunction

 
Function PenetrationType(string racekey)

 

[abridged]


endfunction

 

globalvariable Function globalcreature(string racekey)
    if (racekey == "Dogs")
        return awadog
    elseif (racekey == "Bears")
        return awaBea
    elseif (racekey == "SabreCats")
        return awaCat
    elseif (racekey == "Chaurus") || (racekey == "ChaurusReapers") || (racekey == "ChaurusHunters")
        return awaCha

 

[etc]


    endif
endFunction

Spell Function awaDamage(string racekey)
    if (racekey == "Dogs")
        return awaDamageDog
    elseif (racekey == "Bears")
        return awaDamageBear
    elseif (racekey == "SabreCats")
        return awaDamageCat
    elseif (racekey == "Chaurus") || (racekey == "ChaurusHunters") || (racekey == "ChaurusReapers")
        return awaDamageChaurus
 

[etc]


    endif
endFunction

 

First off, every time I want to get the racekey of something and apply an effect I run it through a separate function. This is pretty inefficient - is there a way I can define the racekey and substitute it into the script? For example:

 

if (for example) racekey == "dogs"

 

Is there a way to -

 

int awa[string gets inserted here"racekey"] += (NumActors -1)

awadamage[string gets inserted here"racekey"].Cast (player, player) ; (or (actor, actor) depending

 

Any way I've tried to do it so far hasn't worked....

 

 

Question 2 - How do I cast (cast?) a string to a keyword? So again if I had racekey via

 

String raceID = MiscUtil.GetActorRaceEditorID(ActorList[1])                                                                               
String raceKey = sslCreatureAnimationSlots.GetRaceKeyByID(raceID)

 

and wanted to do a

 

If Actor.HasKeyword([insert string here])      ?

 

This of course does not work as the keyword needs to be defined as a property..... Any way around this? What I'm trying to do is give the actor the "racekey" keyword after a certain num of encounters and then have the script check for that when some stuff happens.

 

 

FInally

I'm also aware that I'm using an outdated method of grabbing some sexlab controllers? They still work. Does this matter?

 

Thanks for looking at my disaster of a script.

 

 

PS I know SL tracks some of this already but I a) can't figure out how and b) want to write it to a global variable anyway for use in MGEF/Spell conditions

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more information, see our Privacy Policy & Terms of Use