View previous topic :: View next topic |
Author |
Message |
khaibar Advanced
Joined: 14 Dec 2007 Posts: 1144
|
Posted: Sat Oct 06, 2012 3:05 am Post subject: CODE: No loss planet |
|
|
This is kinda big update, so I will post the codes one by one
hopefully i will finish in an hour or so
First of all the loot code, where killer gets 1 mod and the one killed looses 2. This is probably the biggest one. Also when a player unit is killed, it drops supply in it's place (encourage pvp)
There has been a lot of debate on which planet to put this on so i made a variable called $planet_loot.
Deploying:
- Check if at least 4 mods are on unit (no way to know if mods are integrated or not when checking, sorry guys)
- Unit is not wrecked
- Give unit 100% autosalvage
process_deploy.php on line 787
before
Code: | for ($uniti = 0; $uniti < (count($unitlist)); $uniti++) { |
after
Code: | for ($uniti = 0; $uniti < (count($unitlist)); $uniti++) { $unit_mod_count=0; |
on line 792
before
Code: | if ($unitlist[$uniti] == $modonunit[$modi]) { |
after
Code: | if ($unitlist[$uniti] == $modonunit[$modi]) { $unit_mod_count++; |
on line 813
Code: | } if( ($unit_mod_count<4) AND ($planet_loot == "Y") ) { $can_drop = "Cannot have less than 4 mods on loot planet"; break; } |
break will exit this for loop
Code: | for ($uniti = 0; $uniti < (count($unitlist)); $uniti++) |
initially i wanted to make it atleast 2 mods (excluding integrated ones), but i don't think i can differentiate between integrated and non integrated mods here so i had to make it 4 total mods (modded + integrated, u still loose only non-integrated ones of course).
Now for the not wrecked part. As you will see later in the code, there are 2 ways to go with this. Either have a W var that signifies a wrecked unit or make a tag like the newbie tag (more logical)
Insert on line 875
Code: | if ((strpos($unitvar[$i], "W")) !== false ) { $can_drop = "Wrecked unit"; } |
or a check for is_wrecked which relates to checking is_wrecked from the database for that unit but such a variable does not exist yet.
Now for the 100% auto salvage
insert on line 1560 (or anywhere related to inserting effects for units)
Code: | if($planet_loot == "Y")
{
$sqltext ="INSERT INTO deployed_effects
(i_target,c_type, i_amount, i_owner, has_duration, i_planet)
VALUES (".$insertedunitid[$i].",'atosv',100,".$userid.",'N',".$iplanet.")";
$res =& $db->query($sqltext, Array() );
if (DB::isError($res)) { ReportDBError($res, "process_deploy"); }
} |
Processing turn:
- Give 1 non-integrated mod to attacker (if attacker is a bandit, destroy it)
- Destroy a mod
- Update database with remaining mods
- Tag unit as wrecked
To reduce the amount of checks, this will be added within the auto salvage code. More details will be given later.
Looting 1 mod (destroy if bandit was killer), destroying one other, 2 mods are kept + update database with remaining mods.
Code: | if($planet_loot == "Y")
{
$loot_count=0; // variable to track loot count
$remaining_mods=""; // remaining mods after loot
if ($unitdata[$weapon->target_id]["unit_id"] != NULL) {
// Get mods of unit before it autosalvages
$data =& $db->getRow("SELECT onmods FROM units WHERE id=".$unitdata[$weapon->target_id]["unit_id"],
array(), DB_FETCHMODE_OBJECT);
if (DB::isError($data)) { ReportDBError($data); }
if (trim($data->onmods) != '') { // Units on loot planets must have atleast 2 mods (excluding integrated) on but I left this check just in case
$data = explode(",",$data->onmods);
foreach ($data as $mod) { // Does this mean that they are not selected randomly? this may cause issues since people can select which mods to loose. Perhaps shuffle the array of strings?
if($loot_count<2){ // still less than 2 mods
if ( ($loot_count==0) AND ($unitdata[$weapon->i_owner]["is_bandit"] == "N") ){ // First loot and killer isn't a bandit
$sql = "UPDATE mods SET m_".$mod."=(m_".$mod."+1) WHERE user_id=? ";
$res =& $db->query($sql, Array($weapon->i_owner) );
if (DB::isError($res)) { ReportDBError($res); }
$msgText = "<frunit>".$unitdata[$weapon->i_on_unit]['i_type_id']."</frunit><DIV CLASS='unitDivLR'>[<font class='helptext'>".$unitdata[$weapon->i_on_unit]["crew_name"]."</font>] looted a <font class='helptextb'>".$TW_mod_names[$mod]."</font> mod!</DIV>";
SetMessage(15, $msgText, $weapon->i_owner); // Give a message that you looted
$msgText = "<frunit>".$unitdata[$weapon->target_id]['i_type_id']."</frunit><DIV CLASS='unitDivLR'>[<font class='helptext'>".$unitdata[$weapon->target_id]["crew_name"]."</font>] lost a <font class='helptextb'>".$TW_mod_names[$mod]."</font> mod!</DIV>"; // Give a message that you lost a mod
SetMessage(15, $msgText, $unitdata[$weapon->target_id]["i_owner"]);
unset($msgText,$sqltext);
} else { // Second loot or killer was a bandit
$msgText = "<frunit>".$unitdata[$weapon->target_id]['i_type_id']."</frunit><DIV CLASS='unitDivLR'>[<font class='helptext'>".$unitdata[$weapon->target_id]["crew_name"]."</font>] lost a <font class='helptextb'>".$TW_mod_names[$mod]."</font> mod!</DIV>"; // Give a message that you lost a mod
SetMessage(15, $msgText, $unitdata[$weapon->target_id]["i_owner"]);
unset($msgText,$sqltext);
}
$loot_count++;
}
else // Loot is over, get remaining stuff, this is quite messy lol
{
if($remaining_mods=="") // still empty
$remaining_mods=$mod;
else $remaining_mods=$remaining_mods.",".$mod; // add second mod, i believe u used ',' as the seperator between mods
}
}
// now update the database before autosalvage kicks in
$sql = "UPDATE units SET onmods=".$remaining_mods." WHERE id=? ";
$res =& $db->query($sql, Array($weapon->target_id) );
if (DB::isError($res)) { ReportDBError($res); }
}
|
Now wreck the unit
Code: | // Wreck the unit
// There are two approaches for this, either add W var to the unit's var list. Or and which i think is more logical have a tag similar to the newbie tag.
// Adding W var, fetch old vars and add W to them
$new_vars=& $db->getRow("SELECT s_var FROM units WHERE id=? ",
array($weapon->target_id), DB_FETCHMODE_OBJECT);
if (DB::isError($vdata)) { ReportDBError($vdata); }
$new_vars="W".$new_vars; // Add it first so that + and I remain at last
$sql = "UPDATE units SET s_var=".$new_vars." WHERE id=? ";
$res =& $db->query($sql, Array($weapon->target_id) );
if (DB::isError($res)) { ReportDBError($res); }
// Other approach, tag the unit as wrecked {requires new variable to be added to table}
$sql = "UPDATE units SET is_wrecked='Y' WHERE id=? "; // I hope the "'" don't cause issues for the queries
$res =& $db->query($sql, $weapon->target_id);
if (DB::isError($res)) { ReportDBError($res); }
}
} |
An issue remains which is removing the wrecked tag (fixing the unit)
However I can't do that because I don't have access to some scripts. Perhaps it should be in HQ right under where u revive crews?
ticket link: https://sourceforge.net/p/dropshock/tickets/25/
Last edited by khaibar on Wed Oct 10, 2012 12:38 am; edited 11 times in total |
|
Back to top |
|
 |
kunjuro Advanced

Joined: 29 May 2008 Posts: 1629 Location: Philippines
|
Posted: Sat Oct 06, 2012 4:33 am Post subject: |
|
|
...Put this into place on konu - see what happens  _________________
Frizz wrote: | Attempting to change mind ... Failed! (0%)
_f |
|
|
Back to top |
|
 |
khaibar Advanced
Joined: 14 Dec 2007 Posts: 1144
|
Posted: Sat Oct 06, 2012 4:38 am Post subject: |
|
|
wut |
|
Back to top |
|
 |
maXDooom Advanced

Joined: 07 Dec 2011 Posts: 757 Location: in perverted places
|
Posted: Sat Oct 06, 2012 5:01 am Post subject: |
|
|
oh wow, i thought coding was easy _________________
Walterohdim wrote: |
I would be so mad I would Tomo Rage, and probably lose my mod ship and council seat.
Walterohdim |
|
|
Back to top |
|
 |
khaibar Advanced
Joined: 14 Dec 2007 Posts: 1144
|
|
Back to top |
|
 |
DesertFox Simple
Joined: 30 Aug 2012 Posts: 37 Location: Io
|
Posted: Sun Oct 07, 2012 8:12 am Post subject: |
|
|
kunjuro wrote: | ...Put this into place on konu - see what happens  |
I think what he meant is that if you put this on Konu.. the planet konu will become a killing field... |
|
Back to top |
|
 |
khaibar Advanced
Joined: 14 Dec 2007 Posts: 1144
|
Posted: Sun Oct 07, 2012 9:03 am Post subject: |
|
|
konu has relics with up to 2k command total output
I don't think it needs a no-loss incentive
+ i have something in mind for it  |
|
Back to top |
|
 |
DesertFox Simple
Joined: 30 Aug 2012 Posts: 37 Location: Io
|
Posted: Mon Oct 08, 2012 4:32 am Post subject: |
|
|
khaibar wrote: | konu has relics with up to 2k command total output
I don't think it needs a no-loss incentive
+ i have something in mind for it  |
I dont like it to be in Konu either.... _________________ In game name : Tirpitz |
|
Back to top |
|
 |
ChaosKiNg3 Advanced
Joined: 28 Nov 2006 Posts: 1671 Location: Cincinnati, Ohio Uh Es Ah
|
Posted: Mon Oct 08, 2012 5:11 am Post subject: |
|
|
Faction Wars for sure, this looks brilliant. Is it possible to also integrate a resource reward for killing enemy units once a good way to "fix" units is worked out? Thinking along the lines of 25% Cmd/Ore to fix a unit, 10% Cmd/Ore rewarded to the killer, 15% resource loss. |
|
Back to top |
|
 |
khaibar Advanced
Joined: 14 Dec 2007 Posts: 1144
|
Posted: Mon Oct 08, 2012 9:06 am Post subject: |
|
|
new resource requires new variables
If frizz starts adding those.. well then  |
|
Back to top |
|
 |
Vinzkillx Simple

Joined: 20 Jun 2012 Posts: 92 Location: Behind you
|
Posted: Tue Oct 09, 2012 4:07 am Post subject: |
|
|
Confused at the code but it's cool  _________________ In game called DevilSteam
one day at PR fac chat ...
DevilSteam [12:11am 19]
But we're all reds
Tirptiz [12:10am 19]
and go to WAAAAAARRRR, all reds must die |
|
Back to top |
|
 |
khaibar Advanced
Joined: 14 Dec 2007 Posts: 1144
|
Posted: Tue Oct 09, 2012 9:03 am Post subject: |
|
|
really :/
It's not that hard...
#troll# |
|
Back to top |
|
 |
corclaork Council Member

Joined: 26 Aug 2008 Posts: 519 Location: The Mohawk Wasteland
|
Posted: Wed Oct 10, 2012 4:41 pm Post subject: |
|
|
khai this would be super useful for taris/riona. make things AS 100% of the time zero penalty at all.. these planets are still full drop cost so i think thats a balancing factor.
cor _________________ Contact Email: calaclark@gmail.com
in game name : corclark
Sacred_Tribune out in the wild. |
|
Back to top |
|
 |
khaibar Advanced
Joined: 14 Dec 2007 Posts: 1144
|
Posted: Wed Oct 10, 2012 11:56 pm Post subject: |
|
|
I have 100% auto salvage and unlimited ammo for tariona in mind  |
|
Back to top |
|
 |
khaibar Advanced
Joined: 14 Dec 2007 Posts: 1144
|
Posted: Mon Dec 10, 2012 1:07 am Post subject: |
|
|
bumping for council |
|
Back to top |
|
 |
|