• 🏆 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!

Roll system problem

Status
Not open for further replies.

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,183
hello there i got another question in the world editor
so i wanted to make a roll system for my map but i did not really work.
so the problem is that the item wich is being rolled for dont being transferd to the wining unit.
i think that the problem is in this trigger but im not sure

  • Item Drop
  • Events
  • Unit - Aunit Loses an item
  • Conditions
  • Actions
  • Set Roll_for_this_item _ (Last dropped item)
  • Item - Remove (Last dropped item)
  • Trigger - Run roll for item <gen> (Ckecking conditions)
I has not added player blue (2) becuae thats a creep team

  • roll for item
  • Events
  • Conditions
  • Actions
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (Player 1 (Red) controller) Equal to User
    • Then - Actions
      • Set roll_count[1] = (Integer((String((Random integer number between 1 and 100)))))
      • Game - Display to (All players) the text: (Name of Player 1 (Red))
      • Game - Display to (All players) the text: Rolls for
      • Game - Display to (All players) the text: (String((Random integer number between 1 and 100)))
    • Else - Actions
      • Do nothing
  • Do nothing
  • Wait 4.00 seconds
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (Player 3 (Teal) controller) Equal to User
    • Then - Actions
      • Set roll_count[2] = (Integer((String((Random integer number between 1 and 100)))))
      • Game - Display to (All players) the text: (Name of Player 3 (Teal))
      • Game - Display to (All players) the text: Rolls for
      • Game - Display to (All players) the text: (String((Random integer number between 1 and 100)))
    • Else - Actions
      • Do nothing
  • Wait 4.00 seconds
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (Player 4 (Purple) controller) Equal to User
    • Then - Actions
      • Set roll_count[3] = (Integer((String((Random integer number between 1 and 100)))))
      • Game - Display to (All players) the text: (Name of Player 4 (Purple))
      • Game - Display to (All players) the text: Rolls for
      • Game - Display to (All players) the text: (String((Random integer number between 1 and 100)))
    • Else - Actions
      • Do nothing
  • Wait 4.00 seconds
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • roll_count[1] Greater than roll_count[2]
      • roll_count[1] Greater than roll_count[3]
    • Then - Actions
      • Game - Display to Player Group - Player 1 (Red) the text: You have won the ro...
      • Hero - Create (Item-type of Roll_for_this_item) and give it to Picked_Hero
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Item carried by Picked_Hero in slot 1) is owned) Equal to True
          • ((Item carried by Picked_Hero in slot 2) is owned) Equal to True
          • ((Item carried by Picked_Hero in slot 3) is owned) Equal to True
          • ((Item carried by Picked_Hero in slot 4) is owned) Equal to True
          • ((Item carried by Picked_Hero in slot 5) is owned) Equal to True
          • ((Item carried by Picked_Hero in slot 6) is owned) Equal to True
        • Then - Actions
          • Hero - Give (Last created item) to Banker
          • Game - Display to Player Group - Player 1 (Red) the text: Your Won Item has b...
        • Else - Actions
          • Do nothing
    • Else - Actions
      • Game - Display to Player Group - Player 1 (Red) the text: You have lost the r...
I will add rep + to those who help
 

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,190
You remove the item from the game. Thus when you try and reference its type in the trigger "roll for item" you pass it a removed item and get 0 which is not a valid item type.

Roll_for_this_item should be an integer (or "item type" in GUI for some reason) which you then assign the type of the item to before it gets removed. Thus later you will know which item type you have to create for the winning unit.

Do nothing does nothing but run an empty function call. Avoid using it.
You have substantial procedural coupling. Consider programming in such a way to reduce that for easier maintence and more efficient code.
 

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,183
i have tested some now and the problem is that the item wont go to the hero the rolling lose/win system works
it just says you have rolled <number>
and you won but the item dont goes to the hero

so i think the problem is
"set roll_for_this_item = last droped item
or the "hero create item type of roll for this item and give it to picked hero
 

Bannar

Code Reviewer
Level 26
Joined
Mar 19, 2008
Messages
3,140
I'll try to repair it step by step. At first, Last dropped item is wrong reference. Better use Item being manipulated.
  • Item Drop
  • Events
  • Unit - Aunit Loses an item
  • Conditions
  • Actions
  • Set Roll_for_this_item _ (Item type of (Item being manipulated)
  • Item - Remove (Item being manipulated)
  • Trigger - Run roll for item <gen> (Ckecking conditions)
If you really do not want blue to be playing as user but as cpu controler try to set players into variables at the begining of the game for furture purposes.
  • init
  • Events
    • Map initialization
  • Conditions
  • Actions
    • player[1] = Player 1 (Red)
    • player[2] = Player 3 (Teal)
    • player[3] = Player 4 (Purple)
Use two integers for checking who won roll. player[4] = winner. Dont convert inveter into string, and again string into integer, its silly.
roll_count[1] and roll_count[2] are 0 by default, but 2nd one will store highest amount.
  • roll for item
  • Events
  • Conditions
  • Actions
    • For each (Integer A) from 1 to 3 do Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (player[Integer A] controller) Equal to User
        • Then - Actions
          • Set roll_count[1] = (Random integer number between 1 and 100)
          • Game - Display to (All players) the text: ((Name of player[Integer A]) + (Rolls for + (String(roll_count[1]))))
          • Custom script: if (udg_roll_count[1] > udg_roll_count[2]) then
          • Set roll_count[2] = roll_count[1]
          • Set player[4] = player[Integer A]
          • Custom script: endif
          • Wait 4.00 seconds
        • Else - Actions
    • Set tempForce = (Player group (Player[4]))
    • Game - Display to tempForce the text: You have won the ro...
    • <further stuff>
Since I dont know what you want to do in next steps I left that part. Although I don't where you set Pickedhero and your actions are wierd, elaborae that.
 
Status
Not open for further replies.
Top