LUA Needs (a list)
Moderator: Team Members
- John Adams
- Retired
- Posts: 9684
- Joined: Thu Jul 26, 2007 6:27 am
- EQ2Emu Server: EQ2Emulator Test Center
- Characters: John
- Location: Arizona
- Contact:
Re: LUA Needs (a list)
How does that tell me it is a Bow?
- thefoof
- Retired
- Posts: 630
- Joined: Wed Nov 07, 2012 7:36 pm
- Location: Florida
Re: LUA Needs (a list)
I'll make a function to return item type from an item pointer, will that work for you?
-
Jabantiz
- Lead Developer
- Posts: 2912
- Joined: Wed Jul 25, 2007 2:52 pm
- Location: California
Re: LUA Needs (a list)
Sorry sleep deprived, figured just grab the range slot but I guess other items could be in that slot...
We will need a new function to determine item type, either a bunch of IsBow(), IsBag(), and so on, or a GetItemType() that returns an int for the item type.
We will need a new function to determine item type, either a bunch of IsBow(), IsBag(), and so on, or a GetItemType() that returns an int for the item type.
- John Adams
- Retired
- Posts: 9684
- Joined: Thu Jul 26, 2007 6:27 am
- EQ2Emu Server: EQ2Emulator Test Center
- Characters: John
- Location: Arizona
- Contact:
Re: LUA Needs (a list)
Here's another one. I looked through the LuaFunctions.cpp functions and didn't see anything specific to telling LUA that the Caster (or target?) just got damaged or blocked (maybe other types?)
OR, if the NPC block's an incoming hit, a 100% chance of that hate towards the NPCs "victim" now, not it's target?
I think the description is poorly written, and it's really about me casting a spell, if I get damaged or block the incoming hit, hate is generated either by chance or certainly.
I'm a little confused by their terminology, so maybe I'm reading this wrong. I see this as, I cast this spell on an NPC, then when the NPC gets damaged, 50% chance of hate towards whomever the NPC currently has targeted (which may not be me?) Doesn't seem very Guardian-like...When damaged this spell has a 50% chance to cast Holding the Line on target's attacker.
-- Increases Threat to target by 27
On a block this spell will cast Holding the Line on target's victim.
-- Increases Threat to target by 27
OR, if the NPC block's an incoming hit, a 100% chance of that hate towards the NPCs "victim" now, not it's target?
I think the description is poorly written, and it's really about me casting a spell, if I get damaged or block the incoming hit, hate is generated either by chance or certainly.
- thefoof
- Retired
- Posts: 630
- Joined: Wed Nov 07, 2012 7:36 pm
- Location: Florida
Re: LUA Needs (a list)
The target of that spell is self though, it's a buff. When the target of the spell (the guardian) is attacked there's a 50% chance to increase hate to targets attacker (npc) or on a block it's a 100% chance. But this should probably not be handled through the spell script and instead added on as a proc. Which we don't have yet.
How we will end up handling this in script is probably something like AddProc(proc_type, chance, spell_id) and RemoveProc() when the spell is removed, but I couldn't tell you that for sure because it's not coded yet
How we will end up handling this in script is probably something like AddProc(proc_type, chance, spell_id) and RemoveProc() when the spell is removed, but I couldn't tell you that for sure because it's not coded yet
- John Adams
- Retired
- Posts: 9684
- Joined: Thu Jul 26, 2007 6:27 am
- EQ2Emu Server: EQ2Emulator Test Center
- Characters: John
- Location: Arizona
- Contact:
Re: LUA Needs (a list)
I guess that is why I am adding to this list 
I forgot to check the Self thing, and that makes much more sense. Thanks.
I forgot to check the Self thing, and that makes much more sense. Thanks.
- John Adams
- Retired
- Posts: 9684
- Joined: Thu Jul 26, 2007 6:27 am
- EQ2Emu Server: EQ2Emulator Test Center
- Characters: John
- Location: Arizona
- Contact:
Re: LUA Needs (a list)
Question, this is one of the first LUA scripts ever written, back in 2008... wondering, does this still need to be this complex? LUA has changed so much.
Sprint
Sprint
Code: Select all
function cast(Caster, Target, PowerCost, SpeedValue)
power_left = GetPower(Caster)
total_power = GetMaxPower(Caster)
if (total_power * PowerCost) < power_left then
speed = GetSpeed(Caster)
if speed < SpeedValue then
SetSpeed(Caster, SpeedValue)
end
new_power = GetPower(Caster) - (total_power * PowerCost)
if new_power > 0 and HasMoved(Caster) == true then
SetPower(Caster, new_power)
elseif new_power <= 0 then
SetSpeed(Caster, 0)
end
else
SetSpeed(Caster, 0)
end
return
end
function tick(Caster, Target, PowerCost, SpeedValue)
cast(Caster, Target, PowerCost, SpeedValue)
end
function remove(Caster, Target)
SetSpeed(Caster, 0)
end- thefoof
- Retired
- Posts: 630
- Joined: Wed Nov 07, 2012 7:36 pm
- Location: Florida
Re: LUA Needs (a list)
We probably need to make a function to check if a spell has already applied a bonus to script this spell properly, but here's one way to script this spell...sprint is a bit tricky since it deals with power percentages and recurring power costs.
Code: Select all
function cast(Caster, Target, PowerCost, SpeedValue)
--Initial power cost of sprint is 15%
if GetPower(Caster) >= GetMaxPower(Caster) * .15 then
SetPower(Caster, GetPower(Caster) - (GetMaxPower(Caster) * .15))
AddSpellBonus(Caster, 609, SpeedValue)
end
SetTempVariable(Caster, "sprint_lastx", GetX(Caster))
SetTempVariable(Caster, "sprint_lasty", GetY(Caster))
SetTempVariable(Caster, "sprint_lastz", GetZ(Caster))
end
function tick(Caster, Target, PowerCost, SpeedValue)
--Recurring tick cost of sprint is 10% of max power, only if the player has moved
--perform math on a string to convert it to number in lua - not sure if this will work or not
local lastx = GetTempVariable(Caster, "sprint_lastx") + 0
local lasty = GetTempVariable(Caster, "sprint_lasty") + 0
local lastz = GetTempVariable(Caster, "sprint_lastz") + 0
if lastx ~= GetX(Caster) or lasty ~= GetY(Caster) or lastz ~= GetZ(Caster) then
if GetPower(Caster) >= GetMaxPower(Caster) * .1 then
SetPower(Caster, GetPower(Caster) - (GetMaxPower(Caster) * .1))
end
end
SetTempVariable(Caster, "sprint_lastx", GetX(Caster))
SetTempVariable(Caster, "sprint_lasty", GetY(Caster))
SetTempVariable(Caster, "sprint_lastz", GetZ(Caster))
end
function remove(Caster, Target)
RemoveSpellBonus(Caster)
SetTempVariable(Caster, "sprint_lastx", nil)
SetTempVariable(Caster, "sprint_lasty", nil)
SetTempVariable(Caster, "sprint_lastz", nil)
end- John Adams
- Retired
- Posts: 9684
- Joined: Thu Jul 26, 2007 6:27 am
- EQ2Emu Server: EQ2Emulator Test Center
- Characters: John
- Location: Arizona
- Contact:
Re: LUA Needs (a list)
Wow, I'll bet there is simpler code in the Space Shuttle's guidance system.
That looks awesome though
That looks awesome though
Who is online
Users browsing this forum: No registered users and 0 guests