- Joined
- Aug 14, 2006
- Messages
- 7,602
Hey!
This JASS trigger is made by Eleandor. But he have not been online for ages and that is why I put the problem to here so it will be fixed soon as possible. The one who can help me will get some REP and credits at the campaign.
This is a campaign. The problem is, that Eleandor made for me a spell book system, where spells are saved in spell books that will be SAVE/LOAD(STORE/RESTORE). The system is working almost perfectly(let's forget one problem for now). But the actually problem is, that chapter 5 and chapter 6 is like "crossroad" chapters where there will be two load trigger(all other chapters have only 1 load triggers). I mean:
So, what I want from you actually? I want you to repair this load trigger somehow and make everything to work clearly.
So, as you can see, I use in both load triggers this action:
Currently, when I load the map. Hero 1 have hero 2's all abilities, but hero 2 doens't have anything(even the spell book).
If you need to have more information or anything, ask freely. I will happily answer to you. This have been bothering for me quite a long time. I don't understand anything about JASS and I do everything by GUI.
This JASS trigger is made by Eleandor. But he have not been online for ages and that is why I put the problem to here so it will be fixed soon as possible. The one who can help me will get some REP and credits at the campaign.
This is a campaign. The problem is, that Eleandor made for me a spell book system, where spells are saved in spell books that will be SAVE/LOAD(STORE/RESTORE). The system is working almost perfectly(let's forget one problem for now). But the actually problem is, that chapter 5 and chapter 6 is like "crossroad" chapters where there will be two load trigger(all other chapters have only 1 load triggers). I mean:
- Hero 1 can be played in chapter 1, 4, 5, 6, ...
- Hero 2 can be played in chapter 2, 5, 6 ...
- Hero 3 can be played in chapter 3, 6 ..
- So, the problem is in chapter 5 and 6. Because there will be two times load trigger. Chapter 5 have to load Hero 1 and 2. And chapter 6 have to load Hero 1, 2 and 3. So, in chapter 5 and 6 there's 2 load trigger that mixes up everything.
So, what I want from you actually? I want you to repair this load trigger somehow and make everything to work clearly.
JASS:
function GetSpellBook takes nothing returns integer
return 'A6AU'
endfunction
function CreateSpell takes integer itemid, integer spellbookid, integer spellid returns nothing
local integer p = 0
set udg_Spell_System_last = udg_Spell_System_last + 1
set udg_Spell_System_item[udg_Spell_System_last] = itemid
set udg_Spell_System_abil[udg_Spell_System_last] = spellbookid
set udg_Spell_System_spell[udg_Spell_System_last] = spellid
loop
exitwhen p > 12
call SetPlayerAbilityAvailable(Player(p), udg_Spell_System_abil[udg_Spell_System_last], false)
set p = p + 1
endloop
endfunction
function UnitAddSpell takes unit u, integer itemid returns boolean
local integer i = 0
set udg_Spell_System_success = false
loop
exitwhen i > udg_Spell_System_last
if (udg_Spell_System_item[i] == itemid) then
if GetUnitAbilityLevel(u, udg_Spell_System_abil[i]) <= 0 then
call UnitAddAbility(u, udg_Spell_System_abil[i])
set udg_Spell_System_success = true
return true
else
call SetUnitAbilityLevel(u, udg_Spell_System_spell[i], GetUnitAbilityLevel(u, udg_Spell_System_spell[i]) + 1)
set udg_Spell_System_success = true
return true
endif
endif
set i = i + 1
endloop
return false
endfunction
function UnitRemoveSpell takes unit u, integer abilid returns boolean
local integer i = 0
loop
exitwhen i > udg_Spell_System_last
if udg_Spell_System_spell[i] == abilid then
if GetUnitAbilityLevel(u, udg_Spell_System_abil[i]) <= 0 then
return false
else
call UnitRemoveAbility(u, udg_Spell_System_abil[i])
set udg_Spell_System_success = true
return true
endif
endif
set i = i + 1
endloop
return false
endfunction
function StoreHero takes gamecache cache, string missionkey, string key, unit whichunit, boolean loadspells returns nothing
local integer i = 0
call StoreBoolean(cache, missionkey, key + "loadspells", loadspells)
if udg_Spell_System_Active then
loop
exitwhen i > udg_Spell_System_last
if GetUnitAbilityLevel(whichunit, udg_Spell_System_abil[i]) > 0 then
call StoreInteger(cache, missionkey, key + "spell" + I2S(i), GetUnitAbilityLevel(whichunit, udg_Spell_System_spell[i]))
if not UnitRemoveAbility(whichunit, udg_Spell_System_abil[i]) then
call BJDebugMsg("could not remove the ability")
endif
//call BJDebugMsg("Level of spell " + I2S(i) + " = " + I2S(GetUnitAbilityLevel(whichunit, udg_Spell_System_spell[i])))
else
call StoreInteger(cache, missionkey, key + "spell" + I2S(i), 0)
endif
set i = i + 1
endloop
endif
call UnitRemoveAbility(whichunit, GetSpellBook())
call TriggerSleepAction(0.0)
call StoreUnit(cache, missionkey, key, whichunit)
endfunction
function RestoreHero takes gamecache cache, string missionkey, string key, player whichplayer, location whichloc, real angle returns unit
local integer i = 0
set bj_lastLoadedUnit = RestoreUnit(cache, missionkey, key, whichplayer, GetLocationX(whichloc), GetLocationY(whichloc), angle)
call TriggerSleepAction(0.0)
if GetStoredBoolean(cache, missionkey, key + "loadspells") == true then
call UnitAddAbility(bj_lastLoadedUnit, GetSpellBook())
if udg_Spell_System_Active then
loop
exitwhen i > udg_Spell_System_last
if HaveStoredInteger(cache, missionkey, key + "spell" + I2S(i)) then
if GetStoredInteger(cache, missionkey, key + "spell" + I2S(i)) > 0 then
call UnitAddAbility(bj_lastLoadedUnit, udg_Spell_System_abil[i])
//call BJDebugMsg("Loading spell " + I2S(i) + ": " + I2S(GetUnitAbilityLevel(bj_lastLoadedUnit, udg_Spell_System_spell[i])))
call SetUnitAbilityLevel(bj_lastLoadedUnit, udg_Spell_System_spell[i], GetStoredInteger(cache, missionkey, key + "spell" + I2S(i)))
endif
else
call BJDebugMsg("")
endif
set i = i + 1
endloop
endif
endif
return bj_lastLoadedUnit
endfunction
-
Load From Chapter 4
-
Events
- Time - Elapsed game time is 2.00 seconds
- Conditions
-
Actions
- -------- === LOAD GAME CACHE === --------
- Game Cache - Create a game cache from TCOCache_4.w3v
- Set GameCache = (Last created game cache)
- -------- === LOAD SPELL BOOK === --------
- Set Spell_System_Active = (Load SpellSystemActive of Spells from GameCache)
- -------- === LOAD HERO SPELLS === --------
- -------- === PHODOM === --------
- -------- === LOAD HEROES === --------
- Set TempLoc = (Center of Phodom Load <gen>)
- Custom script: call RestoreHero ( udg_GameCache, "TCO_Heroes", "TCO_Phodom", Player(0), udg_TempLoc, 0.00 )
- Set AAAPhodom = (Last restored unit)
- Custom script: call RemoveLocation(udg_TempLoc)
- -------- === LOAD RESOURCES === --------
- Player - Set Player 1 (Red) Current gold to (Load TCO_Gold of TCO_Resources from (Last created game cache))
- Player - Set Player 1 (Red) Current lumber to (Load TCO_Wood of TCO_Resources from (Last created game cache))
-
Events
-
Load From Chapter 2
-
Events
- Time - Elapsed game time is 0.00 seconds
- Conditions
-
Actions
- -------- === LOAD GAME CACHE === --------
- Game Cache - Create a game cache from TCOCache_2.w3v
- Set GameCache = (Last created game cache)
- -------- === LOAD SPELL BOOK === --------
- Set Spell_System_Active = (Load SpellSystemActive of Spells from GameCache)
- -------- === LOAD HERO SPELLS === --------
- -------- === FRADZ === --------
- -------- === LOAD HEROES === --------
- Set TempLoc = (Center of Fradz Load <gen>)
- Custom script: call RestoreHero ( udg_GameCache, "TCO_Heroes", "TCO_Fradz", Player(0), udg_TempLoc, 0.00 )
- Set AAAFradz = (Last restored unit)
- Custom script: call RemoveLocation(udg_TempLoc)
-
Events
So, as you can see, I use in both load triggers this action:
- Set Spell_System_Active = (Load SpellSystemActive of Spells from GameCache)
Currently, when I load the map. Hero 1 have hero 2's all abilities, but hero 2 doens't have anything(even the spell book).
If you need to have more information or anything, ask freely. I will happily answer to you. This have been bothering for me quite a long time. I don't understand anything about JASS and I do everything by GUI.
Last edited: