[Mini-Release] HeroCards w/ random reward

07/05/2009 21:19 pro4never#1
Ok so not a huge release but I figured I'd give people an example of how to do some nice "random" cp rewards (or any rewards tbh) from item use.

*NOTE* For the record, this is for CoEmu2.0.nano, obvious from the scripting but just figured I'd make sure nubs knew.


Under Use item put this anywhere in the case section. Simply look for case numbers, paste this one line above one of them so you aren't cutting into any other script. Again you should know this from adding/modifying ANYTHING in there, but if this is your first script. That's how you do it.


Code:
case 722839://HeroCard (AP)//this is simply which item is being used, herocard item id is 722839 but you can change it to any item you want
                    {
                        int AwardCPN = 1;
///simply had to declare it first, 1 is not used
                        RandomCP = Nano.Rand.Next(1, 101);
///rolls number 1-100 (for some reason it never rolls top number so I'm using 1-101, I assume that's normal I dunno I'm new to programing lol)
                        if (RandomCP <= 100)
//saying if it rolls less than 100 (top number)
                        {
                            AwardCPN = Nano.Rand.Next(1, 11);//rolls 1-10
                            CPs(+AwardCPN, CSocket);
//awards the number rolled
                            CSocket.Send(ConquerPacket.Chat(0, "SYSTEM", CSocket.Client.Name, "You received  " + AwardCPN + " CPs from the HeroCard!!.", Struct.ChatType.Top));
//spits out how much you received in the top left corner of the screen
                        }
                        if (RandomCP == 100)
///if 100 is rolled originally, top number in this case but you could add other if statements for if it rolls lets say 99, 98 etc
                        {
                            CPs(+500, CSocket);
///awards 500 cp, can be changed easy
                            ConquerPacket.ToServer(ConquerPacket.Chat(0, "SYSTEM", "ALLUSERS", "CONGRATULATIONS! " + CSocket.Client.Name + " Is so lucky to win 500 CP from opening a HeroCard!!", Struct.ChatType.NewBroadcast), 0);
//sends out a server broadcast saying who won the cp, note you have to have broadcast working on your server for this section to work but broadcast fix is already on forum and is easy as hell

                            CSocket.Send(ConquerPacket.Chat(0, "SYSTEM", CSocket.Client.Name, "Woa!! Something random happened: You won 500 CPs from the HeroCard! You are just so lucky!.", Struct.ChatType.Top));
//again, top left corner states how much you won

                        }
                        break;

                    }

So I went a little comment crazy there describing what everything does for noobs but you can always remove those if you don't need them.

Feel free to use/modify the script as you see fit. You can change it to any item you want, you can change what is given, the rewards, anything in there.

The script itself is fairly basic but I feel that noobs especially should take a look at it. The principles behind it are/can be used for countless applications.
07/06/2009 14:29 samehvan#2
thnx but notice that if ur random returns with 100 this will be awarded twice so u should remove the = from ur first if " if (RandomCP <= 100) " to be " if (RandomCP < 100) " or add an else word be4 ur second if to be licke this " else if (RandomCP == 100) " thanks again
07/06/2009 15:55 m7med#3
i have this error Error 1 The name 'RandomCP' does not exist in the current context
07/06/2009 16:09 PeTe Ninja#4
i think peopel whoa re releaseing item info like this should release all at once or none at all :D
07/06/2009 20:49 pro4never#5
Quote:
Originally Posted by samehvan View Post
thnx but notice that if ur random returns with 100 this will be awarded twice so u should remove the = from ur first if " if (RandomCP <= 100) " to be " if (RandomCP < 100) " or add an else word be4 ur second if to be licke this " else if (RandomCP == 100) " thanks again
Ooops I thought I had fixed that, I posted an older version of it I guess :P

Simpy remove the = in the first part and it will work as you said


Quote:
Originally Posted by m7med View Post
i have this error Error 1 The name 'RandomCP' does not exist in the current context
Code:
public static int RandomCP;
Not that hard to define something rofl

Quote:
Originally Posted by PeTe Ninja View Post
i think peopel whoa re releaseing item info like this should release all at once or none at all :D
it is complete, all you had to do was say public stat int RandomCP;

You have to define it just like any other code.
07/07/2009 08:38 sawickas#6
For coemu or lotf?
07/07/2009 09:16 Jay1029#7
That's very helpful for people that are learning like me. Thanks =)
07/07/2009 15:59 pro4never#8
Quote:
Originally Posted by sawickas View Post
For coemu or lotf?
Please look at the code and you will see it is for coemu.

The scripting looks completely different between them and is easily distinguished.
07/07/2009 17:11 n0mansland#9
Quote:
*NOTE* For the record, this is for CoEmu2.0.nano, obvious from the scripting but just figured I'd make sure nubs knew.
or he could atleast read the whole post before asking what's it for x.x... unless you just added that but I don't see "last edited"

anyway cool release good job
07/07/2009 20:57 pro4never#10
Quote:
Originally Posted by n0mansland View Post
or he could atleast read the whole post before asking what's it for x.x... unless you just added that but I don't see "last edited"

anyway cool release good job
ooh I forgot I had put that there but now that you mention it I did post it there to avoid stupid comments like his.


Also fyi, I bought domain/hosting for my server lastnight, everything will be switched over to it as soon as I transfer over my databases and shit ^^

I have 1 year of hosting pre-payed so the site will be up 24/7 for the next year at least unless I shut it down, will be forwarding current site to that one for people who are too stupid to read that it's updated.

YAY PROGRESS ^^
07/08/2009 02:27 n0mansland#11
Haha that's cool, I got a house system up :) Database coding works really well with that stuff. I'm adding house admin right now..

Needa edit the database so it saves HousePoints and need to figure out instances..
07/08/2009 02:42 pro4never#12
Quote:
Originally Posted by n0mansland View Post
Haha that's cool, I got a house system up :) Database coding works really well with that stuff. I'm adding house admin right now..

Needa edit the database so it saves HousePoints and need to figure out instances..
Yah database works awesome.

For a second I thought you had instancing working :( aww well.


Ps: New hosting/forums/remote database is online

alchemyco.org