Archived copy of war3source.com, the War3Source forum (2009–2020), rebuilt from the Internet Archive by wc3mods.net. This page was captured on 2013-01-25 (original capture). Forum · All archived topics · Wiki · Bug tracker · Blog

War3:Source

Development => Tutorials => Topic started by: -El Diablo on November 30, 2012, 05:50:25 PM



Title: Adding your own Immunities to War3Source
Post by: -El Diablo on November 30, 2012, 05:50:25 PM
To add your own Immunity_Something, just add yours to the last part of the list.

Make sure you replace Something word with what ever you choose.

EXAMPLE CODE BELOW

Locate file CONSTANTS.INC and edit this code:

Code:
enum War3Immunity
{
Immunity_None = 0, //generic zero
Immunity_Ultimates, // Immune from ultimates
Immunity_PhysicalDamage, // Immune from health taking
Immunity_MagicDamage, // Immune from magic based stuff (doesnt not include ultimates)
Immunity_Items, // Immune from shop items
Immunity_Skills, // Immune from all skills
Immunity_Wards, // Immune ward modifiers/damage. skill immunity includes ward immunity
Immunity_Abilities, // Immune from abilities (not implemented by core)
        Immunity_Something, // Immune from something of your choice as this is an example
}; // The last of PimpinJuice's sexy syntax

Next in the same file locate this code and add your bImmunitySomethings to the last part of the list preferably, but if its for yourself just add it after bImmunityAbilities.  If you add it after bImmunityAbilities, then prepare to compile all your code again.

If your updating svn, make it the last thing on the list so that everyone does not have to recompile their whole source!

Code:
enum W3Buff
{
buffdummy=0,
bBuffDenyAll, //DENY=not allowed to have any buffs, aka "purge"

fLowGravitySkill, //0.4 ish?
fLowGravityItem, //0.4 ish?
bLowGravityDenyAll,

fInvisibilitySkill, //0.4 ish?
fInvisibilityItem, //0.4 ish?
bInvisibilityDenyAll,
bInvisibilityDenySkill, //needed for orc
bDoNotInvisWeapon,
bInvisWeaponOverride, //set true to use override amount, ONLY 1 RACE SHALL USE THIS AT A TIME PER CLIENT
iInvisWeaponOverrideAmount, ///amolunt of 0-255 , do not have to set back to 255, just set bInvisWeaponOverride to false
///11

fMaxSpeed, //for increasing speeds only! MUST BE MORE THAN 1.0
fMaxSpeed2, //for increasing speeds only!, added onto fMaxSpeed buff, MUST BE MORE THAN 1.0

fSlow, //for decreeasing speeds only! MUST BE LESS THAN 1.0
fSlow2, //for decreeasing speeds only! MUST BE LESS THAN 1.0. allows a race to have stacking slows
bSlowImmunity, //immune to slow?

bImmunitySkills, //is immune to skills
bImmunityUltimates, // is immune to ultimates
bImmunityWards, // is immune to wards, skill immunity includes ward immunity
bImmunityItems, // is immune to items
bImmunityAbilities, // is immune to abilities

fAttackSpeed, //attack speed multipler!

bStunned, //cannot shoot, cannot cast, cannot move, basically everything below
bBashed, //cannot move
bDisarm,//cannot shoot
bSilenced,  //cannot cast
bHexed,  // no skill proc
bPerplexed, //cannot use items / proc items

bNoMoveMode,//move type none! overrrides all other movestypes
bFlyMode,   //fly mode
bFlyModeDeny,
bNoClipMode,

fArmorPhysical,
fArmorMagic,

//DO NOT USE GLOW FOR INVIS
iGlowRed, //glowing the player 0-255
iGlowGreen,
iGlowBlue,
iGlowAlpha, //careful this is like invisiblity
iGlowPriority, //highest priority takes effect
fGlowSetTime, //time is recorded, those with same prioirty will compete via time. not something u set


fHPRegen, ///float sum! NO NEGATIVES! MINIM regin rate is 0.5 / second ( 1 hp per 2 seconds)
fHPDecay, //float sum, NO NEGATIVES, postive means lose this much HP / second, same requirements as fHPRegen
fHPRegenDeny, //set true to deny hp regen
iAdditionalMaxHealth,   ///increase / decrease in maxhp

//44
fDodgeChance, //Registers a chance to dodge, (Note: 0.7 would equal a 30% chance to dodge)
bDodgeMode, //Set 0 for Pre, 1 for post (quick regen)

fVampirePercent, //Sets a % of damage done to give back as health
fVampirePercentNoBuff, // Same as fVampirePercent, but doesn't overheal
fMeleeVampirePercent, // Sets a % of damage done to give back as health when the damage was caused by melee
fMeleeVampirePercentNoBuff, // Same as fMeleeVampirePercent, but doesn't overheal

fBashChance, //Registers a chance to bash, (Note: 0.7 would equal a 30% chance to bash)
iBashDamage, //Does a certain amount of damage when you bash an enemy (more similar to warcraft 3's bash, default 0)
fBashDuration, //Sets the duration of bash's stun

fCritChance, //Registers a chance to crit, (Note: 0.7 would equal a 30% chance to crit)
iCritMode, //Default 0 (all damage qualifies for crit) 1 (bullet damage crit) 2 (grenade damage crit) 3 (melee damage crit) 4 (melee and bullet crit) 5 (melee and grenade crit) 6 (bullet and grenade crit)
fCritModifier, //Sets the critical strike modifer, default 1.0

iDamageMode, //Default 0 (all damage qualifies for damage increase) 1 (bullet damage damage increase) 2 (grenade damage damage increase) 3 (melee damage damage increase) 4 (melee and bullet damage increase) 5 (melee and grenade damage increase) 6 (bullet and grenade damage increase)

iDamageBonus, //Gives a direct increase to damage done
fDamageModifier, //Gives a % increase to damage done

        bImmunitySomething, // Make sure you put yours before the MaxBuffLoopLimitTemp

MaxBuffLoopLimitTemp, //this is a variable that is for loops, this number is automatically generated from the enum.

}

Now add

   buffpropertiesarray[ bImmunitySomething ][DefaultValue]=false;
   buffpropertiesarray[ bImmunitySomething ][BuffStackType]=bHasOneTrue;   

to the list below with your own bImmunitySomething  ...

Code:
//create an buffpropertiesarray[W3Buff][W3BuffProperties]; (separate from the array that stores every client's buffs)
//we fill the array with its properties
stock InitiateBuffPropertiesArray(buffpropertiesarray[W3Buff][W3BuffProperties])
{

for(new i=0;i<MaxBuffLoopLimit;i++)
{
buffpropertiesarray[W3Buff:i][DefaultValue]=-99;
buffpropertiesarray[W3Buff:i][BuffStackType]=ERRUNDEFINED;
}

buffpropertiesarray[buffdummy][DefaultValue]=false;
buffpropertiesarray[buffdummy][BuffStackType]=bHasOneTrue;

buffpropertiesarray[bBuffDenyAll][DefaultValue]=false;
buffpropertiesarray[bBuffDenyAll][BuffStackType]=bHasOneTrue;

buffpropertiesarray[fLowGravitySkill][DefaultValue]=1.0;
buffpropertiesarray[fLowGravitySkill][BuffStackType]=fMinimum;

buffpropertiesarray[fLowGravityItem][DefaultValue]=1.0;
buffpropertiesarray[fLowGravityItem][BuffStackType]=fMinimum;

buffpropertiesarray[ bLowGravityDenyAll ][DefaultValue]=false;
buffpropertiesarray[ bLowGravityDenyAll ][BuffStackType]=bHasOneTrue;

buffpropertiesarray[ fInvisibilitySkill ][DefaultValue]=1.0;
buffpropertiesarray[ fInvisibilitySkill ][BuffStackType]=fMinimum;

buffpropertiesarray[ fInvisibilityItem ][DefaultValue]=1.0;
buffpropertiesarray[ fInvisibilityItem ][BuffStackType]=fMinimum;

buffpropertiesarray[ bInvisibilityDenyAll ][DefaultValue]=false;
buffpropertiesarray[ bInvisibilityDenyAll ][BuffStackType]=bHasOneTrue;

buffpropertiesarray[ bInvisibilityDenySkill ][DefaultValue]=false;
buffpropertiesarray[ bInvisibilityDenySkill ][BuffStackType]=bHasOneTrue;

buffpropertiesarray[ bDoNotInvisWeapon ][DefaultValue]=false;
buffpropertiesarray[ bDoNotInvisWeapon ][BuffStackType]=bHasOneTrue;

buffpropertiesarray[ bInvisWeaponOverride ][DefaultValue]=false;
buffpropertiesarray[ bInvisWeaponOverride ][BuffStackType]=bHasOneTrue;

buffpropertiesarray[ iInvisWeaponOverrideAmount ][DefaultValue]=255;
buffpropertiesarray[ iInvisWeaponOverrideAmount ][BuffStackType]=iMinimum;

buffpropertiesarray[ fMaxSpeed ][DefaultValue]=1.0;
buffpropertiesarray[ fMaxSpeed ][BuffStackType]=fMaximum;

buffpropertiesarray[ fMaxSpeed2 ][DefaultValue]=1.0;
buffpropertiesarray[ fMaxSpeed2 ][BuffStackType]=fMaximum;


buffpropertiesarray[ fSlow ][DefaultValue]=1.0;
buffpropertiesarray[ fSlow ][BuffStackType]=fStacked;

buffpropertiesarray[ fSlow2 ][DefaultValue]=1.0;
buffpropertiesarray[ fSlow2 ][BuffStackType]=fStacked;

buffpropertiesarray[ bSlowImmunity ][DefaultValue]=false;
buffpropertiesarray[ bSlowImmunity ][BuffStackType]=bHasOneTrue;

// buffpropertiesarray[ fIncomingDamage ][DefaultValue]=1.0;
// buffpropertiesarray[ fIncomingDamage ][BuffStackType]=fStacked;

buffpropertiesarray[ bImmunitySkills ][DefaultValue]=false;
buffpropertiesarray[ bImmunitySkills ][BuffStackType]=bHasOneTrue;

buffpropertiesarray[ bImmunityWards ][DefaultValue]=false;
buffpropertiesarray[ bImmunityWards ][BuffStackType]=bHasOneTrue;

buffpropertiesarray[ bImmunityUltimates ][DefaultValue]=false;
buffpropertiesarray[ bImmunityUltimates ][BuffStackType]=bHasOneTrue;

buffpropertiesarray[ bImmunityItems ][DefaultValue]=false;
buffpropertiesarray[ bImmunityItems ][BuffStackType]=bHasOneTrue;

buffpropertiesarray[ bImmunitySomething ][DefaultValue]=false;
buffpropertiesarray[ bImmunitySomething ][BuffStackType]=bHasOneTrue;

buffpropertiesarray[ bImmunityAbilities ][DefaultValue]=false;
buffpropertiesarray[ bImmunityAbilities ][BuffStackType]=bHasOneTrue;

buffpropertiesarray[ fAttackSpeed ][DefaultValue]=1.0;
buffpropertiesarray[ fAttackSpeed ][BuffStackType]=fStacked;

buffpropertiesarray[ bStunned ][DefaultValue]=false;
buffpropertiesarray[ bStunned ][BuffStackType]=bHasOneTrue;

buffpropertiesarray[ bBashed ][DefaultValue]=false;
buffpropertiesarray[ bBashed ][BuffStackType]=bHasOneTrue;

buffpropertiesarray[ bDisarm ][DefaultValue]=false;
buffpropertiesarray[ bDisarm ][BuffStackType]=bHasOneTrue;

buffpropertiesarray[ bSilenced ][DefaultValue]=false;
buffpropertiesarray[ bSilenced ][BuffStackType]=bHasOneTrue;

buffpropertiesarray[ bPerplexed ][DefaultValue]=false;
buffpropertiesarray[ bPerplexed ][BuffStackType]=bHasOneTrue;

buffpropertiesarray[ bHexed ][DefaultValue]=false;
buffpropertiesarray[ bHexed ][BuffStackType]=bHasOneTrue;

buffpropertiesarray[ bNoMoveMode ][DefaultValue]=false;
buffpropertiesarray[ bNoMoveMode ][BuffStackType]=bHasOneTrue;

buffpropertiesarray[ bFlyMode ][DefaultValue]=false;
buffpropertiesarray[ bFlyMode ][BuffStackType]=bHasOneTrue;

buffpropertiesarray[ bFlyModeDeny ][DefaultValue]=false;
buffpropertiesarray[ bFlyModeDeny ][BuffStackType]=bHasOneTrue;


buffpropertiesarray[ bNoClipMode ][DefaultValue]=false;
buffpropertiesarray[ bNoClipMode ][BuffStackType]=bHasOneTrue;


buffpropertiesarray[ fArmorPhysical ][DefaultValue]=0;
buffpropertiesarray[ fArmorPhysical ][BuffStackType]=fAbsolute;

buffpropertiesarray[ fArmorMagic ][DefaultValue]=0;
buffpropertiesarray[ fArmorMagic ][BuffStackType]=fAbsolute;

buffpropertiesarray[ iGlowRed ][DefaultValue]=255;
buffpropertiesarray[ iGlowRed ][BuffStackType]=DoNotCache;

buffpropertiesarray[ iGlowGreen ][DefaultValue]=255;
buffpropertiesarray[ iGlowGreen ][BuffStackType]=DoNotCache;

buffpropertiesarray[ iGlowBlue ][DefaultValue]=255;
buffpropertiesarray[ iGlowBlue ][BuffStackType]=DoNotCache;

buffpropertiesarray[ iGlowAlpha ][DefaultValue]=255;
buffpropertiesarray[ iGlowAlpha ][BuffStackType]=DoNotCache;

buffpropertiesarray[ iGlowPriority ][DefaultValue]=0;
buffpropertiesarray[ iGlowPriority ][BuffStackType]=DoNotCache;

buffpropertiesarray[ fGlowSetTime ][DefaultValue]=0;
buffpropertiesarray[ fGlowSetTime ][BuffStackType]=DoNotCache;



buffpropertiesarray[ fHPRegen][DefaultValue]=0.0;
buffpropertiesarray[ fHPRegen][BuffStackType]=fAbsolute;

buffpropertiesarray[ fHPDecay][DefaultValue]=0.0;
buffpropertiesarray[ fHPDecay][BuffStackType]=fAbsolute;

buffpropertiesarray[ fHPRegenDeny][DefaultValue]=false;
buffpropertiesarray[ fHPRegenDeny][BuffStackType]=bHasOneTrue;

buffpropertiesarray[ iAdditionalMaxHealth ][DefaultValue]=0;
buffpropertiesarray[ iAdditionalMaxHealth ][BuffStackType]=iAbsolute;

buffpropertiesarray[ fDodgeChance ][DefaultValue]=0.0;
buffpropertiesarray[ fDodgeChance ][BuffStackType]=fAbsolute;

buffpropertiesarray[ bDodgeMode  ][DefaultValue]=0;
buffpropertiesarray[ bDodgeMode   ][BuffStackType]=bHasOneTrue;

buffpropertiesarray[ fVampirePercent][DefaultValue]=0.0;
buffpropertiesarray[ fVampirePercent][BuffStackType]=fAbsolute;

buffpropertiesarray[ fVampirePercentNoBuff][DefaultValue]=0.0;
buffpropertiesarray[ fVampirePercentNoBuff][BuffStackType]=fAbsolute;

buffpropertiesarray[ fMeleeVampirePercent][DefaultValue]=0.0;
buffpropertiesarray[ fMeleeVampirePercent][BuffStackType]=fAbsolute;

buffpropertiesarray[ fMeleeVampirePercentNoBuff][DefaultValue]=0.0;
buffpropertiesarray[ fMeleeVampirePercentNoBuff][BuffStackType]=fAbsolute;

buffpropertiesarray[ fBashChance ][DefaultValue]=0.0;
buffpropertiesarray[ fBashChance ][BuffStackType]=fAbsolute;

buffpropertiesarray[ iBashDamage ][DefaultValue]=0;
buffpropertiesarray[ iBashDamage ][BuffStackType]=iAbsolute;

buffpropertiesarray[ fBashDuration ][DefaultValue]=0.0;
buffpropertiesarray[ fBashDuration ][BuffStackType]=fAbsolute;

buffpropertiesarray[ fCritChance ][DefaultValue]=0.0;
buffpropertiesarray[ fCritChance ][BuffStackType]=fAbsolute;

buffpropertiesarray[ iCritMode ][DefaultValue]=-1;
buffpropertiesarray[ iCritMode ][BuffStackType]=iLastValue;

buffpropertiesarray[ fCritModifier ][DefaultValue]=0.0;
buffpropertiesarray[ fCritModifier ][BuffStackType]=fAbsolute;

buffpropertiesarray[ iDamageBonus ][DefaultValue]=0;
buffpropertiesarray[ iDamageBonus ][BuffStackType]=iAbsolute;

buffpropertiesarray[ fDamageModifier ][DefaultValue]=0.0;
buffpropertiesarray[ fDamageModifier ][BuffStackType]=fAbsolute;

buffpropertiesarray[ iDamageMode ][DefaultValue]=-1;
buffpropertiesarray[ iDamageMode ][BuffStackType]=iLastValue;



//check that all indexes have been set
for(new i=0;i<MaxBuffLoopLimit;i++)
{
if(buffpropertiesarray[W3Buff:i][DefaultValue]==-99)
{
SetFailState("Buff index %d [DefaultValue] was not set properly!",i);
}
if(buffpropertiesarray[W3Buff:i][BuffStackType]==ERRUNDEFINED)
{
SetFailState("Buff index %d [BuffStackType] was not set properly!",i);
}
}

}


Now locate file WAR3SOURCE_INTERFACE.INC and edit the following code:

Code:
stock bool:W3HasImmunity(client,War3Immunity:immunityindex) {
//Immunity_Ability
//add magic immunity etc later
if(immunityindex==Immunity_Abilities) {
return W3GetBuffHasTrue(client,bImmunityAbilities);
}
if(immunityindex==Immunity_Items) {
return W3GetBuffHasTrue(client,bImmunityItems);
}
if(immunityindex==Immunity_Skills) {
return W3GetBuffHasTrue(client,bImmunitySkills);
}
if(immunityindex==Immunity_Ultimates) {
return W3GetBuffHasTrue(client,bImmunityUltimates);
}
if(immunityindex==Immunity_Wards) {
return W3GetBuffHasTrue(client,bImmunityWards)||W3GetBuffHasTrue(client,bImmunitySkills);
}
if(immunityindex==Immunity_Something) {
return W3GetBuffHasTrue(client,bImmunitySomething);
}

return false;

}


Now you can set your new buff using:

War3_SetBuff(client,bImmunitySomething,thisRaceID,true);

And you can check for it using:

if(W3HasImmunity(client,Immunity_Something))
{
    // Client has Immunity_Something enabled
}
else
{
    // Client does not have Immunity_Something enabled
}


For the best results, recompile all of war3source.


Title: Re: Adding your own Immunities to War3Source
Post by: Remy Lebeau on November 30, 2012, 06:26:53 PM
Fantastic guide!  Thank you very much.