@Request a simple Faction or Race System Script

Nash

New member
Messages
86
Points
0
Hi Guys,
           i wanna request a simple faction Script
like on loggin you get option to choose your faction For ex. Holy and Darkness
Choose 1 faction and you get item according to that faction.
and it also changes your aura diffrent aura for diffrent faction

Point*- Both Factions Can pvp any where in server except Main town !!

Thx in advance 

                                                                                                   Regards,

                                                                                                          Nas#

 
For the aura you can use @aura, wich you get with this patch, but I've preferred to use effects from the effects_list.txt for making the script useable without any source mod.

For a faction vs faction pvp you'll need to perform a source modification, which I don't know.

Your script could be like this (untested so there may be errors/bugs):

// [jaBote] Simple faction script.// Can be done with arrays to save lots of variables and improve efficiency, but this one is easier to understand except for the menu making which is automatic./// @configurations are in OnInit label.- script Factions Manager -1,{ OnInit: set .forever, 1; // Are factions forever (value: 1) or can you decide them whenever you log in (value: 0)? set .totalfactions, 2 // Total number of factions // Faction 1 parameters set .faction1_name$, "Red"; // Name for faction 1 set .faction1_item, 7575; // CHANGE it to any item ID you want. It should be character-bound. set .faction1_effect, 22; // CHANGE it to an existent effect from effects_list.txt set .faction1_effectdelay, 10000; // Delay, in milliseconds, for reapplying the faction effect so it seems a consistent aura // Faction 2 parameters set .faction2_name$, "Blue"; // Name for faction 2 set .faction2_item, 7576; // CHANGE it to any item ID you want. It should be character-bound. set .faction2_effect, 33; // CHANGE it to an existent effect from effects_list.txt set .faction2_effectdelay, 10000; // Delay, in milliseconds, for reapplying the faction effect so it seems a consistent aura // Add more factions here if you want // More info on effects: https://github.com/HerculesWS/Hercules/blob/master/doc/effect_list.txt set .init, 1; end; OnPCLoginEvent: if (!.init) donpcevent strnpcinfo(3)+"::OnInit"; // Faction data from OnInit MUST be loaded if (!(.forever && faction)) { // Need to set faction as you don't have one mes "Hey " + strcharinfo(0) + "! Pick a faction!"; for (set .@i, 1; .@i <= .totalfactions; set .@i, .@i + 1){ // Dynamic menu set set .@menu$, .@menu$ + getd(".faction" + .@i + "_name$"); // Dynamically getting the name of the faction if (.@i < .totalfactions) set .@menu$, .@menu$ + ":"; } set faction, select(.@menu$); next; mes "You're now in the " + getd(".faction" + faction + "_name$") + " faction."; getitem getd(".faction" + faction + "_item"); close2; } doevent strnpcinfo(3)+"::OnMakeAura"; // Do Aura Loop end; OnMakeAura: enable_items; // May be a possible exploit but it's necessary misceffect getd(".faction" + faction + "_effect"); addtimer getd(".faction" + faction + "_effectdelay"),strnpcinfo(3)+"::OnAuraRefresh"; end; OnAuraRefresh: deltimer strnpcinfo(3)+"::OnAuraRefresh"; doevent strnpcinfo(3)+"::OnMakeAura"; // Start again end; OnPCLogoutEvent: if (!.forever && countitem(getd(".faction" + faction + "_item"))) delitem getd(".faction" + faction + "_item"),1; end;}

Check if it works.

Edit: I'd seriously better make an array version of this, I'll do it again later of tomorrow when I have time but I can't right now.

Edit 2: Made some corrections, thanks Capuche.

 
Last edited by a moderator:
You'll need a source edit for that, which I'm unable to perform.

Sorry for being short but I'm on my cellphone right now.

 
*Wild Capuche approach*

I believe you don't need freeloop(1);

if (.init) donpcevent strnpcinfo(3)+"::OnInit"; // Faction data from OnInit MUST be loaded
must be

if (!.init) donpcevent strnpcinfo(3)+"::OnInit"; // Faction data from OnInit MUST be loaded
to load OnInit when it's not

 
LoL Capuche you're right about the init, but I made this in a hurry and didn't have time to revise it. Talking of the freeloop(1) I've also put it because I misunderstood the command, so it's removed now. Thanks.

A more efficient and easier to understand (there are no getd's), but a bit harder to configure version (I mean, using arrays) could be like this:

// [jaBote] Simple faction script.// Done with arrays to save lots of variables and improve efficiency (especially when using 3+ factions).-  script  Factions Manager  -1,{  OnInit:    // Factions configurations.    set .forever, 1; // Are factions forever (value: 1) or can you decide them whenever you log in (value: 0)?        // To add more factions, you need to increase ALL arrays with proper information.    // You can add up to 127 factions. Number of factions is calculated based on the size of the arrays    // eg: setarray .faction_names$[1],"Red","Blue";  ------> setarray .faction_names$[1],"Red","Blue","Yellow";    setarray .faction_names$[1],"Red","Blue"; // Faction names    setarray .faction_items[1],7575,7576; // Items to give to faction players, CHANGE them to any item IDs you want. They should be character-bound and not obtainable anywhere else.    setarray .faction_effects[1],22,33; // Effects for faking an aura, CHANGE them to any existent effects from effects_list.txt    setarray .faction_effectdelays[1],10000,10000; // Delay, in milliseconds, for reapplying the faction effects so they seem consistents auras    // More info on effects: https://github.com/HerculesWS/Hercules/blob/master/doc/effect_list.txt    set .init, 1;    end;  OnPCLoginEvent:    if (!.init) donpcevent strnpcinfo(3)+"::OnInit"; // Faction data from OnInit MUST be loaded    if (!(.forever && faction)) {  // Need to set faction as you don't have one      mes "Hey " + strcharinfo(0) + "! Pick a faction!";      for (set .@i, 1; .@i < getarraysize(.faction_items); set .@i, .@i + 1){  // Dynamic menu set. Condiction is strict because of the array offsets        set .@menu$, .@menu$ + .faction_names$[.@i]; // Dynamically getting the name of the faction        if (.@i < (getarraysize(.faction_items) - 1)) set .@menu$, .@menu$ + ":";      }      set faction, select(.@menu$);      next;      mes "You're now in the " + .faction_names$[faction] + " faction.";      getitem .faction_items[faction];      close2;    }    doevent strnpcinfo(3)+"::OnMakeAura"; // Do Aura Loop    end;    OnMakeAura:    enable_items; // May be a possible exploit but it's necessary    misceffect .faction_effects[faction];    addtimer .faction_effectdelays[faction],strnpcinfo(3)+"::OnAuraRefresh";    end;    OnAuraRefresh:    deltimer strnpcinfo(3)+"::OnAuraRefresh";    doevent strnpcinfo(3)+"::OnMakeAura"; // Start again    end;      OnPCLogoutEvent:    if (!.forever && countitem(.faction_items[faction])) delitem .faction_items[faction],1;    end;}

This one is much faster and does the same. This script is just a BASIC faction system, and you can only make some other scripts react to the faction the players are in. Any advanced actions (Faction guardians, PvP between factions, etc), require source edits.

 
Last edited by a moderator:
For the aura you can use @aura, wich you get with this patch, but I've preferred to use effects from the effects_list.txt for making the script useable without any source mod.

For a faction vs faction pvp you'll need to perform a source modification, which I don't know.

Your script could be like this (untested so there may be errors/bugs):

// [jaBote] Simple faction script.// Can be done with arrays to save lots of variables and improve efficiency, but this one is easier to understand except for the menu making which is automatic./// @configurations are in OnInit label.- script Factions Manager -1,{ OnInit: set .forever, 1; // Are factions forever (value: 1) or can you decide them whenever you log in (value: 0)? set .totalfactions, 2 // Total number of factions // Faction 1 parameters set .faction1_name$, "Red"; // Name for faction 1 set .faction1_item, 7575; // CHANGE it to any item ID you want. It should be character-bound. set .faction1_effect, 22; // CHANGE it to an existent effect from effects_list.txt set .faction1_effectdelay, 10000; // Delay, in milliseconds, for reapplying the faction effect so it seems a consistent aura // Faction 2 parameters set .faction2_name$, "Blue"; // Name for faction 2 set .faction2_item, 7576; // CHANGE it to any item ID you want. It should be character-bound. set .faction2_effect, 33; // CHANGE it to an existent effect from effects_list.txt set .faction2_effectdelay, 10000; // Delay, in milliseconds, for reapplying the faction effect so it seems a consistent aura // Add more factions here if you want // More info on effects: https://github.com/HerculesWS/Hercules/blob/master/doc/effect_list.txt set .init, 1; end; OnPCLoginEvent: if (!.init) donpcevent strnpcinfo(3)+"::OnInit"; // Faction data from OnInit MUST be loaded if (!(.forever && faction)) { // Need to set faction as you don't have one mes "Hey " + strcharinfo(0) + "! Pick a faction!"; for (set .@i, 1; .@i <= .totalfactions; set .@i, .@i + 1){ // Dynamic menu set set .@menu$, .@menu$ + getd(".faction" + .@i + "_name$"); // Dynamically getting the name of the faction if (.@i < .totalfactions) set .@menu$, .@menu$ + ":"; } set faction, select(.@menu$); next; mes "You're now in the " + getd(".faction" + faction + "_name$") + " faction."; getitem getd(".faction" + faction + "_item"); close2; } doevent strnpcinfo(3)+"::OnMakeAura"; // Do Aura Loop end; OnMakeAura: enable_items; // May be a possible exploit but it's necessary misceffect getd(".faction" + faction + "_effect"); addtimer getd(".faction" + faction + "_effectdelay"),strnpcinfo(3)+"::OnAuraRefresh"; end; OnAuraRefresh: deltimer strnpcinfo(3)+"::OnAuraRefresh"; doevent strnpcinfo(3)+"::OnMakeAura"; // Start again end; OnPCLogoutEvent: if (!.forever && countitem(getd(".faction" + faction + "_item"))) delitem getd(".faction" + faction + "_item"),1; end;}

Check if it works.

Edit: I'd seriously better make an array version of this, I'll do it again later of tomorrow when I have time but I can't right now.

Edit 2: Made some corrections, thanks Capuche.
Thx thx thx alot 

Now can any 1 provide me src mods for this ???

 
I'd prefer you to use my second version, which is more resource cost-effective, which I made on the other reply to this post.

About the related source mods: it's quite complicated to make them as far as I know, so I doubt you can get those mods so easily. In rAthena forums there's a full faction ststem made by an user named Lilith, but it's sold for $20, but it's incompatible with Hercules.

 
Last edited by a moderator:
Back
Top