peacemaking, provocation and brainAI add

Archive of posts related to former distro versions. Be aware that posts here do not refer to the current distro and may not work.
Locked
coltain
Grandmaster Poster
Posts: 159
Joined: Tue Mar 20, 2007 7:17 am

peacemaking, provocation and brainAI add

Post by coltain »

I`m not going to post here entire scripts but the main parts should be enough.

sysEvent.inc add

Code: Select all

const EVID_MUSICIANSHIP     := 0x1134; //number set as You need
peacemaking skill:
When a player passes all skill checks, target is ok and all that a script sends an event to a peace target.

Code: Select all

    var event := array;   
        event .+ type := EVID_MUSICIANSHIP;
        event .+ subcommand := SKILLID_PEACEMAKING;
        event .+ source := who;
        event .+ time := time;
        sendevent(target,event);
time - how long a target is to be calm

provocation skill:
[player sets 2 npc to fight]

Code: Select all

    var evv1 := array;   
        evv1 .+ type := EVID_MUSICIANSHIP;
        evv1 .+ subcommand := SKILLID_PROVOCATION;
        evv1 .+ target := target1;
        
    var evv2 := array;   
        evv2 .+ type := EVID_MUSICIANSHIP;
        evv2 .+ subcommand := SKILLID_PROVOCATION;
        evv2 .+ target := target2;
       
        if(target1.npctemplate)
            sendevent( target2,evv1);
        endif
        if(target2.npctemplate)
            sendevent(target1,evv2);
        endif  
BrainAI add
I added it to virtual.src

Code: Select all

use uo;
use os;

include ":brainAI:npcNerves";
include ":brainAI:npcCommands";
include "include/Sysevent";
program BrainNerve(params)
	var npc		:= params[1];
	//var nerve_name:= params[2];
	var event	:= params[3];
	//var settings	:= params[4];
	//var scripts	:= params[5];
	params := 0; // Not needed anymore.

	while ( npc )
		if ( event )
			case ( event.type )
                EVID_MUSICIANSHIP:
                        if(event.subcommand==SKILLID_PEACEMAKING)
                            spokoj(npc,event.time);
                            break;
                        endif
                        if(event.subcommand==SKILLID_PROVOCATION)
                            bij(npc,event.target);
                            break;
                        endif  
                default:
                    break;
    		endcase
						
			event := 0;
		endif
		
		event := Wait_For_Event(900000);
	endwhile
endprogram

function bij(npc,cel)
    AI_ClearThoughts(npc, CLR_BOTH);
    AI_EndNerve(npc, "Combat", WAKEUP);
    AI_Attack(npc, cel);
    return 1;
endfunction

function spokoj(npc, time)
    AI_ClearThoughts(npc, CLR_BOTH);
    AI_EndNerve(npc, "Combat", WAKEUP);
    AI_WarMode(npc);
    AI_Speak(npc, "*Postac uspokaja sie pod wplywem melodii*", SPEAK_TEXTTYPE_DEFAULT, SPEAK_DOEVENT_ENABLE, WAKEUP);
//translation mobile is calming down
    Setobjproperty(npc,"#uspokojona",1);
    //AI_Speak(npc, "Peace Time: "+time, SPEAK_TEXTTYPE_DEFAULT, SPEAK_DOEVENT_ENABLE, WAKEUP);
    sleep(time);
    Eraseobjproperty(npc,"#uspokojona");
    return 1;
endfunction

and a little add to shouldWatch.src (to keep peace time)

Code: Select all

var npc := params[1];
if(Getobjproperty(npc,"#uspokojona"))
        return 0;
endif
I tested it and it works. If somone have better ideas I wait for them.
User avatar
tekproxy
Forum Regular
Posts: 352
Joined: Thu Apr 06, 2006 5:11 pm

Post by tekproxy »

Thanks for posting this.

I'm a little busy at work now but I'll try and translate it and get it to compile and test it and let you know how it goes.
Locked