Mob die and respawn.

For any problems with Dawn of Light website or game server, please direct questions and problems here.

Moderator: Support Team

Mob die and respawn.

Postby Ethran » Fri Aug 15, 2014 10:21 am

Greetings all, i'm new in these forums and i started a little my adventure with scripting. I hate to bother other ppls but i need little help/hints for my script.
So let me explain, i'm working on mob called Tabor he can be found in Spraggon Den. He spawn a Ghost of Tabor when he dies(and it work in my script) but i got problem with a check.
When his ghost is up, he should not respawn unless that ghost will be killed by a players.
Any ideas how i can improve my code?

Here is a fragment of my code:
Code: Select all
public override void Die(GameObject killer) { GamePlayer player = killer as GamePlayer; if (killer is GamePlayer) { GameNPC mob = new GameNPC(); mob.X = player.X; mob.Y = player.Y; mob.Z = player.Z + 10; mob.CurrentRegion = player.CurrentRegion; mob.Heading = player.Heading; mob.Name = "Ghost of Tabor"; mob.GuildName = "Spirit of Tabor"; //mob.Flags = 4; mob.Level = 36; mob.Realm = 0; mob.Model = 127; mob.Strength = 400; mob.Constitution = 200; mob.Quickness = 80; mob.Dexterity = 80; mob.RoamingRange = 0; mob.MaxSpeedBase = 200; mob.Size = 120; mob.RespawnInterval = -1; mob.MaxDistance = 2000; mob.TetherRange = 1500; mob.SetOwnBrain(new GhostTaborBrain()); mob.AddToWorld(); } //The mob is killed by the killer base.Die(killer); bool canBossRespawn = false; foreach (GameNPC npc in GetNPCsInRadius((WorldMgr.VISIBILITY_DISTANCE))) { if (npc.Name == "Ghost of Tabor") { canBossRespawn = false; break; } else { canBossRespawn = true; } } }
Regards Ethran
"Power is always dangerous. It attracts the worst. And corrupts the best. I never asked for power. Power is only given to those who are prepared to lower themselves to pick it up. "
-Ragnar Lothbrok
User avatar
Ethran
DOL Apprentice
 
Posts: 27
Joined: Thu Aug 07, 2014 7:32 pm

Re: Mob die and respawn.

Postby dargon » Sat Aug 16, 2014 5:17 pm

Maybe instead of killing the mob, on mobs death, heal it and change its flag to ghost, and its name. this way its the same mob, and thus wont allow the other mob to spawn. OR spawn Tabor as a 666 model (invisible) with peace and have it check for Ghost of Tabor, if it isnt there, model = (tabors real model); and turn peace off.
Mannik: Admin of Forsaken Worlds Reborn
dargon
DOL Follower
 
Posts: 451
Joined: Sun Apr 15, 2007 6:55 pm

Re: Mob die and respawn.

Postby Ethran » Sat Aug 16, 2014 6:52 pm

Maybe instead of killing the mob, on mobs death, heal it and change its flag to ghost, and its name. this way its the same mob, and thus wont allow the other mob to spawn. OR spawn Tabor as a 666 model (invisible) with peace and have it check for Ghost of Tabor, if it isnt there, model = (tabors real model); and turn peace off.
Good idea :) but what about drops? If i change name drops will stay inside mob or i also need to add drops into Ghost of Tabor?
"Power is always dangerous. It attracts the worst. And corrupts the best. I never asked for power. Power is only given to those who are prepared to lower themselves to pick it up. "
-Ragnar Lothbrok
User avatar
Ethran
DOL Apprentice
 
Posts: 27
Joined: Thu Aug 07, 2014 7:32 pm

Re: Mob die and respawn.

Postby Leodagan » Sun Aug 17, 2014 6:21 am

Why not use a GameNPC subclass for this kind of scripting ?
Code: Select all
public class GameGhostNPC : GameNPC { protected bool m_isGhost = false; public override int RespawnInterval { // if dying as living respawning quickly as ghost, if ghost respawn normal time to living. get { return m_isGhost ? base.RespawnInterval : 1000; } set { base.RespawnInterval = value; } } protected override int RespawnTimerCallback(RegionTimer respawnTimer) { // Called when respawning this mob if (!m_isGhost) { // was not ghost so we are respawning as ghost // change mob Name ? Model ? Level ? Skills ? /* */ m_isGhost = true; } else { // Restore everything to "living state" /* */ m_isGhost = false; } return base.RespawnTimerCallback(respawnTimer); } }
Use this subclass for the NPC you want to create, Add all specific "Model Change" "Loot Change" "Name Change" in the RespawnTimerCallback override.

During the RespawnTimerCallback the GameNPC isn't Added to World so every change made here will be applied in the "base.RespawnTimerCallback(respawnTimer)" when the real Respawn code is called.
User avatar
Leodagan
Developer
 
Posts: 1350
Joined: Tue May 01, 2012 9:30 am
Website: https://daoc.freyad.net
Location: Lyon

Re: Mob die and respawn.

Postby Ethran » Sun Aug 17, 2014 7:39 am

Thanks for hints! I'm gonna now dance with it, and do my best ;)
Kind Regards.
"Power is always dangerous. It attracts the worst. And corrupts the best. I never asked for power. Power is only given to those who are prepared to lower themselves to pick it up. "
-Ragnar Lothbrok
User avatar
Ethran
DOL Apprentice
 
Posts: 27
Joined: Thu Aug 07, 2014 7:32 pm


Return to “%s” Support

Who is online

Users browsing this forum: No registered users and 1 guest