|
|
#21 |
Member
|
|
|
|
|
#22 |
Member
|
so I don't quite understand how efficient code works. There is a trigger and you got functions. Meanwhile I wrote a little in the code. Luckyly I had a backup. I got compiling errors. But some intended changes worked.
|
|
|
|
#23 |
Member
Join Date: Jan 2010
Location: Germany
Posts: 5,042
|
Was there a question in that?
__________________
I might edit my p0sts frequently and rapidly after posting.
DotA code of the week:
Jass:
function Func0243 takes nothing returns nothing
call Func0242()
endfunction
|
|
|
|
#24 |
Member
|
Yes. How is JASS more efficient? when I need to refer to a function in evry if-case the game goes slower?
|
|
|
|
#25 |
Member
Join Date: Jan 2010
Location: Germany
Posts: 5,042
|
Exactly. It's just unneeded, and the GUI-Jass is just painful to watch. If you create an if-condition, it does horrible things with nots to it and so on.
The point is, many functionsbe especially careful with those that have BJ in their name use many more CPU cycles than necessary. While that doesn't matter for most smaller maps, if you want a stable map with lots of features (like >400 unique triggered abilities on >100 heroes) you should think about what makes the game slower.
__________________
I might edit my p0sts frequently and rapidly after posting.
DotA code of the week:
Jass:
function Func0243 takes nothing returns nothing
call Func0242()
endfunction
|
|
|
|
#26 |
Member
Join Date: Aug 2010
Location: Serbia, Belgrade
Posts: 52
|
Any huge map should have at least core systems coded in v/jass.
You probably know that Skibi's Castle TD map created by Blizzard o.O? What if I tell you that converting code into jass, optimizing it and cleaning leaks can remove all lag from game. Btw here you go the most simple example, GUI will generate BJ functions just like MauranKilom said above, and they look like this:
Jass:
function CameraSetSmoothingFactorBJ takes real factor returns nothing
call CameraSetSmoothingFactor(factor)
endfunction
|
|
|
|
#27 |
Member
|
I didn't use native since I dont know how to use them. Let's say a unit receives debuff "thunderclap" and I want it to be hexed.
It would be something like this in GUI I assume function qz takes nothing returns boolean 'A000'==castedspell function trigger_actions takes nothing returns nothing locals unit u player p if (qz()) set u= createUnit(*owner of casting unit*,'U000',30.) call u to use 'A002' at casted unit call triggersleepaction(1) call removeunit u function Init_trigger_**** takes nothing return noithing call Addactions (Init_trigger_****,TriggerActions) I think I could write if ('A000'==castedspell) instead, right? So I had 1 function less How do natives work? I dont want to do a trigger everytime for: A unit dies, Elapsed Time, aquires item, yea Btw: 1 smaller problem, I faced: http://www.youtube.com/watch?v=UaQcT...ature=youtu.be I created the endboss looking this way. I changed it's collision size to 800 assuming it's the size a unit can walk through. However, look: You can walk through it. Why? |
|
|
|
#28 |
Member
|
I know there was a -snow command in earlier DotA. I want to transform a part of the map into same terrain of Sentinel Spawning Zone. So after you completed your quest in Valhalla you'll be sent back to DotA world. The spawning zone is supposed to symbolize it.
|
|
|
|
#29 |
Member
Join Date: Jan 2010
Location: Germany
Posts: 5,042
|
I'm not sure you understand what "native" means.
I believe collision size can't take arbitrary values (according to this 48 is the upper limit), so setting it to 500 does nothing. Can the boss move? If not, consider placing pathing blockers around him. You can set the terrain at a specified location to a specified "texture". I'll look how it is/was done in dota though.
__________________
I might edit my p0sts frequently and rapidly after posting.
DotA code of the week:
Jass:
function Func0243 takes nothing returns nothing
call Func0242()
endfunction
|
|
|
|
#31 |
Member
|
I gonna recode every unit placement again with loops, natives etc. If I understood correctly natives are already implemented functions.
Another questions. I got the Code from 6.67 deprotected. wouldn't it be the easiest way to get item data hero data and unit data from it and delete the spawning units + unit placement part? |
|
|
|
#32 |
Member
|
How do actions work? E.g.
Player_event_death if (true) then ... Will the code beneath REgisterEVent always be executed or only if the event is really triggered? |
|
|
|
#33 |
Member
Join Date: Aug 2010
Location: Serbia, Belgrade
Posts: 52
|
Code:
Test
Events
Unit - A unit owned by Player 1 (Red) Dies
Conditions
(Unit-type of (Triggering unit)) Equal to Footman
Actions
Skip remaining actions
It will check it's condition next, if returned boolean equal to true, actions will be executed. In our example, if player red owned footman dies our trigger will do nothing. That's why people created many scripts named libraries that handle and recycle such events. Imagine having 100 spells in your map, each time when unit cast spell 100 triggers fire their condition function/s and check for right one. Ofc only 1 will run actions below, but conditions can often be huge and complex so it will slow down map. I won't even mention bad jass coding where you use conditions as actions to speed up your code. But to return to topic you should always register as many events you can within single trigger, it's always better to have 1 trigger, 1 event, and 1 huge "if then else" with function calls (Execute/Run trigger in GUI) instead 100 triggers that do some checking each time unit cast spell or do something else. |
|
|
|
#34 | |
Member
Join Date: Jan 2010
Location: Germany
Posts: 5,042
|
Quote:
__________________
I might edit my p0sts frequently and rapidly after posting.
DotA code of the week:
Jass:
function Func0243 takes nothing returns nothing
call Func0242()
endfunction
|
|
|
|
|
#35 | |
Member
|
Quote:
Event: unit dies Condition: none Actions: If Spell=A00 then .. else (If Spell==A01 then.. else( If Spell=A02 then.. else (if Spell=A03 ..... |
|
|
|
|
#36 |
Member
Join Date: Jan 2010
Location: Germany
Posts: 5,042
|
Yes, that's what he meant. But again, dota has probably over 200 spells that each have their own trigger, and most of them throw their actions into the conditions (even for timer stuff). So don't worry too much about what he said.
__________________
I might edit my p0sts frequently and rapidly after posting.
DotA code of the week:
Jass:
function Func0243 takes nothing returns nothing
call Func0242()
endfunction
|
|
|
|
#37 | |
Member
|
Quote:
I want to summarize, say if Im right. call RegisterTriggerEvent <- if this line is not executed following code of the function won't be executed This is my recoded Map Init func function InitTrig_init takes nothing returns nothing local integer i=0 local integer k=1 local integer j=0 local integer l=0 local unit u set gg_trg_init = CreateTrigger( ) loop exitwhen k==6 call SetPlayerAlliance(Player(k),Player(0),ConvertAllia nceType(3),true) call SetPlayerAlliance(Player(k),Player(0),ConvertAllia nceType(4),true) call SetPlayerAlliance(Player(0),Player(k),ConvertAllia nceType(3),true) call SetPlayerAlliance(Player(0),Player(k),ConvertAllia nceType(4),true) call SetPlayerMaxHeroesAllowed( 1, Player(k) ) if(IsPlayerSlotState(Player(k),ConvertPlayerSlotSt ate(1))) then set udg_PlayersPlaying=udg_PlayersPlaying+1 endif set k=k+1 endloop //====UNIT PLACEMENT================ loop exitwhen j==6+2*udg_PlayersPlaying set u=CreateUnitAtLoc(Player(6), 'nmcf',GetRectCenter(Rect(-3650.00, -9450.00, -3200.00, -9000.00)), GetRandomDirectionDeg() ) call IssuePointOrderLocBJ( u, "patrol", Location(-2400.,-9050.)) set u=CreateUnitAtLoc(Player(6), 'nmcf',GetRandomLocInRect(Rect(-4350.00, -11350.00, -3800.00, -11050.00)), GetRandomDirectionDeg() ) call IssuePointOrderLocBJ( u, "patrol", GetRandomLocInRect(Rect(-3300.,-11300.,-3400,-11100))) set j=j+1 endloop loop exitwhen i==5 call SetPlayerStateBJ( Player(i+1), PLAYER_STATE_RESOURCE_GOLD, 1450-150*udg_PlayersPlaying) call CreateFogModifierRectBJ( true, Player(1), FOG_OF_WAR_VISIBLE, Rect(-900.,-8000.,900.,-5300.) ) set i=i+1 endloop call FogEnable(true) call SetTimeOfDay( 22.00 ) call UseTimeOfDayBJ( false ) call SetPlayerFlagBJ( PLAYER_STATE_GIVES_BOUNTY, true, Player(6) ) //====Difficulty=================== call SetPlayerHandicap(Player(6),.75) if (udg_PlayersPlaying ==3) then call SetPlayerTechResearchedSwap('Rhme',1, Player(6)) call SetPlayerHandicap(Player(6),1.) endif if (udg_PlayersPlaying ==4) then call SetPlayerTechResearchedSwap('Rhme',2, Player(6)) call SetPlayerHandicap(Player(6),1.2) endif if (udg_PlayersPlaying ==5) then call SetPlayerTechResearchedSwap('Rhme',3, Player(6)) call SetPlayerHandicap(Player(6),1.5) endif //============================D O O D A D S============================== set udg_Bomb[9]=CreateDestructable('LTex',-5216.,-1056.,269.,2.,0) set udg_Bomb[8]=CreateDestructable('LTex',-9888.,-4832.,269.,2.,0) set udg_Bomb[7]=CreateDestructable('LTex',-10080.,-4512.,269.,2.,0) set udg_Bomb[6]=CreateDestructable('LTex',-10272.,-4256.,269.,2.,0) set udg_Bomb[5]=CreateDestructable('LTex',-10272.,-4000.,269.,2.,0) set udg_Bomb[4]=CreateDestructable('LTex',-10080.,-4000.,269.,2.,0) set udg_Bomb[3]=CreateDestructable('LTex',-10016.,-3808.,269.,2.,0) set udg_Bomb[2]=CreateDestructable('LTex',-9952.,-4000.,269.,2.,0) set udg_Bomb[1]=CreateDestructable('LTex',-10080.,-3424.,269.,2.,0) set udg_Bomb[0]=CreateDestructable('LTex',-7840.,1440.,269.,2.,0) set udg_Bomb[17]=CreateDestructable('LTex',-8544.,-2400.,269.,2.,0) set udg_Bomb[16]=CreateDestructable('LTex',-8864.,-1312.,269.,2.,0) set udg_Bomb[15]=CreateDestructable('LTex',-10400.,-1312.,269.,2.,0) set udg_Bomb[14]=CreateDestructable('LTex',-10400.,-2144.,269.,2.,0) set udg_Bomb[13]=CreateDestructable('LTex',-7456.,-1952.,269.,2.,0) //====DOORS PLACEMENT================ set udg_EisenTorVert[0]=CreateDestructable('DTg5',-7872.,2304.,270.,.9,0) set udg_EisenTorVert[1]=CreateDestructable('DTg5',-2688.,-9600.,270.,.9,0) set udg_EisenTorVert[2]=CreateDestructable('DTg5',-9600.,-5504.,270.,.9,0) set udg_EisenTorVert[3]=CreateDestructable('DTg5',10816.,-576.,270.,.9,0) set udg_EisenTorHor[0]=CreateDestructable('DTg7',-5504.,-1280.,.0,.9,0) set udg_EisenTorHor[1]=CreateDestructable('DTg7',-7552.,-10816.,.0,.9,0) set udg_EisenTorHor[2]=CreateDestructable('DTg7',-6016.,1088.,.0,.9,0) set udg_EisenTorHor[3]=CreateDestructable('DTg7',-1536.,-10688.,.0,.9,0) set udg_EisenTorHor[4]=CreateDestructable('DTg7',-384.,2496.,.0,.9,0) set udg_EisenTorHor[5]=CreateDestructable('DTg7',-4864.,1152.,.0,.9,0) set udg_EisenTorHor[6]=CreateDestructable('DTg7',-9216.,3136.,.0,.9,0) set udg_EisenTorHor[7]=CreateDestructable('DTg7',-4672.,-11328.,.0,.9,0) set udg_EisenTorHor[8]=CreateDestructable('DTg7',8128.,-6848.,.0,.9,0) set udg_EisenTorHor[9]=CreateDestructable('DTg7',8128.,-7488.,.0,.9,0) set udg_EisenTorHor[10]=CreateDestructable('DTg7',8128.,-8128.,.0,.9,0) set udg_EisenTorHor[11]=CreateDestructable('DTg7',-5696.,-7744.,.0,.9,0) set udg_EisenTorHor[12]=CreateDestructable('DTg7',9152.,-6848.,.0,.9,0) set udg_EisenTorHor[13]=CreateDestructable('DTg7',9152.,-7488.,.0,.9,0) set udg_EisenTorHor[14]=CreateDestructable('DTg7',9152.,-8128.,.0,.9,0) set udg_EisenTorHor[15]=CreateDestructable('DTg7',8128.,-8768.,.0,.9,0) set udg_EisenTorHor[16]=CreateDestructable('DTg7',9152.,-8768.,.0,.9,0) set udg_EisenTorHor[17]=CreateDestructable('DTg7',-4992.,-5760.,.0,.9,0) set udg_EisenTorHor[18]=CreateDestructable('DTg7',1024.,-10688.,.0,.9,0) set udg_EisenTorHor[19]=CreateDestructable('DTg7',-9344.,-8640.,.0,.9,0) set udg_EisenTorHor[20]=CreateDestructable('DTg7',-5376.,2432.,.0,.9,0) set udg_EisenTorHor[21]=CreateDestructable('DTg7',4928.,-11072.,.0,.9,0) set udg_EisenTorHor[22]=CreateDestructable('DTg7',4608.,-1344.,.0,.9,0) set udg_EisenTorHor[23]=CreateDestructable('DTg7',6272.,-3968.,.0,.9,0) set udg_EisenTorHor[24]=CreateDestructable('DTg7',-8704.,3136.,.0,.9,0) set udg_EisenTorHor[25]=CreateDestructable('DTg7',4928.,-10432.,.0,.9,0) set udg_ElvDoors[0]=CreateDestructable('LTe1',.0,-5440.,270.,.9,0) // ArenaDoor set udg_ElvDoors[1]=CreateDestructable('LTe1',-9792.,-1216.,270.,.9,0) //Door to Catapults set udg_LGatesHor[0]=CreateDestructable('LTg1',-9664.,-2944.,270.,.9,0) // BombRoom Door endfunction |
|
|
||
| Last edited by Bashtime; 08-28-2012 at 10:07 PM. | ||
|
|
#38 |
Member
Join Date: Jan 2010
Location: Germany
Posts: 5,042
|
I'm not even sure what your question is right now...
When a trigger is fired because of any event (those are added by TriggerRegisterEvent()), the condition function(s) will be executed and if it(all of them) returns true, the action function(s?) will be executed. Now, nothing prevents you from placing the code to be executed into the condition function rather than the action function. But this is apparently considered bad coding by the mapmaking community, which icefrog seemingly doesn't care about.
__________________
I might edit my p0sts frequently and rapidly after posting.
DotA code of the week:
Jass:
function Func0243 takes nothing returns nothing
call Func0242()
endfunction
|
|
|
|
#39 |
Member
|
The worst part in the map right now is the trivia part by the former developer. there are 700 lines Code for 70 questions with ABCD. About 200 boolean functions integer=20,21...70. How can I make this code better?
|
|
|
|
#40 |
Member
Join Date: Aug 2010
Location: Serbia, Belgrade
Posts: 52
|
@MauranKilom well it's sad to see such bad coding in such popular map.
I still remember how some ultimate spells used to freeze my old PC ^_^ |
|