| 04-16-2008, 06:33 PM | #1 |
I'm creating a hero map with some triggered spells but they all tend to lag when they are used the first time. There are no problems afterwards and everything loads nice and fast. Is there any way to pre-load the trigger ressources before the spell is actually cast the first time (Maybe when the hero is chosen)? That way it wouldnt interrupt the gameplay. |
| 04-16-2008, 06:35 PM | #2 |
When you talk about the 'First time lag', yes you can prevent it with preplacing a unit of that unit type and remove it on Map init. |
| 04-16-2008, 06:37 PM | #3 |
The things that cause first cast lag are models that have not been used before; these can be preloaded with the preload native; native Preload takes string filename returns nothing. |
| 04-16-2008, 06:40 PM | #4 |
Thanks for your answers (+rep) Do I have to preload both unit and effects? Am I missing some other things as well? |
| 04-16-2008, 06:45 PM | #5 |
Preload units (and abilities), models (and textures). I don't think there are many other things that will be noticable. |
| 04-16-2008, 07:08 PM | #6 |
I've tried pre-loading every imaginable model file using the preload native but there is still some start lag. I've even tried creating the unit at initialization but the spell still lag the first time (The spell creates that unit). Am I missing something? You talk about preloading abilities.. do you mean the effects used in the abilities or what? And do I have to do something special for textures (Aren't they just loaded with the models)? EDIT: Typo |
| 04-16-2008, 07:32 PM | #7 |
You could always try just creating and destroying the effects at map init instead of using Preload; see if that works better. There may be something with the animations not all being preloaded, or something similar... |
| 04-16-2008, 07:52 PM | #8 |
Post the triggers. Abilities must be preloaded, for example the ones you add to dummy units, etc. |
| 04-16-2008, 08:03 PM | #9 |
Creates a totem at the position of the hero and assings the totem some spells based on the level of the ability. JASS:globals // Each player unit array gg_ability_war_totem_self real array gg_ability_war_totem_pos_x real array gg_ability_war_totem_pos_y effect array gg_ability_war_totem_effect_1 effect array gg_ability_war_totem_effect_2 //effect array gg_ability_war_totem_effect_3 // Defaults string gg_ability_war_totem_effect_1_string = "Abilities\\Spells\\Items\\AIfb\\AIfbTarget.mdl" string gg_ability_war_totem_effect_2_string = "Abilities\\Spells\\Orc\\WarDrums\\DrumsCasterHeal.mdl" //string gg_ability_war_totem_effect_3_string = "" endglobals function ability_war_totem takes nothing returns nothing local unit unit_triggering = GetTriggerUnit() local player player_triggering = GetOwningPlayer(unit_triggering) local integer player_id = GetPlayerId(player_triggering) local integer ability_war_totem_level = GetUnitAbilityLevel(unit_triggering, 'A001') - 1 // Create the totem set gg_ability_war_totem_self[player_id] = CreateUnit(player_triggering, 'n000', GetUnitX(gg_player_hero[player_id]), GetUnitY(gg_player_hero[player_id]), 270.00) // Register totem position set gg_ability_war_totem_pos_x[player_id] = GetUnitX(gg_ability_war_totem_self[player_id]) set gg_ability_war_totem_pos_y[player_id] = GetUnitY(gg_ability_war_totem_self[player_id]) // // Give auras to totem // Healing aura (Hero) call UnitAddAbility(gg_ability_war_totem_self[player_id], 'A005') call SetUnitAbilityLevel(gg_ability_war_totem_self[player_id], 'A005', ability_war_totem_level) // Command aura call UnitAddAbility(gg_ability_war_totem_self[player_id], 'A007') call SetUnitAbilityLevel(gg_ability_war_totem_self[player_id], 'A007', ability_war_totem_level) // Endurance aura call UnitAddAbility(gg_ability_war_totem_self[player_id], 'A009') call SetUnitAbilityLevel(gg_ability_war_totem_self[player_id], 'A009', ability_war_totem_level) // Effects set gg_ability_war_totem_effect_1[player_id] = AddSpecialEffect(gg_ability_war_totem_effect_1_string, gg_ability_war_totem_pos_x[player_id], gg_ability_war_totem_pos_y[player_id]) set gg_ability_war_totem_effect_2[player_id] = AddSpecialEffect(gg_ability_war_totem_effect_2_string, gg_ability_war_totem_pos_x[player_id], gg_ability_war_totem_pos_y[player_id]) //set gg_ability_war_totem_effect_3[player_id] = AddSpecialEffect(gg_ability_war_totem_effect_3_string, gg_ability_war_totem_pos_x[player_id], gg_ability_war_totem_pos_y[player_id]) // Remove War Totem artifact call DestroyEffect(gg_player_hero_artifact[player_id].artifact_effect[0]) // Cleanup set unit_triggering = null set player_triggering = null endfunction // Forced by WE function InitTrig_war_totem takes nothing returns nothing endfunction What do you mean when you say that I have to "preload abilities"? Preload effect models or what? I can't find a preload native that takes anything else than a model string as an argument. I've already tried using the following as preload JASS:call CreateUnit(Player(0), 'n000', 0, 0, 0) // Create the totem call Preload(gg_ability_war_totem_effect_1_string) // Effect 1 call Preload(gg_ability_war_totem_effect_2_string) // Effect 2 call Preload("Doodads\\Barrens\\Props\\TaurenTotem\\TaurenTotem0.mdl") // The totem model call Preload("Abilities\\Spells\\Other\\ANrm\\ANrmTarget.mdl") // Heal effect of the totem's aura Edit: Added some info. |
| 04-16-2008, 08:06 PM | #10 |
At Init: Create a unit, add abilities to it, remove unit -> Abilities Preloaded You will need to do this for 'A005', 'A007' and 'A009' by the looks of it. |
| 04-16-2008, 08:14 PM | #11 | |
Quote:
That did it, thanks! Strange that you have to actually create the unit and assign the abilities and not just load the model files.. +Rep to everyone above. |
| 04-16-2008, 08:41 PM | #12 |
The model files are one thing. For war3 loading an ability seems to take enough time to cause some first cast lag. I guess it is about the button and perhaps some event listeners, etc. |
