• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Overwrite value in Hashtable

Status
Not open for further replies.
Level 19
Joined
Aug 16, 2007
Messages
881
Why aren't you able to overwrite values in a hashtable? Something may be wrong, but I can't make it work. I've made a quest system for my map, to simple add and complete quests... The thing is I can't overwrite
  • Hashtable - Save False as 1 of LoopInt[1] in QuestCompleted_Hashtable
with
  • Hashtable - Save True as 1 of LoopInt[1] in QuestCompleted_Hashtable
Could you please check the triggers?


  • Quest Add and Complete
    • Events
      • Unit - A unit Acquires an item
    • Conditions
    • Actions
      • Set p[0] = (Owner of (Triggering unit))
      • Set PlayerGroup[0] = (Player group(p[0]))
      • For each (Integer LoopInt[0]) from 1 to Quest_MaxQuests, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item-type of (Item being manipulated)) Equal to Quest_Item[LoopInt[0]]
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Hero level of (Triggering unit)) Greater than or equal to Quest_Required_Level[LoopInt[0]]
                • Then - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Load LoopInt[0] of (Player number of p[0]) from QuestAccepted_Hashtable) Equal to False
                    • Then - Actions
                      • Unit - Add Quest_Ability[LoopInt[0]] to (Triggering unit)
                      • Hashtable - Save True as LoopInt[0] of (Player number of p[0]) in QuestAccepted_Hashtable
                      • Hashtable - Save False as LoopInt[0] of (Player number of p[0]) in QuestCompleted_Hashtable
                      • Game - Display to PlayerGroup[0] for 5.00 seconds the text: (Quest Accepted: + (Name of (Item being manipulated)))
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Load LoopInt[0] of (Player number of p[0]) from QuestCompleted_Hashtable) Equal to True
                        • Then - Actions
                          • Unit - Remove Quest_Ability[LoopInt[0]] from (Triggering unit)
                          • Game - Display to PlayerGroup[0] for 5.00 seconds the text: (Quest Completed: + (Name of (Item being manipulated)))
                          • Hero - Add Quest_ExpReward[LoopInt[0]] experience to (Triggering unit), Show level-up graphics
                          • Player - Add Quest_GoldReward[LoopInt[0]] to p[0] Current gold
                          • Hashtable - Save False as LoopInt[0] of (Player number of p[0]) in QuestCompleted_Hashtable
                        • Else - Actions
                          • Game - Display to PlayerGroup[0] for 5.00 seconds the text: You have already ac...
                • Else - Actions
                  • Game - Display to PlayerGroup[0] for 5.00 seconds the text: You do not meet up ...
            • Else - Actions
      • Custom script: call DestroyForce(udg_PlayerGroup[0])


  • Quest 1 Child Rescued
    • Events
      • Unit - A unit enters Quest1ChildsRescuePoint <gen>
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Lost Child (Quest 1)
    • Actions
      • For each (Integer LoopInt[1]) from 1 to 10, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Triggering unit) Equal to Quest_ChildsMissing_EventUnit[LoopInt[1]]
            • Then - Actions
              • Game - Display to (All players) the text: (String(LoopInt[1]))
              • >>>>Hashtable - Save True as 1 of LoopInt[1] in QuestCompleted_Hashtable<<<<
              • Set Quest_ChildsMissing_EventOn[LoopInt[1]] = False
              • Unit - Hide (Triggering unit)
              • Unit - Kill (Triggering unit)
              • Set Quest_ChildsMissing_EventUnit[LoopInt[1]] = No unit
              • Set PlayerGroup[0] = (Player group((Player(LoopInt[1]))))
              • Game - Display to PlayerGroup[0] for 5.00 seconds the text: Child got home! Go ...
              • Custom script: call DestroyForce(udg_PlayerGroup[0])
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Load 1 of LoopInt[1] from QuestCompleted_Hashtable) Equal to True
                • Then - Actions
                  • Game - Display to (All players) the text: true
                • Else - Actions
                  • Game - Display to (All players) the text: false
            • Else - Actions


As you can see, when I take the quest I save the QuestCompleted_Hashtable boolean as false and when I completed the quest I set it as true, but that doesn't work...

Thanks.

Edit: I'm using two hashtables to store two booleans, in order to check three things:

Accepted(False) + Completed(False) = New Quest
Accepted(True) + Completed(False) = Text: You have already accepted/completed this quest!
Accepted(True) + Completed(True) = Reward
 
a)
  • (Load LoopInt[0] of (Player number of p[0]) from QuestCompleted_Hashtable) Equal to True
You make a check about LoopInt[0], when you set the quest to be completed as LoopInt[1]

b)
  • Unit - Add Quest_Ability[LoopInt[0]] to (Triggering unit)
    • Hashtable - Save True as LoopInt[0] of (Player number of p[0]) in QuestAccepted_Hashtable
    • Hashtable - Save False as LoopInt[0] of (Player number of p[0]) in QuestCompleted_Hashtable
You have two actions in there, you don't need the first one, since it will return false anyway.

The problem I see is that you make the checks as LoopInt[0], when it should be LoopInt[1].
 
Level 19
Joined
Aug 16, 2007
Messages
881
Well, I don't really think that's the problem actually. Because this debug text:


  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
  • If - Conditions
    • (Load 1 of LoopInt[1] from QuestCompleted_Hashtable) Equal to True
    • Then - Actions
      • Game - Display to (All players) the text: true
    • Else - Actions
      • Game - Display to (All players) the text: false
always returns false...
 
The default value of a boolean is always false, this is why you get that. Plus, why don't you use instead of:
  • Hashtable - Save True as 1 of LoopInt[1] in QuestCompleted_Hashtable
the
  • Hashtable - Save True as 1 of (Key (Owner of (Triggering unit))) in QuestCompleted_Hashtable
I didn't see you involved loop in it. You had better add a more stable value, like the one I suggested.
 
Level 19
Joined
Aug 16, 2007
Messages
881
Well, I know it's always false, so I removed the action storing it as false in the Accept/complete trigger, but it still doesn't work.

Your example with
  • Hashtable - Save True as 1 of (Key (Owner of (Triggering unit))) in QuestCompleted_Hashtable
won't work because the "child" is owned by player 11.


EDIT: Nevermind, I've got this to work now! :) Thanks anyway Pharaoh_ +rep
 
Last edited:
Status
Not open for further replies.
Top