• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • ✅ Time to vote for the top 3 models! The POLL for Hive's 6th HD Modeling Contest: Mechanical is now open! 📅 Poll close on July 16, 2024! 🔗 Cast your vote now!
  • ✅ The POLL for Hive's Texturing Contest #33 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!

Need help with trigger in jass

Status
Not open for further replies.

ies

ies

Level 2
Joined
Jun 11, 2019
Messages
5
Hey, I wanted to make emoji system triggered by keypress, map is arena so bound to hero.
Here's what I have.
JASS:
/*globals used: emojicharge integer array (index is playerID, supposed to be cooldown, when value isn't 0, player cannot express his awe);
Hero unit array (assigned unit for each player once he picks hero)*/
function Trig_Emoji_Conditions takes nothing returns boolean
return emojicharge[GetPlayerId(GetTriggerPlayer())]==0
endfunction
function Trig_Emoji_Actions takes nothing returns nothing
local unit u = Hero[GetPlayerId(GetTriggerPlayer())]
call DestroyEffect(AddSpecialEffectTarget("wpson.mdx",u,"overhead"))
set emojicharge[GetPlayerId(GetTriggerPlayer())]=1
call TriggerSleepAction(15)
set emojicharge[GetPlayerId(GetTriggerPlayer())]=0
endfunction
function InitTrig_Emoji takes nothing returns nothing
local trigger gg_trg_Emoji=CreateTrigger()
local integer i=0
loop
call TriggerRegisterPlayerKeyEventBJ(gg_trg_Emoji,Player(i),bj_KEYEVENTTYPE_DEPRESS,bj_KEYEVENTKEY_UP)
exitwhen i==bj_MAX_PLAYER_SLOTS
endloop
call TriggerAddCondition(gg_trg_Emoji,Condition(function Trig_Emoji_Conditions))
call TriggerAddAction(gg_trg_Emoji,function Trig_Emoji_Actions)
set t=null
endfunction
It never reaches actions.
 
Level 41
Joined
Feb 27, 2007
Messages
5,184
Put a BJDebugMsg(“text”) call in the conditions to see if they are at least being evaluated. If that doesn’t show then something with your trigger definition is funky, but I don’t see it.

If you just recently moved from GUI you JASS it could be because GUI uses GetConvertedPlayerId() which starts at 1 while JASS expects GetPlayerId() which starts at 0.
 

ies

ies

Level 2
Joined
Jun 11, 2019
Messages
5
It doesn't reach condition either, just now I noticed I forgot to increase the integer while checking for players so it was forever looping on player 0 smh.
Edit:
It's reaching to actions now but not displaying the model, I checked other parts of code with debug messages and the final problem has to be the AddSpecialEffectTarget. I pretty much just made plane but I guess that's not valid as effect? Do I need to create unit instead?
 
Last edited:

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,233
Please format your triggers to be human readable...
JASS:
/*globals used: emojicharge integer array (index is playerID, supposed to be cooldown, when value isn't 0, player cannot express his awe);
  Hero unit array (assigned unit for each player once he picks hero)*/
function Trig_Emoji_Conditions takes nothing returns boolean
    return emojicharge[GetPlayerId(GetTriggerPlayer())]==0
endfunction

function Trig_Emoji_Actions takes nothing returns nothing
    local unit u = Hero[GetPlayerId(GetTriggerPlayer())]
    call DestroyEffect(AddSpecialEffectTarget("wpson.mdx",u,"overhead"))
    set emojicharge[GetPlayerId(GetTriggerPlayer())]=1
    call TriggerSleepAction(15)
    set emojicharge[GetPlayerId(GetTriggerPlayer())]=0
endfunction

function InitTrig_Emoji takes nothing returns nothing
    local trigger gg_trg_Emoji=CreateTrigger()
    local integer i=0
    loop
        call TriggerRegisterPlayerKeyEventBJ(gg_trg_Emoji,Player(i),bj_KEYEVENTTYPE_DEPRESS,bj_KEYEVENTKEY_UP)
        exitwhen i==bj_MAX_PLAYER_SLOTS
    endloop
    call TriggerAddCondition(gg_trg_Emoji,Condition(function Trig_Emoji_Conditions))
    call TriggerAddAction(gg_trg_Emoji,function Trig_Emoji_Actions)
    set t=null
endfunction
The problem is that the initialization thread is crashing because you never increment 'i' in the loop. This causes the loop to run infinitely until the operation limit is reached and the thread crashes.
 
Status
Not open for further replies.
Top