Aller au contenu

Photo

On Hit Apply


  • Veuillez vous connecter pour répondre
6 réponses à ce sujet

#1
Baragg

Baragg
  • Members
  • 271 messages
I want to apply some dmg when a weapon hits. How best to go about this?

#2
Shadooow

Shadooow
  • Members
  • 4 470 messages
Best way? forget on onhit, make it as normal damage itemproperty.



Why?



1) onhits are not very much efficient, lvl 20 player can fire onhit script every second, and if more players had this onhit...

2) damage applied in the onhit script does not add into damage applied by weapon that means that resistances/immunities are applied again, also you can't combine damage so lets say your onhit would does 1d6 sonic and 4dmg electrical, this would happen:

1) normal hit, damage number appear over player's head, damage is printed in log

2) 1d6 sonic is applied, another number shows over player's hand, damage is printed in log

3) 4 electrical - another number shows over player's hand, damage is printed in log again



As long it can be implemented as itemproperty I would stick with it, but if you imply on onhit, I will suggest you to make custom spell and custom itemproperty, player do no need to have this, its server-side. Basically you copy onhit spell to new line and change the script, then make new onhit cast spell itemproperty with this line and add it to the weapon and then make the script.

#3
Baragg

Baragg
  • Members
  • 271 messages
I was seeking to make a dart weapon for dms only, we have some dm event games that can be quite long if there are not a mess of players on. So this weapon would be a way a dm could throw a dart and reduce the amount of hp a boss creature has left.



I want to have the dart to hit, then get the amount of hp the critter has left apply x dmg, then check the hp left to insure x amount has been done. If x is not done apply more dmg..........etc.........untill x amount of dmg has been sustained by critter. So one dart would do the job, this would be for dms only, and only to be used in events.

#4
Baragg

Baragg
  • Members
  • 271 messages
Maybe best just to use a targeting widget now that I think on it.

#5
Genisys

Genisys
  • Members
  • 525 messages
Yes, that sounds like a good idea... (like a DM Harm Rod - though not as powerful as harm)

Maybe one that took say 10% of the monster's Hit Points / Use..?
Let me draw this up for you, I love tagbased scripting..

Here is your script...

//script name:  dm_harm_rod  (make an item with this exact tagname)
//Don't forget to give the item the Cast Spell:   Activate Item (Long Range) property..(unlimited uses / day)
//////////////////////////////////////////////////////////////////////////
//Created By: Geinsys (Guile)
//Created On: 9/02/10
/////////////////////////////////////////////
/*
   This tagbased item will take 10% of the
   target's hit points, only a DM may use
   this item! No Visual Effect is used..
*/
/////////////////////////////////////////////

//Set this to FALSE if you  want PC's allowed to use this DM item
//this means DM's can log on as a player and use it....

const int DM_USE_ONLY = TRUE; //Default = TRUE (Only a DM can use it)

//////////////////////////////////////////////////////////////////////////////
//Required Include
#include "x2_inc_switches"
//////////////////////////////////////////////////////////////////////////////
//Main Script
void main()
{
 int nEvent =GetUserDefinedItemEventNumber();
 if(nEvent !=  X2_ITEM_EVENT_ACTIVATE)return;

 //Define all Variables here..
 object oPC = GetItemActivator();
 object oTarget = GetItemActivatedTarget();
 object oItem = GetItemActivated();
 int nHP, nInt;
 string sMsg, sName, sID;
 effect eDamage;

if(DM_USE_ONLY == TRUE)
{
 if(!GetIsPC(oPC))
 {
  DestroyObject(oItem, 0.0);
  FloatingTextStringOnCreature("You are not a DM!", oPC, FALSE);
  sName = GetName(oPC);
  sID = GetPCPlayerName(oPC);
  sMsg = "***WARNING*** - " + sName + " / " + sID + " / Has used the DM Harm Rod AS A PC!!";
  WriteTimestampedLogEntry(sMsg);  //Tell the Admin about this problem..
 }
}

 nHP = GetCurrentHitPoints(oTarget);
 if(nHP >=10)
 {
   nInt = nHP / 10;  //10% of the targets current hit points
 }
 //Otherwise they only have 9 or less Hit Points
 else { nInt = 1; } // always deal at least 1 dmg

 //NOTE: Some monsters may have damage immunity or resistance to positive damage!
 //this of course would lower the amount of damage dealt by this rod (rare)
 eDamage = EffectDamage(nInt, DAMAGE_TYPE_POSITIVE, DAMAGE_POWER_NORMAL);

 ApplyEffectToObject(DURATION_TYPE_INSTANT, eDamage, oTarget, 0.0);

}

Modifié par Genisys, 03 septembre 2010 - 12:30 .


#6
ehye_khandee

ehye_khandee
  • Members
  • 855 messages
The above script has errors in it....



Line 39 should be changed in the above script to read



if(!GetIsDM(oPC))



NOT "if(!GetIsPC(oPC))" which it is now. DM's are PLAYERS too.



You should test your script before posting them Guile.



You might also use a float for HP because dividing by ten can get you a decimal number, then convert it to INT before applying damage to the target.



Details, details, always details.



Be well. Game on.

GM_ODA


#7
Baragg

Baragg
  • Members
  • 271 messages
Thanks yall.