- Joined
- Oct 19, 2007
- Messages
- 51
**DISCLAIMER** : I am not sure if this is the proper location for this post, though it seemed there were other posts of a similar nature in this forum. I'm sorry if this is the wrong spot for this.
EDIT: IT occurred to me this belongs in the JASS section. Mod, help please?
So in a virus infection map I've been modding for a while now(near as I can tell, oldest version by Velex), I'm trying to make it so the body spawns red blood cells (workers which can mine from mines located around the body) at buildings called "bone marrow" and so that they spawn up to a limit that I can variably define on individual marrows (to facilitate upgrading the number of blood cells a single bone marrow.
Originally I tried using mana to do this, but the real to int (and vice versa) conversions were causing problems. I made the mistake of converting the trigger from gui to jass (which I am not terribly experienced with) AND trying to change it to work off of an ability on the bone marrow at the same time. The result (after LOTS of attempted syntax fixing), is a trigger, which, as far as I can tell, ought to work, but doesnt. There's something that's going on here which I don't understand. I've added debug messages, and from what I can see in the map, what's happening makes no sense to me.
It enters the first loop, says the message there, but does not go on to the next loop (suggesting the 'exitwhen' got a true, and left the loop prematurely), but the function never displays the "done" at the bottom of the trigger. Here's the Jass version I made, variables are pretty self-documenting in some cases, ambiguous cases will be explained below.
This is the actual trigger that picks every bone marrow on the map (dynamically stored in the global unit group 'marrows' and checks to spawn a red blood cell at it.
What the trigger does is:
The Variables are as follows:
As previously stated, the trigger just seems to stop just after the first loop is entered...
I'm 100% open to any ideas for a way of redoing the system that would preserve it's functionality (and maybe improve performance [though this has not been found out be lacking in the old gui version,save for the little inaccuracy]). I, of course would be able to do it myself (help is appreciated!) but I'm just not doing too well in the ideas category. If you need the map itself, I can attach it; I can also post the original GUI working trigger, if it would help to see a "working" version of what I want accomplished. The main reason for switching to JASS was because the GUI version leaked so much, the map's max playtime was brought to about...err...12 mins?
Much appreciated,
KEvin [SkoobyDoo]
EDIT: IT occurred to me this belongs in the JASS section. Mod, help please?
So in a virus infection map I've been modding for a while now(near as I can tell, oldest version by Velex), I'm trying to make it so the body spawns red blood cells (workers which can mine from mines located around the body) at buildings called "bone marrow" and so that they spawn up to a limit that I can variably define on individual marrows (to facilitate upgrading the number of blood cells a single bone marrow.
Originally I tried using mana to do this, but the real to int (and vice versa) conversions were causing problems. I made the mistake of converting the trigger from gui to jass (which I am not terribly experienced with) AND trying to change it to work off of an ability on the bone marrow at the same time. The result (after LOTS of attempted syntax fixing), is a trigger, which, as far as I can tell, ought to work, but doesnt. There's something that's going on here which I don't understand. I've added debug messages, and from what I can see in the map, what's happening makes no sense to me.
It enters the first loop, says the message there, but does not go on to the next loop (suggesting the 'exitwhen' got a true, and left the loop prematurely), but the function never displays the "done" at the bottom of the trigger. Here's the Jass version I made, variables are pretty self-documenting in some cases, ambiguous cases will be explained below.
JASS:
function Trig_Marrowspawn_nearest_mine takes nothing returns boolean
return ( GetUnitTypeId(GetFilterUnit()) == 'n000' )
endfunction
function Trig_Marrowspawn_Actions takes nothing returns nothing
local unit thismarrow
local unit compare
local unit nearestmine
local unit newblood
local group g = CreateGroup()
local group nearbymines = CreateGroup()
local player marrowner
local player comparehim
local location thisplace
local integer cv
local integer count
local group marrows
set marrows = udg_marrows
loop
call DisplayTextToForce( GetPlayersAll(), "Starting marrowloop" )
set thismarrow = FirstOfGroup(marrows)
call DisplayTextToForce( GetPlayersAll(), GetUnitName(thismarrow) )
call DisplayTextToForce( GetPlayersAll(), UnitId2String(GetUnitTypeId(thismarrow)) )
exitwhen ( thismarrow == null )
set thisplace = GetUnitLoc ( thismarrow )
set cv = GetUnitUserData(thismarrow)
set count=0
call GroupEnumUnitsInRect( g , bj_mapInitialPlayableArea , null )
loop
call DisplayTextToForce( GetPlayersAll(), "Counting bloods loop" )
call DisplayTextToForce( GetPlayersAll(), I2S(count) )
set compare = FirstOfGroup(g)
exitwhen (compare == null)
set comparehim = GetOwningPlayer(compare)
if ( GetUnitUserData(compare) == cv ) and ( marrowner == comparehim ) then
set count = count + 1
endif
call GroupRemoveUnit(g, compare)
endloop
if ( count < ( GetUnitAbilityLevel( thismarrow, 'A02E') - 1 ) ) then
call DisplayTextToForce( GetPlayersAll(), "Trying to spawn" )
call IncUnitAbilityLevel( thismarrow, 'A02E' )
set newblood = CreateUnitAtLoc( marrowner , 'u00O' , thisplace , GetRandomReal(0,360) )
call SetUnitUserData( newblood, cv )
set nearbymines = GetUnitsInRangeOfLocMatching( 500.00, thisplace, Condition(function Trig_Marrowspawn_nearest_mine))
set nearestmine = FirstOfGroup( nearbymines )
if ( nearestmine != null ) then
call IssueTargetOrder( newblood, "harvest", nearestmine )
endif
endif
call GroupRemoveUnit(marrows, thismarrow)
endloop
set thismarrow = null
set compare = null
set nearestmine = null
set newblood = null
set marrowner = null
set comparehim = null
call DestroyGroup(g)
call DestroyGroup(nearbymines)
call DestroyGroup(marrows)
call RemoveLocation(thisplace)
call DisplayTextToForce( GetPlayersAll(), "Done" )
endfunction
//===========================================================================
function InitTrig_Marrowspawn takes nothing returns nothing
set gg_trg_Marrowspawn = CreateTrigger( )
call TriggerRegisterTimerEventPeriodic( gg_trg_Marrowspawn, 5.00 )
call TriggerAddAction( gg_trg_Marrowspawn, function Trig_Marrowspawn_Actions )
endfunction
This is the actual trigger that picks every bone marrow on the map (dynamically stored in the global unit group 'marrows' and checks to spawn a red blood cell at it.
What the trigger does is:
- Select a bone marrow from group marrows
- Count the number of red blood cells associated with that bone marrow (via matching custom value)
- If there are less red blood cells found than the current ability level of the tracking ability, it should spawn a red blood cell at the location of the bone marrow and order it to mine from the nearest gold mine.
- Display done before the trigger is done executing, regardless of what happened. (Debugging purposes only)
The Variables are as follows:
- Thismarrow - is the current 'bone marrow' unit being looked at.
- Compare - is the red blood cell the trigger is currently counting.
- nearestmine - is used to find the nearest gold mine in the event of a spawning.
- newblood - is used to store the new unit for modification
- g - is used to gather the red blood cells to be compared to 'thismarrow'
- nearbymines - ...
- marrowner - the owner of 'thismarrow'.
- comparehim - the owner of 'compare'
- thisplace - the location of 'thismarrow'
- cv - custom value of 'thismarrow'
- marrows - The local copy of the global group marrows(udg_marrows) so I can easily cycle through the list.
- udg_marrows - Complete list of every bone marrow that has been constructed and not destroyed, maintained by another trigger, and has not been modified since the last version, so I'm assuming there is nothing wrong with this group.
As previously stated, the trigger just seems to stop just after the first loop is entered...
I'm 100% open to any ideas for a way of redoing the system that would preserve it's functionality (and maybe improve performance [though this has not been found out be lacking in the old gui version,save for the little inaccuracy]). I, of course would be able to do it myself (help is appreciated!) but I'm just not doing too well in the ideas category. If you need the map itself, I can attach it; I can also post the original GUI working trigger, if it would help to see a "working" version of what I want accomplished. The main reason for switching to JASS was because the GUI version leaked so much, the map's max playtime was brought to about...err...12 mins?
Much appreciated,
KEvin [SkoobyDoo]
Last edited: