Implementing: Procs

EQ2Emulator Development forum.

Moderator: Team Members

User avatar
John Adams
Retired
Posts: 9684
Joined: Thu Jul 26, 2007 6:27 am
EQ2Emu Server: EQ2Emulator Test Center
Characters: John
Location: Arizona
Contact:

Re: Implementing: Procs

Post by John Adams » Tue Nov 26, 2013 6:09 am

Nice. Exciting :)

Jabantiz
Lead Developer
Posts: 2912
Joined: Wed Jul 25, 2007 2:52 pm
Location: California

Re: Implementing: Procs

Post by Jabantiz » Tue Nov 26, 2013 4:35 pm

Implemented most of the proc types, we have no code for block however so can't implement that yet. Need clarification on heal and beneficial though, are they when an entity casts or the spell lands on them, or do we want both. Also will heal trigger a beneficial proc?

Jabantiz
Lead Developer
Posts: 2912
Joined: Wed Jul 25, 2007 2:52 pm
Location: California

Re: Implementing: Procs

Post by Jabantiz » Tue Nov 26, 2013 6:07 pm

Committed all my code for procs, only block, heal, and beneficial procs haven't been implemented yet, waiting for clarification on heal and beneficial and we have no code for blocking yet so can't add that either.

User avatar
thefoof
Retired
Posts: 630
Joined: Wed Nov 07, 2012 7:36 pm
Location: Florida

Re: Implementing: Procs

Post by thefoof » Tue Nov 26, 2013 6:09 pm

A heal and buffs count as beneficial, but a buff doesn't count as a heal, hope that helps :mrgreen:, also I don't know if there are any procs like this that proc on being the target of the spell, I think only the caster but I could be wrong.

Jabantiz
Lead Developer
Posts: 2912
Joined: Wed Jul 25, 2007 2:52 pm
Location: California

Re: Implementing: Procs

Post by Jabantiz » Tue Nov 26, 2013 6:27 pm

Added beneficial and heal procs, didn't test all possible proc types so keep an eye out for errors.

User avatar
John Adams
Retired
Posts: 9684
Joined: Thu Jul 26, 2007 6:27 am
EQ2Emu Server: EQ2Emulator Test Center
Characters: John
Location: Arizona
Contact:

Re: Implementing: Procs

Post by John Adams » Wed Nov 27, 2013 8:33 am

Cool, so (unless I missed it) what tells the code there is a Proc? Just the fact the function proc() exists in a script? Or did we add a flag to the spells/items tables?

Jabantiz
Lead Developer
Posts: 2912
Joined: Wed Jul 25, 2007 2:52 pm
Location: California

Re: Implementing: Procs

Post by Jabantiz » Wed Nov 27, 2013 1:35 pm

You need to use AddProc to register the proc on a spawn and RemoveProc to remove the proc

Here is my test item script I assigned to an item one of my chars already had

Code: Select all

function equipped(Item, Player)
   AddProc(Player, 1, 50, Item)
   Say(Player, "Equipped")
end

function unequipped(Item, Player)
   RemoveProc(Player, Item)
   Say(Player, "UnEquiped")
end

function proc(Item, Caster, Target, Type)
   Say(Caster, "Proc type: " .. Type)
end
When the item is equipped the player will do a Say() and add the proc, when unequipped the player will do a Say() and remove the proc, when a proc actually goes off the player will just do a Say()

User avatar
John Adams
Retired
Posts: 9684
Joined: Thu Jul 26, 2007 6:27 am
EQ2Emu Server: EQ2Emulator Test Center
Characters: John
Location: Arizona
Contact:

Re: Implementing: Procs

Post by John Adams » Thu Nov 28, 2013 11:42 pm

I should have asked more specifically about Spells, since I am not doing anything with Items at this time.

Remember, I am assuming a Spell Proc is one of the sub-spells that I'm trying to avoid creating ;)

Jabantiz
Lead Developer
Posts: 2912
Joined: Wed Jul 25, 2007 2:52 pm
Location: California

Re: Implementing: Procs

Post by Jabantiz » Thu Nov 28, 2013 11:50 pm

Basically the same thing

Code: Select all

function cast(Caster, Target)
    AddProc(Target, 1, 8.5) -- 8.5% chance to proc an offensive (1) spell
end

function proc(Caster, Target, Type)
    -- proc code here
end

function remove(Caster, Target)
    RemoveProc(Target)
end
no need for another spell, it is possible to add spell data to the proc function if we need it, or we can just hardcode the procs

Jabantiz
Lead Developer
Posts: 2912
Joined: Wed Jul 25, 2007 2:52 pm
Location: California

Re: Implementing: Procs

Post by Jabantiz » Thu Dec 05, 2013 1:56 pm

Was looking at Blessed Weapon spell an noticed the proc has a duration (2sec stun) which this system can't handle, we could apply the stun but no way to remove it after 2 seconds. Looking for options on how to handle procs with durations, 3 options I came up with are:

Add an optional duration parameter to AddControlEffect, will work in this case but won't solve the problem if the proc is a DoT
Use a new spell for the portions with durations, would really suck making a spell from scratch
Make a new lua function for timers in spell scripts, no clue what this will involve, might add the most control while keeping everything in 1 spell script

Which one do you guys think would be the best? Any other ideas how to handle this?

Jabantiz
Lead Developer
Posts: 2912
Joined: Wed Jul 25, 2007 2:52 pm
Location: California

Re: Implementing: Procs

Post by Jabantiz » Thu Dec 05, 2013 11:32 pm

In a spell script the proc function will now receive the spell data

User avatar
John Adams
Retired
Posts: 9684
Joined: Thu Jul 26, 2007 6:27 am
EQ2Emu Server: EQ2Emulator Test Center
Characters: John
Location: Arizona
Contact:

Re: Implementing: Procs

Post by John Adams » Fri Dec 06, 2013 6:47 am

Do we know why there is a duration1 and duration2 value? Are both used? If not, can duration2 be used for "secondary durations"?

Jabantiz
Lead Developer
Posts: 2912
Joined: Wed Jul 25, 2007 2:52 pm
Location: California

Re: Implementing: Procs

Post by Jabantiz » Fri Dec 06, 2013 8:25 am

There are checks against duration2 in the code, no clue what it does off hand though, will look into it later today

Jabantiz
Lead Developer
Posts: 2912
Joined: Wed Jul 25, 2007 2:52 pm
Location: California

Re: Implementing: Procs

Post by Jabantiz » Fri Dec 06, 2013 9:08 am

I lied about later today, took a quick look before I head out

It is used to determine a random duration between duration1 and duration2, if they are not equal

Code: Select all

int32 Spell::GetSpellDuration(){
	if(spell->duration1 == spell->duration2)
		return spell->duration1;

	int32 difference = 0;
	int32 lower = 0;
	if(spell->duration2 > spell->duration1){
		difference = spell->duration2 - spell->duration1;
		lower = spell->duration1;
	}
	else{
		difference = spell->duration1 - spell->duration2;
		lower = spell->duration2;
	}
	int32 duration = (rand()%difference) + lower;
	return duration;
}

User avatar
John Adams
Retired
Posts: 9684
Joined: Thu Jul 26, 2007 6:27 am
EQ2Emu Server: EQ2Emulator Test Center
Characters: John
Location: Arizona
Contact:

Re: Implementing: Procs

Post by John Adams » Fri Dec 06, 2013 9:15 am

That's interesting. Ever heard of such a thing? I hadn't.... but it's a cool custom feature otherwise ;)

The way I have been doing scripts, if the value of the "duration" of the effect is always the same across all tiers, I simply (wait for it...) hard-code the value in the script :) For example, if the duration of the stun is always 10 seconds across all tiers, then I stun the target for 10 right in the LUA script - no other functions needed. I thought that's what AddControlEffect() was for.

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests