DragonPrime - LoGD Resource Community
Welcome Guest
  • Good morning, Guest.
    Please log in, or register.
  • December 13, 2017, 01:00:23 AM
Home Forums News Downloads Login Register Advanced Search
* * *
DragonPrime Menu
Login
 
 
Resource Pages
Search

Pages: [1]   Go Down
  Print  
Author Topic: Is It Possible To....  (Read 434 times)
0 Members and 1 Guest are viewing this topic.
TGTarheel
Captain of the Guard
***
Offline Offline

Posts: 183


View Profile
« on: September 25, 2017, 07:49:59 PM »

Just a complete random curiousity question...

is it possible to set a Creature, in the Creature Editor...to attack only a certain gender...or only a certain race....or only a certain alignment character?
Logged
Stephen.Kise
Codemeister
****
Online Online

Posts: 379


So meme'd up.


View Profile
« Reply #1 on: September 26, 2017, 09:55:09 AM »

That is a very neat idea for something such as a highwayman that targets women. It very much is possible - however without a module to prevent the fight from starting, the creature has a chance to hit once, through the surprise attack mechanic. This can be done through an AI script (Be careful who you give creature editor). You would have to decide on what conditions the creature should attack. If you want it to attack women, you would want to check if $session['user']['sex'] is the constant SEX_FEMALE.

Code:
<?php
global $session$enemies$badguy;
if (
$session['user']['sex'] == SEX_FEMALE) {
    
//We want our highwayman to attack women, but not men. Return to continue the next round of fighting.
    
return;
}
foreach (
$enemies as $id => $enemy) {
    if (
$enemy['creaturename'] == $badguy['creaturename']) {
        unset(
$enemies[$id]);
        
//Remove the highwayman from the fight array. He should flee in group combat.
    
}
}
$badguy['creaturegold'] = 0;
$badguy['creatureexp'] = 0;
$badguy['dead'] = true;
// Remove the rewards, remove the creature from the fight.
output("The Highwayman notices a little too late that you are a male and flees!`n");
« Last Edit: September 26, 2017, 09:57:27 AM by Stephen.Kise » Logged

Slowly progressing fork with PHP 7 support: https://github.com/stephenKise/Legend-of-the-Green-Dragon
Cheap VPS Hosting (10$ credit!): https://m.do.co/c/acde75b086c5
TGTarheel
Captain of the Guard
***
Offline Offline

Posts: 183


View Profile
« Reply #2 on: September 26, 2017, 12:26:03 PM »

That is a very neat idea for something such as a highwayman that targets women. It very much is possible - however without a module to prevent the fight from starting, the creature has a chance to hit once, through the surprise attack mechanic. This can be done through an AI script (Be careful who you give creature editor). You would have to decide on what conditions the creature should attack. If you want it to attack women, you would want to check if $session['user']['sex'] is the constant SEX_FEMALE.

Code:
<?php
global $session$enemies$badguy;
if (
$session['user']['sex'] == SEX_FEMALE) {
    
//We want our highwayman to attack women, but not men. Return to continue the next round of fighting.
    
return;
}
foreach (
$enemies as $id => $enemy) {
    if (
$enemy['creaturename'] == $badguy['creaturename']) {
        unset(
$enemies[$id]);
        
//Remove the highwayman from the fight array. He should flee in group combat.
    
}
}
$badguy['creaturegold'] = 0;
$badguy['creatureexp'] = 0;
$badguy['dead'] = true;
// Remove the rewards, remove the creature from the fight.
output("The Highwayman notices a little too late that you are a male and flees!`n");

Neat.  so this is not a module, but something which goes in the Creature Editor, right?

Because that is what I am looking for.

I am looking to create a few creatures that only attack men...and a few that attack only women.

As an extension to this, I also wanted to create a creature that only attacks a certain race...for example, only Elves or only Trolls, or only Humans or whatever.
Logged
Stephen.Kise
Codemeister
****
Online Online

Posts: 379


So meme'd up.


View Profile
« Reply #3 on: September 27, 2017, 12:22:07 PM »

That is a very neat idea for something such as a highwayman that targets women. It very much is possible - however without a module to prevent the fight from starting, the creature has a chance to hit once, through the surprise attack mechanic. This can be done through an AI script (Be careful who you give creature editor). You would have to decide on what conditions the creature should attack. If you want it to attack women, you would want to check if $session['user']['sex'] is the constant SEX_FEMALE.

Code:
<?php
global $session$enemies$badguy;
if (
$session['user']['sex'] == SEX_FEMALE) {
    
//We want our highwayman to attack women, but not men. Return to continue the next round of fighting.
    
return;
}
foreach (
$enemies as $id => $enemy) {
    if (
$enemy['creaturename'] == $badguy['creaturename']) {
        unset(
$enemies[$id]);
        
//Remove the highwayman from the fight array. He should flee in group combat.
    
}
}
$badguy['creaturegold'] = 0;
$badguy['creatureexp'] = 0;
$badguy['dead'] = true;
// Remove the rewards, remove the creature from the fight.
output("The Highwayman notices a little too late that you are a male and flees!`n");

Neat.  so this is not a module, but something which goes in the Creature Editor, right?

Because that is what I am looking for.

I am looking to create a few creatures that only attack men...and a few that attack only women.

As an extension to this, I also wanted to create a creature that only attacks a certain race...for example, only Elves or only Trolls, or only Humans or whatever.
Yes, you can drop this script into a creatures 'AI Script' field. Anyone with creature editor can edit an AI - so be VERY, VERY careful who you give creature editor to. It should be treated like the 'Run Raw SQL' or 'Megauser' superuser flags.
Logged

Slowly progressing fork with PHP 7 support: https://github.com/stephenKise/Legend-of-the-Green-Dragon
Cheap VPS Hosting (10$ credit!): https://m.do.co/c/acde75b086c5
TGTarheel
Captain of the Guard
***
Offline Offline

Posts: 183


View Profile
« Reply #4 on: September 28, 2017, 01:00:47 AM »

Cool.  Have to try it.
Logged
TGTarheel
Captain of the Guard
***
Offline Offline

Posts: 183


View Profile
« Reply #5 on: October 03, 2017, 06:44:15 AM »

Hummm, I do not see anywhere in the Creature Editor I can do this.

I should mention, at the moment, I am running 1.1.0 - is that matter?  Is this something that can only be done on higher versions?

Again, this was a curiousity question.


I now have a test server...and I am looking at the possibility of an upgrade, but ONLY if it can be done without breaking anything I already have in place.
Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  


*
DragonPrime Notices
Play LoGD on Dragonprime

Support Us
No funds raised yet this year
Your help is greatly appreciated!
Recent Topics
DragonPrime LoGD
Who's Online
20 Guests, 2 Users
Stephen.Kise, Wolfsbanewillow
Home Forums News Downloads Login Register Advanced Search