[wpdev-commits] xmlscripts/scripts/skills __init__.py,1.5,1.6 mining.py,1.4,1.5
Brought to you by:
rip,
thiagocorrea
|
From: <co...@us...> - 2003-10-03 16:21:16
|
Update of /cvsroot/wpdev/xmlscripts/scripts/skills
In directory sc8-pr-cvs1:/tmp/cvs-serv18209/scripts/skills
Modified Files:
__init__.py mining.py
Log Message:
little work on global skill checking and mining
Index: __init__.py
===================================================================
RCS file: /cvsroot/wpdev/xmlscripts/scripts/skills/__init__.py,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** __init__.py 2 Oct 2003 19:26:19 -0000 1.5
--- __init__.py 3 Oct 2003 16:21:10 -0000 1.6
***************
*** 1,60 ****
import wolfpack
from wolfpack.consts import *
! #SKILLID, STRGAIN, DEXGAIN, INTGAIN, ANTIMACRO
skilltable = \
{
! ALCHEMY: [0, 0.5, 0.5, FALSE],
! ANATOMY: [0.15, 0.5, 0.5, TRUE ],
! ANIMALLORE: [0, 0.5, 0.5, TRUE ],
! ITEMID: [0, 0.5, 0.5, TRUE ],
! ARMSLORE: [0.75, 0.5, 0.5, TRUE ],
! PARRYING: [0.75, 0.5, 0.5, FALSE],
! BEGGING: [0, 0.5, 0.5, TRUE ],
! BLACKSMITHING: [1, 0.5, 0.5, FALSE],
! BOWCRAFT: [0.6, 0.5, 0.5, FALSE],
! PEACEMAKING: [0, 0.5, 0.5, TRUE ],
! CAMPING: [2, 0.5, 0.5, TRUE ],
! CARPENTRY: [2, 0.5, 0.5, FALSE],
! CARTOGRAPHY: [0, 0.5, 0.5, FALSE],
! COOKING: [0, 0.5, 0.5, FALSE],
! DETECTINGHIDDEN: [0, 0.5, 0.5, TRUE ],
! ENTICEMENT: [0, 0.5, 0.5, TRUE ],
! EVALUATINGINTEL: [0, 0.5, 0.5, TRUE ],
! HEALING: [0.6, 0.5, 0.5, TRUE ],
! FISHING: [0.5, 0.5, 0.5, TRUE ],
! FORENSICS: [0, 0.5, 0.5, TRUE ],
! HERDING: [1.625,0.5, 0.5, TRUE ],
! HIDING: [0, 0.5, 0.5, TRUE ],
! PROVOCATION: [0, 0.5, 0.5, TRUE ],
! INSCRIPTION: [0, 0.5, 0.5, FALSE],
! LOCKPICKING: [0, 0.5, 0.5, TRUE ],
! MAGERY: [0, 0.5, 0.5, TRUE ],
! MAGICRESISTANCE: [0.25, 0.5, 0.5, TRUE ],
! TACTICS: [0, 0.5, 0.5, FALSE],
! SNOOPING: [0, 0.5, 0.5, TRUE ],
! MUSICIANSHIP: [0, 0.5, 0.5, TRUE ],
! POISONING: [0, 0.5, 0.5, TRUE ],
! ARCHERY: [0.25, 0.5, 0.5, FALSE],
! SPIRITSPEAK: [0, 0.5, 0.5, TRUE ],
! STEALING: [0, 0.5, 0.5, TRUE ],
! TAILORING: [0.38, 0.5, 0.5, FALSE],
! TAMING: [1.4, 0.5, 0.5, TRUE ],
! TASTEID: [0.2, 0.5, 0.5, TRUE ],
! TINKERING: [0.5, 0.5, 0.5, FALSE],
! TRACKING: [0, 0.5, 0.5, TRUE ],
! VETERINARY: [0.8, 0.5, 0.5, TRUE ],
! SWORDSMANSHIP: [0.75, 0.5, 0.5, FALSE],
! MACEFIGHTING: [0.9, 0.5, 0.5, FALSE],
! FENCING: [0.45, 0.5, 0.5, FALSE],
! WRESTLING: [0.9, 0.5, 0.5, FALSE],
! LUMBERJACKING: [2, 0.5, 0.5, TRUE ],
! MINING: [2, 0.5, 0.5, TRUE ],
! MEDITATION: [0, 0.5, 0.5, TRUE ],
! STEALTH: [0, 0.5, 0.5, TRUE ],
! REMOVETRAPS: [0, 0.5, 0.5, TRUE ],
! NECROMANCY: [0, 0.5, 0.5, TRUE ],
! FOCUS: [0, 0.5, 0.5, FALSE],
! CHIVALRY: [0, 0.5, 0.5, TRUE ]
}
--- 1,71 ----
+ import time
import wolfpack
+ import whrandom
+ import wolfpack.settings
from wolfpack.consts import *
! STRGAIN = 0
! DEXGAIN = 1
! INTGAIN = 2
! GAINFACTOR = 3
! SKILLCAP = 4
! ANTIMACRO = 5
!
! #SKILLID, STRGAIN, DEXGAIN, INTGAIN, GAINFACTOR, SKILLCAP, ANTIMACRO
skilltable = \
{
!
! ALCHEMY: [0, 0.5, 0.5, 1, 1000, FALSE],
! ANATOMY: [0.15, 0.15, 0.7, 1, 1000, TRUE ],
! ANIMALLORE: [0, 0, 1, 1, 1000, TRUE ],
! ITEMID: [0, 0, 1, 1, 1000, TRUE ],
! ARMSLORE: [0.75, 0.15, 0.1, 1, 1000, TRUE ],
! PARRYING: [0.75, 0.25, 0, 1, 1000, FALSE],
! BEGGING: [0, 0, 0, 1, 1000, TRUE ],
! BLACKSMITHING: [1, 0, 0, 1, 1000, FALSE],
! BOWCRAFT: [0.6, 1.6, 0, 1, 1000, FALSE],
! PEACEMAKING: [0, 0, 0, 1, 1000, TRUE ],
! CAMPING: [2, 1.5, 1.5, 1, 1000, TRUE ],
! CARPENTRY: [2, 0.5, 0, 1, 1000, FALSE],
! CARTOGRAPHY: [0, 0.75, 0.75, 1, 1000, FALSE],
! COOKING: [0, 2, 3, 1, 1000, FALSE],
! DETECTINGHIDDEN: [0, 0.4, 0.6, 1, 1000, TRUE ],
! ENTICEMENT: [0, 0.25, 0.25, 1, 1000, TRUE ],
! EVALUATINGINTEL: [0, 0, 1, 1, 1000, TRUE ],
! HEALING: [0.6, 0.6, 0.8, 1, 1000, TRUE ],
! FISHING: [0.5, 0.5, 0, 1, 1000, TRUE ],
! FORENSICS: [0, 0.2, 0.8, 1, 1000, TRUE ],
! HERDING: [1.625,0.625, 0.25, 1, 1000, TRUE ],
! HIDING: [0, 0.8, 0.2, 1, 1000, TRUE ],
! PROVOCATION: [0, 0.45, 0.05, 1, 1000, TRUE ],
! INSCRIPTION: [0, 0.2, 0.8, 1, 1000, FALSE],
! LOCKPICKING: [0, 2, 0, 1, 1000, TRUE ],
! MAGERY: [0, 0, 1.5, 1, 1000, TRUE ],
! MAGICRESISTANCE: [0.25, 0.25, 0.5, 1, 1000, TRUE ],
! TACTICS: [0, 0, 0, 1, 1000, FALSE],
! SNOOPING: [0, 2.5, 0, 1, 1000, TRUE ],
! MUSICIANSHIP: [0, 0.8, 0.2, 1, 1000, TRUE ],
! POISONING: [0, 0.4, 1.6, 1, 1000, TRUE ],
! ARCHERY: [0.25, 0.75, 0, 1, 1000, FALSE],
! SPIRITSPEAK: [0, 0, 1, 1, 1000, TRUE ],
! STEALING: [0, 1, 0, 1, 1000, TRUE ],
! TAILORING: [0.38, 1.63, 0.5, 1, 1000, FALSE],
! TAMING: [1.4, 0.2, 0.4, 1, 1000, TRUE ],
! TASTEID: [0.2, 0, 0.8, 1, 1000, TRUE ],
! TINKERING: [0.5, 0.2, 0.3, 1, 1000, FALSE],
! TRACKING: [0, 1.25, 1.25, 1, 1000, TRUE ],
! VETERINARY: [0.8, 0.4, 0,8, 1, 1000, TRUE ],
! SWORDSMANSHIP: [0.75, 0.25, 0, 1, 1000, FALSE],
! MACEFIGHTING: [0.9, 0.1, 0, 1, 1000, FALSE],
! FENCING: [0.45, 0.55, 0, 1, 1000, FALSE],
! WRESTLING: [0.9, 0.1, 0, 1, 1000, FALSE],
! LUMBERJACKING: [2, 0, 0, 1, 1000, TRUE ],
! MINING: [2, 0, 0, 1, 1000, TRUE ],
! MEDITATION: [0, 0, 0, 1, 1000, TRUE ],
! STEALTH: [0, 0, 0, 1, 1000, TRUE ],
! REMOVETRAPS: [0, 0, 0, 1, 1000, TRUE ],
! NECROMANCY: [0, 0, 0, 1, 1000, TRUE ],
! FOCUS: [0, 0, 0, 1, 1000, FALSE],
! CHIVALRY: [0, 0, 0, 1, 1000, TRUE ]
}
***************
*** 93,96 ****
backpack.additem( resourceitem )
! socket.clilocmessage( table[ resname ][ SUCCESSCLILOC ], "", YELLOW, NORMAL )
return OK
--- 104,200 ----
backpack.additem( resourceitem )
! socket.clilocmessage( table[ resname ][ SUCCESSCLILOC ], "", GREEN, NORMAL )
! return OK
!
!
! def checkskill( char, skillid, chance ):
! if char.dead:
! return OOPS
! skillvalue = char.skill[ skillid ]
! skillscap = wolfpack.settings.getNumber( "General", "SkillCap", 700 ) * 10
! charskillcap = char.skillcap[ skillid ]
! chartotalskills = totalskills( char )
!
! if chance >= whrandom.random():
! mult = 0.5
! else:
! mult = 0.2
!
! gainchance = float( skillscap - chartotalskills ) / skillscap
! gainchance += float( charskillcap - skillvalue ) / charskillcap / 2
! gainchance = ( ( gainchance + ( 1.0 - chance ) * mult ) / 2 ) * skilltable[ skillid ][ GAINFACTOR ]
!
! if gainchance < 0.01:
! gainchance = 0.01
!
! if gainchance >= whrandom.random() or skillvalue < 100:
! skillgain( char, skillid )
!
! return OK
!
!
! def skillgain( char, skillid ):
! skillvalue = char.skill[ skillid ]
! charskillcap = char.skillcap[ skillid ]
! skillscap = wolfpack.settings.getNumber( "General", "SkillCap", 700 ) * 10
! charskilllock = char.skilllock[ skillid ]
! chartotalskills = totalskills( char )
!
! #Skill growing
! if skillvalue < charskillcap and charskilllock == GROWUP:
! #Base skill value < 10.0 ?
! toGain = 1
! if skillvalue <= 100:
! toGain = whrandom.randint( 1, 5 )
!
! #Pull down skill which is marked as GROWDOWN
! if ( chartotalskills / skillscap ) >= whrandom.random():
! for i in range( 0, ALLSKILLS ):
! if char.skilllock[ i ] == GROWDOWN and skillvalue > toGain:
! char.skill[ i ] = char.skill[ i ] - toGain
! break
!
! if chartotalskills + toGain <= skillscap:
! char.skill[ skillid ] = char.skill[ skillid ] + toGain
!
! #Stats growing
! if charskilllock == GROWUP:
! if float( skilltable[ skillid ][ STRGAIN ] ) / 33.3 > whrandom.random():
! statgain( char, STRENGTH )
! elif float( skilltable[ skillid ][ DEXGAIN ] ) / 33.3 > whrandom.random():
! statgain( char, DEXTERITY )
! elif float( skilltable[ skillid ][ INTGAIN ] ) / 33.3 > whrandom.random():
! statgain( char, INTELLIGENCE )
!
!
! char.update()
return OK
+
+
+ def statgain( char, stat ):
+ #STATGAINDELAY is not over ?
+ if char.hastag( 'laststatgain' ) and ( time.time() - char.gettag( 'laststatgain' ) ) < STATGAINDELAY:
+ return OOPS
+
+ char.settag( 'laststatgain', time.time() )
+ if float( totalstats( char ) ) / wolfpack.settings.getNumber( "General", "StatCap", 225 ) >= whrandom.random():
+ if stat == STRENGTH:
+ char.strength = char.strength + 1
+ char.updatestats()
+ elif stat == DEXTERITY:
+ char.dexterity = char.dexterity + 1
+ char.updatestats()
+ elif stat == INTELLIGENCE:
+ char.intelligence = char.intelligence + 1
+ char.updatestats()
+
+ return OK
+
+ def totalskills( char ):
+ total = 0
+ for i in range( 0, ALLSKILLS ):
+ total += char.skill[ i ]
+ return total
+
+ def totalstats( char ):
+ return char.strength + char.dexterity + char.intelligence
Index: mining.py
===================================================================
RCS file: /cvsroot/wpdev/xmlscripts/scripts/skills/mining.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** mining.py 2 Oct 2003 20:33:49 -0000 1.4
--- mining.py 3 Oct 2003 16:21:10 -0000 1.5
***************
*** 16,20 ****
oresound = 0x126
!
# Name, reqSkill, minSkill, maxSkill, successClilocId, itemId, color, mutateVeinChance%, VeinChanceToFallback%
--- 16,21 ----
oresound = 0x126
! #in seconds
! miningdelay = 1600
# Name, reqSkill, minSkill, maxSkill, successClilocId, itemId, color, mutateVeinChance%, VeinChanceToFallback%
***************
*** 64,67 ****
--- 65,69 ----
success = 0
char.addtimer( 1400, "skills.mining.effecttimer", [oresound] )
+ char.settag( 'is_mining', servertime() + miningdelay )
char.turnto( pos )
char.action( 11 )
***************
*** 72,81 ****
if char.skill[ MINING ] > reqskill:
if whrandom.randint( oretable[ resname ][ MINSKILL ], oretable[ resname ][ MAXSKILL ] ) < char.skill[ MINING ]:
! if whrandom.random() < 0.5:
success = 1
skills.successharvest( char, veingem, oretable, resname, 1 ) # 1 - amount of ore
if success == 0:
! socket.clilocmessage( 501869, "", YELLOW, NORMAL ) # You loosen some rocks but fail to find any usable ore.
char.deltag('nowmining')
--- 74,84 ----
if char.skill[ MINING ] > reqskill:
if whrandom.randint( oretable[ resname ][ MINSKILL ], oretable[ resname ][ MAXSKILL ] ) < char.skill[ MINING ]:
! if whrandom.random() < 0.9:
success = 1
skills.successharvest( char, veingem, oretable, resname, 1 ) # 1 - amount of ore
+ skills.checkskill( char, MINING, 0 )
if success == 0:
! socket.clilocmessage( 501869, "", GRAY, NORMAL ) # You loosen some rocks but fail to find any usable ore.
char.deltag('nowmining')
***************
*** 108,117 ****
# Player can reach that ?
if char.pos.map != pos.map or char.pos.distance( pos ) > MINING_MAX_DISTANCE:
! socket.clilocmessage( 500446, "", YELLOW, NORMAL ) # That is too far away
! return OK
!
! # Already mining ?
! if char.hastag('is_mining'):
! socket.clilocmessage( 503029, "", YELLOW, NORMAL ) # You are already digging.
return OK
--- 111,115 ----
# Player can reach that ?
if char.pos.map != pos.map or char.pos.distance( pos ) > MINING_MAX_DISTANCE:
! socket.clilocmessage( 500446, "", RED, NORMAL ) # That is too far away
return OK
***************
*** 121,125 ****
#Mine char ?!
if target.char:
! socket.clilocmessage( 501863, "", YELLOW, NORMAL ) # You can't mine that.
return OK
--- 119,123 ----
#Mine char ?!
if target.char:
! socket.clilocmessage( 501863, "", RED, NORMAL ) # You can't mine that.
return OK
***************
*** 138,142 ****
mining( char, target.pos, tool )
else:
! socket.clilocmessage( 501862, "", YELLOW, NORMAL ) # You can't mine there.
return OK
--- 136,140 ----
mining( char, target.pos, tool )
else:
! socket.clilocmessage( 501862, "", RED, NORMAL ) # You can't mine there.
return OK
***************
*** 147,151 ****
mining( char, target.pos, tool )
else:
! socket.clilocmessage( 501862, "", YELLOW, NORMAL ) # You can't mine there.
return OK
else:
--- 145,149 ----
mining( char, target.pos, tool )
else:
! socket.clilocmessage( 501862, "", RED, NORMAL ) # You can't mine there.
return OK
else:
|