I'm not sure how i'd find this in the reference...
Say I want a verb which works when another mob is near. But, I want to make it so that it is only available if the nearby mob fits specific requirements; how do I do this? Can I?
ID:180472
Jun 4 2001, 5:16 pm
|
|
In response to Leftley
|
|
On 6/4/01 9:26 pm Leftley wrote:
On 6/4/01 9:16 pm Foomer wrote: That's more of what I wanted; Any mob that has a certain variable set to... |
In response to Foomer
|
|
That's more of what I wanted; Any mob that has a certain variable set to... OK, then I think I'm a little outgunned here, unless it so happens that that certain variable can be replaced by rearranging your types. Say if you want to make it so players can only attack monsters, and you're trying to set it up so that all monsters have a variable called "ismonster" which is set to 1--you could simply declare all your monster types as subtypes of one broad monster type, and give a verb to the broad monster type as I said above. However, if the variable condition is something which can occur with ANY mob... I'm at a loss. I don't know, maybe you can use if statements to modify a set src statement... At any rate, a simple solution would be to make the verb universally accessible, but make it not work if you try to use it on something which doesn't meet certain conditions. For example, mob player verb revive(M as mob) if (M.health > 0) usr << "[M] doesn't need your help!" return //This stops players from using the verb on living targets M.health = 1 world << "[usr] gives CPR to [M]!" The verb is accessible and can be used on targets that aren't eligible to be revived (people who are still alive!), but it won't accomplish anything. |
In response to Leftley
|
|
I think I'll just explain the whole of what I'm trying to do...
Part of my PC/NPC compatable buy/sell system... I want a verb called 'list' that is only available when you are near a mob that has an item in their contents with a certain variable set to 1. When available, this command lists all items in the nearby player's inventory marked with this certain variable setting (I think I can pull that part off...) ***** Another question, is there any way to limit what things come up on a pupup list when you type 'get' and there are a dozen items near, or something like that? Can I make it so that only items with a certain variable will be available on that list??? |
In response to Foomer
|
|
On 6/4/01 10:22 pm Foomer wrote:
I think I'll just explain the whole of what I'm trying to do... I think you want something like the following (I haven't tested this yet; I may have done the dynamic verb addition and removal all wrong): /obj/tradeverbs verb/listforsale() set name = "list" set src in oview(1) var/obj/o usr << "[src] is offering the following for sale:" for (o in contents) if (o.forsale) usr << "[o]" /obj var/forsale = 0 proc/SetForSale(v) forsale=v if (v) loc:IncForSale() else loc:DecForSale() /mob var/numforsale = 0 var/listforsaleverb = null proc/IncForSale() if (numforsale==0) listforsaleverb=new /obj/tradeverbs/verb/listforsale(src) numforsale++ proc/DecForSale() numforsale-- if (numforsale==0) verbs.Remove(listforsaleverb) del listforsaleverb listforsaleverb=null P.S. Sorry about the formatting. I can't make a double newline in these forums, even in a <PRE> element. |
In response to Pmikell
|
|
Hmm... It "looks" more like what I want, but I can't really say because I don't understand what most of it means. I guess it's time to crack open the reference again...
I think you want something like the following (I haven't tested this yet; I may have done the dynamic verb addition and removal all wrong): /obj/tradeverbsverb/listforsale()set name = "list"set src in oview(1)var/obj/ousr << "[src] is offering the following for sale:"for (o in contents)if (o.forsale)usr << "[o]"/objvar/forsale = 0proc/SetForSale(v)forsale=vif (v)loc:IncForSale()elseloc:DecForSale()/mobvar/numforsale = 0var/listforsaleverb = nullproc/IncForSale()if (numforsale==0)listforsaleverb=new /obj/tradeverbs/verb/listforsale(src)numforsale++proc/DecForSale()numforsale--if (numforsale==0)verbs.Remove(listforsaleverb)del listforsaleverblistforsaleverb=null P.S. Sorry about the formatting. I can't make a double newline in these forums, even in a <PRE> element. |
Say I want a verb which works when another mob is near. But, I want to make it so that it is only available if the nearby mob fits specific requirements; how do I do this? Can I? Remember that you can add and remove verbs by their path in the code. usr.verbs += /mob/verb/appreciate_value usr.verbs -= /mob/verb/appreciate_value If you popped this into Move, for example: mob/Move() . = ..() var/mob/M for(M in oview(1)) //for every mob, excluding me, in range if(M.meets_requirements) //if they meet the requirements if(!src.verbs.Find(/mob/verb/appreciate_value)) //if I don't have this verb yet src.verbs += /mob/verb/appreciate_value //add my verb break if(!M) //if no eligible target was found if(src.verbs.Find(/mob/verb/appreciate_value)) src.verbs -= /mob/verb/appreciate_value //remove my verb Whenever the player moved near a mob that had the meets_requirements set to 1, the player would get access to the 'appreciate_value' verb. If any eligible target is found, M will be set to the first mob found. So there isn't any eligible targets in range, the verb will be removed. I think this should suit your purpose! |
In response to Spuzzum
|
|
Great, I can use that to fix my other goofy commands! :o)
Say I want a verb which works when another mob is near. But, I want to make it so that it is only available if the nearby mob fits specific requirements; how do I do this? Can I? |
In response to Foomer
|
|
Yeah, with a bit of tampering I 'think' I've gotten it to do exactly what I wanted. Thanks!
Hmm... It "looks" more like what I want, but I can't really say because I don't understand what most of it means. I guess it's time to crack open the reference again... /obj/tradeverbsverb/listforsale()set name = "list"set src in oview(1)var/obj/ousr << "[src] is offering the following for sale:"for (o in contents)if (o.forsale)usr << "[o]"/objvar/forsale = 0proc/SetForSale(v)forsale=vif (v)loc:IncForSale()elseloc:DecForSale()/mobvar/numforsale = 0var/listforsaleverb = nullproc/IncForSale()if (numforsale==0)listforsaleverb=new /obj/tradeverbs/verb/listforsale(src)numforsale++proc/DecForSale()numforsale--if (numforsale==0)verbs.Remove(listforsaleverb)del listforsaleverblistforsaleverb=null P.S. Sorry about the formatting. I can't make a double newline in these forums, even in a <PRE> element. |
In response to Spuzzum
|
|
Only problem now... Is there any way to limit what comes up when the player types in a verb like:
look(obj/O as obj in src.contents) If the player clicks on "look", they will be asked to choose from a list of items in the player's inventory, which gives them a complete list of what's in that player's inventory! I'd prefer that not happen, and only items marked 'for sale' are shown in the box... is thee any way to change this? |
In response to Foomer
|
|
On 6/5/01 2:58 pm Foomer wrote:
Only problem now... Is there any way to limit what comes up when the player types in a verb like: You can manipulate lists directly within the arguments (which should suit your purpose in this case) : mob/proc/GenerateListForSale() var/L[0] for(var/obj/O in src) if(O.for_sale) L += O return L mob/verb/look(obj/O in GenerateListForSale()) //yadda yadda yadda See? |
Hmm. I'm not sure what you're after exactly, but if the "specific requirements" were such that you could distinguish them by a mob type, then I'd put the verb under the mob you want to meet the requirements and then add in a set src line. Example:
/mob
healer
verb
recover()
set src = view(3) //Any player who can see the healer and is within 3 spaces can use this verb
usr << "You recover!"
usr.health += 10
Any player who's near enough to the healer and has a line of sight can use the recover() verb and get 10 health. This system works fine so long as you can distinguish mobs readily by type, but if you wanted a verb that would be accessible only if there was a nearby mob that, say, had 50% or less of their maximum health, or had over 1000 gold, or some other such requirement, then I'm not sure how you'd go about making the verb inaccessible.