How to properly fix or implement monsters using magic/skill?

06/17/2022 09:38 KingGannon#1
I do feel that I should know this but missed out on something

I'm using conquer client v5065, this is redux source
The original code for Redux source will have magic monsters (messengers, AZ spawns, snake king, fiend bats etc) and guards using physical attacks and magic spells/skills are non-existent in the AI.

I went to look at Monster.cs and made my attempt under the
case MonsterMode.Attack
then under
else if (Common.Clock - LastAttack > BaseMonster.AttackSpeed)

I have changed to this code

Code:
if (BaseMonster.SkillType == 8036 && (target is Player) && !target.HasEffect(ClientEffect.BlueName))
{
	Mode = MonsterMode.Idle;
}
else if(BaseMonster.SkillType > 0)
{
	LastAttack = Common.Clock; 

	var skill = Database.ServerDatabase.Context.MagicType.GetById(BaseMonster.SkillType);

	uint dmg = CalculateSkillDamage(target, skill, skill.Percent < 100);
	var packet = SkillEffectPacket.Create(UID, target.UID, BaseMonster.SkillType, 0);
	packet.AddTarget(target.UID, dmg);

	SendToScreen(packet);
	var pack = InteractPacket.Create(UID, target.UID, target.X, target.Y, InteractAction.MagicAttack, 0);
	pack.MagicType = BaseMonster.SkillType;
	pack.MagicLevel = 0;
	pack.Target = target.UID;
	CombatEngine.ProcessInteractionPacket(pack);
                            
	if (dmg > 0) 
	{
		target.ReceiveDamage(dmg, UID);
	}
}
else
{
	LastAttack = Common.Clock;
	CombatEngine.ProcessInteractionPacket(InteractPacket.Create(UID, TargetID, target.X, target.Y, InteractAction.Attack, 0));
}
Problem is whenever the monster using magic spell/skill reduces their target's HP to 0, it's still not considered dead. As a player you're not dead. When the guard kills a monster that monster HP is 0 but not dead it sits there idle with 0 HP and doesn't respawn.

Anyone know what to do?
06/17/2022 12:38 Energetic(H)#2
my advice let this source if you cant code this source alot missy and bad coded
06/17/2022 20:41 KingGannon#3
Quote:
Originally Posted by Energetic(H) View Post
my advice let this source if you cant code this source
Not sure I understand what exactly you are trying to say "let this source if I cannot code this source" ???

Quote:
Originally Posted by Energetic(H) View Post
alot missy and bad coded
My best interpretation is for me to choose another source that's not redux cause it's "missy and bad coded" No idea what you mean by missy


Either way, whatever public source released, Redux or not. There will still be work required to be done and changing sources doesn't solve underlying issues which is the ongoing process of coding and making the game work. None of the sources out there, public or not, are even close to being flawlessly coded nor complete without needing any work to get it in a "playable" state.
Eventually, it will comes back to something similar this. Where I will have a bug in the game code or game issues and have to try to fix it up.
For this case, somehow fixing one part of the bug and then breaking another part of the game. Still ended up coming back to ask to help or fix advice.
Getting stuck is only part of the process. Learning and coding and fixing the source + bugs in the code is still something not just me but all of us will have to do if we are going to properly run a game.
06/17/2022 22:01 Spirited#4
Was curious and looked a little more into it. It looks like most combat methods check the Alive property on entities after dealing damage. The ReceiveDamage method doesn't have any checks against life and doesn't call Kill on the player. Take a look at references to ReceiveDamage and you'll see what I mean.
06/19/2022 08:20 KingGannon#5
Spirited to the rescue again
Thank you Boss, for taking the time and looking into it
I don't know what I'd do without you pointing that out
I probably be frantically searching all over the place before I learn it was right under my nose all along

I had a look at the code and fixed it
and pretty much as you had said too - there isn't any checks against life so I added it
if Life <= 0
Kill target

and for those Messengers + Snake King + Water Devils etc now the price of death really hurts melee classes like they are supposed to
06/19/2022 08:39 Spirited#6
Quote:
Originally Posted by KingGannon View Post
Spirited to the rescue again
Thank you Boss, for taking the time and looking into it
I don't know what I'd do without you pointing that out I probably be frantically searching all over the place before I learn it was right under my nose all along

I had a look at the code and fixed it
and pretty much as you had said to there isn't any checks against life so I added it
if Life <= 0
Kill target

and those Messengers + Snake King + Water Devils etc now the price of death really hurts melee classes like they are supposed to
Awesome, glad to know that fixed it. Have fun!