Help with skill level

05/04/2011 03:21 ConquerFreakish#1
This is based on 5017 Reunited CO source....
I wanna learn how to specify Skill Level in my if statements. Like for example
PHP Code:
                  if (SkillId==1002)
                                {                  
                                    
MyChar.SkillLooping SkillId;
                                    
MyChar.SkillLoopingX = (ushort)x;
                                    
MyChar.SkillLoopingY = (ushort)y;
                                    
MyChar.SkillLoopingTarget Target;
                                    
MyChar.AtkType 21;
                                    
MyChar.Attack();
                                    
MyChar.Attacking true;
                                    
CurMP-=130;
                                } 
Im trying to code in the magic skills to take mana. And a elementary tornado isnt gonna take 130 mana.
05/04/2011 08:53 pro4never#2
No offense but why not simplify the entire thing...

Instead of the SkillLooping, X, Y, Target all being different values... just save the attack packet that is sent from the client and just re-process it through the packet processor every X ms (based on attack speed/attack type... I'd calculate "next attack" in the final attack code you are using.

So in simpler terms..

public byte[] AttackPacket = null;
public DateTime NextAttack = DateTime.Now; //just so it's initialized

On SUCCESSFUL attack set AttackPacket = current packet being processed (you'd need to edit some of your attack methods to accept the actual packet... but it's simple enough to do) and set NextAttack = DateTime.Now.AddMilliseconds(AttackSpeedForSkill/AttackType);

Then in your threading system (per character or however you are doing it) just check if DateTime.Now > MyChar.NextAttack && MyChar.AttackPacket != null

Remember to null out the attack packet on... movement, portal, scroll, death, target killed or out of range...