Page 1 of 2
SetMaxHP(Target, (GetMaxHP(Target) + 50))
Posted: Fri May 20, 2016 8:09 am
by Gangrenous
Tried this in a script to do an HP buff on spell cast, definitely causing a server crash.
Code: Select all
function cast(Caster, Target, Type, Min, Max)
SetMaxHP(Target, (GetMaxHP(Target) + 50))
end
Re: SetMaxHP(Target, (GetMaxHP(Target) + 50))
Posted: Fri May 20, 2016 3:59 pm
by Jabantiz
For a buff spell you would want to use
AddSpellBonus() and
RemoveSpellBonus() to remove it, for a list of id's we have
this wiki page. So for an HP buff it would be
Code: Select all
function cast (Caster, Target)
AddSpellBonus(Target, 500, 50)
end
As for that code crashing I will have to look into it.
Re: SetMaxHP(Target, (GetMaxHP(Target) + 50))
Posted: Fri May 20, 2016 4:53 pm
by Gangrenous
I think I had tried 606

Re: SetMaxHP(Target, (GetMaxHP(Target) + 50))
Posted: Fri May 20, 2016 5:57 pm
by Zcoretri
provocating wrote:I think I had tried 606

That would be a blue stat on an item. Do we support blue stats yet?
Re: SetMaxHP(Target, (GetMaxHP(Target) + 50))
Posted: Fri May 20, 2016 6:57 pm
by Gangrenous
I got 606 from a post Jabantiz did, back around 2014
http://eq2emulator.net/phpBB3/viewtopic ... xHP#p29118
But sigh, still an issue. I am getting frustrated. It is doing something strange still. The first time I cast it, it seems to work but your current HP never goes up to the max like it should, just sits at the current value. If you can the spell again it last a half a second, then if I cast again same thing. If I do a /reload spells sometimes it lets me cast it again but either goes to default HP or on occasion to the adjusted +50hp, but rarely last the amount of time it should, 27 minutes.
Re: SetMaxHP(Target, (GetMaxHP(Target) + 50))
Posted: Sun May 22, 2016 3:59 pm
by Jabantiz
Zcoretri wrote:That would be a blue stat on an item. Do we support blue stats yet?
Good to see you posting again Z.
We currently keep track of blue stats, but I would say the vast majority of them are not actually used yet.
provocating wrote:But sigh, still an issue. I am getting frustrated. It is doing something strange still. The first time I cast it, it seems to work but your current HP never goes up to the max like it should, just sits at the current value. If you can the spell again it last a half a second, then if I cast again same thing. If I do a /reload spells sometimes it lets me cast it again but either goes to default HP or on occasion to the adjusted +50hp, but rarely last the amount of time it should, 27 minutes.
I assume the spell is not set to toggle? It would seems when it needs to overwrite something the time is not being reset for some reason, I will look into it. As for the hp not going up I think I have an idea about that, I assume you are casting the buff when you are already full hp, if so can you go fight a mob so you take damage and then see if it regens up to max?
Re: SetMaxHP(Target, (GetMaxHP(Target) + 50))
Posted: Wed May 25, 2016 5:46 pm
by Gangrenous
No, not set to toggle, set to normal. What is does currently, as I have it set is this.
Max HP goes all the way to what I set it to. I start regen up to that amount. I recast the spell and the max HP goes up to my normal HP. Everytime I cast the spell the duration changes to random amounts. Then after a cast or two the duration stays at around a half a second, at least for the effect. The icon does still show up but the duration for the icon is wrong.
Re: SetMaxHP(Target, (GetMaxHP(Target) + 50))
Posted: Thu May 26, 2016 10:53 am
by Zcoretri
provocating wrote:No, not set to toggle, set to normal. What is does currently, as I have it set is this.
Max HP goes all the way to what I set it to. I start regen up to that amount. I recast the spell and the max HP goes up to my normal HP. Everytime I cast the spell the duration changes to random amounts. Then after a cast or two the duration stays at around a half a second, at least for the effect. The icon does still show up but the duration for the icon is wrong.
How long is the duration of this buff? Can you post your complete script?
Re: SetMaxHP(Target, (GetMaxHP(Target) + 50))
Posted: Thu May 26, 2016 11:34 am
by Gangrenous
27 Minutes
Code: Select all
--[[
Script Name : Spells/Mage/Summoner/Conjuror/MinorShielding.lua
Script Author : Provocating
Script Date : 2016.05.20 02:05:09
Script Notes : Enter special notes here
:
--]]
function cast(Caster, Target, MaxVal)
-- AddSpellBonus(Caster, 606, 50)
AddSpellBonus(Caster, 500, 50)
end
function tick(Caster, Target, Type, Min, Max)
-- code to process each call_frequency (tick) set in spell_tiers
end
function remove(Caster, Target)
RemoveSpellBonus(Caster)
end
Re: SetMaxHP(Target, (GetMaxHP(Target) + 50))
Posted: Thu May 26, 2016 7:25 pm
by Gangrenous
More info on this issue. I made a new Lua Routine - SetMitigationBase. After creating this new routine I did notice it reacts the exact same way as the HP one, the exact same way. But as interesting as it is, the SetStrBase and SetWisBase react perfectly as they should. I hope that helps. I will test some more attributes as I get time.
Re: SetMaxHP(Target, (GetMaxHP(Target) + 50))
Posted: Fri May 27, 2016 1:46 pm
by Gangrenous
Well I found one of them. Maybe this can help. So I had made a LUA to change the mitigation base and it acted the exact same way as HP. This is what is causing the problem.
Code: Select all
ItemStatsValues* EquipmentItemList::CalculateEquipmentBonuses(Entity* entity){
ItemStatsValues* stats = new ItemStatsValues;
memset(stats, 0, sizeof(ItemStatsValues));
//entity->GetInfoStruct()->mitigation_base = 0;
MEquipmentItems.lock();
for(int8 i=0;i<NUM_SLOTS;i++){
if(items[i] && items[i]->details.item_id > 0){
master_item_list.CalculateItemBonuses(items[i], entity, stats);
if (items[i]->armor_info && !items[i]->IsShield())
entity->GetInfoStruct()->mitigation_base += items[i]->armor_info->mitigation_high;
}
}
MEquipmentItems.unlock();
return stats;
}
This line I have remarked out.
Code: Select all
//entity->GetInfoStruct()->mitigation_base = 0;
It sets the mitigation back to 0. Maybe I am changing the incorrect mitigation value? Is there a mitigation value that is safer to adjust?
Re: SetMaxHP(Target, (GetMaxHP(Target) + 50))
Posted: Fri May 27, 2016 5:12 pm
by Jabantiz
Commenting out that line will result in the mitigation being added on top of itself when that function is called again, everything is calculated from scratch and that is why mit and stats are reset to 0 in this function.
The original crash that this thread started with has been found and fixed.
The buff only lasting for like a half second when reapplying the buff before it expired is a little more tricky, from what I can tell is the buff is applied a second time (brief flash of 2 icons) but the stats aren't applied a second time, it the seems to cancel the first and when it cancels that first one the stats go with it just leaving the second that didn't apply any stats so it goes back to normal. It has been a while since I worked with the spell system so this will take some time to figure out what is going on.
Re: SetMaxHP(Target, (GetMaxHP(Target) + 50))
Posted: Fri May 27, 2016 5:57 pm
by Gangrenous
Jabantiz wrote:Commenting out that line will result in the mitigation being added on top of itself when that function is called again, everything is calculated from scratch and that is why mit and stats are reset to 0 in this function.
Oh I know, I was in a hurry when typing it out. Also keep in mind I am learning as I go. I am not even close to familiar with the source in this project.
Re: SetMaxHP(Target, (GetMaxHP(Target) + 50))
Posted: Fri May 27, 2016 5:58 pm
by Gangrenous
Also do you get the crazy random durations on recast?
Re: SetMaxHP(Target, (GetMaxHP(Target) + 50))
Posted: Fri May 27, 2016 6:08 pm
by Jabantiz
provocating wrote:Also do you get the crazy random durations on recast?
No, the duration on the icon matches what the spell is, the effect seems to always fade about half a second after I reapply the buff.