Jump to content

Need some help updating quest property values.


Evangela

Recommended Posts

The project I'm working on calls for a lot of updating of properties from a quest script, such that I've had to condense them into arrays to make it faster. The problem though is that the array elements change as expected, but the properties on the quest script don't.

 

 

 

Function RegisterForRaceKillCount(Int aiVictimRaceID, Int aiUpdateKillCount)
    Debug.notification("A kill count has been registered.")

    Int[] victimRaceKill = new Int[20]
    
    ;victimRaceKill[] StatManager.GiantsKilled
    victimRaceKill[0] = StatManager.GiantsKilled
    victimRaceKill[1] = StatManager.FalmersKilled
    victimRaceKill[2] = StatManager.HagravensKilled

    ; Creatures #1
    victimRaceKill[3] = StatManager.ChaurusesKilled
    victimRaceKill[4] = StatManager.ChaurusReapersKilled
    victimRaceKill[5] = StatManager.DragonsKilled
    victimRaceKill[6] = StatManager.DragonPriestsKilled
    victimRaceKill[7] = StatManager.SkeletonsKilled
    victimRaceKill[8] = StatManager.WispsKilled
    victimRaceKill[9] = StatManager.WolvesKilled
    victimRaceKill[10] = StatManager.WerewolvesKilled

    ; Creatures #2
    victimRaceKill[11] = StatManager.BlackBearsKilled
    victimRaceKill[12] = StatManager.BrownBearsKilled
    victimRaceKill[13] = StatManager.SnowBearsKilled
    victimRaceKill[14] = StatManager.SprigganMatronsKilled
    victimRaceKill[15] = StatManager.SpriggansKilled
    victimRaceKill[16] = StatManager.SabreCatsKilled
    victimRaceKill[17] = StatManager.SnowySabreCatsKilled
    victimRaceKill[18] = StatManager.TrollsKilled
    victimRaceKill[19] = StatManager.FrostTrollsKilled
    
    ; Set the kill count.
    victimRaceKill[aiVictimRaceID] = aiUpdateKillCount
    
    Debug.notification("Kill count: " +victimRaceKill[aiVictimRaceID]+ " Quest kill Count: " +StatManager.WolvesKilled)
EndFunction

 


I'm testing with killing wolves. They are in the 9th position in the array. When one is killed, the value of the array element is changed to 1 but the WolvesKilled(StatsManager.WolvesKilled) property on the Quest script remains at 0.

Is this a limitation of array assignment I've forgotten? How can I update the script properties using this method?

Things work out fine when I increment the stats like: StatManage.WolvesKilled += 1. Yeah that works. However, I wish to avoid coding long and tiring if/elseif chains and I'm not sure the Event I'm using is fast enough to process what's soon to be about 30 properties to update.

 

Link to comment
Share on other sites

The WolvesKilled property on the script assigned to the StatManager variable is not updating as expected. Correct?

 

I think the reason is that you are assigning the current property's value to the array and then updating the array. You are not updating the property value itself. I don't know what type of property WolvesKilled might be. As such I cannot give any advice as I do not want to say anything that would prove non-working.

 

That said, a method to achieve what you want:

WolvesKilled would need to be a GlobalVariable property. And VictimRaceKill would need to be a GlobalVariable array. Then the following could be used:

(victimRaceKill[aiVictimRaceID] as GlobalVariable).Mod(aiUpdateKillCount)

This grabs the stored global variable and modifies it up or down as needed.

Link to comment
Share on other sites

The WolvesKilled property on the script assigned to the StatManager variable is not updating as expected. Correct?

 

I think the reason is that you are assigning the current property's value to the array and then updating the array. You are not updating the property value itself. I don't know what type of property WolvesKilled might be. As such I cannot give any advice as I do not want to say anything that would prove non-working.

 

That said, a method to achieve what you want:

WolvesKilled would need to be a GlobalVariable property. And VictimRaceKill would need to be a GlobalVariable array. Then the following could be used:

(victimRaceKill[aiVictimRaceID] as GlobalVariable).Mod(aiUpdateKillCount)

This grabs the stored global variable and modifies it up or down as needed.

You're correct with your question.

 

My properties are all integer properties on a separate Quest script(the Stat Manager) which by default initialize to 0. These are to be updated by a story manager script and then the results sent to another script(all three scripts talk to each other).

 

I was afraid that was possibly the issue. Thanks, I'll try your method.

Edited by Rasikko
Link to comment
Share on other sites

Another method to consider, is to only use an Int array property in the StatManager script, which would mean you don't have to use Global Variables. In the StatManager script:

Int[] Property victimRaceKill Auto 

OnInit()
    VictimRaceKill = New Int[20]
EndEvent 

Then your function can just do:

 

Function RegisterForRaceKillCount(Int aiVictimRaceID, Int aiUpdateKillCount)
    Debug.notification("A kill count has been registered.")

    StatManager.victimRaceKill[aiVictimRaceID] = aiUpdateKillCount
    
EndFunction

And in your other scripts, instead of accessing the int properties, you just access the VictimRaceKill array.

Edited by dylbill
Link to comment
Share on other sites

Rasikko wrote: "I'm testing with killing wolves. They are in the 9th position in the array. When one is killed, the value of the array element is changed to 1

but the WolvesKilled(StatsManager.WolvesKilled) property on the Quest script remains at 0."

Function RegisterForRaceKillCount(Int aiVictimRaceID, Int aiUpdateKillCount)

  Int[] victimRaceKill = new Int[20]
 
  victimRaceKill[0] = StatManager.GiantsKilled
; ..
  victimRaceKill[9] = StatManager.WolvesKilled
; ..
  victimRaceKill[19]= StatManager.FrostTrollsKilled
 
; Set the kill count.
    victimRaceKill[aiVictimRaceID] = aiUpdateKillCount
EndFunction

Where do you have stored the value from "aiUpdateKillCount"?

Let us assume next values:

    aiVictimRaceID    = 9
    aiUpdateKillCount = 0   

now it will look as following

    victimRaceKill[9] = 0

that means your script code overwrite the array entry for "WolvesKilled".

Edited by ReDragon2013
Link to comment
Share on other sites

  • Recently Browsing   0 members

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