MMORPG Toolkit beta 0.1
|
|
Hugh Perkins
Junior Member
Join date: 26 Nov 2003
Posts: 25
|
11-29-2003 07:18
Here is the MMORPG Toolkit beta 0.1
What works: - you can build monsters and they will chase you and attack you - you can attack the monsters - you can build weapons of varying power - you can create shields - you can lock all of this and set up your own game where people battle out between themselves or with monsters according to the rules that you set!
There's probably a couple of buggettes at this stage so please don't hesitate to IM me / email me or whatever.
Hugh
Your rights to usage and derivation:
You can use this code and derive from it freely as long as you dont affect my ability or rights to do the same, for this code, here or in any other game/platform.
Instructions for use:
Each player will probably want: - a weapon - a shield - a CS GRI Tag
You might also want to make some monsters.
Here's how to make each item:
Weapon
- Create a weapon-looking thing (swords work best for now) - add the Weapon module (see below)
Shield:
- create a shield-looking things, or perhaps a scriptable outfit - add the Shield module (see below)
CS GRI Tag:
- create a bracelet - add the following modules (from below): --- SendDmg --- ReceiveDmg --- Stats --- SecureComms - add sounds called "swordhit" and "swordswing"
Monster: - create a monster thing (it'll float so something like an evil eye would be good) - make sure the blue local axis points up, and the red local axis points forward - add the following modules (from below): --- SendDmg --- ReceiveDmg --- Stats --- SecureComms --- InternalWeapon --- MonsterAI - add sounds called "swordhit" and "swordswing"
|
|
Hugh Perkins
Junior Member
Join date: 26 Nov 2003
Posts: 25
|
SendDmg module
11-29-2003 07:21
SendDmg module Add this to monsters and CS GRI Tags to allow that monster/avatar to attack other game participants. Your rights to usage and derivation: You can use this code and derive from it freely as long as you dont affect my ability or rights to do the same, for this code, here or in any other game/platform. // The SendDmg module is responsible for sending damage to monsters or other players // // It forms part of the CombatSystems GRI and should be combined with the other CombatSystems GRI modules // into something like a bracelet that all game participants will wear // // You will need in addition: // - a weapon object / magical stave / wand - make this using the Weapons module // - other players to attack, or monsters // // The CombatSystems GRI modules are: // - ReceiveDmg // - SendDmg // - SecureComms // - Stats // // Roles and responsibilities: // SendDmg is responsible for: // - receiving and validating weapon commands // - modulation of attacks for current stats (eg attackRange, AttackSpeed ) // - enforcement of death condition wrt attacking // // Parameters: // ChannelWpn - make sure this is the same as what is on your weapon modules // // Public interface: // // Methods: // // DeathCondition: // llLinkedMessage( "DEATHCONDITIONON" ) // tell it attacking no longer allowed, player is dead // llLinkedMessage( "DEATHCONDITIONOFF" ) // tell it attacking allowed again, player is alive // // Attack: // llShout( ChannelWpn, "ATTACK-=-<Target key>-=-<AttackType>-=-<AttackVector>-=-<Power>-=-<CoolDown>" // Swords send this to the SendDmg module when player has told them to attack someone // // Stats update: // llLinkedMessage( "STATUPDATE-=-<StatName>-=-<Stat Value>" ); // to receive stats updates // This module caches AttackPower, AttackRange and AttackSpeed // // Events: // // Attack: // llLinkedMessage( "SENDSECURECOM-=-ATTACK-=-<Target key>-=-<AttackType>-=-<AttackVector>-=-<Power>" ); // SendDmg module sends this to other avatars/monsters, via the SecureComms module, to attack them // // (note <param> means "the value of parameter param") // // // Detail on attacks // ================= // // Mostly, stuff is just passed through for now // We will enforce here CoolDown and modulate attacks for AttackSpeed, AttackRange and AttackPower //
integer ChannelWpn = 4;
integer AttackPower = 100; integer AttackSpeed = 100; integer AttackRange = 100;
integer DeathConditionOn = FALSE;
key OurKey = "";
Debug( string message ) { llWhisper( 0, llGetScriptName() + ": " + message ); }
TellPlayer( string message ) { llWhisper( 0, message ); }
GetKey() { if( llGetAttached() == 0 ) { OurKey = llGetKey(); } else { OurKey = llGetOwner(); } }
default { state_entry() { GetKey(); llWhisper( 0, llGetScriptName() + " Compile complete" ); llListen( ChannelWpn, "", "", "" ); } on_rez( integer param ) { GetKey(); } listen( integer channel, string name, key id, string message ) { list Arguments; Arguments = llParseString2List( message, ["-=-"],[] ); string SourceOwnerKey; SourceOwnerKey = llList2String( Arguments, 1 ); if( SourceOwnerKey == OurKey ) { //TellPlayer( (string)SourceOwnerKey + " " + (string)PlayerKey ); string Command; Command = llList2String( Arguments, 0 ); //TellPlayer( Command ); if( Command == "ATTACK" ) { //TellPlayer( (string)DeathConditionOn ); if( !DeathConditionOn ) { // Debug( "Checking for flying..." ); if( (llGetAgentInfo( OurKey ) & AGENT_FLYING )== 0 ) { Debug( "Attacking..." ); key Target; string AttackType; string AttackVector; integer Power; float CoolDown; Target = llList2String( Arguments, 2 ); AttackType = llList2String( Arguments, 3 ); AttackVector = llList2String( Arguments, 4 ); Power = (integer)llList2String( Arguments, 5 ); CoolDown = (float)llList2String( Arguments, 6 ); // Need to add stuff to handle AttackRange here... // Maybe Send Weapon range from weapon to SendDmg module over ChannelWpn? Power = ( Power * AttackPower )/ 100; CoolDown = ( CoolDown * 100 ) / AttackSpeed; llMessageLinked( LINK_SET, 0, "SENDSECURECOM-=-ATTACK-=-" + (string)Target + "-=-" + AttackType + "-=-" + AttackVector + "-=-" + (string)Power, "" ); llShout( ChannelWpn, "HITSUCCESS-=-" + (string)id ); } else { llWhisper( 0, "You cannot attack while flying" ); } } } } } link_message( integer sendernum, integer num, string message, key id ) { list Arguments; Arguments = llParseString2List( message, ["-=-"],[] ); string Command; Command = llList2String( Arguments, 0 ); if( Command == "STATUPDATE" ) { string StatName; integer StatValue; StatName = llList2String( Arguments, 1 ); StatValue = (integer)llList2String( Arguments, 2 ); if( StatName == "AttackSpeed" ) { AttackSpeed = StatValue; } else if( StatName == "AttackRange" ) { AttackRange = StatValue; } else if( StatName == "AttackPower" ) { AttackPower = StatValue; } } else if( Command == "DEATHCONDITIONON" ) { DeathConditionOn = TRUE; } else if( Command == "DEATHCONDITIONOFF" ) { DeathConditionOn = FALSE; } else if( Command == "SENDDMG" ) { if( llList2String( Arguments, 1 ) == "ATTACK" ) { //TellPlayer( (string)DeathConditionOn ); if( !DeathConditionOn ) { // Debug( message ); key Target; string AttackType; string AttackVector; integer Power; float CoolDown; Target = llList2String( Arguments, 3 ); AttackType = llList2String( Arguments, 4 ); AttackVector = llList2String( Arguments, 5 ); Power = (integer)llList2String( Arguments, 6 ); CoolDown = (float)llList2String( Arguments, 7 ); // Need to add stuff to handle AttackRange here... // Maybe Send Weapon range from weapon to SendDmg module over ChannelWpn? Power = ( Power * AttackPower )/ 100; CoolDown = ( CoolDown * 100 ) / AttackSpeed; llMessageLinked( LINK_SET, 0, "SENDSECURECOM-=-ATTACK-=-" + (string)Target + "-=-" + AttackType + "-=-" + AttackVector + "-=-" + (string)Power, "" ); } } } } }
|
|
Hugh Perkins
Junior Member
Join date: 26 Nov 2003
Posts: 25
|
ReceiveDmg module
11-29-2003 07:24
ReceiveDmg module Add this to monsters and CS GRI Tags to allow them to receive damage. Your rights to usage and derivation: You can use this code and derive from it freely as long as you dont affect my ability or rights to do the same, for this code, here or in any other game/platform. // The ReceiveDmg module is responsible for receiving and processing damage dealt by other avatars or by monsters // attacking the player // // It forms part of the CombatSystems GRI and should be combined with the other CombatSystems GRI modules // into something like a bracelet that all game participants will wear // // You will need in addition: // - a weapon object / magical stave / wand - make this using the Weapons module // - other players to attack, or monsters // // The CombatSystems GRI modules are: // - ReceiveDmg // - SendDmg // - SecureComms // - Stats // // Roles and responsibilities: // ReceiveDmg is responsible for: // - communicating with shield/protection objects to determine and instantiate current protection values // - receiving attacks, via the SecureComms module, and applying them to the Avatar // - enforcement of Death Condition // // Parameters: // ChannelShield - make sure this is the same as what is on your shield modules // DeathTime - length of time you will be dead for when you die // // Public interface: // // Methods: // // Attack methods: // llLinkedMessage( "RECEIVEDSECURECOM-=-ATTACK-=-<Target key>-=-<AttackType>-=-<AttackVector>-=-<Power>" ); // This is an attack message, normally received via the SecureComms modulem from an attacking monster or avatar // // Shield commmunication methods; // llWhisper( "PROTECTIONRESPONSE-=-<ShieldName>-=-<AC>-=-<MR>-=-<ProjArmour>" ); // This is a shield response message detailed its AC, MR and Projectile Armour // llWhisper( "INVCHANGE" ); // Shields and protection items send this as they are attached or detached // // Stats update: // llLinkedMessage( "STATUPDATE-=-Life-=-<Current Life>" ); // // Events: // // DeathCondition event: // llLinkedMessage( "DEATHCONDITIONON" ); // player is dead // llLinkedMessage( "DEATHCONDITIONOFF" ); // player is alive again // // Damage instantiation: // llLinkedMessage( "RAISESTAT-=-Life-=-<minus Damage>" ); // update Life when attacked // // Shield Communication: // llWhisper( "PROTECTIONPING" ); // Ask shields and protection equipment for current stats // // (note <param> means "the value of parameter param") // // // Detail on attacks // ================= // // Currently processes the following attack types: // AttackType = "DirectDamage" // AttackVector = {"MELEE" | "MAGIC" | "PROJECTILE"} (any of these values) // // Power is modulated according to current protection values (AC, MR etc) according to // the AttackVector. AC protects against Melee, MR protects against Magic, and Projectile protects against projectiles // // Damage = ( Power * 100 ) / ( 100 + <protectionvalue> ) //
integer ChannelShield = 5; integer ChannelDead = 7;
integer DeathTime = 10;
integer AC = 0; integer MR = 0; integer ProjArmour = 0;
integer NewAC = 0; integer NewMR = 0; integer NewProjArmour = 0;
integer PingInProgress = FALSE; integer PingSent = 0; integer RedoPing = FALSE;
key OurKey = ""; integer bIsAvatar = FALSE; integer bGotAnimPerms = FALSE; integer bDeathConditionOn = FALSE; integer TimeDied = 0;
TellPlayer( string Message ) { llWhisper( 0, Message ); }
Debug( string message ) { llWhisper( 0, llGetScriptName() + ": " + message ); }
GetKey() { if( llGetAttached() == 0 ) { OurKey = llGetKey(); } else { OurKey = llGetOwner(); } }
GetPermsIfNeeded() { bGotAnimPerms = FALSE; if( llGetAttached() == 0 ) { bIsAvatar = FALSE; } else { bIsAvatar = TRUE; } if( bIsAvatar ) { llRequestPermissions( llGetOwner(), PERMISSION_TRIGGER_ANIMATION ); } }
PingProtection() { if( !PingInProgress ) { PingSent = (integer)llGetWallclock(); NewAC = 0; NewMR = 0; NewProjArmour = 0; llWhisper( ChannelShield, "PROTECTIONPING" ); PingInProgress = TRUE; llSetTimerEvent( 10.0 ); } else { RedoPing = TRUE; } }
ReduceStat( string StatName, integer Amount ) { llMessageLinked( LINK_SET, 0, "RAISESTAT-=-" + StatName + "-=-" + "-" + (string)Amount, "" ); }
SetStat( string StatName, integer Value ) { llMessageLinked( LINK_SET, 0, "SETSTAT-=-" + StatName + "-=-" + (string)Value, "" ); }
ProcessDirectDamage( string AttackVector, integer Power ) { integer Damage; if( AttackVector == "MELEE" ) { Damage = ( Power * 100 ) / ( 100 + AC ); } else if( AttackVector == "MAGIC" ) { Damage = ( Power * 100 ) / ( 100 + MR ); } else if( AttackVector == "PROJECTILE" ) { Damage = ( Power * 100 ) / ( 100 + ProjArmour ); } ReduceStat( "Life", Damage ); }
ProcessAttack( string AttackType, string AttackVector, integer Power ) { if( AttackType == "DirectDamage" ) { ProcessDirectDamage( AttackVector, Power ); } else if( AttackType == "ManaDamage" ) { }else if( AttackType == "IncreaseMoveSpeed" ) { }else if( AttackType == "IncreaseAttackSpeed" ) { }else if( AttackType == "IncreaseAttackRange" ) { } }
StatsPing() { llMessageLinked( LINK_SET, 0, "PINGSTATS", "" ); }
Init() { GetKey(); GetPermsIfNeeded(); StatsPing(); RedoPing = FALSE; PingProtection(); }
EnforceDeathCondition() { llShout( ChannelDead, (string)OurKey ); if( bIsAvatar ) { TellPlayer( "You are dead. Please wait..."); // llShout( Channel, "KILLED" +"-=-" + (string)llFrand(1000.0) + "-=-" + (string)Attackerid + "-=-" + (string)Playerid ); llMessageLinked( LINK_SET, 0, "DEATHCONDITIONON", "" ); if( bGotAnimPerms ) { llStartAnimation( "dead" ); } llMoveToTarget( llGetPos(), 0.2 ); TimeDied = (integer)llGetWallclock(); bDeathConditionOn = TRUE; } else { llMoveToTarget( llGetPos(), 0.2 ); TimeDied = (integer)llGetWallclock(); bDeathConditionOn = TRUE; llSleep( DeathTime ); llDie(); } }
default { state_entry() { Debug( "Compile complete" ); llSetTimerEvent( 10.0 ); Init(); llListen( ChannelShield, "", "","" ); } on_rez( integer param ) { Init(); } listen( integer channel, string name, key id, string message ) { list Arguments; Arguments = llParseString2List( message, ["-=-"], [] ); string Command; Command = llList2String( Arguments, 0 ); if( Command == "PROTECTIONRESPONSE" ) { NewAC = NewAC + (integer)llList2String( Arguments, 2 ); NewMR = NewMR + (integer)llList2String( Arguments, 3 ); NewProjArmour = NewProjArmour + (integer)llList2String( Arguments, 4 ); } else if( Command == "INVCHANGE" ) { PingProtection(); } } timer() { if( PingInProgress ) { if( llAbs( (integer)llGetWallclock() - PingSent ) > 10 ) { AC = NewAC; MR = NewMR; ProjArmour = NewProjArmour; PingInProgress = 0; if( RedoPing ) { RedoPing = FALSE; PingProtection(); } } } if( bDeathConditionOn ) { if( llAbs((integer)llGetWallclock() - TimeDied ) > DeathTime ) { SetStat( "Life", 100 ); llMessageLinked( LINK_SET, 0, "DEATHCONDITIONOFF", "" ); if( bGotAnimPerms ) { llStopAnimation("dead"); } llStopMoveToTarget(); bDeathConditionOn = FALSE; TellPlayer( "Ressurection completed" ); // llShout( Channel, "RESURRECTED-=-" + (string)llFrand(1000.0) +"-=-" + (string)Playerid +"-=-" ) ; } else { llShout( ChannelDead, (string)OurKey ); } } } link_message( integer sendernum, integer num, string message, key id ) { list Arguments; Arguments = llParseString2List( message, ["-=-"], [] ); string Command; Command = llList2String( Arguments, 0 ); //Debug( "link message " + message + " " + Command ); if( Command == "RECEIVEDSECURECOM" ) { if( llList2String( Arguments, 1 ) == "ATTACK" ) { if( ! bDeathConditionOn ) { key Target; Target = (key)llList2String( Arguments, 2 ); // Debug( (string)Target + " " + (string)OurKey ); if( Target == OurKey ) { string AttackType; string AttackVector; integer Power; AttackType = llList2String( Arguments, 3 ); AttackVector = llList2String( Arguments, 4 ); Power = (integer)llList2String( Arguments, 5 ); ProcessAttack( AttackType, AttackVector, Power ); } } } } else if( Command == "STATUPDATE" ) { if( llList2String( Arguments, 1 ) == "Life" ) { if( (integer)llList2String( Arguments, 2 ) <= 0 ) { if( !bDeathConditionOn ) { EnforceDeathCondition(); } } } } } run_time_permissions( integer perms ) { bGotAnimPerms = TRUE; } }
|
|
Hugh Perkins
Junior Member
Join date: 26 Nov 2003
Posts: 25
|
Stats Module
11-29-2003 07:27
Stats Module The stats module holds life, and displays it over the player's CS GRI Tag. Add this to monsters and CS GRI Tags to allow them to have life, and to die. Your rights to usage and derivation: You can use this code and derive from it freely as long as you dont affect my ability or rights to do the same, for this code, here or in any other game/platform. Hugh Perkins // The Stats module is responsible for storing stats for the Avatar, such as life, mana, and so on // // It forms part of the CombatSystems GRI (CS GRI) and should be combined with the other CombatSystems GRI modules // into something like a bracelet that all game participants will wear // // You will need in addition: // - a weapon object / magical stave / wand - make this using the Weapons module // - other players to attack, or monsters // // The CombatSystems GRI modules are: // - ReceiveDmg // - SendDmg // - SecureComms // - Stats // // Roles and responsibilities: // Stats is responsible for: // - Storing current avatar stats // - responding to stat update messages ("SETSTAT", "RAISESTAT") // - Letting other CS GRI modules know when a stat has changed // - Displaying stats to user // // Parameters: // - no parameters, it learns everything from other modules // - you can set initial values for avatar statistics here if you want // // Public interface: // // Methods: // // Modify statistics: // llLinkedMessage( "RAISESTAT-=-<Stat Name>-=-<Amount to add to statistic>" ); // can be negative // llLinkedMessage( "SETSTAT-=-<Stat Name>-=-<New value for stat>" ); // negative numbers will be floored to zero // llLinkedMessage( "PINGSTATS" ); // asks stats module to send all known stats (in statupdate messages) // // Events: // // Stats update: // llLinkedMessage( "STATUPDATE-=-<Stat Name>-=-<New value for stat>" ); // let other CS GRI modules know a stat // has changed // // (note <param> means "the value of parameter param") // // Your rights to use this code: // ============================= // // You can freely use and derive from this code as long as you dont affect my ability or rights to do so myself. // // Hugh Perkins //
integer Life = 100; integer AttackSpeed = 100; // percent of norm integer MoveSpeed = 100; // percent of norm integer Mana = 100; integer AttackRange = 100; // percent of norm integer AttackPower = 100; // percent of norm
vector GREEN = <0,4,0>; vector RED = <4,0,0>; vector ORANGE = <4,0.5,0>; vector YELLOW = <4,4,0>; vector BLUE = <0,0,4>;
SetText( string text, vector color ) { llSetText( text, color,1.0 ); }
ShowLife() { if( Life > 50 ) { SetText( "Life: " + (string)Life, GREEN ); } else if( Life > 10 ) { SetText( "Life: " + (string)Life, ORANGE ); } else if( Life > 0 ) { SetText( "Life: " + (string)Life, RED ); } else { SetText( "-- " + llKey2Name(llGetOwner() ) + "'s Corpse --", RED ); } }
SendStat( string StatName ) { if( StatName == "Life" ) { llMessageLinked( LINK_SET, 0, "STATUPDATE-=-Life-=-" + (string)Life, "" ); } else if( StatName == "AttackSpeed" ) { llMessageLinked( LINK_SET, 0, "STATUPDATE-=-AttackSpeed-=-" + (string)AttackSpeed, "" ); } else if( StatName == "MoveSpeed" ) { llMessageLinked( LINK_SET, 0, "STATUPDATE-=-MoveSpeed-=-" + (string)MoveSpeed, "" ); } else if( StatName == "Mana" ) { llMessageLinked( LINK_SET, 0, "STATUPDATE-=-Mana-=-" + (string)Mana, "" ); } else if( StatName == "AttackRange" ) { llMessageLinked( LINK_SET, 0, "STATUPDATE-=-AttackRange-=-" + (string)AttackRange, "" ); } else if( StatName == "AttackPower" ) { llMessageLinked( LINK_SET, 0, "STATUPDATE-=-AttackPower-=-" + (string)AttackPower, "" ); } }
BroadcastStats() { SendStat( "Life" ); SendStat( "AttackSpeed" ); SendStat( "MoveSpeed" ); SendStat( "Mana" ); SendStat( "AttackRange" ); }
integer GetStat( string StatName ) { if( StatName == "Life" ) { return Life; } else if( StatName == "AttackSpeed" ) { return AttackSpeed; } else if( StatName == "MoveSpeed" ) { return MoveSpeed; } else if( StatName == "Mana" ) { return Mana; } else if( StatName == "AttackRange" ) { return AttackRange; } else if( StatName == "AttackPower" ) { return AttackRange; } return 0; }
SetStat( string StatName, integer StatValue ) { if( StatValue < 0 ) { StatValue = 0; } if( StatName == "Life" ) { Life = StatValue; ShowLife(); } else if( StatName == "AttackSpeed" ) { AttackSpeed = StatValue; } else if( StatName == "MoveSpeed" ) { MoveSpeed = StatValue; } else if( StatName == "Mana" ) { Mana = StatValue; } else if( StatName == "AttackRange" ) { AttackRange = StatValue; } else if( StatName == "AttackPower" ) { AttackPower = StatValue; } SendStat( StatName ); }
default { state_entry() { ShowLife(); } on_rez( integer param ) { ShowLife(); } link_message( integer sendernum, integer num, string message, key id ) { list Arguments; Arguments = llParseString2List( message, ["-=-"], [] ); string Command; Command = llList2String( Arguments, 0 ); string StatName; StatName = llList2String( Arguments, 1 ); integer StatValue; StatValue = (integer)llList2String( Arguments, 2 ); integer CurrentStat; if( Command == "SETSTAT" ) { SetStat( StatName, StatValue ); } else if( Command == "RAISESTAT" ) { CurrentStat = GetStat( StatName ); SetStat( StatName, CurrentStat + StatValue ); } else if( Command == "MINSTAT" ) { // MinStat( StatName, StatValue ); } else if( Command == "MAXSTAT" ) { // MaxStat( StatName, StatValue ); } else if( Command == "PINGSTATS" ) { BroadcastStats(); } } }
|
|
Hugh Perkins
Junior Member
Join date: 26 Nov 2003
Posts: 25
|
SecureComs module
11-29-2003 07:30
SecureComms module The SecureComms module is responsible for communicating between CS GRI Tags. Add this to monsters and to CS GRI Tags to allow avatars and monsters to attack each other. Your rights to usage and derivation: You can use this code and derive from it freely as long as you dont affect my ability or rights to do the same, for this code, here or in any other game/platform. Hugh Perkins // The SecureComms module is responsible for communications between the CombatSystems GRI and other avatars/monsters // // It forms part of the CombatSystems GRI and should be combined with the other CombatSystems GRI modules // into something like a bracelet that all game participants will wear // // You will need in addition: // - a weapon object / magical stave / wand - make this using the Weapons module // - other players to attack, or monsters // // The CombatSystems GRI modules are: // - ReceiveDmg // - SendDmg // - SecureComms // - Stats // // Roles and responsibilities: // SecureComms is responsible for: // - Receiving messages from GRI modules and passing them to other avatars/monsters // - Receivng messags from other avatars/monsters and passing them to GRI modules // - communications security and encryption (for now, we just use Channel number for this) // // Parameters: // ChannelInterActor - channel number for communication with other GRIs / monsters // // Public interface: // // Methods: // // llLinkedMessage( "SENDSECURECOM-=-<message>" ); // GRI modules send this to send <message> to other GRIs/monsters. // llShout( "<message>" ); // Other GRI modules send this to send <message> to this GRI // // Events: // // llLinkedMessage( "RECEIVEDSECURECOM-=-<message>" ); // Tell GRI modules about a message received from outside world // llShout( "<message>" ); // Communicate an internally-sourced GRI message to the outside world // // (note <param> means "the value of parameter param") // // Your rights to use this code: // ============================= // // You can freely use and derive from this code as long as you dont affect my ability or rights to do so myself. // // Hugh Perkins //
integer ChannelInterActor = 1;
Debug( string message ) { llWhisper( 0, llGetScriptName() + ": " + message ); }
default { state_entry() { llWhisper(0, llGetScriptName() + " Compile complete"); llListen( ChannelInterActor, "","","" ); } listen( integer channel, string name, key id, string message ) { llMessageLinked( LINK_SET, 0, "RECEIVEDSECURECOM-=-" + message, "" ); } link_message( integer sendernum, integer num, string message, key id ) { list Arguments; Arguments = llParseString2List( message, ["-=-"],[] ); //Debug( message ); string Command; Command = llList2String( Arguments, 0 ); //Debug( Command ); if( Command == "SENDSECURECOM" ) { string MessageToSend; MessageToSend = llGetSubString( message, llStringLength( "SENDSECURECOM") ,1000); //Debug( (string)ChannelInterActor + " " + MessageToSend ); llShout( ChannelInterActor, MessageToSend ); } } }
|
|
Hugh Perkins
Junior Member
Join date: 26 Nov 2003
Posts: 25
|
Shield module
11-29-2003 07:36
Shield module The shield module increases the resistance to damage of players. Add it to clothing or shield-like items to give them protective power. The exact protection values are in the paramters at the top of hte script (MR, AC and ProjArmour) Your rights to usage and derivation: You can use this code and derive from it freely as long as you dont affect my ability or rights to do the same, for this code, here or in any other game/platform. Hugh Perkins // The Shield module is used to create shields and protection equipment that players can wear // // Just slot it into something shield-like and wear it, or give it out to players to wear, or sell it // // Players will need in addition: // - to be wearing a CombatSystems GRI object (eg appropriately scripting bracelet) // - a weapon object / magical stave / wand - make this using the Weapons module // - other players to attack, or monsters // // Roles and responsibilities: // Shield is responsible for: // - telling the CombatSystems GRI (CS GRI) its protection ratings (AC, MR, Projectile Armour) // - letting the CS GRI know when it is attached or detached // // Parameters: // ChannelShield - make sure this is the same as what is on your CS GRI modules // AC - Resistance to melee damage of the shield // MR - Resistance to magic damage // ProjArmour - Resistance to projectile attacks // // Public interface: // // Methods: // // Shield Communication: // llWhisper( "PROTECTIONPING" ); // CS GRI sends this to ask shields to send their protection stats // // Events: // // Shield commmunication methods; // llWhisper( "PROTECTIONRESPONSE-=-<ShieldName>-=-<AC>-=-<MR>-=-<ProjArmour>" ); // Shield lets CS GRI know what it is called, and its protection statistics // llWhisper( "INVCHANGE" ); // Shield sends this when attached or detached // // (note <param> means "the value of parameter param") //
integer ChannelShield = 5;
integer MR = 0; integer AC = 10; integer ProjArmour = 5;
SendInvChangedMessage() { llWhisper( ChannelShield, "INVCHANGE" ); }
default { state_entry() { //llListen( ChannelShield, llKey2Name( llGetOwner() ), llGetOwner(), "" ); llListen( ChannelShield, "", "", "" ); SendInvChangedMessage(); } on_rez( integer param ) { } attach( key id ) { // this covers both attach and detach SendInvChangedMessage(); } listen( integer channel, string name, key id, string message ) { if( message == "PROTECTIONPING" ) { llWhisper( ChannelShield, "PROTECTIONRESPONSE-=-" + llGetObjectName() + "-=-" + (string)AC + "-=-" + (string)MR + "-=-" + (string)ProjArmour ); } } }
|
|
Hugh Perkins
Junior Member
Join date: 26 Nov 2003
Posts: 25
|
Weapon module
11-29-2003 07:37
Weapon module Add this to a sword-like thing that players wear in order to let them attack other people or monsters. Your rights to usage and derivation: You can use this code and derive from it freely as long as you dont affect my ability or rights to do the same, for this code, here or in any other game/platform. Hugh Perkins // The Weapon module is responsible for responding to player commands to attack another player or monster // // Just slot it into something sword, batton, wand or stave-like and wear it, or give it out to players to wear, or sell it // Weapons can be melee, or magical, or projectile, or just about anything you can imagine!!!! // // Players will need in addition: // - to be wearing a CombatSystems GRI object (eg appropriately scripting bracelet) // - other players to attack, or monsters // // Optional other items for plqyers: // - shield object // // Roles and responsibilities: // The Weapon module is responsible for: // - responding to player commands asking it to attack something // - definition of attack type, power and so on // - enforcement of charge time, recharge time, and charge limitations, as required by weapon designer // // Parameters: // ChannelWpn - make sure this is the same as what is on the SendDmg module of your CS GRI // // Public interface: // // Methods: // Player controls weapon via attachment interface. No explicit methods // // Events: // // Attack: // llWhisper( ChannelWpn, "ATTACK-=-<Target key>-=-<AttackType>-=-<AttackVector>-=-<Power>-=-<CoolDown>" // Swords send this to the SendDmg module to attack other avatars or monsters // // (note <param> means "the value of parameter param") // // // Detail on attacks // ================= // // - AttackType, AttackVector and Power are defined by the CS GRI REceiveDmg module. See ReceiveDmg module // documentation for more info // - Cooldown is used to enforce a delay between attacks with the weapon // - Currently Cooldown is enforced by the weapon, but this will be migrated to the SendDmg module, in order // to allow enforcement of the AttackSpeed stat //
integer ChannelWpn = 4;
string AttackType = "DirectDamage"; string AttackVector = "MELEE"; integer AttackPower = 20; float CoolDown = 0.5;
string PlayerName; key Playerid;
float LastAttack = 0; integer have_permissions = FALSE; integer Message2displayed = FALSE;
TellPlayer( string Message ) { llWhisper(0,PlayerName + ", " + Message ); }
TellOwner( string Message ) { // llInstantMessage( Playerid, Message ); }
GenericInit() { Playerid = llGetOwner(); PlayerName = llKey2Name( Playerid ); PlayerName = llGetSubString( PlayerName, 0, llSubStringIndex( PlayerName, " ") );
TellPlayer( "Switch to mouselook to attack!" ); llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION| PERMISSION_TAKE_CONTROLS); llPreloadSound( "swordhit" ); llPreloadSound( "swing1" );
Message2displayed = FALSE; llSetTimerEvent(5.0); }
default { state_entry() { llListen( ChannelWpn, "","","" ); GenericInit(); } on_rez(integer startparam) { GenericInit(); }
timer() { llSay(0, "Use me wisely, " + PlayerName + "!"); llSetTimerEvent(0.0); Message2displayed = TRUE; } run_time_permissions(integer perms) { if(perms & (PERMISSION_TAKE_CONTROLS)) { llTakeControls(CONTROL_FWD | CONTROL_BACK | CONTROL_RIGHT | CONTROL_LEFT | CONTROL_ROT_RIGHT | CONTROL_ROT_LEFT | CONTROL_UP | CONTROL_DOWN | CONTROL_ML_LBUTTON, TRUE, TRUE); have_permissions = TRUE; } } attach(key attachedAgent) { if (attachedAgent != NULL_KEY) { Playerid = llGetOwner(); llRequestPermissions(Playerid, PERMISSION_TRIGGER_ANIMATION| PERMISSION_TAKE_CONTROLS); } else { if (have_permissions) { llReleaseControls(); have_permissions = FALSE; } } }
control(key name, integer levels, integer edges) { if ( ((edges & CONTROL_ML_LBUTTON) == CONTROL_ML_LBUTTON) &&((levels & CONTROL_ML_LBUTTON) == CONTROL_ML_LBUTTON) ) { if( LastAttack < llGetTimeOfDay() - CoolDown ) { LastAttack = llGetTimeOfDay(); llSensor("","",ACTIVE | AGENT,2.0,PI/4); llStartAnimation("sword_strike_R"); llPlaySound("swing1",1.0 ); } } } sensor(integer num_detected) { integer TargetFound = FALSE; key Targetid; string TargetName;
TargetFound = FALSE;
integer i; i = 0; //TellPlayer( "sense event..." ); while( TargetFound == FALSE && i < num_detected ) { //TellPlayer( llDetectedName(i) + " " + (string)llDetectedType(i) + " " + (string)SCRIPTED); if( ( ( llDetectedType(i) & SCRIPTED ) == SCRIPTED ) || ( ( llDetectedType(i) & AGENT ) == AGENT ) ) { //TellPlayer( "target found: " + llDetectedName(i) ); TargetFound = TRUE; Targetid = llDetectedKey(i); TargetName = llDetectedName(i); } i++; } if( TargetFound ) { llWhisper( ChannelWpn, "ATTACK" + "-=-" + (string)Playerid + "-=-" + (string)Targetid + "-=-" + AttackType + "-=-" + AttackVector + "-=-" + (string)AttackPower + "-=-" + (string)CoolDown ); } }
listen( integer channel, string name, key id, string message ) { if( message == "HITSUCCESS-=-" + (string)llGetKey() ) { llPlaySound( "swordhit", 1.0); } } }
|
|
Hugh Perkins
Junior Member
Join date: 26 Nov 2003
Posts: 25
|
InternalWeapon module - for monsters
11-29-2003 07:40
InternalWeapon module - for monsters This is what monsters and robots use as a weapon. Just add it in along with the rest of the monster modules. You can change the values of damage and so on in the paramters at the top. Your rights to usage and derivation: You can use this code and derive from it freely as long as you dont affect my ability or rights to do the same, for this code, here or in any other game/platform. Hugh Perkins string WeaponName = "SWORD";
string AttackType = "DirectDamage"; string AttackVector = "MELEE"; integer AttackPower = 20; float CoolDown = 0.5;
float LastAttack = 0;
Debug( string message ) { llWhisper( 0, llGetScriptName() + ": " + message ); }
ProcessAttackRequest() { // Debug( "attack request received" ); if( LastAttack < llGetTimeOfDay() - CoolDown ) { LastAttack = llGetTimeOfDay(); // Debug( "Attacking..." ); //llSensor("","",SCRIPTED | AGENT,2.0,PI/4); llSensor("","",ACTIVE | AGENT,2.0,PI/4); //llSensor("","",SCRIPTED,2.0,PI/4); //llStartAnimation("sword_strike_R"); llPlaySound("swing1",1.0 ); } }
SendAttackCodes( key Targetid ) { llMessageLinked( LINK_SET, 0, "SENDDMG-=-ATTACK" + "-=-" + (string)llGetKey() + "-=-" + (string)Targetid + "-=-" + AttackType + "-=-" + AttackVector + "-=-" + (string)AttackPower + "-=-" + (string)CoolDown, "" ); }
default { state_entry() { Debug( "Compile complete" ); } sensor(integer num_detected) { // integer TargetFound = FALSE; key ThisTargetid; integer SensorType; // string TargetName;
// TargetFound = FALSE;
// integer i; // i = 0; // Debug( "sense event..." ); // while( TargetFound == FALSE && i < num_detected ) // { // Debug( llDetectedName(0) + " " + (string)llDetectedType(0) + " " + (string)SCRIPTED); // if( ( ( llDetectedType(i) & SCRIPTED ) == SCRIPTED ) || ( ( llDetectedType(i) & AGENT ) == AGENT ) ) // { // Debug( "target found: " + llDetectedName(0) ); //TargetFound = TRUE; ThisTargetid = llDetectedKey(0); //ThisTarget //TargetName = llDetectedName(i); // } // i++; // } // if( TargetFound ) // { SendAttackCodes( ThisTargetid); llPlaySound( "swordhit", 1.0); // } } link_message( integer sendernum, integer num, string message, key id ) { // Debug( message ); list Arguments; Arguments = llParseString2List( message, ["-=-"],[] ); string Command; Command = llList2String( Arguments, 0 ); // Debug( Command ); if( Command == "INTERNALWEAPON" ) { // Debug( llList2String( Arguments, 1 ) ); if( llList2String( Arguments, 1 ) == WeaponName ) { // Debug( llList2String( Arguments, 2 ) ); if( llList2String( Arguments, 2 ) == "ATTACK" ) { ProcessAttackRequest(); } } } } }
|
|
Hugh Perkins
Junior Member
Join date: 26 Nov 2003
Posts: 25
|
MonsterAI module
11-29-2003 07:42
MonsterAI module Add this to monsters to make them attack nearby avatars. Monsters will need to be equiped with an InternalWeapon module to be able to attack. Your rights to usage and derivation: You can use this code and derive from it freely as long as you dont affect my ability or rights to do the same, for this code, here or in any other game/platform. Hugh Perkins integer ChannelDeadPeople = 7;
float IdealSpeed = 5; float Mass = 8; float StrikeDistance=1.8; float CoolDown = 1.0;
float IdealAttackDistance = 1.5;
//integer RotDisabled = FALSE; integer TranslateDisabled = FALSE; integer WorldState = TRUE; integer Initialized = FALSE; integer AttackDisabled = FALSE;
float LastTimeWorldOn; float LastAttack = 0; string LastTarget = "";
list DeadPeople = []; list NewDeadPeople = [];
Debug( string message ) { llWhisper( 0, llGetScriptName() + ": " + message ); }
Attack( key Target ) { llMessageLinked( LINK_SET, 0, "INTERNALWEAPON-=-SWORD-=-ATTACK-=-" + (string)Target, "" ); }
SetWorldOn() { if( !Initialized || !WorldState ) { Debug("Activating"); WorldState = TRUE; Initialized = TRUE; LastTimeWorldOn = llGetTimeOfDay();
llSetStatus(STATUS_PHYSICS,FALSE); llSetRot(ZERO_ROTATION); llSetStatus(STATUS_PHYSICS,TRUE);
llSetStatus(STATUS_ROTATE_X, FALSE); llSetStatus(STATUS_ROTATE_Y, FALSE); llSetStatus(STATUS_ROTATE_Z, FALSE);
llSetRot(ZERO_ROTATION);
LastTarget = ""; llSetTimerEvent(5.0);
llSetBuoyancy(1.0); llSetHoverHeight(2.0,FALSE,0.2);
llSensorRemove(); llSensorRepeat("","",AGENT,15,PI,1.0); } }
TurnTowardsTarget( vector NormalizedVectorToTarget ) { vector EulerRot; rotation RotBetweenWorldAndTarget; RotBetweenWorldAndTarget = llRotBetween( <1,0,0>, NormalizedVectorToTarget ); //Debug( (string)RotBetweenWorldAndTarget ); rotation RotToGoTo; RotToGoTo = RotBetweenWorldAndTarget; //Debug( (string)llRot2Fwd(<0,0,0,1> )); llSetStatus(STATUS_PHYSICS, FALSE ); llSetRot( llRotBetween( <1,0,0>, NormalizedVectorToTarget ) ); llSetStatus(STATUS_PHYSICS, TRUE ); RotToGoTo = llEuler2Rot(<0,0,1>); llRotLookAt( RotToGoTo, llGetMass() * 2, llGetMass() / 5 ); } Init() { Mass = llGetMass(); DeadPeople = []; NewDeadPeople = []; SetWorldOn(); }
default { state_entry() { Debug( "Compile complete" ); Init(); llListen( ChannelDeadPeople, "","",""); llSetTimerEvent( 10.0); } on_rez(integer start_param) { Init(); } sensor(integer num_detected) { //Debug("Sensor event");
integer i; integer TargetNum = 0; integer bTargetFound = FALSE; list SearchList; for( i = 0; i< num_detected && ! bTargetFound; i++ ) { if( llListFindList( DeadPeople, [ (string)llDetectedKey(i) ]) == -1 ) { bTargetFound = TRUE; TargetNum = i; } }
if( bTargetFound ) { vector VectorToTarget; VectorToTarget = llDetectedPos(TargetNum) - llGetPos(); VectorToTarget.z = 0; vector NormalizedVectorToTarget; NormalizedVectorToTarget = llVecNorm(VectorToTarget);
//Debug( "Detectedname: " + llDetectedName(0) );
TurnTowardsTarget( NormalizedVectorToTarget );
if( WorldState ) // world on { if( LastAttack < llGetTimeOfDay() - CoolDown && llVecMag(VectorToTarget) <StrikeDistance) { //llSay(0, "Chomp!"); LastAttack = llGetTimeOfDay(); if( !AttackDisabled ) { Attack( llDetectedKey(TargetNum) ); } } else { if( llVecMag(VectorToTarget) - IdealAttackDistance > IdealSpeed ) { // Debug( "far from target" ); vector NextStep; NextStep = llGetPos() + NormalizedVectorToTarget * IdealSpeed; if( !TranslateDisabled ) { llMoveToTarget( NextStep, 1.0); } } else { if( !TranslateDisabled ) { // Debug( "near target" ); llMoveToTarget( llGetPos() + (llVecMag(VectorToTarget) - IdealAttackDistance ) * NormalizedVectorToTarget , 1.0); } } } } } } listen( integer channel, string name, key id, string message ) { list SearchList; SearchList = [ message ]; if( llListFindList( NewDeadPeople, SearchList ) == -1 ) { //Debug( "Adding " + message + " to new dead list" ); NewDeadPeople = NewDeadPeople + SearchList; } if( llListFindList( DeadPeople, SearchList ) == -1 ) { //Debug( "Adding " + message + " to dead list" ); DeadPeople = DeadPeople + SearchList; } } timer() { DeadPeople = NewDeadPeople; NewDeadPeople = []; } }
|
|
Hugh Perkins
Junior Member
Join date: 26 Nov 2003
Posts: 25
|
For experts only: debug modules
11-29-2003 07:48
These modules are strictly for scripting experts only. They help with unit and integration testing for those who will be modifying and improving these scripts. RelayAgent module: This whispers the inter-object shouts to you. Commands available: echo_on, echo_off Your rights to usage and derivation: You can use this code and derive from it freely as long as you dont affect my ability or rights to do the same, for this code, here or in any other game/platform. integer MessagesOn = TRUE; integer Channel = 4;
integer g_listener=-1;
SayInChannel( string Message ) { llShout( Channel, Message ); llInstantMessage( llGetOwner(), "InChannel:" + Message ); }
TellOwner( string message ) { llWhisper( 0, message ); }
Init() { llInstantMessage( llGetOwner(), "Your id: " + (string)llGetOwner() ); }
DoMonitoring(integer channel, string name, key id, string message) { list Arguments; Arguments = llParseString2List( message, ["-=-"], [] ); string Command; Command = llList2String( Arguments, 0 ); if( channel != 0 ) { if( MessagesOn ) { //llInstantMessage(llGetOwner(),name + " - " + (string)id + " - " + message); TellOwner( name + " - " + (string)channel + " - " + message); } } else { if( message == "echo_off" ) { MessagesOn = FALSE; llSay(0,message); } else if( message == "echo_on" ) { MessagesOn = TRUE; llSay(0,message); } else if( Command == "relay" ) { string MessageToRelay; MessageToRelay = llGetSubString( message, 8,1000); if( llSubStringIndex( MessageToRelay, "$MYID$") != -1 ) { integer myidposition; myidposition = llSubStringIndex( MessageToRelay, "$MYID$"); MessageToRelay = llGetSubString( MessageToRelay, 0, myidposition - 1 ) + (string)llGetOwner() + llGetSubString( MessageToRelay, myidposition + 6, 1000); } SayInChannel( MessageToRelay ); } } }
AddChannelListener() { llListen(1,"","",""); llListen(4,"","",""); llListen(5,"","",""); }
RemoveListeners() { if( g_listener != -1 ) { llListenRemove( g_listener ); g_listener = -1; } }
default { state_entry() { Init(); AddChannelListener(); llListen(0,"",llGetOwner(),""); } on_rez( integer param ) { Init(); } listen(integer channel, string name, key id, string message ) { DoMonitoring(channel, name, id, message); } }
LinkSniff: - Lets you hear what's going on between the objects, the LinkMessages. - commands available: linkechoon, linkechooff Your rights to usage and derivation: You can use this code and derive from it freely as long as you dont affect my ability or rights to do the same, for this code, here or in any other game/platform. integer bEchoOn = TRUE;
Debug( string message ) { llWhisper( 0, llGetScriptName() + ": " + message ); }
default { state_entry() { llWhisper(0, llGetScriptName() + " Compile complete"); llListen( 0, "","","" ); } link_message( integer sendernum, integer num, string message, key id ) { if( bEchoOn ) { //if( llSubStringIndex( message, "SECURECOM" ) != -1 ) //{ llWhisper( 0, "LinkSniff: " + (string) sendernum + " " + message ); //} } } listen( integer channel, string name, key id, string message ) { if( message == "linkechooff" ) { Debug( "link echo off" ); bEchoOn = FALSE; }else if( message == "linkechoon" ) { Debug( "link echo on" ); bEchoOn = TRUE; } } }
Hugh Perkins
|
|
Chip Midnight
ate my baby!
Join date: 1 May 2003
Posts: 10,231
|
11-29-2003 08:05
Very cool Hugh! 
_____________________
 My other hobby: www.live365.com/stations/chip_midnight
|
|
Eggy Lippmann
Wiktator
Join date: 1 May 2003
Posts: 7,939
|
11-29-2003 09:43
Way to go Hugh! Though you should probably post that in the script library.
|
|
Bizcut Vanbrugh
Registered User
Join date: 23 Jul 2006
Posts: 99
|
07-30-2006 18:16
awsome post and scripts
|
|
Bizcut Vanbrugh
Registered User
Join date: 23 Jul 2006
Posts: 99
|
anyon using or used it
09-26-2006 18:39
has anyone done any work with the kit here if so send me a im i am wnting to use it for the sim i am helping to run. thanks
|
|
Dimentox Travanti
DCS Coder
Join date: 10 Sep 2006
Posts: 228
|
09-27-2006 07:19
Can you post it in the repository also http://lsl.dimentox.com
_____________________
LSL Scripting Database - http://lsl.dimentox.com
|
|
Dimentox Travanti
DCS Coder
Join date: 10 Sep 2006
Posts: 228
|
09-27-2006 07:21
Biz, I have not yet but was wondering if anyone wanted to do a Dungon Sim. I have land but alas my shop takes up to many prims already.
So if anyone has some decent land and wants to build a multi tiered dungor to work this let me know ingame or on here through pm.
_____________________
LSL Scripting Database - http://lsl.dimentox.com
|
|
Bizcut Vanbrugh
Registered User
Join date: 23 Jul 2006
Posts: 99
|
09-29-2006 07:16
well i have been playying around with this alot lately and even been having my friends help out ( here wear this and this and attack this monster when it rezzes) we have been having loads of fun. the only problem is we cant seem to do ranged weapons for it. i am a bit of a noob when it comes to scripting but i am not seeing o how to do the renged weapons for this system. anybody care to tell me how. I would really like to know.
P.S. had a great fight in the sim i am part of last night. rezzed a bunch of "air sharks" i had made made 3 different ones 1 HUGE boss several smaller tough ones and then a BUT LOAD of small weak one. Sent 5 space marines armed with chain sowrds into the ruins and let the chaos begin. 3 of the 5 marines died before it was all said and done and all of themonsters were dead. it is a great system i just whish it had an experince system built into it as well. that would help loads.
|
|
Poodle Noodle
Castlevania: Legends RPG
Join date: 28 Jan 2006
Posts: 32
|
Sounds Cool
11-26-2006 08:56
Howdy!
Is there anywhere in world that I could try this out?
|
|
Chosen Few
Alpha Channel Slave
Join date: 16 Jan 2004
Posts: 7,496
|
11-26-2006 09:39
Hugh, that's awesome. Thanks for sharing this. I can't wait to play with it.
_____________________
.
Land now available for rent in Indigo. Low rates. Quiet, low-lag mainland sim with good neighbors. IM me in-world if you're interested.
|