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

Codegen 1.0.2

Status
Not open for further replies.
Level 3
Joined
Mar 1, 2018
Messages
41
I've been trying to use this system on a map and it's doing strange things that are a bit hard for me to debug:

I've added some functions in GUI to help - like say the name of the ability being saved and the level, when I load I get the right name and level most of the time, but the abilities are not added to my hero.

With items sometimes (if I save a big number of items, the items are saved, other times they are not)

Also, sometimes I save and get a code, then load and get less abilities or items, then save and get a diferent code... something like
load a code
save without changing anything - but the code now is diferent? for the same things!?

is the "saveload_maxvalue" the problem? wich value should it be for certain number of integers?
how to know the right value?

last time i checked, 3 out of 5 abilities were saved

the system link:
CodeGen 1.0.2
 
Last edited:

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,196
You will need to link the system for people to have some idea what you are asking about.

Make sure that all abilities and items that you want saved are registered with the system. Also make sure the range of all fields that are saved is sufficient for the hero being saved.
 
Level 3
Joined
Mar 1, 2018
Messages
41
Thanks I just added the link, I've made sure of all that even before copying into my map I tested adding some abilities in the test map

Added the option to save wood, and to make the hero drop the items in a region and save all the items in that region (I also save an "item counter" before saving items, so when loading items in region I load the counter and run a loop from 1 to the counter)

but just now i've tested and even in the test map, if I start to drop 10 or more items in the item region, the codes start to get scrambled and loading a code and saving exactly the same things will start to generate diferent codes for the same objects being saved.

should I paste the triggers from the test map? or the ones from the other map?
 
Level 3
Joined
Mar 1, 2018
Messages
41
I think I found the reason the codes are getting "scrambled", if I load once and save once, it's ok, but after 1 save and 1 load, if I save a 2nd time in the same "game" the 2nd save becomes "scrambled" and gives items that I didn't have, etc...
It's like the rule of only save once every game.
 
Level 3
Joined
Mar 1, 2018
Messages
41
Thanks TriggerHappy I would be very happy to use the most advanced systems you have but when I open the test map some problems happen...

I can ctrl+F9 and test - everything works perfectly

However, if i try to save your test map with a diferent name things go sideways - just by saving with my editor the map gives me a fatal error when I try to test it.

The editor is JassNewGenPack
Also happens with Vanilla from 1.27a
Also happens with Sharpcraft (and I do have all requirements installed) (sharpcraft seems to work fine)
I'm not sure if I also tried your codeless system in 1.28b and it also got me fatal error.

This is v1.3.9 if I just save the test map with the name "test" and run it this is the result:


on v3.00 pjass gives me 13 compile errors if I save, goes to WC3 start menu when I "test map"
on v2.00 world edit crashes when I opne the test map
v1.3.9 is the only version i am able to test


From what I remember changing saveload_maxvalue could cause some issues.

At this moment I have 18 items only in consumables and only 14 abilities ... I think I tried leaving it at 7 but some of the stuff wasn't getting saved.
I could ignore saving abilities but it would be too bad since I would like players to be "forced" to stick to their build instead of being able to change their characters build anytime they wanted.
(kinda like one of the worst things that has happened to diablo from D2 to D3...)
 
Last edited:
Level 3
Joined
Mar 1, 2018
Messages
41
yes i knew when I tried and was expecting it not to work but the fatal error happens in v1.3.9 wich was where I tried first I was hoping it worked on other editors but it didn't and tried the newer versions as a desperation attempt

I forgot but I can't even try vanilla because of the doodad limit I only made 30% of the map and I'm already 300 doodads over the limit
 
Last edited:
Level 3
Joined
Mar 1, 2018
Messages
41
Here are the changes I made to the testmap triggers (before importing) to get the system to save wood, items in region, and points for each unit ability level

I had it on 19 and it was able to perform perfectly if I only save and load once every test, saving and loading a 2nd time will create a scrambled code.

the last time I used 7 max value, it either saved only half of the items in the region or saved most of the items but no abilities... also on the last test with 7 I saved 4rings + 4orbs lvl3 bloodmage with 2 abilities, got back 2rings 4 orbs blood mage with 8100 intelligence

Codegen ini
  • CodeGen Init Copy
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- -------------------- --------
      • -------- The below options are for saving load codes to the Warcraft III folder. --------
      • -------- You can modify the filename via the SaveLoad_Filename variable within the save trigger. --------
      • -------- -------------------- --------
      • Set SaveLoad_SaveToDisk = True
      • Set SaveLoad_Directory = Save
      • -------- -------------------- --------
      • -------- Some configurables --------
      • -------- -------------------- --------
      • Set SaveLoad_Alphabet = abcdefghkmnopqrstuvwxyzABCDEFGHJKLMNOPQRSTUVWXYZ0123456789
      • Set SaveLoad_CheckName = True
      • Set SaveLoad_Security = True
      • Set SaveLoad_HyphenSpace = 5
      • Set SaveLoad_SeperationChar = -
      • Set SaveLoad_Lower = |c002a4580
      • Set SaveLoad_Number = |cffffcc00
      • Set SaveLoad_Upper = |cff008000
      • -------- -------------------- --------
      • -------- Increase the value if you want to save bigger numbers --------
      • -------- Decrease it if you want to generate a smaller save code but only be able to save smaller values --------
      • -------- It's suggested to not increase it above 7 --------
      • -------- -------------------- --------
      • Set SaveLoad_MaxValue = 19
      • -------- -------------------- --------
      • -------- Store all the heroes you want to be able to be saved below. --------
      • -------- -------------------- --------
      • Set SaveLoad_Hero[0] = Blood Mage
      • Set SaveLoad_Hero[1] = Lich
      • Set SaveLoad_Hero[2] = Blademaster
      • Set SaveLoad_Hero[3] = Demon Hunter
      • Set SaveLoad_HeroCount = 3
      • -------- -------------------- --------
      • -------- Store all the abilities you want to be able to be saved below. --------
      • -------- -------------------- --------
      • Set SaveLoad_Abilities[0] = Flame Strike
      • Set SaveLoad_Abilities[1] = Siphon Mana
      • Set SaveLoad_Abilities[2] = Phoenix
      • Set SaveLoad_Abilities[3] = Banish
      • Set SaveLoad_Abilities[4] = Bash
      • Set SaveLoad_Abilities[5] = Chain Lightning
      • Set SaveLoad_AbilityCount = 5
      • -------- -------------------- --------
      • -------- ******************************************************* Unit Ability to save pts --------
      • Set Unit_Ability[0] = Cripple test
      • Set Unit_Ability[1] = Curse test
      • Set Unit_Ability_Count = 1
      • -------- -------------------- --------
      • -------- Store all the items you want to be able to be saved below. --------
      • -------- -------------------- --------
      • Set SaveLoad_Item[0] = (Item-type of No item)
      • Set SaveLoad_Item[1] = Claws of Attack +15
      • Set SaveLoad_Item[2] = Crown of Kings +5
      • Set SaveLoad_Item[3] = Kelen's Dagger of Escape
      • Set SaveLoad_Item[4] = Mask of Death
      • Set SaveLoad_Item[5] = Orb of Frost
      • Set SaveLoad_Item[6] = Ring of Protection +5
      • Set SaveLoad_ItemCount = 6
      • -------- -------------------- --------
      • -------- Don't modify below this line. --------
      • -------- This is just here to copy variables to your map --------
      • -------- -------------------- --------
      • Set SaveLoad_Full = SaveLoad_Alphabet
      • Set SaveLoad_Error = <Empty String>
      • Set SaveLoad_Base = (Length of SaveLoad_Alphabet)
      • Set SaveLoad_Char[0] = <Empty String>
      • Set Load[0] = 0
      • Set LoadCount = 0
      • Custom script: call CodeGen_Init()
SaveTrigger
  • Save Abilities Copy
    • Events
      • Player - Player 1 (Red) types a chat message containing -save as An exact match
      • Player - Player 2 (Blue) types a chat message containing -save as An exact match
      • Player - Player 3 (Teal) types a chat message containing -save as An exact match
      • Player - Player 4 (Purple) types a chat message containing -save as An exact match
    • Conditions
    • Actions
      • -------- Find the players hero, and save it. I realize it leaks but it's just for demonstration. --------
      • Set SaveCount = 0
      • Unit Group - Pick every unit in (Units owned by (Triggering player) matching (((Matching unit) is A Hero) Equal to True)) and do (Set Hero = (Picked unit))
      • Custom script: set udg_Save[udg_SaveCount] = CodeGen_ConvertUnit(GetUnitTypeId(udg_Hero))
      • -------- kill the dummies - save unit without modifiers!! --------
      • Unit - Remove All buffs from Hero
      • Unit - Move Hero instantly to (Center of itemsave <gen>)
      • -------- drop items from inv!!! --------
      • Hero - Drop the item from slot 1 of Hero
      • Hero - Drop the item from slot 2 of Hero
      • Hero - Drop the item from slot 3 of Hero
      • Hero - Drop the item from slot 4 of Hero
      • Hero - Drop the item from slot 5 of Hero
      • Hero - Drop the item from slot 6 of Hero
      • -------- Save heroes level. --------
      • Set SaveCount = (SaveCount + 1)
      • Set Save[SaveCount] = (Hero level of Hero)
      • -------- Save STR --------
      • Set SaveCount = (SaveCount + 1)
      • Set Save[SaveCount] = (Strength of Hero (Exclude bonuses))
      • Set SaveCount = (SaveCount + 1)
      • Set Save[SaveCount] = (Agility of Hero (Exclude bonuses))
      • Set SaveCount = (SaveCount + 1)
      • Set Save[SaveCount] = (Intelligence of Hero (Exclude bonuses))
      • -------- Save players gold. --------
      • Set SaveCount = (SaveCount + 1)
      • Set Save[SaveCount] = ((Triggering player) Current gold)
      • -------- WOOD --------
      • Set SaveCount = (SaveCount + 1)
      • Set Save[SaveCount] = ((Triggering player) Current lumber)
      • -------- ******************* SAVE UNIT ABILITY AS POINTS --------
      • Set UNIT_uniAbility_Lvls = 0
      • For each (Integer A) from 0 to Unit_Ability_Count, do (Actions)
        • Loop - Actions
          • Set UNIT_uniAbility_Lvls = (UNIT_uniAbility_Lvls + (Level of Unit_Ability[(Integer A)] for Hero))
          • -------- because of starting lvl1 --------
          • Set UNIT_uniAbility_Lvls = (UNIT_uniAbility_Lvls - 1)
      • Set SaveCount = (SaveCount + 1)
      • Set Save[SaveCount] = UNIT_uniAbility_Lvls
      • -------- Save heroes items. --------
      • -------- Save heroes items. --------
      • Set SaveCount = (SaveCount + 1)
      • Item - Pick every item in itemsave <gen> and do (Actions)
        • Loop - Actions
          • Set SaveItemRegionNR = (SaveItemRegionNR + 1)
      • -------- Nr of items --------
      • Set Save[SaveCount] = SaveItemRegionNR
      • Item - Pick every item in itemsave <gen> and do (Actions)
        • Loop - Actions
          • Set SaveCount = (SaveCount + 1)
          • Set Item = (Picked item)
          • Custom script: set udg_Save[udg_SaveCount] = CodeGen_ConvertItem(GetItemTypeId(udg_Item))
      • -------- Save heroes skills --------
      • For each (Integer A) from 0 to SaveLoad_AbilityCount, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of SaveLoad_Abilities[(Integer A)] for Hero) Greater than 0
            • Then - Actions
              • -------- save skill level --------
              • Set SaveCount = (SaveCount + 1)
              • Set Save[SaveCount] = (Level of SaveLoad_Abilities[(Integer A)] for Hero)
              • Game - Display to (All players) the text: (String(Save[SaveCount]))
              • Set SaveCount = (SaveCount + 1)
              • Custom script: set udg_Save[udg_SaveCount] = bj_forLoopAIndex
            • Else - Actions
      • -------- ************************************************************************************************************ --------
      • -------- -------------------- --------
      • -------- Set the filename for where the loadcode will be stored. --------
      • -------- -------------------- --------
      • Set SaveLoad_Directory = Save
      • Set SaveLoad_Filename = (((testmap) + (Name of (Triggering player))) + ('s + ( + (((Name of Hero) + <Empty String>) + .txt))))
      • -------- Show Code --------
      • Custom script: set udg_Code = CodeGen_Compile()
      • Game - Display to (Player group((Triggering player))) for 60.00 seconds the text: Code
Load Trigger
  • Load Abilities Copy
    • Events
      • Player - Player 1 (Red) types a chat message containing -load as A substring
      • Player - Player 2 (Blue) types a chat message containing -load as A substring
      • Player - Player 3 (Teal) types a chat message containing -load as A substring
      • Player - Player 4 (Purple) types a chat message containing -load as A substring
    • Conditions
      • (String((Substring((Entered chat string), 1, 6))) as Lower case) Equal to -load
    • Actions
      • -------- Check if load is valid --------
      • Set Code = (Substring((Entered chat string), 7, 999))
      • Custom script: call CodeGen_Load(udg_Code)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • SaveLoad_Valid Equal to False
        • Then - Actions
          • Game - Display to (Player group((Triggering player))) for 10.00 seconds the text: SaveLoad_Error
          • Skip remaining actions
        • Else - Actions
      • -------- Start loading, load the hero first. --------
      • Set LoadCount = 0
      • Unit Group - Pick every unit in (Units owned by (Triggering player) matching (((Matching unit) is A Hero) Equal to True)) and do (Unit - Remove (Picked unit) from the game)
      • Unit - Create 1 SaveLoad_Hero[Load[LoadCount]] for (Triggering player) at ((Triggering player) start location) facing Default building facing degrees
      • Set Hero = (Last created unit)
      • Selection - Select (Last created unit) for (Triggering player)
      • -------- Load heroes level --------
      • Set LoadCount = (LoadCount + 1)
      • Hero - Set (Last created unit) Hero-level to Load[LoadCount], Hide level-up graphics
      • -------- Load STR --------
      • Set LoadCount = (LoadCount + 1)
      • Hero - Modify Strength of Hero: Set to Load[LoadCount]
      • Set LoadCount = (LoadCount + 1)
      • Hero - Modify Agility of Hero: Set to Load[LoadCount]
      • Set LoadCount = (LoadCount + 1)
      • Hero - Modify Intelligence of Hero: Set to Load[LoadCount]
      • -------- Now load players gold --------
      • Set LoadCount = (LoadCount + 1)
      • Player - Set (Triggering player) Current gold to Load[LoadCount]
      • -------- Load WOOD --------
      • Set LoadCount = (LoadCount + 1)
      • Player - Set (Triggering player) Current lumber to Load[LoadCount]
      • -------- ******************* LOAD UNIT ABILITY PTS --------
      • Set LoadCount = (LoadCount + 1)
      • Set Unit_Ability_PlayerPTS[(Player number of (Triggering player))] = Load[LoadCount]
      • -------- Now items --------
      • -------- Now items --------
      • Item - Pick every item in itemsave <gen> and do (Actions)
        • Loop - Actions
          • Item - Remove (Picked item)
      • Set LoadCount = (LoadCount + 1)
      • Set ItemCount = Load[LoadCount]
      • For each (Integer A) from 1 to Load[LoadCount], do (Actions)
        • Loop - Actions
          • Set LoadCount = (LoadCount + 1)
          • Item - Create SaveLoad_Item[Load[LoadCount]] at (Random point in itemsave <gen>)
      • -------- abilities --------
      • For each (Integer A) from 1 to 5, do (Actions)
        • Loop - Actions
          • Set LoadCount = (LoadCount + 1)
          • Set AbilityLevel = Load[LoadCount]
          • Game - Display to (All players) the text: (String(AbilityLevel))
          • Set LoadCount = (LoadCount + 1)
          • For each (Integer B) from 1 to AbilityLevel, do (Actions)
            • Loop - Actions
              • Custom script: call SelectHeroSkill(udg_Hero, udg_SaveLoad_Abilities[udg_Load[udg_LoadCount]])
 
Last edited:
Status
Not open for further replies.
Top