loop
exitwhen i == TOTAL_PLAYERS
set t = CreateTrigger()
call TriggerRegisterPlayerChatEvent(t, Player(i), "-", false)
call TriggerAddCondition(t, Condition(function main))
set playerDatum[i].npcTrig = t
call DisplayTimedTextToPlayer(Player(i), 0, 0, 15, "Are you a guy or a girl? Type '-male' or '-female' to choose your gender!")
set i = i + 1
endloop
In some cases it might not be as straightforward as having a variable/array position for each player, e.g. there are some events which have to be binded to a single player (player unit events), and so you would need to loop over your total players and create a trigger for each one (but the condition/action could be the same).
Here's an example
JASS:loop exitwhen i == TOTAL_PLAYERS set t = CreateTrigger() call TriggerRegisterPlayerChatEvent(t, Player(i), "-", false) call TriggerAddCondition(t, Condition(function main)) set playerDatum[i].npcTrig = t call DisplayTimedTextToPlayer(Player(i), 0, 0, 15, "Are you a guy or a girl? Type '-male' or '-female' to choose your gender!") set i = i + 1 endloop
Actually Chaosy gave the answer.
Hello can anyone show me an example of MPI?? THX!
IcemanBo said:But your example had not much to do with MPI. Your code is an example for usage of loops
set playerDatum[i].npcTrig = t
I don't think that's true.
AFAIK the OP's question was
Chaosy described the general approach to making something MPI, but didn't give an actual example, which is what my post did (a string event that works for all players). The only problem with my answer is that the OP does GUI and not (v)JASS, which was not mentioned in the OP.
Can you convert it in GUI? im not good in jass
struct FlameWave extends array
implement Alloc
implement StructAttach
unit caster
private integer lvl
real dmgPerMainHit
real dmgPerSideHit
boolean continue
boolean tick
Missile dragon
public method onTimerExpire takes nothing returns nothing
set caster = null
call detach(caster)
call this.deallocate()
endmethod
public method onExpire takes nothing returns nothing
endmethod
public method onLoop takes nothing returns boolean
local real x
local real y
local real angle = GetRandomAngle()
local group g
local unit u
if not continue then
//call DestroyGroup(g)
return false
endif
set x = dragon.x + (GetRandomInt(1,200) * Cos(angle))
set y = dragon.y + (GetRandomInt(1,200) * Sin(angle))
call DestroyEffect(AddSpecialEffect(FW_BRANCH_FX, x, y))
set g = CreateGroup()
call GroupEnumUnitsInRange(g, x, y, FW_BRANCH_RADIUS, getTargetFilter(GetOwningPlayer(caster)))
set u = FirstOfGroup(g)
loop
exitwhen u == null
call spellDamage(caster,u,dmgPerSideHit)
call GroupRemoveUnit(g,u)
set u = FirstOfGroup(g)
endloop
call DestroyGroup(g)
return true
endmethod
implement FAT
implement T32Interface
static method onFinish takes Missile this returns boolean
set FlameWave(this.data).continue = false
return true
endmethod
static method onCollide takes Missile this, unit justHit returns boolean
if isViableTarget(this.source,justHit) then
call spellDamage(this.source, justHit, FlameWave(this.data).dmgPerMainHit * BurningSoul.applyBurnPercentage(this.source,justHit))
endif
return false
endmethod
implement MissileStruct
public static method shoot takes unit casterv, real x, real y, boolean isPhoenix returns nothing
local thistype this = thistype.allocate()
//local unit cast = casterv
local real casx = GetUnitX(casterv)
local real casy = GetUnitY(casterv)
local integer spellId = FW_ID
local real ang = Atan2((y - casy),(x - casx))
local real dist = FW_DIST
local Missile m
if not isPhoenix then
set this.caster = casterv
else
set this.caster = GetPlayerHero(GetOwningPlayer(casterv))
endif
set lvl = GetUnitAbilityLevel(caster, spellId)
call setu(caster, this)
set dmgPerMainHit = (FW_CORE_INT + (FW_CORE_INT_FACTOR * lvl)) * GetHeroInt(caster,true)
set dmgPerSideHit = (FW_BRANCH_INT + (FW_BRANCH_INT_FACTOR * lvl)) * GetHeroInt(caster,true)
set continue = true
//---------------------------------------------------------
set m = Missile.create(casx, casy, 100, ang, dist, 100)
set m.model = FW_FX
set m.speed = FW_SPEED
set m.collision = 150
set m.data = this
set m.source = caster
set dragon = m
call thistype.launch(m)
call runTime(20,this)
call add()
endmethod
endstruct
the problem with your example is that no GUI-er will ever need anything like that.
answers are valid and correct ones
Hello can anyone show me an example of MPI?? THX!