| 08-12-2003, 08:55 PM | #106 | |
Quote:
Not sure yet. Probably mostly self programmed stuff. From the looks of it the script you told me too look it as more specifically designed with PHP code snippets in mind, so the functions that would make it most apealing (highlighting) probably wouldn't work. The way the site is going to work is going to be largely based on Everything2 if you've ever used that, except it'll be PHP instead of Perl. The idea is that users will receive xp for posting new functions, and other users can vote functions up or down. High voted functions will have links to them on the front page. Functions with lots of downvotes will be easy to single out for deletion =) |
| 08-13-2003, 08:17 PM | #107 |
More stuff to add: Code:
DisableAbilityForPlayerForDuration(abilityId, duration) AddAbilityLifeTimer(whichUnit, abilityId, duration) AddItemLifeTimer(itemId, duration) AddDoodadLifeTimer(whichDoodad, duration) RespawnItemAfterPickup(item whichItem, real waittime, boolean repeating) CreatePermDeformationWithTimer 2DArrayIndex(element1, element2, 2dsize) SlowUnit(unit whichUnit, real percent, real duration) Avatar(whichUnit) //Reproduces exact default effect GrowUnit(whichUnit, growamount, growperiod) AttachAOEDamageToUnit(whichUnit, damage, radius, ff, duration) AttachLineDamageToUnit(... integer degreeOffset) //Degree offset is +/- relative to unit facing CountPlayersInLeaderboard CountPlayersInMultiboard GetPlayerInMultiboardPosition(integer position, multiboard lb) MakeUnitUnselectable(unit whichUnit) //Would give locust ability and generate triggers to remove from selection if selected (just in case) StunUnit(unit whichUnit, real duration) //Would create the stun special effect and manually disable the unit MoveUnitInstantlyOverTime(whichunit, loc1, loc2, duration) MoveUnitInstantlyOverTimeCheckCliff(whichunit, loc1, loc2, duration, cliffheight) KnockbackUnitNoDrop(caster, whichunit, magnitude) //Won't knock back to lower heights KnockbackUnitDrop(caster, whichunit, magnitude) //Will //These would make a group of units circle a target unit //either by giving move orders or by instantly moving them //the rotateunit boolean determines whether they also //actually move in a circle around the target. The onmove //boolean is ignored if rotating is set to false. It determines //whether the rotating only occurs if the unit is moving //The facing booleans are similar but for the circling units //rotating their facing. MakeGroupCircleUnitOrder(whichGroup, whichUnit, radius, boolean rotateunit, boolean unitonmove, boolean rotatefacing, boolean facingonmove) MakeGroupCircleUnitInstant(whichGroup, whichUnit, radius, boolean rotateunit, boolean unitonmove, boolean rotatefacing, boolean facingonmove) //Would return a point on a spiral. Using dotindex could have //inside a for loop to make spirals. GetSpiralPoint(location center, real radius, numcirc, numdots, dotindex) GetRectArea(rect) OrderUnitToPatrolCircle(unit whichUnit, location center, real radius) //Would generate trigger to detect another order being given and delete itself NOTE: The following would be used to get the targets of Shockwave and Carrion Swarm like spells and would return a unitgroup of the targets. Code:
-GetLineTargets(distance, angle, radius) -GetLineExpandingRadiusTargets(distance, angle, radius, growrate, finalradius) NOTE: The following would generate an array of triggers that would be run individually, in order to make waits possible. This should work for unit groups since we can IterateGroup(). I'm not sure a FirstofForce exists, I'll have to look. Code:
-ForForceWithWaits -ForGroupWithWaits I'm gonna edit this post to add more to this list as I think of them, as a reminder for once the site is actually up =) Completed: Code:
//Simple emulation of real healing for use in JASS spells
function TargetHeal takes unit whichUnit, real healAmount returns nothing
call SetUnitLifeBJ( whichUnit, ( GetUnitStateSwap(UNIT_STATE_LIFE, whichUnit) + healAmount ))
call AddSpecialEffectTargetUnitWithTimer( "origin", whichUnit, "Abilities\\Spells\\Human\\Heal\\HealTarget.mdl", 1.8 )
endfunctionCode:
//AOE extension of above function
//Notice suffix "simple", a "complex" suffix would indicate that it
//does partial/quarter/etc healing
function AOEHealSimple takes unit whichUnit, real healAmount, real radius, boolean friendlyfire returns nothing
local integer i = 1
local unit temp_iterateunit = null
local group tempgroup = CreateGroup()
//Todo: add alive check
set tempgroup = GetUnitsInRangeOfLocMatching(radius, GetUnitLoc(whichUnit))
loop
exitwhen i > CountUnitsInGroup(tempgroup)
set temp_iterateunit = IterateGroup(tempgroup, i)
if( IsUnitAlly(temp_iterateunit, GetOwningPlayer(whichUnit)) == true or friendlyfire == true ) then
call TargetHeal(temp_iterateunit, healAmount)
endif
set i = i + 1
endloop
endfunction |
| 08-13-2003, 08:24 PM | #108 |
Sounds good. I have some new functions for you: Code:
//Works the same way as the blizzard.j function, but works with 0-based slot indices
//Returns the 0-based slot index of the specified item type
//Are there more than 1 items of this type it returns the slot index of the first item it finds
//(= the one with the lower slot index)
//Returns -1, if it can't find an item of that type
function GetInventoryIndexOfItemType takes unit whichUnit, integer itemId returns integer
local integer index
local item indexItem
set index = -1
loop
set indexItem = UnitItemInSlot(whichUnit, index)
if (indexItem != null) and (GetItemTypeId(indexItem) == itemId) then
return index
endif
set index = index +1
exitwhen index >= bj_MAX_INVENTORY
endloop
return -1
endfunction
//Drops all items of the specified type to the position, where the unit resides
//Returns the number of dropped items
function UnitRemoveItemsById takes unit whichUnit, integer itemId returns integer
local integer removed = 0
local integer itemSlot
loop
set itemSlot = GetInventoryIndexOfItemType(whichUnit,itemId)
exitwhen itemSlot == -1
call UnitRemoveItemFromSlot(whichUnit, itemSlot)
set removed = removed + 1
endloop
return removed
endfunction
//Removes all items of the specified type from the specified unit
//Returns the number of dropped items
function RemoveItemsFromUnitById takes unit whichUnit, integer itemId returns integer
local integer removed = 0
local integer itemSlot
loop
set itemSlot = GetInventoryIndexOfItemType(whichUnit,itemId)
exitwhen itemSlot == -1
call RemoveItem(UnitRemoveItemFromSlot(whichUnit, itemSlot))
set removed = removed + 1
endloop
return removed
endfunction |
| 08-14-2003, 12:00 AM | #109 |
data can you please delete this huge thread and post a single file in a new thread? it would be alot easier, and if you would delete posts already incorporated in the pack and keep the newest version in the 1st post that would be great too. And i hope an updates list isn't asking too much. |
| 08-14-2003, 07:46 AM | #110 |
Starcraftfreak could you create a GetInventoryIndexOfItemClass function ? |
| 08-14-2003, 08:09 PM | #111 | |
Quote:
He will do a website (or is doing). @dataangel: The script pack should be called "WC3Campaigns Script Pack", because you didn't make all of the functions, so in my opinion you shouldn't put your name on it. You did many good functions, but I think, the name of the whole pack should not contain the name of any of the script developers. Am I right with my assumption, that functions like RemoveLocation or RemoveRegion just delete the data stored in a location or region variable? I think the variable remains, but the function deletes the data stored in the variable. Can someone confirm that. Is it possible to test that with Peppars Handle - functions (these variable types are all childs of handle)? And if I'm right, does this mean, that when using this function, it saves memory? Or does it only make sense with local variables? Code:
native RemoveRect takes rect whichRect returns nothing native RemoveRegion takes region whichRegion returns nothing native RemoveLocation takes location whichLocation returns nothing @Krakau: Something that returns the index of the first item matching a class (powerup,...)? |
| 08-14-2003, 11:09 PM | #112 |
mr. starcraftfreak: i believe ur right about the data being deleted and not the variable. i don't think it is possible to actually remove a variable because variables are allocated when the code is compiled. with the exception of stacks and the like, i don't think memory can be allocated or removed once a program has been compiled, and i haven't even seen jass do stacks. An interesting thought is with the arrays. Does jass automatically allocate x amount of spaces when u create an array, or does it allocate new memory as u add to the array? |
| 08-15-2003, 09:05 AM | #113 | |
Quote:
Yes like the item type. |
| 08-15-2003, 10:48 AM | #114 | |
Quote:
Originally it was going to be named after me because I thought that I would be writing the vast majority of the functions. But with the number of contributions, that won't be so anymore. The site will have accounts with user/passes to identify authors, and you'll be able to vote functions up or down to give authors more credit or 'xp' points to single out authors that write lots of good code =) And yes the thread will be deleted as soon as the site is up. Skull has given me ftp access so this should go much quicker now. |
| 08-15-2003, 06:12 PM | #115 |
Please don't delete the thread. It was a nice discussion and contains some important and interesting information, so at least keep it, instead of deleting. |
| 08-17-2003, 07:44 PM | #116 | |
Quote:
It allocates it dynamically actually. |
| 08-17-2003, 08:16 PM | #117 |
data angel: that's good to know. i'm not so worried about having so many arrays in my code now. |
| 08-18-2003, 07:26 PM | #118 |
Hell guys, don't you check your functions for syntax/compile errors?! I found two problems: 1) Code:
function IsPrime takes integer i returns boolean
local integer c = 2
if ModuloInteger(i,2) == 0 and i != 2 then
set i = 0
else
loop
exitwhen c > R2I(SquareRoot(I2R(i)))
if ModuloInteger(i,c) == 0 then
set c = i
set i = 0
endif
set c = c + 1
endloop
endif
if( i != 0 )
return true
endif
return false
endfunctionIn the if statement before return, the then is missing. Solution: [code] function IsPrime takes integer i returns boolean local integer c = 2 if ModuloInteger(i,2) == 0 and i != 2 then set i = 0 else loop exitwhen c > R2I(SquareRoot(I2R(i))) if ModuloInteger(i,c) == 0 then set c = i set i = 0 endif set c = c + 1 endloop endif if( i != 0 ) then return true endif return false endfunction [code] 2) Code:
function ByteToHex takes integer b returns string
local string charmap = "0123456789abcdef"
local integer c1 = ModuloInteger( b, 16 )
local integer c2 = b / 16
return SubString( charmap, c2, c2 + 1 ) + SubString( charmap, c1, c1 + 1 )
endfunction
function ColorToStringFraction takes real alpha, real red, real green, real blue returns string
return ByteToHex( alpha * 255 ) + ByteToHex( red * 255 ) + ByteToHex( green * 255 ) + ByteToHex( blue * 255 )
endfunctionA function that takes an integer, needs an integer! :ggani: Solution: Code:
function ColorToStringFraction takes real alpha, real red, real green, real blue returns string
return ByteToHex( R2I(alpha * 255) ) + ByteToHex( R2I(red * 255) ) + ByteToHex( R2I(green * 255) ) + ByteToHex( R2I(blue * 255) )
endfunctionI don't know, whether the creators, dataangel, or something weird is responsible for that. I can only tell you, that I downloaded the whole pack from the first page of this thread, added it to Blizzard.j and put it into UMSWE (to add the new functions to the GUI). When I wanted to save my testmap, I got something like hundreds of compile errors. At first I tuned around at my test map, but after deleting all the triggers, I knew, that something else was wrong. Then after checking the modified blizzard.j with Jass Syntax Checker, I corrected the mistakes. So if you don't, use Jass Syntax Checker. Funny is that the Jass Syntax Checker finds 1 error in the code of Blizzard (blizzard.j line 6647). I have created a new function: Code:
function DistanceBetweenUnits takes unit unitA, unit unitB returns real
local real dx = GetUnitX(unitB) - GetUnitX(unitA)
local real dy = GetUnitY(unitB) - GetUnitY(unitA)
return SquareRoot(dx * dx + dy * dy)
endfunction |
| 08-18-2003, 07:50 PM | #119 | |
Quote:
Actually, I found that bug some time ago, although I might have announced it poorly (page 2.) I reuploaded my text file after fixing it. |
| 08-18-2003, 08:17 PM | #120 |
During the development of a new, very difficult function, I came up with the idea to add globals to blizzard.j. Do you guys think, that we can't import it? If yes, I have to disappoint you, we can import it into maps and that works. If you don't believe me, either test it or go here: http://www.battle.net/forums/thread....3-maps&T=46813 Brett_Wood tested it himself. |
