ArcEmu: [lua] How To Stop A Combat - ArcEmu

Jump to content

Toggle shoutbox Lastest Announcements

dfighter  : (07 December 2014 - 12:06 PM) Arcemu is in hibernation mode, please read http://arcemu.org/fo...showtopic=26903
dfighter  : (01 January 2013 - 05:56 PM) Arcemu wishes you all a happy new year!
Hasbro  : (12 September 2012 - 10:01 AM) Please excuse our outage from the web! Our web host had a major malfunction!
dfighter  : (01 September 2012 - 04:05 PM) Since the spam bots just don't want to stop, I've enabled admin verification when registering.
dfighter  : (23 January 2012 - 09:56 PM) Please note that from now on you will need to confirm your email on the wiki in order to edit it!
Hasbro  : (31 December 2011 - 12:50 PM) Happy New Years all!
Navid  : (26 December 2011 - 04:09 AM) Merry Christmas !!!!!! Happy holidays all :)
WAmadeus  : (24 December 2011 - 03:54 PM) Merry Christmas to all!
dfighter  : (24 December 2011 - 11:05 AM) The Arcemu team wishes y'all a Merry Christmukkah!
Hasbro  : (05 October 2011 - 12:53 PM) Looking for web designers for upcoming web related project. If you're interested in designing user interfaces contact me
dfighter  : (02 September 2011 - 03:47 PM) So who here wants vehicles in Arcemu? :P http://arcemu.org/fo...showtopic=25440
Hasbro  : (14 August 2011 - 03:25 PM) Join us on irc, grab an irc client and connect to irc.freenode.net join channel #arcemu /server irc.freenode.net:6667 /join #arcemu
jackpoz  : (03 August 2011 - 05:33 AM) to all Lua Engine (old one) users: please check http://arcemu.org/fo...showtopic=25274
Hasbro  : (20 May 2011 - 05:27 PM) Looking for people experienced with CMake configuration and setup! Contact me asap
Hasbro  : (15 May 2011 - 05:03 PM) ArcEmu is recruiting C++ programmers, contact Hasbro if interested.
paroxysm  : (03 May 2011 - 06:26 PM) Updated luabridge gossip example to describe the whole gossip creation process rather than just how to create menu. Gossip tutorial
paroxysm  : (23 April 2011 - 11:35 AM) Lua writers can refer to the Luabridge Tutorials section in the Wiki to learn how to write gossip code correctly.
Hasbro  : (20 April 2011 - 05:22 PM) Thank you for your continuous contribution of bug reports, we are working on them.
Hasbro  : (17 April 2011 - 03:20 AM) Please consider donating to support our bills. Donations can be sent using PayPal to donations@arcemu.org - Thank you for your support.
paroxysm  : (10 April 2011 - 12:43 AM) Refer to the Luabridge Tutorials section in the Wiki to learn the new syntax of luabridge.
Resize Shouts Area

Labels

Make sure when posting a help or release topic you put [c++] or [lua] BEFORE your topic title!
Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

[lua] How To Stop A Combat

#1 User is offline   Magnifikator 

  • Interested
  • PipPipPipPip
  • Group: Members
  • Posts: 398
  • Joined: 05-October 11
  • Gender:Male
  • Location:Switzerland
  • Server OS:Windows

Posted 12 August 2012 - 11:46 AM

I'm looking for a Lua command that stops a combat.
Tried already with:
pUnit:DisableCombat(1)
pUnit:SetCombatCapable(1)
pUnit:SetUInt32Value(59, 0) -- not attackable

But .npc info say always: In Combat, even the NPC has friendly faction

--[[
Dont Kill the Fat One
http://de.wowhead.com/quest=9889 

.worldport 530 -3289.18 6003.41 -1.35
]]--

local Unkor = 18262

function UnkorTakesDamage(pUnit, event, pAttacker, pAmount)

print(pUnit:GetHealthPct())
	
	if (pUnit:GetHealthPct()<30) then
--
-- here code to stop combat
--
		pUnit:SetFaction(35) -- set to friendly faction to be able to open the quest window
		pUnit:SendChatMessage(14, UNIVERSAL, "I give up! Please don't kill me!")
		pUnit:RegisterEvent("UnkorReset", 60000, 1)
	end
end

function UnkorReset(pUnit, Event)
	pUnit:SetFaction(45)
--
-- here code to reset
--
end

RegisterUnitEvent(Unkor, UNIT_EVENT_ON_DAMAGE_TAKEN, "UnkorTakesDamage")

Try out the LoE ArcEmu World database. Please visit dev.LandOfElves.net.

Posted Image


0

#2 User is offline   Loken 

  • Enthusiast
  • PipPipPip
  • Group: Members
  • Posts: 186
  • Joined: 19-July 11
  • Gender:Male
  • Location:Lordaeron
  • Interests:Arcemu, WOW.
  • Server OS:Windows

Posted 12 August 2012 - 01:33 PM

pUnit:DisableCombat(1) should work fine. At least its working fine to me.

edit: you tested it with the reloadscript command? because that could be the problem...
Posted Image
Posted Image
0

#3 User is offline   Magnifikator 

  • Interested
  • PipPipPipPip
  • Group: Members
  • Posts: 398
  • Joined: 05-October 11
  • Gender:Male
  • Location:Switzerland
  • Server OS:Windows

Posted 12 August 2012 - 02:30 PM

View PostLoken, on 12 August 2012 - 01:33 PM, said:

edit: you tested it with the reloadscript command? because that could be the problem...

Not anymore. I already have seen that it makes problem.

Short briefing about the quest:
Part 1: Kill 10 mobs. No problem. Works fine. Doesn't need script
Part 2: Hit Unkor but don't kill him. After some hits he should give up and you can finish this part of a multi quest.

First Unkor is a questgiver but also an enemy. So you can't open the quest window in the beginning.

I thought I can do it like that:
Check some percentage of his health and if it's lower make him stopping combat and give him a friendly faction for 1 minute.

With pUnit:DisableCombat(1) and Unit:SetFaction(45) the following thing happens:
The NPC change the faction (green) and I can open the quest window to finish this quest and take the next one.
But my player char continuous hitting the NPC and if I check with .npc info it's written 'Creature is in combat'. The NPC's health is also not recharging and if I move he turns into my direction.

What I wanted is that the combat stops and the NPC is neutral or friendly for some time.
Try out the LoE ArcEmu World database. Please visit dev.LandOfElves.net.

Posted Image


0

#4 User is offline   Loken 

  • Enthusiast
  • PipPipPip
  • Group: Members
  • Posts: 186
  • Joined: 19-July 11
  • Gender:Male
  • Location:Lordaeron
  • Interests:Arcemu, WOW.
  • Server OS:Windows

Posted 12 August 2012 - 03:25 PM

I see. You need to stop the player. There should be a spelltrigger for this quest, or you can try spawning another "fat" in a different phase and switch them
Posted Image
Posted Image
0

#5 User is offline   Magnifikator 

  • Interested
  • PipPipPipPip
  • Group: Members
  • Posts: 398
  • Joined: 05-October 11
  • Gender:Male
  • Location:Switzerland
  • Server OS:Windows

Posted 12 August 2012 - 03:38 PM

Hui, what a hack :D

And what do you mean with spell trigger ?

Dfighter !!! I need more Lua commands :lol:
Try out the LoE ArcEmu World database. Please visit dev.LandOfElves.net.

Posted Image


0

#6 User is offline   Loken 

  • Enthusiast
  • PipPipPip
  • Group: Members
  • Posts: 186
  • Joined: 19-July 11
  • Gender:Male
  • Location:Lordaeron
  • Interests:Arcemu, WOW.
  • Server OS:Windows

Posted 12 August 2012 - 07:23 PM

local Unkor = 18262

function UnkorTakesDamage(pUnit, event, pAttacker, pAmount)

print(pUnit:GetHealthPct())
	
	if (pUnit:GetHealthPct()<30) then

                pAttacker:CastSpell(32174)
                pAttacker:StopPlayerAttack()
		pUnit:SetFaction(35) -- set to friendly faction to be able to open the quest window
		pUnit:SendChatMessage(14, UNIVERSAL, "I give up! Please don't kill me!")
		pUnit:RegisterEvent("UnkorReset", 60000, 1)
	end
end

function UnkorReset(pUnit, Event)
	pUnit:SetFaction(45)
--
-- here code to reset
--
end

RegisterUnitEvent(Unkor, UNIT_EVENT_ON_DAMAGE_TAKEN, "UnkorTakesDamage")


View PostMagnifikator, on 12 August 2012 - 03:38 PM, said:

Dfighter !!! I need more Lua commands :lol:

The command its there... just need to be reported and fixed :P
Posted Image
Posted Image
0

#7 User is offline   Magnifikator 

  • Interested
  • PipPipPipPip
  • Group: Members
  • Posts: 398
  • Joined: 05-October 11
  • Gender:Male
  • Location:Switzerland
  • Server OS:Windows

Posted 13 August 2012 - 01:40 PM

Quote

The command its there... just need to be reported and fixed :P

I don't understand. The command is where ?
Try out the LoE ArcEmu World database. Please visit dev.LandOfElves.net.

Posted Image


0

#8 User is offline   Loken 

  • Enthusiast
  • PipPipPip
  • Group: Members
  • Posts: 186
  • Joined: 19-July 11
  • Gender:Male
  • Location:Lordaeron
  • Interests:Arcemu, WOW.
  • Server OS:Windows

Posted 13 August 2012 - 02:04 PM

View PostMagnifikator, on 13 August 2012 - 01:40 PM, said:

I don't understand. The command is where ?

In the lua engine
if (pUnit:GetHealthPct()<30) then

                pAttacker:CastSpell(32174)
                pAttacker:StopPlayerAttack() <------- IM BUGGED  :lol:  
                pUnit:SetFaction(35) -- set to friendly faction to be able to open the quest window


Posted Image
Posted Image
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users