• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] [need help] jass script kills all triggers

Status
Not open for further replies.
Level 6
Joined
Feb 18, 2005
Messages
263
Hi
i wrote a little jass script, that should simply manage some harmless way to learn skills when getting an item. Include some requirements and stuff, but without gamecache.

But once i finished the scripting, compiled it (without any errors) and tested it, i saw that no trigger i had added did anything at all.
I tested adding some simple new ones, or to copy 'n' paste my jass into a new map. but neither way was successfull.

Could anyone please help me fixing thos script?

Code:
function foo takes nothing returns nothing
    local integer tmp_item
    //for each item that teaches a skill do
        //summon Bear
        set tmp_item = 'I001'
        set udg_item_req_str[tmp_item]           = 0
        set udg_item_req_agi[tmp_item]           = 0
        set udg_item_req_int[tmp_item]           = 100 //average IQ
        set udg_item_req_lvl[tmp_item]           = 0
        set udg_item_spellbook_ability[tmp_item] = 'A00A' //the summon bear spellbook
        set udg_item_ability[tmp_item]           = 'A006' //the summon bear spell
        set udg_item_max_lvl[tmp_item]           = 1
        set udg_item_rarity[tmp_item]            = 1 //the higher the number the higher the chance for this item to be picked
        set udg_item_color[tmp_item]             = 1 //0=all, 1=elf, 2=human, 3=undead -> maybe later 5 colors + artifacts as in MtG

        //summon Falcon
        set tmp_item = 'I000'
        set udg_item_req_str[tmp_item]           = 0
        set udg_item_req_agi[tmp_item]           = 0
        set udg_item_req_int[tmp_item]           = 90 //easy spell
        set udg_item_req_lvl[tmp_item]           = 0
        set udg_item_spellbook_ability[tmp_item] = 'A00C' //the summon falcon spellbook
        set udg_item_ability[tmp_item]           = 'A007' //the summon falcon spell
        set udg_item_max_lvl[tmp_item]           = 1
        set udg_item_rarity[tmp_item]            = 1 //the higher the number the higher the chance for this item to be picked
        set udg_item_color[tmp_item]             = 1 //0=all, 1=elf, 2=human, 3=undead -> maybe later 5 colors + artifacts as in MtG

        //summon Quillbeast
        set tmp_item = 'I002'
        set udg_item_req_str[tmp_item]           = 0
        set udg_item_req_agi[tmp_item]           = 0
        set udg_item_req_int[tmp_item]           = 0
        set udg_item_req_lvl[tmp_item]           = 0
        set udg_item_spellbook_ability[tmp_item] = 'A00D' //the summon quillbeast spellbook
        set udg_item_ability[tmp_item]           = 'A005' //the summon quillbeast spell
        set udg_item_max_lvl[tmp_item]           = 1
        set udg_item_rarity[tmp_item]            = 1 //the higher the number the higher the chance for this item to be picked
        set udg_item_color[tmp_item]             = 1 //0=all, 1=elf, 2=human, 3=undead -> maybe later 5 colors + artifacts as in MtG
    //endfor
endfunction

function error takes string message returns nothing
	call DisplayTextToForce( GetPlayersAll(), message )
endfunction

function learnSkillFromItem takes unit hero, integer myitem returns boolean
	local integer is_str = GetHeroStatBJ(bj_HEROSTAT_STR, hero, false)
	local integer is_agi = GetHeroStatBJ(bj_HEROSTAT_AGI, hero, false)
	local integer is_int = GetHeroStatBJ(bj_HEROSTAT_INT, hero, false)
	local integer is_lvl = GetHeroLevel(hero)

	local integer req_str = udg_item_req_str[myitem]
	local integer req_agi = udg_item_req_agi[myitem]
	local integer req_int = udg_item_req_int[myitem]
	local integer req_lvl = udg_item_req_lvl[myitem]

	local integer item_ability  = udg_item_spellbook_ability[myitem]
	local integer item_abi_mlvl = udg_item_max_lvl[myitem]

	if ( req_str > is_str ) then
		call error("you are not strong enough")
		return false
	endif
	if ( req_agi > is_agi ) then
		call error("you are not fast enough")
		return false
	endif
	if ( req_int > is_int ) then
		call error("you are not smart enough")
		return false
	endif
	if ( req_lvl > is_lvl ) then
		call error("you do not have the required level")
		return false
	endif


	if ( GetUnitAbilityLevelSwapped(item_ability, hero) == item_abi_mlvl ) then
		call error("you have already maxed this skill")
		return false
	endif

	if ( GetUnitAbilityLevelSwapped(item_ability, hero) == 0 ) then
		//call add_ability_to_unit(hero, item_ability)
		return true
	endif

	if ( GetUnitAbilityLevelSwapped(item_ability, hero) > 0 ) then
		//call increase_ability(hero, item_ability)
		return true
	endif

	call error("unknown error")
	return false
endfunction
 
Level 11
Joined
Jul 15, 2004
Messages
333
Do you know why it don't work? Because of the arrays!
They can only hold exacly 8192 things on.
You wrote there 'I001' which is in real number something like 64564684 (just example it is much bigger), so that means 'I001' is way to larger number than the array limit.

You have to do little function, like:
Code:
function GetThingID takes integer id, returns integer
local integer i=0
if id=='I000' then
  set i=1
elseif id=='I001' then
  set i=2
elseif id=='I002' then       //add your other IDs here...
  set i=3
endif
return i
endfunction

and fixing your func:
Code:
...
        set tmp_item = GetThingID('I001') 
        set udg_item_req_str[tmp_item]           = 0 
        set udg_item_req_agi[tmp_item]           = 0 
        set udg_item_req_int[tmp_item]           = 100
...
 
Level 6
Joined
Feb 18, 2005
Messages
263
thanks for yyour idea. but i have another one:
Code:
function Item2integer takes intger I returns integer
   return I - 'I000'
endfunction

thisfunction is way shorter than the one you suggested and does the same ^^

but this does not sovle the problem i had: the code emoved ALL triggers from the map, GUI and jass alike.

I do not believe that this little mistake has done that... but i wil test it ^^
 
Status
Not open for further replies.
Top