• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Get Creature CID

Arn

Member
Joined
Mar 8, 2010
Messages
282
Reaction score
18
Hello, and I apologize for making a thread again so soon, however I have a different problem now.

I have a creature, who's position I know, who's type I know, and of which I have the UID. I need to get the CID for the creature so that I can plug that into doCombat, so that my spell is cetered on the creature rather than the player casting the spell. I would use target, but the npc is not hostile, so that doesn't work.

Any help?
 
Thats what I used to get the creature in the first place.

So i have


creature = getTopCreature(pos)

which gives me

creature.type
creature.uid

but not cid

- - - Updated - - -

Bump. Theres no way that there isnt SOME WAY of getting a creature's CID if you know its UID and position. Come on. Somebody!
 
Heres the error when I try to say the cid of creature.

Code:
[28/06/2012 18:11:25] Lua Script Error: [Spell Interface] 
[28/06/2012 18:11:25] data/spells/scripts/runesmith/runebomb.lua:onCastSpell
[28/06/2012 18:11:25] data/spells/scripts/runesmith/runebomb.lua:26: attempt to concatenate local 'creature' (a table value)
[28/06/2012 18:11:25] stack traceback:
[28/06/2012 18:11:25] 	[C]: in function '__concat'
[28/06/2012 18:11:25] 	data/spells/scripts/runesmith/runebomb.lua:26: in function <data/spells/scripts/runesmith/runebomb.lua:20>

Heres the code im using.

Code:
doCreatureSay(cid,"cid: " .. creature, TALKTYPE_SAY)

Is there a way I can show all the values in the table returned by getTopCreature?
 
Aparently it is. However, that still doesn't solve my problem. The combat area is still being done with the center based on where the player cast the spell, and not the position of the npc that is temporarily summoned by the spell. I'll paste the code so you can take a look.


Code:
function check(cid, pos, npcName)
checkPosInSquare(cid, pos, npcName)
end

local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_FIREAREA)
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE)
setCombatFormula(combat, COMBAT_FORMULA_SKILL, 1, -10, 1, -10)
setCombatArea(combat,createCombatArea({{1, 1, 1},
  {1, 2, 1},
  {1, 1, 1}}))
  
  function finish(cid, combat, var)
  doCombat(cid, combat, var)
  end
  

function onCastSpell(cid, var)
	startPos = getCreaturePosition(cid)

	doCreateNpc('runebomb', startPos)

	local creature = checkPosInSquare(cid, startPos, 'runebomb')

	local ncid = creature.uid

	addEvent(finish, 3000, ncid, combat, var)
end

The function checkPosInSquare just checks the surrounding 8 squares from the original cast point, to find the npc that was temporarily summoned.
 
What's checkPosInSquare? and... try this:
Code:
function onCastSpell(cid, var)
	local startPos = getCreaturePosition(cid)
    local npcPos = {x = startPos.x + 1, y = startPos.y - 1, z = startPos.z}

	if (doCreateNpc('runebomb', npcPos)) then
        local npcId = getTopCreature(npcPos).uid
        if (isNpc(npcId)) then
            addEvent(finish, 3000, npcId, combat, var)
        end
    else
        error("failed to create npc")
    end
    return true
end
 
Your script does the exact same thing as mine, only in a slightly different way.

My script creates the npc, and I let the system decide where to put it. This way, if theres trees or rocks in the way, the player can still drop the 'runebomb'. Your script places the npc to the top right corner of the starting position. Other than that, the scripts are identical.

Also, your code generates this error:

Code:
[28/06/2012 19:10:05] Lua Script Error: [Spell Interface] 
[28/06/2012 19:10:05] data/spells/scripts/runesmith/runebomb.lua:onCastSpell
[28/06/2012 19:10:05] data/spells/scripts/runesmith/runebomb.lua:24: attempt to call global 'isNpc' (a nil value)
[28/06/2012 19:10:05] stack traceback:
[28/06/2012 19:10:05] 	[C]: in function 'isNpc'
[28/06/2012 19:10:05] 	data/spells/scripts/runesmith/runebomb.lua:24: in function <data/spells/scripts/runesmith/runebomb.lua:18>

- - - Updated - - -

Also, as an update, it doesn't seem to matter if I use the npc's CID as what I plug in for doCombat. The explosion is still occuring on the location that the player was originally in. See pictures please.

d3mR2.png


52ZCo.png


- - - Updated - - -

Bump. There has to be a way to do this. I was thinking, if I made it a monster instead of an npc? Or is there some kind of way to have an npc cast a spell? I noticed that doCombat, can't even be called from inside an npc lua file.

Please help, I've been working all day on this script.

- - - Updated - - -

Okay, so, I FINALLY have a messy solution. I just create the npc, and then teleport it to the starting position. It happens too fast to see the runebomb get dropped anywhere else. The only problem I have now is that it makes this gay ass blue shimmer when the npc is spawned. Is there a way to stop that?

- - - Updated - - -

Last edit for tonight. Looks like the spell isn't taking mana or exhausting the player. No idea why. Any suggestions?

- - - Updated - - -

I lied, final edit. I now spawn all the runebombs in a far away location, and teleport them in. That way it looks like they spawn under the player. Yay. Done for today.
 

Attachments

Last edit for tonight. Looks like the spell isn't taking mana or exhausting the player. No idea why. Any suggestions?
Are you trying to use it on a GM or a normal player? If you're not doing it on a GM, make sure you added exhaustion on spells.xml, i.e: exhaustion="1000" etc.
 
I did, still not working.

- - - Updated - - -

Ok, fixed it. I was correct. Spell won't cost mana, nor will it exhaust you, if you do not return the results of doCombat. So, I did that, and it works fine now. Thanks for all the help guys.

the swag is strong with you all
 
Back
Top