Elĩţέ Găмέrś™
April 19, 2024, 03:33:03 pm
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Welcome to Elite Gamers Community have fun and contribute to the community and be Rewarded.
 
  Home Help Search Arcade Gallery Links Staff List Login Register  

[Tut] How to make Range attacks

Pages: [1]
  Print  
Author Topic: [Tut] How to make Range attacks  (Read 16 times)
Unidentical
Administrator
Known Member
*

Karma: +105/-0
Posts: 69


I have the cape! I am an admin, dont double post!


View Profile WWW
« on: December 03, 2007, 08:57:18 pm »

This goes to Hybird From HCO so huge thanks Cheesy

Ok, For example heres Hercules, // Will be any comments (Comments are on the right of the slashes)


Note this is only suitable for PHYSICAL attacks, Not magic like Fire Circle or w/e.

Code:
1115: // Hercules
  begin
   if Lvl > 4 then Exit; // Invalid Spell if Level is higher than 4
   if Attacker.Character.Stamina < 25 then Exit; // check stamina
   if (Attacker.Character.Equipment[ItemPos_Lefthand].ItemID div 1000) <>
      (Attacker.Character.Equipment[ItemPos_Righthand].ItemID div 1000) then
    Exit;
   // above checks if their two weapon-types match

   Attacker.Character.Stamina := Attacker.Character.Stamina - 25;
   // update stamina

   Attacker.SendPacket(StatTypePacket(Attacker.Character.CharacterID, Attacker.Character.Stamina, ST_STAMINA, Attacker.Character.CurrentHP));
  // send new stamina to client

   Targets := TargetsInRange(Attacker, Damage, Lvl+1, DT_PHYSICAL, 0.25);
  // lvl+1 is the range
  // 0.25 is the offset of how much to cut off the damage

   Packet := MAttackPacket(Attacker.Character.CharacterID,
                           X, Y, SpellID, Lvl, Targets);
   Attacker.SendPacket(Packet);
   SendRangePacket(Attacker.Character, MaxViewDistance, MaxViewDistance, Packet);
  // above sends and constructs the packet
   Targets.Free; // dispose of the memory used by 'targets' hashtable
  end;

This is how it should be done

Code:
(spell id): // (spell name)
  begin
   if Lvl > (highest level) then Exit; // Invalid Spell if Level is higher than ( highest level of the spell)
   if Attacker.Character.Stamina < (amount of stanima) then Exit; // check stamina
   if (Attacker.Character.Equipment[ItemPos_Lefthand].ItemID div 1000) <>
      (Attacker.Character.Equipment[ItemPos_Righthand].ItemID div 1000) then
    Exit;
   // above checks if their two weapon-types match

   Attacker.Character.Stamina := Attacker.Character.Stamina - (amount of stanima;
   // update stamina

   Attacker.SendPacket(StatTypePacket(Attacker.Character.CharacterID, Attacker.Character.Stamina, ST_STAMINA, Attacker.Character.CurrentHP));
  // send new stamina to client

   Targets := TargetsInRange(Attacker, Damage, Lvl+1, DT_PHYSICAL, 0.25);
  // lvl+1 is the range
  // 0.25 is the offset of how much to cut off the damage

   Packet := MAttackPacket(Attacker.Character.CharacterID,
                           X, Y, SpellID, Lvl, Targets);
   Attacker.SendPacket(Packet);
   SendRangePacket(Attacker.Character, MaxViewDistance, MaxViewDistance, Packet);
  // above sends and constructs the packet
   Targets.Free; // dispose of the memory used by 'targets' hashtable
  end;

^^^^ was done by me well some of it

Thanks Cheesy
Report Spam   Logged


Share on Facebook Share on Twitter



Pages: [1]
  Print  
 
Jump to:  

Bookmark this site! | Upgrade This Forum
SMF For Free - Create your own Forum

Powered by SMF | SMF © 2016, Simple Machines
Privacy Policy