[General] Quest Variable Indexing [Need help!]

Status
Not open for further replies.
Level 4
Joined
Aug 22, 2010
Messages
54
So i've created my own quest system which works, however - i'm optimizing the system, and this requires a better index system than what i have now.

I define all the required quest variables at the start of the map with a standard array.

My issue is i'm using the array for QUEST INDEX, not for calling player number. I'm currently keeping track of the player kills and the state of the quests for each player, with variables for each player.
The quests are MUI - but it's extremely tedious, when coding in GUI.

Quest_Array
= Quest_Array + 1
Quest_Name(Quest_Array) = Maintaining Balance
Quest_Description(Quest_Array) = Slay 10 wolves.
Quest_UnitType(Quest_Array) = Wolf
Quest_AmountRequired(Quest_Array) = 10
Quest_Player1Kills(Quest_Array) = 0
Quest_Player2Kills(Quest_Array) = 0
Quest_Player3Kills(Quest_Array) = 0
Quest_Player4Kills(Quest_Array) = 0


I would like to store player kills like this instead for easier access of the variables when coding triggers:
Quest_PlayerKills(Quest_Array, Player_Number) or something like that. Instead of having 4 variables with the same array.

Quest_Array = Quest_Array + 1
Quest_Name(Quest_Array) = Maintaining Balance
Quest_Description(Quest_Array) = Slay 10 wolves.
Quest_UnitType(Quest_Array) = Wolf
Quest_AmountRequired(Quest_Array) = 10
Quest_PlayerKills(Quest_Array, Player_Number) = 0

This would make If/then/else statements way shorter in triggers.
I would like to avoid hashtables all together if possible.

Example: Current method

Event
A unit dies

For each Integer A from 1 to Quest_Array do
If TriggeringUnit = Quest_Unit(Integer_A) then
If Get:TriggeringPlayer(Get:OwnerOf(Killing Unit)) = 1 then
Quest_Player1Kills(Quest_Array) = Quest_Player1Kills(Quest_Array) + 1
else
If Get:TriggeringPlayer(Get:OwnerOf(Killing Unit)) = 2 then
Quest_Player2Kills(Quest_Array) = Quest_Player2Kills(Quest_Array) + 1
else
If Get:TriggeringPlayer(Get:OwnerOf(Killing Unit)) = 3 then
Quest_Player3Kills(Quest_Array) = Quest_Player3Kills(Quest_Array) + 1
else
If Get:TriggeringPlayer(Get:OwnerOf(Killing Unit))= 4 then
Quest_Player4Kills(Quest_Array) = Quest_Player4Kills(Quest_Array) + 1
else


Example: Goal

Event
A unit dies

For each Integer A from 1 to Quest_Array do
If TriggeringUnit = Quest_Unit(Integer_A) then
Quest_PlayerKills(Quest_Array, Get:TriggeringPlayer(Get:OwnerOf(Killing Unit)) = Quest_PlayerKills(Quest_Array, Get:TriggeringPlayer(Get:OwnerOf(Killing Unit)) + 1
else
 
Last edited:
Level 6
Joined
Aug 28, 2015
Messages
213
You can set a variable "Quest_MaxPlayer" to the amount of maximum playing player and do:

set Quest_PlayerNumber = GetOwnerOf(Killing Unit)
set Quest_DiedType = GetUnittypeOf(triggering unit)

for (Quest_Array) from (1) to (Quest_MaxQuestNumber) do:
--if (Unit Type(Quest_DiedType)) equals (Unit Type(Quest_UnitType)) then:
----Quest_PlayerKills((Quest_Array * Quest_MaxPlayer) + Quest_PlayerNumber) += 1
 
Status
Not open for further replies.
Top