Aller au contenu

Photo

Major XP mod, help wold sure help ;)


  • Veuillez vous connecter pour répondre
11 réponses à ce sujet

#1
niapet

niapet
  • Members
  • 41 messages
Hello everyone,



after finally acquainting me with XML and fixing a number of problems in my
PW's menus I decided it would be possible to now implement a system I have
wanted to put together for a while.  I would like to disable parties
on my PW, both to cut down on lag and to create a stronger sense of
individualness and realism for the server.



What I have done so far (not implemented in the world yet of course) is
simply removing the buttons from all the XML menus that allows players to
invite others to their party and also the accept buttons for good measure. 
This step will eliminate parties; however it will also make partying for
adventuring fruitless since players will no longer share XP.



What I need to do is implement a system that will share XP by proximity. 
In effect I would like all XP a PC earns to be shared with all
other PCs within a certain distance from themselves (The longest distance a
ranged and or/spell can be use from would be the ideal I imagine).  Then
Players can still adventure together without the need of the party. I can
also add a line to any quests that dish out xp for turning items in to give out
the xp to all pcs within a small distance as well.



So, does anyone have any ideas on how to do this?  Is sharing xp in
this way possible? If so is it easy or convoluted to do so?  I am not
the best scripter in the world but I have a basic grasp so any help would
be very much appreciated.

Modifié par niapet, 16 mai 2011 - 02:50 .


#2
GhostOfGod

GhostOfGod
  • Members
  • 863 messages
Off the top of my head you could do something like this:
EDITED:

void main()
{
    object oPC = GetLastKiller();

    if (GetIsObjectValid(GetMaster(oPC)))
    {
        oPC = GetMaster(oPC);
    }
    if (!GetIsPC(oPC)) return;

    int iXP = 100;//whatever you want your xp to be

    //AddJournalQuestEntry("", 1, oPC, FALSE, FALSE);
    GiveXPToCreature(oPC, iXP);

    int iNth = 1;
    object oShareXP = GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR, PLAYER_CHAR_IS_PC, oPC, iNth, CREATURE_TYPE_IS_ALIVE, CREATURE_ALIVE_TRUE, CREATURE_TYPE_REPUTATION, REPUTATION_TYPE_FRIEND);
    while (GetIsObjectValid(oShareXP))
    {
        if (GetDistanceBetween(oPC, oShareXP) < 10.0)
        {
            //AddJournalQuestEntry("", 1, oPC, FALSE, FALSE);
            GiveXPToCreature(oShareXP, iXP);
        }
        else return;
        iNth++;
        oShareXP = GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR, PLAYER_CHAR_IS_PC, oPC, iNth, CREATURE_TYPE_IS_ALIVE, CREATURE_ALIVE_TRUE, CREATURE_TYPE_REPUTATION, REPUTATION_TYPE_FRIEND);
    }
}


Might need some alterations here or there but hope this gets you started in the right direction. Honeslty not sure if this would cause any type of lag or anything. Never tried anything like it.

Modifié par GhostOfGod, 17 mai 2011 - 03:10 .


#3
niapet

niapet
  • Members
  • 41 messages
This looks helpful, would you use this as a user defined script or heartbeat? Also how would i go about getting the value of the last xp that oPC earned? because on this line:

int iXP = 100;//whatever you want your xp to be

100 should be whatever the last xp amount oPC earned. That way it will share xp from killing mobs as well as sharing xp for doing quests

#4
MasterChanger

MasterChanger
  • Members
  • 686 messages

niapet wrote...

This looks helpful, would you use this as a user defined script or heartbeat? Also how would i go about getting the value of the last xp that oPC earned? because on this line:

int iXP = 100;//whatever you want your xp to be

100 should be whatever the last xp amount oPC earned. That way it will share xp from killing mobs as well as sharing xp for doing quests


Don't put it in user-defined or OnHB. Put it OnDeath for the creatures killed, and assign the XP first to the killer and then to those nearby.

Then write another script to be used in conversations for quest XP reward. Give it a parameter that specifies the XP (and if you want flexibility, the range for XP-for-those-nearby). Then on the line when you give XP in your conversations, just use your script instead.

You've got to capture the moment when you give XP to the PC in the first place, rather than trying to retrieve that info later on to share with those nearby.

#5
GhostOfGod

GhostOfGod
  • Members
  • 863 messages

GhostOfGod wrote...
int iXP = 100;//whatever you want your xp to be


I just kinda slapped that in there. I wasn't sure how you wanted to defind the XP.

As is, this script will give the killer and all the players within 10 meters of the player, 100XP. There are a lot of things you could do with this. You could set a variable on each creature that is checked for the amount of XP it is worth. You could check its CR and do some kinda math to come up with a good amount of xp for each monster. And if you wanted the nearby players to get a lesser amount then you could do some math on the line that gives the XP to those near. Or devide up the XP etc..

Really a lot of ways to go with it.

And yes, as the Master pointed out, this would be used for your modules creatures OnDeath script. If you wanted a current death script that you are using to still run if your creatures are killed, then you can just add an ExecuteScript line to the bottom of the example script above.

Good luck.

P.S. And don't forget that when using a custom XP system for your module you need to set your modules XP scale to 0 in the module properties.

Modifié par GhostOfGod, 17 mai 2011 - 02:07 .


#6
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages
You may alos want to add a check to make sure the PC, you are sharing the XP with, is friendly with the PC who did the killing.

#7
GhostOfGod

GhostOfGod
  • Members
  • 863 messages

Lightfoot8 wrote...

You may alos want to add a check to make sure the PC, you are sharing the XP with, is friendly with the PC who did the killing.


Good call Lightfoot. Script above edited. I think I did it right. I haven't tested GetNearestCreature with the reputation parameter but it should be good.

#8
niapet

niapet
  • Members
  • 41 messages
Cool, thanks for all the help! I'm usually glad if i get even one response for a question but this is great, especially considering how big of a modification to the game environment this will be.

At the moment the module gives out 30 xp per monster killed if the monsters CR matches the PC level, it is 5 less per CR lower and 5 more per CR higher to a minimum of 5 and a maximum of 100. (i.e. a level 3 PC gets 30xp for killing a CR 3 and 25 for a CR 2 and 35 for a CR 4 etc..)

So this formula should work to replicate that in script form:

Let Mxp = Mob CR
Let Pxp = PC killer's level

Then

[(Mxp – Pxp)* 5] + 30 = XP to give to Killer and all within 10 meters

That should work, and since the script will be based on the killers CR it should keep power leveling to a minimum.

I was trying to work it out in the script so I could contribute a little here =P  but I couldnt find a function to get the Mob's chalange rating??

Modifié par niapet, 18 mai 2011 - 12:08 .


#9
kevL

kevL
  • Members
  • 4 070 messages
int nCR = FloatToInt(GetChallengeRating(OBJECT_SELF));

you might increase 10m.
i think 40m is long range spells, and 60m is for longbows - i think*

#10
niapet

niapet
  • Members
  • 41 messages
Right, thanks, I did intend to increase the 10m to whatever the longest a psudo party member might be away from the killer (ie longest spell or missile weapon range +10m for good measure)

#11
Morbane

Morbane
  • Members
  • 1 883 messages

niapet wrote...

I was trying to work it out in the script so I could contribute a little here =P  but I couldnt find a function to get the Mob's chalange rating??


Sometimes challenge rating is shortened to CR - so you could try to script assist that abbreviated keyword - just a random suggestion. :whistle:

Another way to search for functions is to incorporate "EC's SuperInclude" - it has every include in one script so you can search ALL of the functions in the game while it is open and in front in the script window.

Modifié par Morbane, 18 mai 2011 - 07:43 .


#12
niapet

niapet
  • Members
  • 41 messages

Morbane wrote...
Another way to search for functions is to incorporate "EC's SuperInclude" - it has every include in one script so you can search ALL of the functions in the game while it is open and in front in the script window.


neat