创建孟获的远古祭祀技能触发器

//判断施放技能施放是远古祭祀。远古祭祀技能id为'A0AB'
function Trig_StartC_Conditions takes nothing returns boolean
	if(not(GetSpellAbilityId()=='A0AB'))then
		return false
	endif
	return true
endfunction
//4楼施放孟获的大象
function Trig_StartC_Actions takes nothing returns nothing
	//GetSpellAbilityUnit技能施放单位,GetOwningPlayer单位所属玩家。这里应该是Player(4),4楼玩家
	set udg_menghuo1[4]=GetOwningPlayer(GetSpellAbilityUnit())
	set udg_menghuo4[4]=GetSpellAbilityUnit()
	//udg_Lead_Point[4]施放技能武将的开始所在位置
	set udg_Lead_Point[4]=GetUnitLoc(GetSpellAbilityUnit())
	//对其使用技能的目标点
	set udg_Target_Point[4]=GetSpellTargetLoc()
	//将点,大小转换为区域
	set udg_Target_Area[4]=RectFromCenterSizeBJ(udg_Target_Point[4],500.00,500.00)
	call RemoveLocation(udg_Temp_Point[4])
	//OffsetLocation返回偏移点坐标位置
	set udg_Temp_Point[4]=OffsetLocation(udg_Target_Point[4],0,-350.00)
	//创建一个圆圈效果单位
	call CreateNUnitsAtLoc(1,'u00J',Player(4),udg_Temp_Point[4],90.00)
	//播放单位动作
	call SetUnitAnimation(GetLastCreatedUnit(),"birth")
	//获取新创建的圆圈效果单位
	set udg_Door[4]=GetLastCreatedUnit()
	//开启计时器
	call StartTimerBJ(udg_menghuo2[4],false,5.00)
endfunction
//初始化触发器
function InitTrig_StartC takes nothing returns nothing
	set gg_trg_StartC=CreateTrigger()
	call TriggerRegisterPlayerUnitEventSimple(gg_trg_StartC,Player(4),EVENT_PLAYER_UNIT_SPELL_EFFECT)
	call TriggerAddCondition(gg_trg_StartC,Condition(function Trig_StartC_Conditions))
	call TriggerAddAction(gg_trg_StartC,function Trig_StartC_Actions)
endfunction


function Trig_CallC_Func001C takes nothing returns boolean
if(not(GetUnitAbilityLevelSwapped('A0AB',udg_menghuo4[4])==1))then
return false
endif
return true
endfunction
function Trig_CallC_Func002C takes nothing returns boolean
if(not(GetUnitAbilityLevelSwapped('A0AB',udg_menghuo4[4])==2))then
return false
endif
return true
endfunction
function Trig_CallC_Func003C takes nothing returns boolean
if(not(GetUnitAbilityLevelSwapped('A0AB',udg_menghuo4[4])==3))then
return false
endif
return true
endfunction
function Trig_CallC_Actions takes nothing returns nothing
	if(Trig_CallC_Func001C())then
		//创建一个1级的大象
		call CreateNUnitsAtLoc(1,'n01A',Player(4),udg_Target_Point[4],bj_UNIT_FACING)
		//udg_Lucifer指定的是大象单位
		set udg_Lucifer[4]=GetLastCreatedUnit()
		//设置单位的颜色
		call SetUnitVertexColor(udg_Lucifer[4],255,255,255,0)
		//设置碰撞 打开/关闭
		call SetUnitPathing(udg_Lucifer[4],false)
		//移动单位 (立刻)应该创建后就在这个位置吧,不用移动啊。
		call SetUnitPositionLoc(udg_Lucifer[4],udg_Target_Point[4])
		//暂停大象,使得大象不能动
		call PauseUnitBJ(true,GetLastCreatedUnit())
		//设置单位 无敌/可攻击。设置大象为无敌的(不可攻击的)
		call SetUnitInvulnerable(GetLastCreatedUnit(),true)
		//打开gg_trg_SetLuciferC触发器
		call EnableTrigger(gg_trg_SetLuciferC)
	else
	endif
	if(Trig_CallC_Func002C())then
	call CreateNUnitsAtLoc(1,'n017',Player(3),udg_Target_Point[4],bj_UNIT_FACING)
	set udg_Lucifer[4]=GetLastCreatedUnit()
	call SetUnitVertexColor(udg_Lucifer[4],255,255,255,0)
	call SetUnitPathing(udg_Lucifer[4],false)
	call SetUnitPositionLoc(udg_Lucifer[4],udg_Target_Point[4])
	call PauseUnitBJ(true,GetLastCreatedUnit())
	call SetUnitInvulnerable(GetLastCreatedUnit(),true)
	call EnableTrigger(gg_trg_SetLuciferC)
	else
	endif
	if(Trig_CallC_Func003C())then
	call CreateNUnitsAtLoc(1,'n018',Player(3),udg_Target_Point[4],bj_UNIT_FACING)
	set udg_Lucifer[4]=GetLastCreatedUnit()
	call SetUnitVertexColor(udg_Lucifer[4],255,255,255,0)
	call SetUnitPathing(udg_Lucifer[4],false)
	call SetUnitPositionLoc(udg_Lucifer[4],udg_Target_Point[4])
	call PauseUnitBJ(true,GetLastCreatedUnit())
	call SetUnitInvulnerable(GetLastCreatedUnit(),true)
	call EnableTrigger(gg_trg_SetLuciferC)
	else
	endif
endfunction
//触发创建大象
function InitTrig_CallC takes nothing returns nothing
set gg_trg_CallC=CreateTrigger()
call TriggerRegisterTimerExpireEventBJ(gg_trg_CallC,udg_menghuo2[4])
call TriggerAddAction(gg_trg_CallC,function Trig_CallC_Actions)
endfunction
function Trig_SetLuciferC_Func002C takes nothing returns boolean
if(not(udg_Temp_I[4]<255))then
return false
endif
return true
endfunction
function Trig_SetLuciferC_Actions takes nothing returns nothing
//(udg_Lucifer[4]表示召唤出来的大象。GetUnitUserData返回一个int类型的用户数据,猜测是单位id
set udg_Temp_I[4]=GetUnitUserData(udg_Lucifer[4])
if(Trig_SetLuciferC_Func002C())then
call SetUnitVertexColor(udg_Lucifer[4],255,255,255,udg_Temp_I[4])
call SetUnitAnimation(udg_Lucifer[4],"Stand Ready")
call SetUnitUserData(udg_Lucifer[4],(udg_Temp_I[4]+3))
else
//移除光圈特效动画
call RemoveUnit(udg_Door[4])
//解除大象限制,可以控制大象了。
call PauseUnitBJ(false,udg_Lucifer[4])
//设置碰撞 打开/关闭  
call SetUnitPathing(udg_Lucifer[4],true)
//设置单位 无敌/可攻击  false 表示大象可以被攻击了。
call SetUnitInvulnerable(udg_Lucifer[4],false)
//设置单位生命计时器
call UnitApplyTimedLifeBJ(160.00,'BTLF',udg_Lucifer[4])
set udg_Lucifer[4]=null
call RemoveLocation(udg_Target_Point[4])
call RemoveLocation(udg_Temp_Point[4])
call DisableTrigger(GetTriggeringTrigger())
endif
endfunction
//4楼召唤大象出来后是无敌的,需要触发gg_trg_SetLuciferC,即会调用Trig_SetLuciferC_Actions
function InitTrig_SetLuciferC takes nothing returns nothing
set gg_trg_SetLuciferC=CreateTrigger()
call DisableTrigger(gg_trg_SetLuciferC)
call TriggerRegisterTimerEventPeriodic(gg_trg_SetLuciferC,0.05)
call TriggerAddAction(gg_trg_SetLuciferC,function Trig_SetLuciferC_Actions)
endfunction

这个是真三U9 v2.17地图实现的jass代码,里面用了很多的触发器,写的很啰嗦,并且对每个玩家都copy了一次。感觉很乱,导致有些玩家对于的索引出错了。

比如5楼二级技能就没有大象,9楼大象时间无限长,10楼没有大象。

理解代码后修复起来就简单了。有空在优化下,写个通用的触发器实现每个玩家的大象技能。





  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值