////BUFF SYSTEM #pragma semicolon 1 #include #include "W3SIncs/sdkhooks" #include "W3SIncs/War3Source_Interface" //for debuff index, see constants, its in an enum new any:buffdebuff[MAXPLAYERSCUSTOM][W3Buff][MAXITEMS+MAXRACES+MAXITEMS2+CUSTOMMODIFIERS]; ///a race may only modify a property once new BuffProperties[W3Buff][W3BuffProperties]; new any:BuffCached[MAXPLAYERSCUSTOM][W3Buff];// instead of looping, we cache everything in the last dimension, see enum W3BuffCache public Plugin:myinfo= { name="War3Source Buff System", author="Ownz (DarkEnergy)", description="War3Source Core Plugins", version="1.0", url="http://war3source.com/" }; public OnPluginStart() { InitiateBuffPropertiesArray(BuffProperties); RegConsoleCmd("bufflist",cmdbufflist); } public bool:InitNativesForwards() { CreateNative("War3_SetBuff",Native_War3_SetBuff);//for races CreateNative("War3_SetBuffItem",Native_War3_SetBuffItem);//foritems CreateNative("War3_SetBuffItem2",Native_War3_SetBuffItem2);//foritems CreateNative("W3BuffCustomOFFSET",NW3BuffCustomOFFSET); CreateNative("W3GetPhysicalArmorMulti",NW3GetPhysicalArmorMulti); CreateNative("W3GetMagicArmorMulti",NW3GetMagicArmorMulti); CreateNative("W3GetBuff",NW3GetBuff); CreateNative("W3GetBuffSumInt",NW3GetBuffSumInt); CreateNative("W3GetBuffHasTrue",NW3GetBuffHasTrue); CreateNative("W3GetBuffStackedFloat",NW3GetBuffStackedFloat); CreateNative("W3GetBuffSumFloat",NW3GetBuffSumFloat); CreateNative("W3GetBuffMinFloat",NW3GetBuffMinFloat); CreateNative("W3GetBuffMaxFloat",NW3GetBuffMaxFloat); CreateNative("W3GetBuffMinInt",NW3GetBuffMinInt); CreateNative("W3GetBuffLastValue",NW3GetBuffLastValue); CreateNative("W3ResetAllBuffRace",NW3ResetAllBuffRace); CreateNative("W3ResetBuffRace",NW3ResetBuffRace); CreateNative("W3GetBuffLoopLimit",NW3GetBuffLoopLimit); return true; } ItemsPlusRacesLoaded(){ return W3GetItemsLoaded()+War3_GetRacesLoaded()+W3GetItems2Loaded()+CUSTOMMODIFIERS; } public NW3BuffCustomOFFSET(Handle:plugin,numParams) { return W3GetItemsLoaded()+War3_GetRacesLoaded()+W3GetItems2Loaded(); } public Native_War3_SetBuff(Handle:plugin,numParams) { if(numParams==4) //client,race,buffindex,value { new client=GetNativeCell(1); new W3Buff:buffindex=GetNativeCell(2); new raceid=GetNativeCell(3); new any:value=GetNativeCell(4); SetBuff(client,buffindex,raceid+W3GetItemsLoaded(),value); //ofsetted /*if(raceid==0){ new String:buf[64]; GetPluginFilename(plugin, buf, sizeof(buf)); ThrowError("warning, war3_setbuff passed zero raceid %s",buf); }*/ } } public Native_War3_SetBuffItem(Handle:plugin,numParams) //buff is from an item { if(numParams==4) //client,race,buffindex,value { new client=GetNativeCell(1); new W3Buff:buffindex=GetNativeCell(2); new itemid=GetNativeCell(3); new any:value=GetNativeCell(4); SetBuff(client,buffindex,itemid,value); //not offseted /*if(itemid==0){ new String:buf[64]; GetPluginFilename(plugin, buf, sizeof(buf)); ThrowError("warning, war3_setbuffitem passed zero itemid %s",buf); }*/ } } public Native_War3_SetBuffItem2(Handle:plugin,numParams) //buff is from an item { if(numParams==4) //client,race,buffindex,value { new client=GetNativeCell(1); new W3Buff:buffindex=GetNativeCell(2); new itemid=GetNativeCell(3); new any:value=GetNativeCell(4); SetBuff(client,buffindex,W3GetItemsLoaded()+War3_GetRacesLoaded()+itemid,value); //not offseted /*if(itemid==0){ new String:buf[64]; GetPluginFilename(plugin, buf, sizeof(buf)); LogError("warning, war3_setbuffitem2 passed zero itemid %s",buf); }*/ } } public NW3GetBuff(Handle:plugin,numParams) { new client=GetNativeCell(1); new W3Buff:buffindex=GetNativeCell(2); new raceiditemid=GetNativeCell(3); new bool:isItem=GetNativeCell(4); if(!isItem){ raceiditemid+=W3GetItemsLoaded(); } if(ValidBuff(buffindex)){ return buffdebuff[client][buffindex][raceiditemid]; } else{ ThrowError("invalidbuffindex"); } return -1; } public NW3GetBuffSumInt(Handle:plugin,numParams) { new client=GetNativeCell(1); new W3Buff:buffindex=GetNativeCell(2); return GetBuffSumInt(client,buffindex); } //stop complaining that we are returning a float! public NW3GetPhysicalArmorMulti(Handle:plugin,numParams) { return _:PhysicalArmorMulti(GetNativeCell(1)); } public NW3GetMagicArmorMulti(Handle:plugin,numParams) { return _:MagicArmorMulti(GetNativeCell(1)); } public NW3GetBuffLastValue(Handle:plugins,numParams) { return GetBuffLastValue(GetNativeCell(1),GetNativeCell(2)); } public NW3GetBuffHasTrue(Handle:plugin,numParams) { //all one true bools are cached return _:GetBuffHasOneTrue(GetNativeCell(1),GetNativeCell(2)); //returns bool } public NW3GetBuffStackedFloat(Handle:plugin,numParams) { return _:GetBuffStackedFloat(GetNativeCell(1),GetNativeCell(2)); //returns float usually } public NW3GetBuffSumFloat(Handle:plugin,numParams) { return _:GetBuffSumFloat(GetNativeCell(1),GetNativeCell(2)); } public NW3GetBuffMinFloat(Handle:plugin,numParams) { return _:GetBuffMinFloat(GetNativeCell(1),GetNativeCell(2)); } public NW3GetBuffMaxFloat(Handle:plugin,numParams) { return _:GetBuffMaxFloat(GetNativeCell(1),GetNativeCell(2)); } public NW3GetBuffMinInt(Handle:plugin,numParams) { return GetBuffMinInt(GetNativeCell(1),GetNativeCell(2)); } public NW3ResetAllBuffRace(Handle:plugin,numParams) { new client=GetNativeCell(1); new race=GetNativeCell(2); for(new buffindex=0;buffindexvalue){ value=value2; } } return value; } LogError("invalid buff index"); return -1; } stock any:CalcBuffMin(client,W3Buff:buffindex) { if(ValidBuff(buffindex)) { new any:value=buffdebuff[client][buffindex][0]; new loop = ItemsPlusRacesLoaded(); for(new i=1;i<=loop;i++) { new any:value2=buffdebuff[client][buffindex][i]; if(value2-1&&FindSendPropOffs(index,"m_nRenderMode")>-1){ new String:class[32]; GetEntityNetClass(index, class, sizeof(class) ); //PrintToServer("%s",class); if(FindSendPropOffs(class,"m_nRenderFX")>-1){ SetEntityRenderMode(index,RENDER_TRANSCOLOR); SetEntityRenderColor(index,GetPlayerR(index),GetPlayerG(index),GetPlayerB(index),alpha); } //else{ // W3Log("deny render fx %d",index); //} //} } stock GetWeaponAlpha(client) { new wep=W3GetCurrentWeaponEnt(client); if(wep>MaxClients && IsValidEdict(wep)) { return GetEntityAlpha(wep); } return 255; } stock ValidBuff(W3Buff:buffindex){ if(_:buffindex>=0&&_:buffindex