ArcEmu: Jacob` - 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

Page 1 of 1

Jacob` Npc Script

#1 User is offline   Sathiriass 

  • Member
  • Pip
  • Group: Members
  • Posts: 13
  • Joined: 04-September 12
  • Gender:Male
  • Server OS:Windows

Posted 24 September 2012 - 03:57 AM

Hey With This Npc It Skips Phases It Starts Out As The 1132 Void Walker (Warlock Pet) And It gets bigger (not working) and transforms to water elemental (does not stay there) then transforms into Fire Elemental (doesnt Stay There) then transforms into a storm thingy Then Into A Mana thing(does Not Stay there) (i forget the name)Then Transforms into Some Human Thing And THen Stays There Till It Dies But What Im Looking For Help With Is To Make My Npc Transforms Stay Longer Till A Certain Health And Get Bigger when it gets attacked




-----On combat-------
Attacks you with melee.
Casts Shadowbolt every 3 seconds on a random player.
at 90% hp he starts phase 1,

------Phase 1-------
Casts shadow bolt every 6 seconds
Heals for 12k every 5 seconds.
At 80% phase 2 starts.

-------Phase 2--------
Changes form
Casts frost shield on itself.
Casts Ice tomb every 8 secs which freezes a random target for 5 seconds.
Casts ice bolt every 5 secs on the main tank.
Starts Phase 3 at 60%

------Phase 3-------
Changes form
Casts fire shield on itself.
Casts fireball every 4 seconds.
Starts phase 4 at 40%

-------Phase 4-------
Changes form
Casts lightning shield evvery 15 seconds on itself.
Casts lightning bolt on a random player every 2 seconds.
Starts phase 5 at 20%

-------Phase 5-------
Changes form
Casts arcane bolt every 4 seconds on a random player.
Starts phase 6 at 5%

-------Phase 6-------
Changes form
Bubbles itself making it immune to anything for 8 seconds.
While bubbled it casts death every 2 seconds on a random player.





Thank You For Your Support And Takeing The Time To Read This :)
Sathiriass Of Genesis

Posted Image
0

#2 User is offline   Satanail 

  • Enthusiast
  • PipPipPip
  • Group: Members
  • Posts: 150
  • Joined: 11-March 12
  • Gender:Male
  • Location:Absurdistan
  • Server OS:Windows

Posted 25 September 2012 - 03:19 PM

Well, i will try to explain this as simple as i can. You have a multiple functions that check the health % of the scripted npc. And at the same time, none of them is removed during the phase change event. So: at phase 1, the npc checks if "Unit:GetHealthPct() <=90" and in second "Unit:GetHealthPct() <=80" in third "Unit:GetHealthPct() <=60" and etc. But when the npc comes in phase 2, the condition for phase 2 is still valid. So this causes all of the functions run at the same time and cause this. Try to do register one function and set 3 conditions - the start and end HP of the phase and a control varable that will make sure the phase is enabled just once. Here is a simple test script that will make the things more clear for you.
local self = getfenv(1)

function OnCombat(Unit, event)
self[tostring(Unit)] = {
	phaseid = 0
}
Unit:RegisterAIUpdateEvent(1000)
end

function AIupdate(Unit)
local vars = self[tostring(Unit)]
if(Unit:GetHealthPct() >=80 and Unit:GetHealthPct() <=90 and vars.phaseid == 0)then
Unit:SendChatMessage(14, 0, "PHASE 1")
Unit:SetModel(1070)
vars.phaseid = 1
 -- code for phase 1
elseif(Unit:GetHealthPct() >=60 and Unit:GetHealthPct() <=80 and vars.phaseid == 1)then
Unit:SendChatMessage(14, 0, "PHASE 2")
Unit:SetModel(6209)
vars.phaseid = 2
 -- code for phase 2
 -- AND ETC.
end
end

function OnDied(Unit, event)
local vars = self[tostring(Unit)]
Unit:SendChatMessage(14, 0, "DIED")
vars.phaseid = 0
Unit:RemoveEvents()
Unit:RemoveAIUpdateEvent()
Unit:DeMorph()
end

function OnLeaveCombat(Unit, event)
local vars = self[tostring(Unit)]
Unit:SendChatMessage(14, 0, "Leave Combat.")
vars.phaseid = 0
Unit:RemoveEvents()
Unit:RemoveAIUpdateEvent()
Unit:DeMorph()
end

RegisterUnitEvent(38581,1,OnCombat)
RegisterUnitEvent(38581,2,OnLeaveCombat)
RegisterUnitEvent(38581,4,OnDied)
RegisterUnitEvent(38581,21,AIupdate)


EDIT, npc 38581 is just a test npc i use for things like this. Make sure you change this ID.
0

#3 User is offline   Sathiriass 

  • Member
  • Pip
  • Group: Members
  • Posts: 13
  • Joined: 04-September 12
  • Gender:Male
  • Server OS:Windows

Posted 26 September 2012 - 07:53 PM

View PostSatanail, on 25 September 2012 - 03:19 PM, said:

Well, i will try to explain this as simple as i can. You have a multiple functions that check the health % of the scripted npc. And at the same time, none of them is removed during the phase change event. So: at phase 1, the npc checks if "Unit:GetHealthPct() <=90" and in second "Unit:GetHealthPct() <=80" in third "Unit:GetHealthPct() <=60" and etc. But when the npc comes in phase 2, the condition for phase 2 is still valid. So this causes all of the functions run at the same time and cause this. Try to do register one function and set 3 conditions - the start and end HP of the phase and a control varable that will make sure the phase is enabled just once. Here is a simple test script that will make the things more clear for you.
local self = getfenv(1)

function OnCombat(Unit, event)
self[tostring(Unit)] = {
	phaseid = 0
}
Unit:RegisterAIUpdateEvent(1000)
end

function AIupdate(Unit)
local vars = self[tostring(Unit)]
if(Unit:GetHealthPct() >=80 and Unit:GetHealthPct() <=90 and vars.phaseid == 0)then
Unit:SendChatMessage(14, 0, "PHASE 1")
Unit:SetModel(1070)
vars.phaseid = 1
 -- code for phase 1
elseif(Unit:GetHealthPct() >=60 and Unit:GetHealthPct() <=80 and vars.phaseid == 1)then
Unit:SendChatMessage(14, 0, "PHASE 2")
Unit:SetModel(6209)
vars.phaseid = 2
 -- code for phase 2
 -- AND ETC.
end
end

function OnDied(Unit, event)
local vars = self[tostring(Unit)]
Unit:SendChatMessage(14, 0, "DIED")
vars.phaseid = 0
Unit:RemoveEvents()
Unit:RemoveAIUpdateEvent()
Unit:DeMorph()
end

function OnLeaveCombat(Unit, event)
local vars = self[tostring(Unit)]
Unit:SendChatMessage(14, 0, "Leave Combat.")
vars.phaseid = 0
Unit:RemoveEvents()
Unit:RemoveAIUpdateEvent()
Unit:DeMorph()
end

RegisterUnitEvent(38581,1,OnCombat)
RegisterUnitEvent(38581,2,OnLeaveCombat)
RegisterUnitEvent(38581,4,OnDied)
RegisterUnitEvent(38581,21,AIupdate)


EDIT, npc 38581 is just a test npc i use for things like this. Make sure you change this ID.



:o It Works !!
Sathiriass Of Genesis

Posted Image
0

#4 User is offline   Satanail 

  • Enthusiast
  • PipPipPip
  • Group: Members
  • Posts: 150
  • Joined: 11-March 12
  • Gender:Male
  • Location:Absurdistan
  • Server OS:Windows

Posted 27 September 2012 - 03:03 AM

View PostSathiriass, on 26 September 2012 - 07:53 PM, said:

:o It Works !!

Didn't had time to rewrite the whole script back then. Here is the whole thing rewritten. Hope it will be useful to you.
0

Share this topic:


Page 1 of 1


Fast Reply

  

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