• 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!

Possibility Of A Change In Targeting Systems

ArkSeyonet

Chancho
Joined
Nov 11, 2008
Messages
201
Reaction score
11
Forgotten Server - Any Distro - I'm quite flexible
Sources/LUA



Well the whole idea behind this is I want to edit the sources, scripts, etc in order to make it as follows:

For the coding where a monster would target a player, it will check their storage value (for a quest) and if they have completed that quest, then it will not attack them.

Basically...

1. Player goes on a quest to rid the world of some boss monster. Upon completion they complete the quest and gain +1 in a storageValue
2. The orcs are thankful that he destroyed this threat to the world, and now all orcs will not attack him.
3. BUT I want to be able to turn around and

A general idea of what I want in an outline format...

Code:
1. OnTarget
     A) If attackingMonster is an Orc
          i. If playerGetStorageValue(5555) == 1 then
               All Orcs will not attack
     B) If attackingMonster is an Elf
          i. If playerGetStorageValue(6666) == 1 then
               All Elves will not attack

I don't really care about whether the monster still follows you or not, as long as he doesn't attack you.
 
Last edited:
If using 0.1 (aka 0.2), it isn't possible w/o a source code edit (a simple one).
Otherwise, use a creatureevent (onAttack) and check if the target's storage is whatever and if the attacker's name is the monster then return false.

0.1 Source edit:
src/monster.cpp:364 edit the whole `if' case with:
[cpp] int32_t val;
if (((creature->getPlayer() && !creature->getPlayer()->hasFlag(PlayerFlag_IgnoredByMonsters)) ||
(creature->getMaster() && creature->getMaster()->getPlayer()))
&& (creature->getPlayer() && creature->getPlayer()->getStorageValue(STORAGE_ID_HERE, val)
&& !!val)) {
return true;
}
[/cpp]
 
Last edited:
Appreciate it. Compiled it just fine, and now I'm going to see if I can play with it a bit. :)

Does that open up any new outside-source scripting for 0.1? Such as:

Code:
function onAttack(cid, target)
     if(isPlayer(cid) and getCreatureName(target):lower() == "Orc") then
          if(getPlayerStorageValue(cid, 8000) ~= 1) then 
               return false 
     elseif(isPlayer(cid) and getCreatureName(target):lower() == "Elf") then
          if(getPlayerStorageValue(cid, 8001) ~= 1) then 
               return false 
          end
     elseif(isMonster(cid) and isPlayer(target)) then
          if(getPlayerStorageValue(target, 8000) ~= 1) then 
               return false 
          end
     end
     return true
end


Or would I have to use one different than 0.1 in order to do that? :)
 
Last edited:
No, it has nothing to do with scripting... The source code edit I provided just checks the player storage, if he doesn't have the storage then he is not an opponent.

A small mistake I did was the check "!!val" that was checking if the val is actually true but should be checking if the val is false so then he is an opponent.
Change that check to"!val"
 
I didn't think it would be adding any other functionality other than the source itself. But I thought it wouldn't hurt to ask anyway.

Yeah I was wondering about the double !! :p two not nots.

Thanks still :)
 
Back
Top