-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New methods to handle summon creatures #4814
base: master
Are you sure you want to change the base?
Conversation
These changes are supposed to clean up the code and make it more readable, but it is quite the opposite, in fact it adds 200 more lines of code that are not necessary. (Especially in C++), in Lua it would be as easy as making a function that calls another and that's it and it would be acceptable Basically what we would be avoiding with these changes is simply not checking null or nil of the master and then knowing if the master is one type or another. I think everyone agrees that it is nicer to write it as you would normally do: local master = creature:getMaster()
if not master then
return
end
if master:isPlayer() then
return
end local master = creature:getMaster()
if master and master:isPlayer() then
return
end or in any case if we wish we can create our custom methods function Creature.getPlayerOwned(self)
local owner = self:getMaster()
if owner and owner:isPlayer() then
return owner
end
end |
Perhaps we could improve the function names; 'Owned' seems confusing at first. The validation appears to check if something is 'controlled by a player,' whether it's directly a player or a creature summoned by. LOC here doesn't equate to quality, as it's |
However, I agree that much of luascript could be impl in lua (Creature) |
Pull Request Prelude
Introduced methods to enhance the
Creature
class, allowing for better handling of creature ownership and master relationships.Changes Proposed
Combat::isPlayerCombat
andPlayer::lastHitIsPlayer
.getPlayerOwned()
,getNpcOwned()
andgetMonsterOwned()
. Methods to determine if the creature is owned, either directly or through its master.isPlayerSummon()
,isNpcSummon()
andisMonsterSummon()
to check the type of creature master.Usage
c++
lua